Search in sources :

Example 1 with MockFileHolder

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));
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) MockFileHolder(org.wso2.carbon.inbound.endpoint.protocol.file.MockFileHolder) VFSOutTransportInfo(org.apache.synapse.commons.vfs.VFSOutTransportInfo) OutTransportInfo(org.apache.axis2.transport.OutTransportInfo) Parameter(org.apache.axis2.description.Parameter) MessageContext(org.apache.axis2.context.MessageContext) MessageContext(org.apache.axis2.context.MessageContext) VFSOutTransportInfo(org.apache.synapse.commons.vfs.VFSOutTransportInfo) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Aggregations

ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 MessageContext (org.apache.axis2.context.MessageContext)1 Parameter (org.apache.axis2.description.Parameter)1 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 OutTransportInfo (org.apache.axis2.transport.OutTransportInfo)1 VFSOutTransportInfo (org.apache.synapse.commons.vfs.VFSOutTransportInfo)1 MockFileHolder (org.wso2.carbon.inbound.endpoint.protocol.file.MockFileHolder)1