Search in sources :

Example 71 with DefaultMessageFactory

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

Example 72 with DefaultMessageFactory

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);
    }
}
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)

Example 73 with DefaultMessageFactory

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"));
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) File(java.io.File) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 74 with DefaultMessageFactory

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));
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 75 with DefaultMessageFactory

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);
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)170 Test (org.junit.Test)163 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)158 Channel (com.adaptris.core.Channel)37 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)36 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 StandaloneProducer (com.adaptris.core.StandaloneProducer)27 ServiceException (com.adaptris.core.ServiceException)26 File (java.io.File)26 ServiceList (com.adaptris.core.ServiceList)18 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)18 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)18 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)18 GuidGenerator (com.adaptris.util.GuidGenerator)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)15 ValidationStage (com.adaptris.transform.validate.ValidationStage)15 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10