Package org.doctester.testbrowser

Examples of org.doctester.testbrowser.Response


    @Test
    public void testSomeMethod() {
       
        getInjector().getInstance(SetupDao.class).generateFortunesForTest();

        Response response
                = makeRequest(Request.GET().url(testServerUrl().path(URL_FORTUNES)));
       
        System.out.println(" " + response.payload);
       
        // make sure escaping works
View Full Code Here


    String URL_JSON = "/json";

    @Test
    public void testHelloJsonController() {
       
        Response response = makeRequest(
            Request
                .GET()
                .url(testServerUrl().path(URL_JSON))
                .contentTypeApplicationJson());
       
        assertThat(
            response.payloadAs(Message.class).message,
            is("Hello, World!"));
       
    }
View Full Code Here

    String URL_PLAINTEXT = "/plaintext";
   
    @Test
    public void helloPlaintextControllerTest() {
       
        Response response = makeRequest(
            Request.GET().url(testServerUrl().path(URL_PLAINTEXT)));
       
        assertThat(response.payload, CoreMatchers.is("Hello, World!"));
        assertThat(
            response.headers.get("Content-Type"),
View Full Code Here

    }
   
    @Test
    public void testSingleGet() {
       
        Response response = makeRequest(
                Request
                        .GET()
                        .url(testServerUrl().path(URL_DB))
                        .contentTypeApplicationJson());
       
        // Just make sure that we get back a World Json.
        assertThat(response.payloadAs(World.class), notNullValue());     
               
    }
View Full Code Here

        assertThatMutipleGetWorksFor(20);
               
    }
   
    private void assertThatMutipleGetWorksFor(int numberOfQueries) {
        Response response = makeRequest(
            Request
                .GET()
                .url(
                    testServerUrl()
                    .path(URL_QUERIES)
                    .addQueryParameter("queries", numberOfQueries + ""))
                .contentTypeApplicationJson());
       
        // Just make sure that we get back an array
        assertThat(response.payloadAs(World[].class).length, is(numberOfQueries));
    }
View Full Code Here

               
    }
   
    private void assertThatUpdateWorks(int numberOfQueries) {
       
        Response response = makeRequest(
            Request.GET()
                .url(
                    testServerUrl()
                    .path(URL_UPDATE)
                    .addQueryParameter("queries", numberOfQueries + ""))
                .contentTypeApplicationJson());
       
        assertThat(response.payloadAs(World[].class).length, is(numberOfQueries));
       
    }
View Full Code Here

public class NotFoundTest extends NinjaDocTester {

  @Test
  public void testThatNotFoundWorksHtml() {
       
        Response response
                = makeRequest(Request.GET().url(testServerUrl().path("/_non_existing_url")));

    assertEquals(404, response.httpStatus);
   
    assertTrue(response.payload
View Full Code Here

  }
   
    @Test
  public void testThatNotFoundWorksJson() {
       
        Response response
                = makeRequest(
                        Request
                                .GET()
                                .url(testServerUrl().path("/_non_existing_url"))
                                .addHeader(HttpConstants.HEADER_ACCEPT, HttpConstants.APPLICATION_JSON));

    assertEquals(404, response.httpStatus);
       
    Message message = response.payloadJsonAs(Message.class);
        Assert.assertThat(message.text, CoreMatchers.equalTo(NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_DEFAULT));

  }
View Full Code Here

  }
   
    @Test
  public void testThatNotFoundWorksXml() {
       
        Response response
                = makeRequest(
                        Request
                                .GET()
                                .url(testServerUrl().path("/_non_existing_url"))
                                .addHeader(HttpConstants.HEADER_ACCEPT, HttpConstants.APPLICATION_XML));

    assertEquals(404, response.httpStatus);

    Message message = response.payloadXmlAs(Message.class);
        Assert.assertThat(message.text, CoreMatchers.equalTo(NinjaConstant.I18N_NINJA_SYSTEM_NOT_FOUND_TEXT_DEFAULT));

  }
View Full Code Here

    String URL_HELLO_WORLD_JSON = "/hello_world.json";
   
    @Test
    public void testGetIndex() {
   
        Response response = makeRequest(
                Request.GET().url(
                        testServerUrl().path(URL_INDEX)));

        assertThat(response.payload, containsString("Hello World!"));
        assertThat(response.payload, containsString("BAM!"));
View Full Code Here

TOP

Related Classes of org.doctester.testbrowser.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.