use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FsMessageProducerTest method testProduceWithNoCreateDir.
@Test
public void testProduceWithNoCreateDir() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsProducer fs = createProducer(subdir);
fs.setCreateDirs(false);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
start(fs);
fs.produce(new DefaultMessageFactory().newMessage(TEXT));
fail();
} catch (ProduceException expected) {
} finally {
FileUtils.deleteQuietly(new File(parentDir, subdir));
stop(fs);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FsMessageProducerTest method testProduceFileAlreadyExists_NioWorker.
@Test
public void testProduceFileAlreadyExists_NioWorker() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsProducer fs = createProducer(subdir);
fs.setCreateDirs(true);
fs.setFsWorker(new NioWorker());
fs.setFilenameCreator(new MetadataFileNameCreator("targetFilename"));
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File dir = new File(parentDir, subdir);
start(fs);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
msg.addMetadata("targetFilename", new GuidGenerator().safeUUID());
dir.mkdirs();
File targetFile = new File(dir, msg.getMetadataValue("targetFilename"));
targetFile.createNewFile();
fs.produce(msg);
fail();
} catch (ProduceException expected) {
} finally {
FileUtils.deleteQuietly(new File(parentDir, subdir));
stop(fs);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FsMessageProducerTest method testBug1675ProduceWithSpacesInDir.
@Test
public void testBug1675ProduceWithSpacesInDir() throws Exception {
String subdir = "A%20Directory%20With%20Spaces";
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
FsProducer producer = createProducer(subdir);
StandaloneProducer sp = new StandaloneProducer(producer);
ServiceCase.execute(sp, new DefaultMessageFactory().newMessage(TEXT));
assertEquals(1, new File(parentDir, "A Directory With Spaces").listFiles().length);
} finally {
FileUtils.deleteQuietly(new File(parentDir, "A Directory With Spaces"));
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FileDataInputParameterTest method testDestination.
@Test
public void testDestination() throws Exception {
AdaptrisMessage m = new DefaultMessageFactory().newMessage();
FileDataInputParameter p = new FileDataInputParameter();
try {
p.url(m);
fail();
} catch (IllegalArgumentException e) {
// ok
}
p.setUrl("file:////tmp/abc");
assertEquals("file:////tmp/abc", p.url(m));
try {
p.setUrl(null);
fail();
} catch (IllegalArgumentException e) {
}
assertEquals("file:////tmp/abc", p.url(m));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class FileDataInputParameterTest method testNonExistingFile.
@Test(expected = CoreException.class)
public void testNonExistingFile() throws Exception {
AdaptrisMessage m = new DefaultMessageFactory().newMessage();
FileDataInputParameter p = new FileDataInputParameter();
try {
p.url(m);
fail();
} catch (IllegalArgumentException e) {
// ok
}
p.setUrl("file:////tmp/doesnotexist");
assertEquals("file:////tmp/doesnotexist", p.url(m));
String result = p.extract(m);
}
Aggregations