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();
}
}
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();
}
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();
}
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);
}
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;
}
Aggregations