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