Search in sources :

Example 1 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class AxisTestClient method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception {
    this.configurators = configurators;
    sender = context.getSender();
    serviceClient = new ServiceClient(context.getConfigurationContext(), null);
    axisOptions = new Options();
    axisOptions.setTo(channel.getEndpointReference());
    serviceClient.setOptions(axisOptions);
}
Also used : Options(org.apache.axis2.client.Options) ClientOptions(org.apache.axis2.transport.testkit.client.ClientOptions) ServiceClient(org.apache.axis2.client.ServiceClient) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 2 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class AxisTestClientContext method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(TransportDescriptionFactory tdf, AxisTestClientContextConfigurator[] configurators) throws Exception {
    cfgCtx = ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
    AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
    TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
    axisCfg.addTransportOut(trpOutDesc);
    sender = trpOutDesc.getSender();
    sender.init(cfgCtx, trpOutDesc);
    boolean useListener = false;
    for (AxisTestClientContextConfigurator configurator : configurators) {
        if (configurator.isTransportListenerRequired()) {
            useListener = true;
            break;
        }
    }
    TransportInDescription trpInDesc;
    if (useListener) {
        trpInDesc = tdf.createTransportInDescription();
    } else {
        trpInDesc = null;
    }
    for (AxisTestClientContextConfigurator configurator : configurators) {
        configurator.setupTransport(trpInDesc, trpOutDesc);
    }
    if (useListener) {
        listenerManager = new ListenerManager();
        listenerManager.init(cfgCtx);
        cfgCtx.setTransportManager(listenerManager);
        listenerManager.addListener(trpInDesc, false);
        listenerManager.start();
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) CustomAxisConfigurator(org.apache.axis2.transport.CustomAxisConfigurator) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) ListenerManager(org.apache.axis2.engine.ListenerManager) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 3 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class AxisTestEndpoint method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(LogManager logManager, AxisTestEndpointContext context, Channel channel, AxisServiceConfigurator[] configurators) throws Exception {
    this.context = context;
    TransportListener listener = context.getTransportListener();
    if (listener instanceof TransportErrorSource) {
        transportErrorSource = (TransportErrorSource) listener;
        errorListener = new TransportErrorListener() {

            public void error(TransportError error) {
                AxisService s = error.getService();
                if (s == null || s == service) {
                    onTransportError(error.getException());
                }
            }
        };
        transportErrorSource.addErrorListener(errorListener);
    } else {
        transportErrorSource = null;
    }
    String path;
    try {
        path = new URI(channel.getEndpointReference().getAddress()).getPath();
    } catch (URISyntaxException ex) {
        path = null;
    }
    String serviceName;
    if (path != null && path.startsWith(Channel.CONTEXT_PATH + "/")) {
        serviceName = path.substring(Channel.CONTEXT_PATH.length() + 1);
    } else {
        serviceName = "TestService-" + UUID.randomUUID();
    }
    service = new AxisService(serviceName);
    service.addOperation(createOperation());
    if (configurators != null) {
        for (AxisServiceConfigurator configurator : configurators) {
            configurator.setupService(service, false);
        }
    }
    // Output service parameters to log file
    // FIXME: This actually doesn't give the expected result because the AxisTestEndpoint might be reused
    // by several test cases and in that case the log file is only produced once
    List<Parameter> params = (List<Parameter>) service.getParameters();
    if (!params.isEmpty()) {
        PrintWriter log = new PrintWriter(logManager.createLog("service-parameters"), false);
        try {
            for (Parameter param : params) {
                log.print(param.getName());
                log.print("=");
                log.println(param.getValue());
            }
        } finally {
            log.close();
        }
    }
    // We want to receive all messages through the same operation:
    service.addParameter(AxisService.SUPPORT_SINGLE_OP, true);
    context.getAxisConfiguration().addService(service);
    // The transport may disable the service. In that case, fail directly.
    if (!BaseUtils.isUsingTransport(service, context.getTransportName())) {
        Assert.fail("The service has been disabled by the transport");
    }
}
Also used : TransportError(org.apache.axis2.transport.base.event.TransportError) AxisServiceConfigurator(org.apache.axis2.transport.testkit.axis2.AxisServiceConfigurator) AxisService(org.apache.axis2.description.AxisService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) TransportErrorSource(org.apache.axis2.transport.base.event.TransportErrorSource) TransportListener(org.apache.axis2.transport.TransportListener) TransportErrorListener(org.apache.axis2.transport.base.event.TransportErrorListener) Parameter(org.apache.axis2.description.Parameter) List(java.util.List) PrintWriter(java.io.PrintWriter) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 4 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class AxisTestEndpointContext method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(TransportDescriptionFactory tdf, AxisTestEndpointContextConfigurator[] configurators) throws Exception {
    server = new UtilsTransportServer();
    TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
    trpInDesc = tdf.createTransportInDescription();
    server.addTransport(trpInDesc, trpOutDesc);
    for (AxisTestEndpointContextConfigurator configurator : configurators) {
        configurator.setupTransport(trpInDesc, trpOutDesc);
    }
    ConfigurationContext cfgCtx = server.getConfigurationContext();
    cfgCtx.setContextRoot("/");
    cfgCtx.setServicePath("services");
    AxisConfiguration axisConfiguration = server.getAxisConfiguration();
    server.start();
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) UtilsTransportServer(org.apache.axis2.transport.UtilsTransportServer) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 5 with Setup

use of org.apache.axis2.transport.testkit.tests.Setup in project wso2-axis2-transports by wso2.

the class JettyEndpoint method setUp.

@Setup
@SuppressWarnings({ "unused", "serial" })
private void setUp(JettyServer server, HttpChannel channel) throws Exception {
    this.server = server;
    final String path = "/" + channel.getServiceName();
    handler = new AbstractHttpHandler() {

        public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException {
            if (pathInContext.equals(path)) {
                JettyEndpoint.this.handle(pathParams, request, response);
                request.setHandled(true);
            }
        }
    };
    server.getContext().addHandler(handler);
    handler.start();
}
Also used : HttpRequest(org.mortbay.http.HttpRequest) HttpResponse(org.mortbay.http.HttpResponse) HttpException(org.mortbay.http.HttpException) IOException(java.io.IOException) AbstractHttpHandler(org.mortbay.http.handler.AbstractHttpHandler) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Aggregations

Setup (org.apache.axis2.transport.testkit.tests.Setup)16 ConnectionFactory (javax.jms.ConnectionFactory)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 InetSocketAddress (java.net.InetSocketAddress)2 Destination (javax.jms.Destination)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 AxisService (org.apache.axis2.description.AxisService)2 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)2 Tunnel (org.apache.axis2.transport.testkit.util.tcpmon.Tunnel)2 GreenMail (com.icegreen.greenmail.util.GreenMail)1 ServerSetup (com.icegreen.greenmail.util.ServerSetup)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PrintWriter (java.io.PrintWriter)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Properties (java.util.Properties)1 BytesMessage (javax.jms.BytesMessage)1 Message (javax.jms.Message)1