Search in sources :

Example 31 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class MultipartMessageBuilderTest method testService_WithContentId.

@Test
public void testService_WithContentId() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Hello World");
    msg.addMetadata("customContentId", new GuidGenerator().safeUUID());
    MultipartMessageBuilder service = new MultipartMessageBuilder().withMimeParts(new InlineMimePartBuilder()).withContentId("%message{customContentId}");
    ExampleServiceCase.execute(service, msg);
    String payload = msg.getContent();
    assertTrue(payload.contains(msg.getMetadataValue("customContentId")));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Example 32 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class JndiHelperTest method testUnbindJdbcConnection.

@Test
public void testUnbindJdbcConnection() throws Exception {
    JdbcPooledConnection connection = new JdbcPooledConnection();
    connection.setConnectUrl("jdbc:derby:memory:" + new GuidGenerator().safeUUID() + ";create=true");
    connection.setDriverImp("org.apache.derby.jdbc.EmbeddedDriver");
    connection.setMinimumPoolSize(1);
    connection.setAcquireIncrement(1);
    connection.setMaximumPoolSize(7);
    connection.setUniqueId(getName());
    InitialContext initialContext = new InitialContext(env);
    JndiHelper.bind(initialContext, connection, true);
    JndiHelper.unbind(initialContext, connection, true);
    JndiHelper.bind(initialContext, connection, false);
    JndiHelper.unbind(initialContext, connection, false);
}
Also used : GuidGenerator(com.adaptris.util.GuidGenerator) InitialContext(javax.naming.InitialContext) JdbcPooledConnection(com.adaptris.core.jdbc.JdbcPooledConnection) Test(org.junit.Test)

Example 33 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class StandardWorkerTest method setUp.

@Before
public void setUp() throws Exception {
    String subDir = new GuidGenerator().safeUUID();
    baseUrl = new URL(PROPERTIES.getProperty(BASE_KEY) + "/" + subDir);
    baseDir = FsHelper.createFileReference(baseUrl);
    baseDir.mkdirs();
}
Also used : GuidGenerator(com.adaptris.util.GuidGenerator) URL(java.net.URL) Before(org.junit.Before)

Example 34 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class StandardWorkerTest method testRenameFile.

@Test
public void testRenameFile() throws Exception {
    FsWorker worker = createWorker();
    String[] testFiles = createTestFiles();
    String newFilename = new GuidGenerator().safeUUID();
    worker.rename(new File(baseDir, testFiles[0]), new File(baseDir, newFilename));
    File[] files = worker.listFiles(baseDir);
    Set set = new HashSet(Arrays.asList(files));
    assertTrue(set.contains(new File(FsHelper.createFileReference(baseUrl), newFilename)));
    try {
        worker.rename(new File(baseDir, testFiles[0]), new File(baseDir, testFiles[1]));
        fail("pre-exisitng new name doesn't cause exception");
    } catch (FsException e) {
    /* ok */
    }
    try {
        worker.rename(baseDir, new File(baseDir, "somename"));
        fail("old file name is dir doesn't cause exception");
    } catch (FsException e) {
    /* ok */
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 35 with GuidGenerator

use of com.adaptris.util.GuidGenerator in project interlok by adaptris.

the class FtpCase method testRename.

@Test
public void testRename() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    String oldName = Thread.currentThread().getName();
    try {
        Thread.currentThread().setName(getName());
        String filename = getRemotePutFilename();
        FileTransferClient client = connectClientImpl();
        client.chdir(getRemotePutDirectory());
        client.put(FILE_TEXT.getBytes(), filename);
        String newFilename = new GuidGenerator().safeUUID();
        client.rename(filename, newFilename);
        client.delete(newFilename);
        client.disconnect();
    } finally {
        Thread.currentThread().setName(oldName);
    }
}
Also used : GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Aggregations

GuidGenerator (com.adaptris.util.GuidGenerator)134 Test (org.junit.Test)120 File (java.io.File)91 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)61 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)30 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)27 TimeInterval (com.adaptris.util.TimeInterval)25 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)23 FilenameFilter (java.io.FilenameFilter)21 ArrayList (java.util.ArrayList)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 Properties (java.util.Properties)15 Adapter (com.adaptris.core.Adapter)14 CoreException (com.adaptris.core.CoreException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)9 ServiceException (com.adaptris.core.ServiceException)8 IOException (java.io.IOException)8