当前位置: 首页>>代码示例>>Java>>正文


Java MkContainer.stop方法代码示例

本文整理汇总了Java中com.jcabi.http.mock.MkContainer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java MkContainer.stop方法的具体用法?Java MkContainer.stop怎么用?Java MkContainer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcabi.http.mock.MkContainer的用法示例。


在下文中一共展示了MkContainer.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pathFromUsers

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtUser return Request with path.
 * @throws Exception If fails
 */
@Test
public void pathFromUsers() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                "{\"body\":\"hi\"}"
            )
        ).start();
    new RtHub(
        container.home()
    ).users().self().json();
    container.stop();
    MatcherAssert.assertThat(
        container.take().uri(),
        CoreMatchers.equalTo(
            new URI("/hub/api/rest/users/me")
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:25,代码来源:RtUserTest.java

示例2: userAgent

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtHub return Request with UserAgent.
 * @throws Exception If fails
 */
@Test
public void userAgent() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple("hello, world!")
        ).start();
    new RtHub(
        container.home()
    ).entry().fetch();
    container.stop();
    MatcherAssert.assertThat(
        container.take().headers(),
        Matchers.hasEntry(
            Matchers.equalTo(HttpHeaders.USER_AGENT),
            Matchers.hasItem(
                String.format(
                    "jb-hub-api-client %s %s %s",
                    Manifests.read("Hub-Version"),
                    Manifests.read("Hub-Build"),
                    Manifests.read("Hub-Date")
                )
            )
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:30,代码来源:RtHubTest.java

示例3: path

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtHub return Request with path.
 * @throws Exception If fails
 */
@Test
public void path() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple("hello, world!")
        ).start();
    new RtHub(
        container.home()
    ).entry().fetch();
    container.stop();
    MatcherAssert.assertThat(
        container.take().uri(),
        CoreMatchers.equalTo(
            new URI("/hub/api/rest")
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:22,代码来源:RtHubTest.java

示例4: authorizationToken

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtHub return Request with Authorization token.
 * @throws Exception If fails
 */
@Test
public void authorizationToken() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple("hello, world!")
        ).start();
    new RtHub(
        container.home(),
        "token"
    ).entry().fetch();
    container.stop();
    MatcherAssert.assertThat(
        container.take().headers(),
        Matchers.hasEntry(
            Matchers.equalTo(HttpHeaders.AUTHORIZATION),
            Matchers.hasItem(
                "token"
            )
        )
    );
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:26,代码来源:RtHubTest.java

示例5: fetchesNotifications

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications can fetch the notifications from the server.
 * @throws Exception If something goes wrong.
 */
@Test
public void fetchesNotifications() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple("[{\"notification\":\"first\"},{\"notification\":\"second\"}]")).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        List<JsonObject> found = notifications.fetch();
        assertTrue(found.size() == 2);
        assertTrue(found.get(0).getString("notification").equals("first"));
        assertTrue(found.get(1).getString("notification").equals("second"));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:24,代码来源:RtNotificationsTestCase.java

示例6: fetchesNotificationsWithError

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications.fetch throws assertion error when the response status is not OK
 * @throws Exception If something goes wrong.
 */
@Test (expected = AssertionError.class)
public void fetchesNotificationsWithError() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_BAD_REQUEST)).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        notifications.fetch();
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:21,代码来源:RtNotificationsTestCase.java

示例7: nothingFetched

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications can fetch 0 notifications from the server.
 * @throws Exception If something goes wrong.
 */
@Test
public void nothingFetched() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple("[]")).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        List<JsonObject> found = notifications.fetch();
        assertTrue(found.size() == 0);
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:22,代码来源:RtNotificationsTestCase.java

示例8: markAsReadOk

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications can mark notifications as read with OK status response
 * @throws Exception If something goes wrong.
 */
@Test
public void markAsReadOk() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK)).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        notifications.markAsRead();
        MkQuery req = server.take();
        assertTrue(req.method().equals(Request.PUT));
        assertTrue(req.body().equals("{}"));
        assertTrue(req.uri().getQuery().contains("last_read_at="));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:25,代码来源:RtNotificationsTestCase.java

示例9: markAsReadReset

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications can mark notifications as read with RESET status response.
 * @throws Exception If something goes wrong.
 */
@Test
public void markAsReadReset() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_RESET)).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        notifications.markAsRead();
        MkQuery req = server.take();
        assertTrue(req.method().equals(Request.PUT));
        assertTrue(req.body().equals("{}"));
        assertTrue(req.uri().getQuery().contains("last_read_at="));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:25,代码来源:RtNotificationsTestCase.java

示例10: markAsReadServerNotOk

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * RtNotifications.markAsRead throws assertion error when there is an
 * unexpected status response.
 * @throws Exception If something goes wrong.
 */
@Test (expected = AssertionError.class)
public void markAsReadServerNotOk() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR)).start(port);
    try {
        Notifications notifications = new RtNotifications(
            new Reason.Fake(),
            "fake_token",
            "http://localhost:"+port+"/"
        );
        notifications.markAsRead();
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:22,代码来源:RtNotificationsTestCase.java

示例11: sendsNotificationsWithUnauthorized

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * NtPost handles unauthorized response.
 * @throws Exception If something goes wrong.
 */
@Test
public void sendsNotificationsWithUnauthorized() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_UNAUTHORIZED))
        .start(port);
    try {
        Notifications notifications = new Notifications.FakeErrorOnMarkRead();
        Post ntp = new NtPost(
        	notifications, "fake_token", "http://localhost:"+port+"/"
        );
        ntp.send();
        MkQuery request = server.take();
        String auth = request.headers().get(HttpHeaders.AUTHORIZATION).get(0);
        assertTrue(auth.contains("fake_token"));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:24,代码来源:NtPostTestCase.java

示例12: sendsNotificationsWithServerError

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * NtPost throws assertion error on unexpected status response.
 * @throws Exception If something goes wrong.
 */
@Test (expected = AssertionError.class)
public void sendsNotificationsWithServerError() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR))
        .start(port);
    try {
    	Notifications notifications = new Notifications.FakeErrorOnMarkRead();
    	Post ntp = new NtPost(
        	notifications, "fake_token", "http://localhost:"+port+"/"
        );
        ntp.send();
        MkQuery request = server.take();
        String auth = request.headers().get(HttpHeaders.AUTHORIZATION).get(0);
        assertTrue(auth.contains("fake_token"));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:mention-notifications-ejb,代码行数:24,代码来源:NtPostTestCase.java

示例13: sendsExportRequestToAwsEs

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * A request is sent to the AWS Es bulk api service.
 * @throws Exception If something goes wrong.
 */
@Test
public void sendsExportRequestToAwsEs() throws Exception {
    List<WebPage> pages = new ArrayList<WebPage>();
    pages.add(this.mockWebPage("http://www.test.com/crawledpage.html"));
    pages.add(this.mockWebPage("https://www.test.com/stuff/crawledpage.html"));
    
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
       .next(new MkAnswer.Simple("{\"status\":\"Unit test successful!\"}"))
       .start(port);
    try {
        new AmazonElasticSearch(
            "testIndex",
            new AccessKeyId.Fake("access_key"),
            new SecretKey.Fake("secret_key"),
            new Region.Fake("ro"),
            new EsEndPoint.Fake("http://localhost:" + port + "/es")
        ).export(pages);
        MkQuery request = server.take();
        assertEquals("/es/_bulk/",request.uri().toString());
        assertTrue("POST".equals(request.method()));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:30,代码来源:AmazonElasticSearchTestCase.java

示例14: sendsDeleteRequestToAwsEs

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * A request to DELETE the index is made to ES.
 * @throws Exception If something goes wrong.
 */
@Test
public void sendsDeleteRequestToAwsEs() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
       .next(new MkAnswer.Simple("{\"status\":\"index deleted\"}"))
       .start(port);
    try {
        new AmazonElasticSearch(
            "index.to.be.deleted",
            new AccessKeyId.Fake("access_key"),
            new SecretKey.Fake("secret_key"),
            new Region.Fake("ro"),
            new EsEndPoint.Fake("http://localhost:" + port + "/es/")
        ).delete();
        MkQuery request = server.take();
        assertEquals("/es/index.to.be.deleted/", request.uri().toString());
        assertTrue("DELETE".equals(request.method()));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:AmazonElasticSearchTestCase.java

示例15: sendsDeleteDocumentRequestToAwsEs

import com.jcabi.http.mock.MkContainer; //导入方法依赖的package包/类
/**
 * A request to DELETE a document, from one index, is made to ES.
 * @throws Exception If something goes wrong.
 */
@Test
public void sendsDeleteDocumentRequestToAwsEs() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
       .next(new MkAnswer.Simple("{\"status\":\"index deleted\"}"))
       .start(port);
    try {
        new AmazonElasticSearch(
            "index",
            new AccessKeyId.Fake("access_key"),
            new SecretKey.Fake("secret_key"),
            new Region.Fake("ro"),
            new EsEndPoint.Fake("http://localhost:" + port + "/es/")
        ).delete("page", "document_id");
        MkQuery request = server.take();
        assertEquals("/es/index/page/document_id/", request.uri().toString());
        assertTrue("DELETE".equals(request.method()));
    } finally {
        server.stop();
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:26,代码来源:AmazonElasticSearchTestCase.java


注:本文中的com.jcabi.http.mock.MkContainer.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。