Search in sources :

Example 1 with NioWorker

use of com.adaptris.fs.NioWorker 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);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) NioWorker(com.adaptris.fs.NioWorker) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) MetadataFileNameCreator(com.adaptris.core.MetadataFileNameCreator) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 MetadataFileNameCreator (com.adaptris.core.MetadataFileNameCreator)1 ProduceException (com.adaptris.core.ProduceException)1 NioWorker (com.adaptris.fs.NioWorker)1 GuidGenerator (com.adaptris.util.GuidGenerator)1 File (java.io.File)1 Test (org.junit.Test)1