Search in sources :

Example 36 with GuidGenerator

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

the class MarshallingBaseCase method testUnmarshalFromUrlStringLocalFile.

@Test
public void testUnmarshalFromUrlStringLocalFile() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    String fname = f.getCanonicalPath();
    if (Os.isFamily(Os.WINDOWS_FAMILY)) {
        // THis is juist to remove c: and leave us with \blah.
        fname = f.getCanonicalPath().substring(2).replaceAll("\\\\", "/");
    }
    marshaller.marshal(adapter, f);
    Adapter o2 = (Adapter) marshaller.unmarshal(new URLString(fname));
    assertRoundtripEquality(adapter, o2);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) URLString(com.adaptris.util.URLString) File(java.io.File) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Example 37 with GuidGenerator

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

the class MarshallingBaseCase method testRoundTripToFile.

@Test
public void testRoundTripToFile() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    marshaller.marshal(adapter, f);
    assertRoundtripEquality(adapter, marshaller.unmarshal(f));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 38 with GuidGenerator

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

the class MarshallingBaseCase method testRoundTripToURL.

@Test
public void testRoundTripToURL() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    marshaller.marshal(adapter, f.toURI().toURL());
    assertRoundtripEquality(adapter, marshaller.unmarshal(f.toURI().toURL()));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 39 with GuidGenerator

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

the class MarshallingBaseCase method testMarshalToFile_NonExistent.

@Test
public void testMarshalToFile_NonExistent() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File dir = File.createTempFile("pfx", ".sfx");
    File nonExistent = new File(dir, new GuidGenerator().getUUID());
    try {
        marshaller.marshal(adapter, nonExistent);
        fail();
    } catch (CoreException expected) {
    } finally {
        FileUtils.deleteQuietly(dir);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 40 with GuidGenerator

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

the class MarshallingBaseCase method testUnmarshal_NonExistent.

@Test
public void testUnmarshal_NonExistent() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    File dir = File.createTempFile("pfx", ".sfx");
    File nonExistent = new File(dir, new GuidGenerator().getUUID());
    try {
        marshaller.unmarshal(nonExistent);
        fail();
    } catch (CoreException expected) {
    } finally {
        FileUtils.deleteQuietly(dir);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) 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