Package org.apache.axis2.transport.http.mock

Examples of org.apache.axis2.transport.http.mock.MockHTTPResponse


        t.start();
        log.info((sslContext == null ? "HTTP" : "HTTPS") + " Sender starting");

        // register with JMX
        mbeanSupport
            = new TransportMBeanSupport(this, "nio-http" + (sslContext == null ? "" : "s"));
        mbeanSupport.register();
       
        state = BaseConstants.STARTED;
    }
View Full Code Here


            String charSetEncoding = BuilderUtil.getCharSetEncoding(contentTypeStr);
            msgContext.setProperty(
                    Constants.Configuration.CHARACTER_SET_ENCODING, charSetEncoding);
            boolean eprFound = false;
            if (endpointsConfiguration != null) {
                URLEndpoint epr = endpointsConfiguration.getEndpoint(request.getRequestLine().getUri());
                if (epr != null) {
                    eprFound = true;
                    String type = TransportUtils.getContentType(contentTypeStr, msgContext);
                    msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type);
                    epr.setParameters(msgContext);

                    Builder builder = epr.getBuilder(type);
                    if (HTTPTransportUtils.isRESTRequest(contentTypeStr)) {
                        RESTUtil.processPOSTRequest(msgContext, is, os,
                                request.getRequestLine().getUri(), contentType, builder, isRestDispatching);
                    } else {
View Full Code Here

            String contentTypeStr = contentType != null ?
                    contentType.getValue() : inferContentType();

            boolean eprFound = false;
            if (endpointsConfiguration != null) {
                URLEndpoint epr = endpointsConfiguration.getEndpoint(request.getRequestLine().getUri());
                if (epr != null) {
                    eprFound = true;
                    String type = TransportUtils.getContentType(contentTypeStr, msgContext);
                    msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type);

                    epr.setParameters(msgContext);

                    Builder builder = epr.getBuilder(type);
                    RESTUtil.processGetAndDeleteRequest(
                            msgContext, os, request.getRequestLine().getUri(),
                            request.getFirstHeader(HTTP.CONTENT_TYPE), builder,
                            method, isRestDispatching);
                }
View Full Code Here

        params = getListenerParameters();


        param = transportIn.getParameter(NhttpConstants.ENDPOINTS_CONFIGURATION);
        if (param != null && param.getValue() != null) {
            endpoints = new URLEndpointsConfigurationFactory().create(param.getValue().toString());
        }
    }
View Full Code Here

        HttpParams params = getClientParameters();
        try {
            String prefix = (sslContext == null ? "http" : "https") + "-Sender I/O dispatcher";
            ioReactor = new DefaultConnectingIOReactor(
                NHttpConfiguration.getInstance().getClientIOWorkers(),
                new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix), params);
            ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
                public boolean handle(IOException ioException) {
                    log.warn("System may be unstable: IOReactor encountered a checked exception : " +
                        ioException.getMessage(), ioException);
                    return true;
View Full Code Here

public abstract class CommonsHTTPTransportSenderTest extends TestCase  {
   
    protected abstract TransportSender getTransportSender();

    public void testInvokeWithServletBasedOutTransportInfo() throws Exception {
        MockHTTPResponse httpResponse = new MockHttpServletResponse();
        ServletBasedOutTransportInfo info = new ServletBasedOutTransportInfo(
                (HttpServletResponse) httpResponse);
        SOAPEnvelope envelope = getEnvelope();
        httpResponse = configAndRun(httpResponse, info, null, getTransportSender());

        assertEquals("Not the expected Header value", "application/xml", httpResponse.getHeaders()
                .get("Content-Type"));
        assertEquals("Not the expected Header value", "custom-value", httpResponse.getHeaders()
                .get("Custom-header"));
        assertEquals("Not the expected body content", envelope.toString().replace("utf", "UTF"),
                new String(httpResponse.getByteArrayOutputStream().toByteArray()));
    }
View Full Code Here

                new String(httpResponse.getByteArrayOutputStream().toByteArray()));
    }
   
    public void testInvokeWithAxisHttpResponseImpl() throws Exception {
        RequestLine line = new BasicRequestLine("", "", new ProtocolVersion("http", 1, 0));
        MockHTTPResponse httpResponse = new MockAxisHttpResponse(line);
        SOAPEnvelope envelope = getEnvelope();
        httpResponse = (MockAxisHttpResponse) configAndRun(httpResponse,
                (OutTransportInfo) httpResponse, null, getTransportSender());

        assertEquals("Not the expected Header value", "application/xml", httpResponse.getHeaders()
                .get("Content-Type"));
        assertEquals("Not the expected Header value", "custom-value", httpResponse.getHeaders()
                .get("Custom-header"));
        assertEquals("Not the expected body content", envelope.toString().replace("utf", "UTF"),
                new String(httpResponse.getByteArrayOutputStream().toByteArray()));
    }
View Full Code Here

    }

    public static MockHTTPResponse configAndRun(MockHTTPResponse outResponse,
            OutTransportInfo outTransportInfo, String epr, TransportSender sender) throws Exception {
        MockHTTPResponse response = outResponse;
        ConfigurationContext confContext = ConfigurationContextFactory
                .createEmptyConfigurationContext();
        TransportOutDescription transportOut = new TransportOutDescription("http");
        Parameter param = new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, false);
        SOAPEnvelope envelope = getEnvelope();
View Full Code Here

public class CommonsHTTPTransportSenderClientSideTest extends AbstractHTTPServerTest {

    public void testInvokeWithEPR() throws Exception {
        int port = getBasicHttpServer().getPort();
        RequestLine line = new BasicRequestLine("", "", new ProtocolVersion("http", 1, 0));
        MockHTTPResponse httpResponse = new MockAxisHttpResponse(line);
        getBasicHttpServer().setResponseTemplate(BasicHttpServer.RESPONSE_HTTP_OK_LOOP_BACK);

        // We only interested on HTTP message sent to the server side by this
        // client hence ignore the processing of response at client side.
        try {
View Full Code Here

            // set ClientOptions to the current outgoing message
            outMsgCtx.setOptions(options);

      // do Target Resolution
      TargetResolver tr = cfgCtx.getAxisConfiguration().getTargetResolverChain();
            if (tr != null) {
                tr.resolveTarget(outMsgCtx);
            }

            // if the transport to use for sending is not specified, try to find it from the URL
      TransportOutDescription transportOut = options.getTransportOut();
      if (transportOut == null) {
View Full Code Here

TOP

Related Classes of org.apache.axis2.transport.http.mock.MockHTTPResponse

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.