Package org.apache.clerezza.jaxrs.testutils

Examples of org.apache.clerezza.jaxrs.testutils.TestWebServer


    }
    Assert.assertEquals("Graph writer", baos.toString());
  }

  private TestWebServer createTestWebServer() {
    return new TestWebServer(new Application() {

      @Override
      public Set<Class<?>> getClasses() {
        Set<Class<?>> result = new HashSet<Class<?>>();
        return result;
View Full Code Here


//  public void testMbwWithUmlaut() throws IOException {
//    testMbw("foob\u00E4r"); // foobär
//  }

  private void testMbw(String param) throws IOException {
    final TestWebServer testWebServer = createTestWebServer(new MyResource());
    int port = testWebServer.getPort();
    URL serverURL = new URL("http://localhost:" + port + "/foo/bar?name=" + param);
    HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
    connection.setRequestMethod("GET");
    connection.addRequestProperty("Accept", "application/json, */*; q=.2");
    BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
    String line = br.readLine();
//    System.out.println(line);
    Assert.assertEquals("{\"name\":\""+param+"\"}", line);
    testWebServer.stop();
  }
View Full Code Here

    Assert.assertEquals("{\"name\":\""+param+"\"}", line);
    testWebServer.stop();
  }

  private TestWebServer createTestWebServer(final Object resource) {
    return new TestWebServer(new Application() {

      @Override
      public Set<Class<?>> getClasses() {
        Set<Class<?>> result = new HashSet<Class<?>>();
        return result;
View Full Code Here

    }
  } 
 
  @Test
  public void testEnforceSlash() throws IOException {   
    final TestWebServer testWebServer = createTestWebServer(new MyResource());
    int port = testWebServer.getPort();
    URL serverURL = new URL("http://localhost:" + port + "/foo/bar");
    HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
    connection = (HttpURLConnection) serverURL.openConnection();
    connection.setRequestMethod("GET");
    connection.addRequestProperty("Accept", "text/html, */*; q=.2")
    Assert.assertEquals(204, connection.getResponseCode());
    Assert.assertTrue(path.endsWith("/"));
    testWebServer.stop();
  }
View Full Code Here

    testWebServer.stop();
  }
 
  @Test
  public void testEnforceNoSlash() throws IOException {
    final TestWebServer testWebServer = createTestWebServer(new MyResource2());
    int port = testWebServer.getPort();
    URL serverURL = new URL("http://localhost:" + port + "/one/two/");
    HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
    connection = (HttpURLConnection) serverURL.openConnection();
    connection.setRequestMethod("GET");

    connection.addRequestProperty("Accept", "text/html, */*; q=.2");
    Assert.assertEquals(204, connection.getResponseCode());
    Assert.assertFalse(path.endsWith("/"));
    testWebServer.stop();
  }
View Full Code Here

    testWebServer.stop();
  }
 
 
  private TestWebServer createTestWebServer(final Object resource) {
    return new TestWebServer(new Application() {

      @Override
      public Set<Class<?>> getClasses() {
        Set<Class<?>> result = new HashSet<Class<?>>();
        return result;
View Full Code Here

//    public void testMbwWithUmlaut() throws IOException {
//        testMbw("foob\u00E4r"); // foobär
//    }

    private void testMbw(String param) throws IOException {
        final TestWebServer testWebServer = createTestWebServer(new MyResource());
        int port = testWebServer.getPort();
        URL serverURL = new URL("http://localhost:" + port + "/foo/bar?name=" + param);
        HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
        connection.setRequestMethod("GET");
        connection.addRequestProperty("Accept", "application/json, */*; q=.2");
        BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
        String line = br.readLine();
//        System.out.println(line);
        Assert.assertEquals("{\"name\":\""+param+"\"}", line);
        testWebServer.stop();
    }
View Full Code Here

        Assert.assertEquals("{\"name\":\""+param+"\"}", line);
        testWebServer.stop();
    }

    private TestWebServer createTestWebServer(final Object resource) {
        return new TestWebServer(new Application() {

            @Override
            public Set<Class<?>> getClasses() {
                Set<Class<?>> result = new HashSet<Class<?>>();
                return result;
View Full Code Here

        }
    }   
   
    @Test
    public void testEnforceSlash() throws IOException {       
        final TestWebServer testWebServer = createTestWebServer(new MyResource());
        int port = testWebServer.getPort();
        URL serverURL = new URL("http://localhost:" + port + "/foo/bar");
        HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
        connection = (HttpURLConnection) serverURL.openConnection();
        connection.setRequestMethod("GET");
        connection.addRequestProperty("Accept", "text/html, */*; q=.2");   
        Assert.assertEquals(204, connection.getResponseCode());
        Assert.assertTrue(path.endsWith("/"));
        testWebServer.stop();
    }
View Full Code Here

        testWebServer.stop();
    }
   
    @Test
    public void testEnforceNoSlash() throws IOException {
        final TestWebServer testWebServer = createTestWebServer(new MyResource2());
        int port = testWebServer.getPort();
        URL serverURL = new URL("http://localhost:" + port + "/one/two/");
        HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection();
        connection = (HttpURLConnection) serverURL.openConnection();
        connection.setRequestMethod("GET");

        connection.addRequestProperty("Accept", "text/html, */*; q=.2");
        Assert.assertEquals(204, connection.getResponseCode());
        Assert.assertFalse(path.endsWith("/"));
        testWebServer.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.jaxrs.testutils.TestWebServer

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.