assertFiles(inFile, moveToDir, false, false);
}
protected Latch configureService(File inFile, boolean streaming, boolean filePayload) throws Exception
{
Service service = new SedaService(muleContext);
service.setName("moveDeleteBridgeService");
String url = fileToUrl(inFile.getParentFile()) + "?connector=moveDeleteConnector";
Transformer transformer = null;
if (streaming)
{
if (filePayload)
{
fail("Inconsistant test case: streaming and file payload are not compatible");
}
else
{
transformer = new FileMessageFactoryAssertingTransformer(ReceiverFileInputStream.class);
}
}
else
{
if (filePayload)
{
transformer = new FileMessageFactoryAssertingTransformer(File.class);
}
else
{
transformer = new FileMessageFactoryAssertingTransformer(byte[].class);
}
}
EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder(url, muleContext);
endpointBuilder.addMessageProcessor(transformer);
if (filePayload)
{
endpointBuilder.addMessageProcessor(new NoActionTransformer());
}
InboundEndpoint endpoint =
muleContext.getEndpointFactory().getInboundEndpoint(endpointBuilder);
((CompositeMessageSource) service.getMessageSource()).addSource(endpoint);
final Latch latch = new Latch();
FunctionalTestComponent testComponent = new FunctionalTestComponent();
testComponent.setMuleContext(muleContext);
testComponent.setEventCallback(new EventCallback()
{
@Override
public void eventReceived(final MuleEventContext context, final Object message) throws Exception
{
assertEquals(1, latch.getCount());
assertEquals(TEST_MESSAGE, context.transformMessageToString());
latch.countDown();
}
});
testComponent.initialise();
final DefaultJavaComponent component = new DefaultJavaComponent(new SingletonObjectFactory(testComponent));
component.setMuleContext(muleContext);
service.setComponent(component);
service.setModel(muleContext.getRegistry().lookupSystemModel());
muleContext.getRegistry().registerService(service);
return latch;
}