use of org.wso2.carbon.inbound.endpoint.protocol.file.MockFileHolder in project wso2-synapse by wso2.
the class VFSTransportSenderTest method testTransportSenderInitAndSend.
/**
* Test Transport sender initialization and sending a file
* @throws AxisFault
*/
public void testTransportSenderInitAndSend() throws AxisFault, XMLStreamException {
// Clear file holder
MockFileHolder.getInstance().clear();
VFSTransportSender vfsTransportSender = new VFSTransportSender();
ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
TransportOutDescription transportOutDescription = new TransportOutDescription("Test");
// Enable Autolock release
transportOutDescription.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE, true));
// Set Autolock release interval with default value
transportOutDescription.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_INTERVAL, 20000));
transportOutDescription.addParameter(new Parameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_SAME_NODE, true));
vfsTransportSender.init(configurationContext, transportOutDescription);
// Create message context
org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext();
populateMessageContext(mc);
String filePath = "test1:///foo/bar/test-" + System.currentTimeMillis() + ".ack";
String parameters = "?transport.vfs.MaxRetryCount=0&transport.vfs.ReconnectTimeout=1&" + "transport.vfs.SendFileSynchronously=true&transport.vfs.CreateFolder=true";
String fURI = filePath + parameters;
OutTransportInfo outTransportInfo = new VFSOutTransportInfo(fURI, true);
vfsTransportSender.sendMessage(mc, fURI, outTransportInfo);
MockFileHolder fileHolder = MockFileHolder.getInstance();
Assert.assertNotNull("File creation failed", fileHolder.getFile(filePath));
}
Aggregations