Package org.wymiwyg.wrhapi

Examples of org.wymiwyg.wrhapi.Response


    // 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


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

    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.PUT).anyTimes();
    String[] contentTypeHeader = { "application/x-mymessage" };
    expect(requestMock.getHeaderValues(HeaderName.CONTENT_TYPE)).andReturn(
        contentTypeHeader).anyTimes();
    // this redundancy makes me prefer not to use mocks
View Full Code Here

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

    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/interface");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
View Full Code Here

    reset();
   
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource2.class);

    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/superclass");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
View Full Code Here

    reset();
   
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource3.class);
 
    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/superclass");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
    replay(requestURI);
    replay(responseMock);
    handler.handle(requestMock, responseMock);
    assertTrue(handleGetInvoked & !superHandleGetInvoked);
   
    reset();
   
    Request requestMock2 = EasyMock.createNiceMock(Request.class);
    Response responseMock2 = EasyMock.createNiceMock(Response.class);
    expect(requestMock2.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI2 = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI2.getPath()).andReturn("/interface");
    expect(requestMock2.getRequestURI()).andReturn(requestURI2).anyTimes();
    replay(requestMock2);
View Full Code Here

    reset();
   
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource4.class);
   
    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.PUT).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/resource");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
    replay(requestURI);
    replay(responseMock);
    handler.handle(requestMock, responseMock);
    assertTrue(handleGetInvoked);
   
    reset();
   
    Request requestMock2 = EasyMock.createNiceMock(Request.class);
    Response responseMock2 = EasyMock.createNiceMock(Response.class);
    expect(requestMock2.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI2 = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI2.getPath()).andReturn("/interface");
    expect(requestMock2.getRequestURI()).andReturn(requestURI2).anyTimes();
    replay(requestMock2);
View Full Code Here

    reset();
   
    JaxRsHandler handler = HandlerCreator.getHandler(MyResource5.class);

    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.PUT).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/resource");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
    replay(requestURI);
    replay(responseMock);
    handler.handle(requestMock, responseMock);
   
    assertTrue(handleGetInvoked && !superHandleGetInvoked);
   
    reset();
   
    Request requestMock2 = EasyMock.createNiceMock(Request.class);
    Response responseMock2 = EasyMock.createNiceMock(Response.class);
    expect(requestMock2.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI2 = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI2.getPath()).andReturn("/superclass");
    expect(requestMock2.getRequestURI()).andReturn(requestURI2).anyTimes();
    replay(requestMock2);
View Full Code Here

  public void testOptions() throws Exception {

    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
   
    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/");
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
    replay(requestMock);
View Full Code Here

  public void testResponseObject() throws Exception {

    JaxRsHandler handler = HandlerCreator.getHandler(new HidingWriter2(),
        new HidingWriter(), new MyResource());
    Request requestMock = EasyMock.createNiceMock(Request.class);
    final Response responseMock = EasyMock.createNiceMock(Response.class);
   
    makeThreadSafe(responseMock, true);
    final MessageBody body = new MessageBody2Read() {

      @Override
      public ReadableByteChannel read() throws IOException {
        return Channels.newChannel(new ByteArrayInputStream(hiddenEntity.getBytes()));
      }

    };
    responseMock.setBody(BodyMatcher.eqBody(body));
    responseMock.addHeader(HeaderName.CONTENT_TYPE, "test/encoded-buffer");
    responseMock.setHeader(HeaderName.CONTENT_LENGTH, (long)entity.length());
    responseMock.setResponseStatus(ResponseStatus.SUCCESS);
    expect(requestMock.getMethod()).andReturn(Method.GET);
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/");
    expect(requestMock.getRequestURI()).andReturn(requestURI);
    replay(requestMock);
    replay(requestURI);
    replay(responseMock);
    Thread thread = new Thread() {

      @Override
      public void run() {
        try {
          responseMock.setResponseStatus(ResponseStatus.SUCCESS);
          responseMock.setHeader(HeaderName.CONTENT_LENGTH, (long)entity.length());
          responseMock.addHeader(HeaderName.get(HeaderName.CONTENT_TYPE.toString()), "test/encoded-buffer");
          responseMock.setBody(body);
        } catch (HandlerException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
View Full Code Here

  public void testQueryParam() throws Exception {

    JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class);
   
    Request requestMock = EasyMock.createNiceMock(Request.class);
    Response responseMock = EasyMock.createNiceMock(Response.class);
    expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
    RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
    expect(requestURI.getPath()).andReturn("/foo").anyTimes();
    expect(requestURI.getQuery()).andReturn("key=value").anyTimes();
    expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.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.