Examples of ResponseImpl


Examples of com.sun.jersey.core.spi.factory.ResponseImpl

        this.out = null;
        this.response = response = (response != null) ? response : Responses.noContent().build();
        this.mappedThrowable = null;

        if (response instanceof ResponseImpl) {
            final ResponseImpl responseImpl = (ResponseImpl)response;
            setStatusType(responseImpl.getStatusType());
            setHeaders(response.getMetadata());
            setEntity(responseImpl.getEntity(), responseImpl.getEntityType());
        } else {
            setStatus(response.getStatus());
            setHeaders(response.getMetadata());
            setEntity(response.getEntity());
        }
View Full Code Here

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

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

    String queryParam = "post1";
    final String bodyString = "body";
    uri.setPath("foo");
    uri.setQuery("name="+queryParam);
View Full Code Here

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

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

    uri.setPath("foo");
    request.setRequestURI(uri);
    request.setMethod(Method.POST);
View Full Code Here

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

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

    String queryParam = "post1";
    uri.setPath("foo");
    uri.setQuery("name="+queryParam);
    request.setRequestURI(uri);
View Full Code Here

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

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

    Request requestMock = EasyMock.createNiceMock(Request.class);
    ResponseImpl responseImpl = new ResponseImpl();

    String stringMessage = "Hello"
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/").anyTimes();
    expect(requestURI.getQuery()).andReturn("value=" + stringMessage)
        .anyTimes();
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
    replay(requestURI);
    handler.handle(requestMock, responseImpl);
    responseImpl.consumeBody();
    Assert.assertArrayEquals(stringMessage.getBytes(), responseImpl.getBodyBytes());

    reset(requestURI);
    responseImpl = new ResponseImpl();
    // now do the same with a decimal value
    String decimalString = "446544";

    expect(requestURI.getPath()).andReturn("/").anyTimes();
    expect(requestURI.getQuery()).andReturn("value=" + decimalString)
        .anyTimes();
    replay(requestURI);
    handler.handle(requestMock, responseImpl);
    responseImpl.consumeBody();
    Assert.assertArrayEquals(("int:" + decimalString).getBytes(), responseImpl.getBodyBytes());
  }
View Full Code Here

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

  @Test
  public void testResponseToOptionsRequest() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class, MyResource2.class);
    RequestURIImpl uri = new RequestURIImpl();
    RequestImpl request = new RequestImpl();
    ResponseImpl response = new ResponseImpl();
    uri.setPath("/");
    request.setRequestURI(uri);
    request.setMethod(Method.OPTIONS);
    handler.handle(request, response);
    Map<HeaderName,String[]> headers = response.getHeaders();
    String[] allowHeader = headers.get(HeaderName.ALLOW);
    Assert.assertNotNull(allowHeader);
    String allow = "";
    for(String st : allowHeader){
      allow += st;
View Full Code Here

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

  @Test
  public void testResponseToOptionsRequestOnSubresource() throws Exception {
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
    RequestURIImpl uri = new RequestURIImpl();
    RequestImpl request = new RequestImpl();
    ResponseImpl response = new ResponseImpl();
    uri.setPath("/sub");
    request.setRequestURI(uri);
    request.setMethod(Method.OPTIONS);
    handler.handle(request, response);
    Map<HeaderName,String[]> headers = response.getHeaders();
    String[] allowHeader = headers.get(HeaderName.ALLOW);
    Assert.assertNotNull(allowHeader);
    String allow = "";
    for(String st : allowHeader){
      allow += st;
View Full Code Here

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

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

    uri.setType(RequestURI.Type.NO_RESOURCE);
    request.setRequestURI(uri);
    request.setMethod(Method.OPTIONS);
    handler.handle(request, response);
    Map<HeaderName,String[]> headers = response.getHeaders();
    String[] allowHeader = headers.get(HeaderName.ALLOW);
    Assert.assertNotNull(allowHeader);
    String allow = "";
    for(String st : allowHeader){
      allow += st;
View Full Code Here

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

    expect(requestURI.getPath()).andReturn("/");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
    replay(requestURI);

    ResponseImpl responseImpl = new ResponseImpl();
    handler.handle(requestMock, responseImpl);
    responseImpl.consumeBody();
   
    assertNotNull(responseImpl.getStatus());
    assertNotNull(responseImpl.getHeaders());
    assertArrayEquals(errMsgBar.getBytes(), responseImpl.getBodyBytes());
  }
View Full Code Here

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

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream("body".getBytes()));
      }
    });
    ResponseImpl responseImpl = new ResponseImpl();
    handler.handle(request, responseImpl);
    assertTrue(exceptionMapperUsed);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.