Package org.apache.clerezza.triaxrs.mock

Examples of org.apache.clerezza.triaxrs.mock.RequestImpl


    mylocale = null;
    mylocale2 = null;

    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);

    RequestImpl request = new RequestImpl();
    RequestURIImpl uri = new RequestURIImpl();
    uri.setPath("/");
    String[] headervalues = new String[1];
    // set a RFC 1766 language tag that can't be converted to a Locale
    headervalues[0] = "i-klingon";
    request.setHeader(HeaderName.ACCEPT_LANGUAGE, headervalues);
    request.setRequestURI(uri);
    request.setMethod(Method.GET);
    Response response = new ResponseImpl();
    handler.handle(request, response);

    assertEquals(mylocale, null);
    assertEquals(mylocale2, null);
View Full Code Here


  @Test
  public void nonEmptySubResourcePath() throws Exception{
    JaxRsHandler handler = HandlerCreator.getHandler(MyRootResource.class, MySubResource.class);
    RequestURIImpl uri = new RequestURIImpl();
    RequestImpl request = new RequestImpl();
    ResponseImpl response = new ResponseImpl();

    uri.setPath("foo/sub");
    request.setRequestURI(uri);
    request.setMethod(Method.GET);

    handler.handle(request, response);

    Assert.assertEquals("subGet", value);
  }
View Full Code Here

  @Test
  public void emptySubResourcePath() throws Exception{
    JaxRsHandler handler = HandlerCreator.getHandler(MyRootResource.class, MySubResource.class);
    RequestURIImpl uri = new RequestURIImpl();
    RequestImpl request = new RequestImpl();
    ResponseImpl response = new ResponseImpl();

    uri.setPath("foo");
    request.setRequestURI(uri);
    request.setMethod(Method.POST);

    handler.handle(request, response);

    Assert.assertEquals("subPost", value);
  }
View Full Code Here

  }

  @Test
  public void requestOnResourcePathTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/foo");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  }

  @Test
  public void requestOnResourcePathContainingEncodedSpaceTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource2.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/test%20resource");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  }

  @Test
  public void requestOnResourcePathContainingPlusTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource4.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/test+resource");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  }

  @Test
  public void requestOnResourcePathContainingSpaceTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource3.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/bla%20bla");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  }

  @Test
  public void reqOnResMethodPathContainingEncSpaceTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/foo/bar%20foo");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  }

  @Test
  public void reqOnResMethodPathContainingSpaceTest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
    RequestImpl requestMock = new RequestImpl();
    RequestURIImpl requestUri = new RequestURIImpl();
    requestUri.setPath("/foo/da%20ja");
    requestMock.setRequestURI(requestUri);
    requestMock.setMethod(Method.GET);
    handler.handle(requestMock, new ResponseImpl());
    assertTrue(methodInvokedForGet);
  }
View Full Code Here

  @Test
  public void testHttpHeadersAndHeaderParam() throws Exception {

    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);

    RequestImpl request = new RequestImpl();
    RequestURIImpl uri = new RequestURIImpl();
    uri.setPath("/");
    String[] headervalues = new String[1];
    headervalues[0] = "en-uk-cockney";
    request.setHeader(HeaderName.ACCEPT_LANGUAGE, headervalues);
    request.setRequestURI(uri);
    request.setMethod(Method.GET);
    Response response = new ResponseImpl();
    handler.handle(request, response);

    assertTrue(mylocale != null);
    assertEquals("en_UK_cockney", mylocale.toString());
View Full Code Here

TOP

Related Classes of org.apache.clerezza.triaxrs.mock.RequestImpl

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.