use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class TraversingFsConsumerTest method testConsume_WithFilter.
@Test
public void testConsume_WithFilter() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setFilterExpression(".*xml");
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
start(sc);
createFiles(baseDir, ".xml", count);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count);
} finally {
stop(sc);
File baseDir = new File(parentDir, subDir);
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class TraversingFsConsumerTest method testConsume.
@Test
public void testConsume() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
start(sc);
createFiles(baseDir, ".xml", count);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count);
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class TraversingFsConsumerTest method createDirectoryTree.
private File createDirectoryTree(File baseDir) {
File result = baseDir;
int i = new Random().nextInt(20);
switch(i % 3) {
case 0:
result = createDirectoryTree(new File(baseDir, new GuidGenerator().safeUUID()));
break;
case 1:
result = new File(baseDir, new GuidGenerator().safeUUID());
break;
default:
result = baseDir;
break;
}
return result;
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class AggregatingFsConsumeServiceTest method testService_MultipleMessages.
@Test
public void testService_MultipleMessages() throws Exception {
GuidGenerator o = new GuidGenerator();
File tempDir = TempFileUtils.createTrackedDir(o);
String url = "file://localhost/" + tempDir.getCanonicalPath().replaceAll("\\\\", "/");
AggregatingFsConsumer afc = createConsumer(url, ".*", new IgnoreOriginalMimeAggregator());
AggregatingFsConsumeService service = createAggregatingService(afc);
try {
writeDataMessage(tempDir, o.safeUUID());
writeDataMessage(tempDir, o.safeUUID());
start(service);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(INITIAL_PAYLOAD);
service.doService(msg);
BodyPartIterator input = MimeHelper.createBodyPartIterator(msg);
assertEquals(2, input.size());
} finally {
stop(service);
}
}
use of com.adaptris.util.GuidGenerator in project interlok by adaptris.
the class DynamicServiceExecutorTest method createMimeMessage.
public static AdaptrisMessage createMimeMessage(Service s, String encoding) throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(s);
MultiPartOutput output = new MultiPartOutput(new GuidGenerator().getUUID());
output.getMimeHeader().addHeader("Subject", "This is the Subject");
output.addPart(xml, encoding, "Service");
output.addPart("pack my jug with a dozen liquor jugs", encoding, "part2");
try (OutputStream out = msg.getOutputStream()) {
output.writeTo(out);
}
return msg;
}
Aggregations