Search in sources :

Example 1 with TransportDescriptionFactory

use of org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory 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 2 with TransportDescriptionFactory

use of org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory 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 3 with TransportDescriptionFactory

use of org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory in project wso2-synapse by wso2.

the class VFSTransportListenerTest method testVFSTransportListenerBasics.

/**
 * Testcase to test basic functionality of {@link VFSTransportListener}
 * @throws Exception
 */
public void testVFSTransportListenerBasics() throws Exception {
    MockFileHolder.getInstance().clear();
    String fileUri = "test1:///foo/bar/test-" + System.currentTimeMillis() + "/DIR/IN/";
    String moveAfterFailure = "test1:///foo/bar/test-" + System.currentTimeMillis() + "/DIR/FAIL/";
    AxisService axisService = new AxisService("testVFSService");
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_FILE_URI, fileUri));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_CONTENT_TYPE, "text/xml"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_FILE_NAME_PATTERN, ".*\\.txt"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_ACTION_AFTER_PROCESS, VFSTransportListener.MOVE));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_ACTION_AFTER_FAILURE, VFSTransportListener.MOVE));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_MOVE_AFTER_FAILURE, moveAfterFailure));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_MOVE_AFTER_FAILED_MOVE, moveAfterFailure));
    axisService.addParameter(new Parameter(VFSConstants.STREAMING, "false"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_LOCKING, VFSConstants.TRANSPORT_FILE_LOCKING_ENABLED));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_INTERVAL, "1000"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_FILE_COUNT, "1"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_INTERVAL, "20000"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_SAME_NODE, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_DISTRIBUTED_LOCK, "true"));
    axisService.addParameter(new Parameter(VFSConstants.TRANSPORT_DISTRIBUTED_LOCK_TIMEOUT, "20000"));
    axisService.addParameter(new Parameter(VFSConstants.FILE_SORT_PARAM, VFSConstants.FILE_SORT_VALUE_NAME));
    axisService.addParameter(new Parameter(VFSConstants.FILE_SORT_ORDER, "true"));
    TransportDescriptionFactory transportDescriptionFactory = new VFSTransportDescriptionFactory();
    TransportInDescription transportInDescription = null;
    try {
        transportInDescription = transportDescriptionFactory.createTransportInDescription();
    } catch (Exception e) {
        Assert.fail("Error occurred while creating transport in description");
    }
    VFSTransportListener vfsTransportListener = getListener(transportInDescription);
    // initialize listener
    vfsTransportListener.init(new ConfigurationContext(new AxisConfiguration()), transportInDescription);
    // Initialize VFSTransportListener
    vfsTransportListener.doInit();
    // Start listener
    vfsTransportListener.start();
    // Create poll entry
    PollTableEntry pollTableEntry = vfsTransportListener.createEndpoint();
    Assert.assertTrue("Global file locking not applied to created poll entry", pollTableEntry.isFileLockingEnabled());
    // Load configuration of poll entry
    pollTableEntry.loadConfiguration(axisService);
    populatePollTableEntry(pollTableEntry, axisService, vfsTransportListener);
    vfsTransportListener.poll(pollTableEntry);
    MockFile targetDir = MockFileHolder.getInstance().getFile(fileUri);
    Assert.assertNotNull("Failed target directory creation", targetDir);
    Assert.assertEquals("Created target directory is not Folder type", targetDir.getName().getType(), FileType.FOLDER);
    MockFile failDir = MockFileHolder.getInstance().getFile(moveAfterFailure);
    Assert.assertNotNull("Fail to create expected directory to move files when failure", failDir);
    MockFileHolder.getInstance().clear();
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) MockFile(org.wso2.carbon.inbound.endpoint.protocol.file.MockFile) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory)

Example 4 with TransportDescriptionFactory

use of org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory in project wso2-synapse by wso2.

the class FIXTransportListenerTest method testFIXTransportListenerInit.

@Test
public void testFIXTransportListenerInit() throws Exception {
    AxisService axisService = new AxisService("testFIXService");
    axisService.addParameter(new Parameter(FIXConstants.FIX_ACCEPTOR_CONFIG_URL_PARAM, "/sample/path/Mock.cfg"));
    axisService.addParameter(new Parameter(FIXConstants.FIX_INITIATOR_CONFIG_URL_PARAM, "/sample/path/Mock2.cfg"));
    ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
    TransportDescriptionFactory transportDescriptionFactory = new TransportDescriptionFactory() {

        @Override
        public TransportOutDescription createTransportOutDescription() throws Exception {
            TransportOutDescription trpOutDesc = new TransportOutDescription("fix");
            trpOutDesc.setSender(new FIXTransportSender());
            return trpOutDesc;
        }

        @Override
        public TransportInDescription createTransportInDescription() throws Exception {
            TransportInDescription trpInDesc = new TransportInDescription("fix");
            trpInDesc.setReceiver(new FIXTransportListener());
            return trpInDesc;
        }
    };
    TransportInDescription transportInDescription = null;
    try {
        transportInDescription = transportDescriptionFactory.createTransportInDescription();
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Error occurred while creating transport in description");
    }
    FIXTransportListener listner = new FIXTransportListener();
    listner.init(cfgCtx, transportInDescription);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with TransportDescriptionFactory

use of org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory in project wso2-synapse by wso2.

the class HttpCoreNIOListenerTest method suite.

public static TestSuite suite() throws Exception {
    ManagedTestSuite suite = new ManagedTestSuite(HttpCoreNIOListenerTest.class);
    // These tests don't work because of a problem similar to SYNAPSE-418
    suite.addExclude("(test=EchoXML)");
    TransportDescriptionFactory tdfNIO = new HttpTransportDescriptionFactory();
    HttpTransportTestSuiteBuilder builder = new HttpTransportTestSuiteBuilder(suite, tdfNIO);
    builder.addAxisTestClientConfigurator(new HttpAxisTestClientConfigurator(false));
    builder.addAxisTestClientConfigurator(new HttpAxisTestClientConfigurator(true));
    return suite;
}
Also used : HttpTransportTestSuiteBuilder(org.apache.axis2.transport.testkit.http.HttpTransportTestSuiteBuilder) ManagedTestSuite(org.apache.axis2.transport.testkit.ManagedTestSuite) TransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)4 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)3 TransportInDescription (org.apache.axis2.description.TransportInDescription)3 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)3 TransportDescriptionFactory (org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory)3 AxisService (org.apache.axis2.description.AxisService)2 Parameter (org.apache.axis2.description.Parameter)2 Setup (org.apache.axis2.transport.testkit.tests.Setup)2 ListenerManager (org.apache.axis2.engine.ListenerManager)1 CustomAxisConfigurator (org.apache.axis2.transport.CustomAxisConfigurator)1 UtilsTransportServer (org.apache.axis2.transport.UtilsTransportServer)1 ManagedTestSuite (org.apache.axis2.transport.testkit.ManagedTestSuite)1 HttpTransportTestSuiteBuilder (org.apache.axis2.transport.testkit.http.HttpTransportTestSuiteBuilder)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 MockFile (org.wso2.carbon.inbound.endpoint.protocol.file.MockFile)1