Package org.mortbay.http

Examples of org.mortbay.http.HttpResponse


public class ProxyHanderUnitTest extends TestCase {

  public void testSendNotFoundSends404ResponseCode() throws Exception {
    ProxyHandler proxyHandler = new ProxyHandler(true, "", "");
    HttpResponse httpResponseMock = createMock(HttpResponse.class);
    httpResponseMock.sendError(HttpResponse.__404_Not_Found, "Not found");
    expectLastCall().once();
    replay(httpResponseMock);
    proxyHandler.sendNotFound(httpResponseMock);
    verify(httpResponseMock);
  }
View Full Code Here


            "sendNotFound", HttpResponse.class) });
   
    String pathInContext = "/invalid";
    String pathParams = "";
    HttpRequest httpRequest = new HttpRequest();
    HttpResponse httpResponse = new HttpResponse();
    httpResponse.setAttribute("NotFound", "True");
   
    proxyHandlerMock.sendNotFound(httpResponse);
    expectLastCall().once();
    replay(proxyHandlerMock);
   
    proxyHandlerMock.handle(pathInContext, pathParams, httpRequest,
        httpResponse);
    assertNull(httpResponse.getAttribute("NotFound"));
    verify(proxyHandlerMock);
  }
View Full Code Here

    public void tearDown() {
        StaticContentHandler.setSlowResources(slowResourcesInitially);
    }

    public void testShouldMakePageNotCachedWhenHandle() throws Exception {
        HttpResponse response = new HttpResponse();
        handler.handle("", "", new HttpRequest(), response);
        assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", response.getField("Expires"));
    }
View Full Code Here

    public void testHandleSetsResponseAttributeInCaseOfMissingResource() throws Exception {
      String pathInContext = "/invalid";
      String pathParams = "";
      HttpRequest httpRequest = new HttpRequest();
      HttpResponse httpResponse = new HttpResponse();
      handler.handle(pathInContext, pathParams, httpRequest, httpResponse);
      assertEquals("True", httpResponse.getAttribute("NotFound"));
    }
View Full Code Here

      });

      String pathInContext = "/driver/?cmd=getNewBrowserSession&1=*chrome&2=http://www.google.com";
      String pathParams = "";
      HttpRequest httpRequest = new HttpRequest();
      HttpResponse httpResponse = new HttpResponse();
     
      expect(mock.getResource(pathInContext)).andReturn(Resource.newResource("found_resource"));
      mock.callSuperHandle(pathInContext, pathParams, httpRequest, httpResponse);
      expectLastCall().once();
      replay(mock);
     
      mock.handle(pathInContext, pathParams, httpRequest, httpResponse);
      assertEquals(HttpResponse.__200_OK, httpResponse.getStatus());
      verify(mock);
    }
View Full Code Here

     * @param address the backchannel address (null to indicate anonymous)
     * @return a suitable Conduit
     */
    public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address)
        throws IOException {
        HttpResponse response = (HttpResponse)inMessage.get(HTTP_RESPONSE);
        Conduit backChannel = null;
        Exchange ex = inMessage.getExchange();
        EndpointReferenceType target = address != null ? address : ex.get(EndpointReferenceType.class);
        if (target == null) {
            backChannel = new BackChannelConduit(response);
View Full Code Here

    protected OutputStream flushHeaders(Message outMessage) throws IOException {
        updateResponseHeaders(outMessage);
        Object responseObj = outMessage.get(HTTP_RESPONSE);
        OutputStream responseStream = null;
        if (responseObj instanceof HttpResponse) {
            HttpResponse response = (HttpResponse)responseObj;

            Integer i = (Integer)outMessage.get(Message.RESPONSE_CODE);
            if (i != null) {
                int status = i.intValue();
                if (status == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                    response.setStatus(status, "Fault Occurred");
                } else if (status == HttpURLConnection.HTTP_ACCEPTED) {
                    response.setStatus(status, "Accepted");
                } else {
                    response.setStatus(status);
                }
            } else {
                response.setStatus(HttpURLConnection.HTTP_OK);
            }

            copyResponseHeaders(outMessage, response);
            responseStream = response.getOutputStream();

            if (isOneWay(outMessage)) {
                response.commit();
            }
        } else if (null != responseObj) {
            String m = (new org.apache.cxf.common.i18n.Message("UNEXPECTED_RESPONSE_TYPE_MSG",
                LOG, responseObj.getClass())).toString();
            LOG.log(Level.WARNING, m);
View Full Code Here

TOP

Related Classes of org.mortbay.http.HttpResponse

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.