use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class ViolationHandlerTest method testAsMetadata.
@Test
public void testAsMetadata() throws Exception {
ViolationsAsMetadata handler = new ViolationsAsMetadata().withMetadataKey(DEFAULT_KEY);
List<SAXParseException> exceptions = Arrays.asList(createException("first"), createException("second"));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
handler.handle(exceptions, msg);
assertTrue(msg.headersContainsKey(DEFAULT_KEY));
SchemaViolations v = (SchemaViolations) new XStreamMarshaller().unmarshal(msg.getMetadataValue(DEFAULT_KEY));
assertEquals(2, v.getViolations().size());
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class ViolationHandlerTest method testAsPayload.
@Test
public void testAsPayload() throws Exception {
OverwritePayload handler = new OverwritePayload();
List<SAXParseException> exceptions = Arrays.asList(createException("first"), createException("second"));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
handler.handle(exceptions, msg);
assertFalse(msg.headersContainsKey(DEFAULT_KEY));
SchemaViolations v = (SchemaViolations) new XStreamMarshaller().unmarshal(msg.getContent());
assertEquals(2, v.getViolations().size());
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class JdbcServiceCase method testBackReferences.
protected <T extends JdbcService> void testBackReferences(T testObject) throws Exception {
JdbcConnection conn = new JdbcConnection();
conn.setConnectUrl("jdbc:derby:memory:" + GUID.safeUUID() + ";create=true");
conn.setDriverImp("org.apache.derby.jdbc.EmbeddedDriver");
testObject.setConnection(conn);
// redmineID #4536, exception listener is set in .init()
testObject.init();
assertEquals(conn, testObject.getConnection());
assertEquals(1, conn.retrieveExceptionListeners().size());
assertTrue(testObject == conn.retrieveExceptionListeners().toArray()[0]);
testObject.start();
testObject.stop();
testObject.close();
// Now marshall and see if it's the same.
XStreamMarshaller m = new XStreamMarshaller();
String xml = m.marshal(testObject);
@SuppressWarnings("unchecked") T testObject2 = (T) m.unmarshal(xml);
// redmineID #4536, exception listener now must simply be set in .init()
testObject2.init();
// If the setter has been used, then these two will be "true"
assertNotNull(testObject2.getConnection());
assertEquals(1, testObject2.getConnection().retrieveExceptionListeners().size());
assertTrue(testObject2 == testObject2.getConnection().retrieveExceptionListeners().toArray()[0]);
testObject2.start();
testObject2.stop();
testObject2.close();
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class XmlExceptionReport method create.
@Override
public Document create(Exception e, String workflow, String location) throws Exception {
// Just use XStream as the marshaller, if we let them configure it, someone might configure
// a XStreamJSON which would be quite bad.
AdaptrisMarshaller m = new XStreamMarshaller();
ExceptionReport report = createReportObject(e, workflow, location);
return createDocument(m.marshal(report), (DocumentBuilderFactoryBuilder) null);
}
use of com.adaptris.core.XStreamMarshaller in project interlok by adaptris.
the class ChannelManagerTest method testGetConfiguration.
@Test
public void testGetConfiguration() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 0, 0);
AdapterManager am1 = new AdapterManager(adapter);
Channel channel = createChannel("c1", 1);
ChannelManager cm1 = new ChannelManager(channel, am1);
Channel marshalledCopy = (Channel) new XStreamMarshaller().unmarshal(cm1.getConfiguration());
assertRoundtripEquality(channel, marshalledCopy);
}
Aggregations