use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUncheckedUnmarshalFromInputStream_WithException.
@Test
public void testUncheckedUnmarshalFromInputStream_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
try {
Object o = AdaptrisMarshaller.uncheckedUnmarshal(marshaller, adapter, () -> {
return new InputStream() {
@Override
public int read() throws IOException {
throw new IOException("testUncheckedUnmarshalFromInputStream_WithException");
}
@Override
public int read(byte[] cbuf, int off, int len) throws IOException {
throw new IOException("testUncheckedUnmarshalFromInputStream_WithException");
}
};
});
fail();
} catch (RuntimeException expected) {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterComponentChecker method applyService.
@Override
public SerializableMessage applyService(String xml, SerializableMessage serializedMsg, boolean rewriteConnections) throws CoreException {
AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
Service service = (Service) marshaller.unmarshal(xml);
if (rewriteConnections) {
service = rewriteConnectionsForTesting(service);
}
AdaptrisMessage msg = messageTranslator.translate(serializedMsg);
try {
initAndStart(service);
service.doService(msg);
} finally {
stopAndClose(service);
}
return messageTranslator.translate(msg);
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterComponentChecker method checkInitialise.
@Override
public void checkInitialise(String xml) throws CoreException {
AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
AdaptrisComponent component = (AdaptrisComponent) marshaller.unmarshal(xml);
prepare(component);
if (component instanceof AllowsRetriesConnection) {
AllowsRetriesConnection retry = (AllowsRetriesConnection) component;
if (retry.connectionAttempts() == -1) {
retry.setConnectionAttempts(0);
}
}
try {
init(component);
} finally {
close(component);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class LicenseExpiryWarningEventTest method testLegacyUnmarshal.
@Test
public void testLegacyUnmarshal() throws Exception {
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
LicenseExpiryWarningEvent evt = (LicenseExpiryWarningEvent) m.unmarshal(LEGACY_LICENSE_EVENT);
assertTrue(DateUtils.isSameDay(new Date(), evt.getExpiryDate()));
// Legacy Unmarshal will of course, change then "when()".
assertFalse(DateUtils.isSameDay(new Date(), evt.when()));
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class StandardAdapterStartUpEventTest method testLegacyUnmarshal.
@Test
public void testLegacyUnmarshal() throws Exception {
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
StandardAdapterStartUpEvent evt = (StandardAdapterStartUpEvent) m.unmarshal(LEGACY_EVENT_XML);
assertEquals("123456", evt.getUniqueId());
}
Aggregations