Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#876 Upgraded to jcabi-http version 1.8 #878

Merged
merged 2 commits into from
Jul 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,17 @@
<groupId>com.jcabi</groupId>
<artifactId>jcabi-xml</artifactId>
</dependency>
<!--
@todo #876 The version of this jcabi-http dependency should be
managed by the parent pom, however, com.jcabi:jcabi is currently
referencing an older version. When the parent references version
1.8 or newer, let's remove the version element here and revert
back to being managed by the parent.
-->
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-http</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.jcabi.incubator</groupId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/jcabi/github/RtSearchPagination.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.jcabi.http.Response;
import com.jcabi.http.Wire;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
Expand Down Expand Up @@ -155,6 +156,10 @@ public Response fetch() throws IOException {
return new RtSearchPagination.Hidden(this.request.fetch());
}
@Override
public Response fetch(final InputStream stream) throws IOException {
return new RtSearchPagination.Hidden(this.request.fetch(stream));
}
@Override
@NotNull(message = "Request should never be NULL")
public <T extends Wire> Request through(final Class<T> type,
final Object... args) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/jcabi/github/wire/CarefulWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.jcabi.http.Wire;
import com.jcabi.log.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -105,7 +106,7 @@ public CarefulWire(@NotNull(message = "wire can't be NULL")
public Response send(final Request req, final String home,
final String method,
final Collection<Map.Entry<String, String>> headers,
final byte[] content) throws IOException {
final InputStream content) throws IOException {
final Response resp = this.origin
.send(req, home, method, headers, content);
final int remaining = Integer.parseInt(
Expand Down
26 changes: 17 additions & 9 deletions src/test/java/com/jcabi/github/RtDeployKeysTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,24 @@ public void canFetchSingleDeployKey() throws IOException {
@Test
public void canCreateDeployKey() throws IOException {
final int number = 2;
final DeployKeys keys = new RtDeployKeys(
new FakeRequest()
.withStatus(HttpURLConnection.HTTP_CREATED)
.withBody(String.format("{\"id\":%d}", number)),
RtDeployKeysTest.repo()
);
MatcherAssert.assertThat(
keys.create("Title", "Key").number(),
Matchers.equalTo(number)
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_CREATED,
String.format("{\"id\":%d}", number)
)
);
container.start();
try {
final DeployKeys keys = new RtDeployKeys(
new ApacheRequest(container.home()), RtDeployKeysTest.repo()
);
MatcherAssert.assertThat(
keys.create("Title", "Key").number(),
Matchers.equalTo(number)
);
} finally {
container.stop();
}
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/jcabi/github/RtReleaseAssetsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ public void listReleaseAssets() throws Exception {
*/
@Test
public void uploadReleaseAsset() throws Exception {
final String body = "{\"id\":1}";
final ReleaseAssets assets = new RtReleaseAssets(
new FakeRequest().withStatus(HttpURLConnection.HTTP_CREATED)
.withBody("{\"id\":1}"),
.withBody(body),
release()
);
MatcherAssert.assertThat(
assets.upload("blah".getBytes(), "text/plain", "hello.txt")
assets.upload(body.getBytes(), "text/plain", "hello.txt")
.number(),
Matchers.is(1)
);
Expand Down
29 changes: 21 additions & 8 deletions src/test/java/com/jcabi/github/RtUserEmailsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
*/
package com.jcabi.github;

import com.jcabi.http.mock.MkAnswer;
import com.jcabi.http.mock.MkContainer;
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.request.ApacheRequest;
import com.jcabi.http.request.FakeRequest;
import java.net.HttpURLConnection;
import java.util.Collections;
Expand Down Expand Up @@ -70,15 +74,24 @@ public void fetchesEmails() throws Exception {
@Test
public void addsEmails() throws Exception {
final String email = "[email protected]";
final UserEmails emails = new RtUserEmails(
new FakeRequest()
.withStatus(HttpURLConnection.HTTP_CREATED)
.withBody(String.format("[{\"email\":\"%s\"}]", email))
);
MatcherAssert.assertThat(
emails.add(Collections.singletonList(email)).iterator().next(),
Matchers.equalTo(email)
final MkContainer container = new MkGrizzlyContainer().next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_CREATED,
String.format("[{\"email\":\"%s\"}]", email)
)
);
container.start();
try {
final UserEmails emails = new RtUserEmails(
new ApacheRequest(container.home())
);
MatcherAssert.assertThat(
emails.add(Collections.singletonList(email)).iterator().next(),
Matchers.equalTo(email)
);
} finally {
container.stop();
}
}

/**
Expand Down