diff --git a/src/test/java/com/jcabi/github/RtDeployKeysTest.java b/src/test/java/com/jcabi/github/RtDeployKeysTest.java index d3a683350..843051a80 100644 --- a/src/test/java/com/jcabi/github/RtDeployKeysTest.java +++ b/src/test/java/com/jcabi/github/RtDeployKeysTest.java @@ -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(); + } } /** diff --git a/src/test/java/com/jcabi/github/RtReleaseAssetsTest.java b/src/test/java/com/jcabi/github/RtReleaseAssetsTest.java index e036f86d9..f1be6cffb 100644 --- a/src/test/java/com/jcabi/github/RtReleaseAssetsTest.java +++ b/src/test/java/com/jcabi/github/RtReleaseAssetsTest.java @@ -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) ); diff --git a/src/test/java/com/jcabi/github/RtUserEmailsTest.java b/src/test/java/com/jcabi/github/RtUserEmailsTest.java index 47814b301..656bd4b28 100644 --- a/src/test/java/com/jcabi/github/RtUserEmailsTest.java +++ b/src/test/java/com/jcabi/github/RtUserEmailsTest.java @@ -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; @@ -70,15 +74,24 @@ public void fetchesEmails() throws Exception { @Test public void addsEmails() throws Exception { final String email = "test1@email.com"; - 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(); + } } /**