Search in sources :

Example 41 with GuidGenerator

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

the class MarshallingBaseCase method testMarshalToURL.

@Test
public void testMarshalToURL() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    URL url = f.toURI().toURL();
    try {
        marshaller.marshal(null, (URL) null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(adapter, (URL) null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(null, url);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(adapter, new URL("http://development.adaptris.com/bugs"));
        fail();
    } catch (CoreException e) {
        assertEquals("URL protocol must be file:", e.getMessage());
    }
    marshaller.marshal(adapter, url);
}
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) URL(java.net.URL) Test(org.junit.Test)

Example 42 with GuidGenerator

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

the class Base58Test method testTranslate.

@Test
public void testTranslate() throws Exception {
    Base58ByteTranslator b = new Base58ByteTranslator();
    String b58 = Base58.encode(new GuidGenerator().getUUID().getBytes(StandardCharsets.UTF_8));
    assertEquals(b58, b.translate(b.translate(b58)));
}
Also used : GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Example 43 with GuidGenerator

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

the class ByteTranslatorTest method testSimpleByteTranslator.

@Test
public void testSimpleByteTranslator() throws Exception {
    ByteTranslator b = new SimpleByteTranslator();
    String uniq = new GuidGenerator().getUUID();
    byte[] bytes = b.translate(uniq);
    String result = b.translate(bytes);
    assertEquals(uniq, result);
}
Also used : GuidGenerator(com.adaptris.util.GuidGenerator) Test(org.junit.Test)

Example 44 with GuidGenerator

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

the class DefaultSerializableMessageTranslator method translate.

@Override
public AdaptrisMessage translate(SerializableMessage message) throws CoreException {
    try {
        AdaptrisMessage adaptrisMessage = null;
        if (StringUtils.isEmpty(message.getContentEncoding())) {
            adaptrisMessage = messageFactory.newMessage(message.getContent(), convertMap(message.getMessageHeaders()));
        } else {
            adaptrisMessage = messageFactory.newMessage(message.getContent(), message.getContentEncoding(), convertMap(message.getMessageHeaders()));
        }
        if (MimeConstants.ENCODING_BASE64.equalsIgnoreCase(message.getMessageHeaders().get(CoreConstants.SERIALIZED_MESSAGE_ENCODING))) {
            adaptrisMessage.setPayload(Base64.getDecoder().decode(message.getContent()));
        }
        if (StringUtils.isEmpty(message.getUniqueId()))
            message.setUniqueId(new GuidGenerator().create(this));
        adaptrisMessage.setUniqueId(message.getUniqueId());
        adaptrisMessage.setNextServiceId(message.getNextServiceId());
        return adaptrisMessage;
    } catch (UnsupportedEncodingException ex) {
        throw new CoreException(ex);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) GuidGenerator(com.adaptris.util.GuidGenerator)

Example 45 with GuidGenerator

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

the class MessageLifecycleEventTest method testSetMleMarkers.

@Test
public void testSetMleMarkers() throws Exception {
    MessageLifecycleEvent mle = new MessageLifecycleEvent();
    List list = Arrays.asList(new MleMarker[] { new MleMarker(MLEMARKER_NAME, true, 0, new GuidGenerator().create(new Object())), new MleMarker(MLEMARKER_NAME, true, 1, new GuidGenerator().create(new Object())) });
    mle.setMleMarkers(list);
    assertEquals(2, mle.getMleMarkers().size());
    assertEquals(list, mle.getMleMarkers());
}
Also used : List(java.util.List) 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