use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromReader_WithException.
@Test
public void testUnmarshalFromReader_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
String s = marshaller.marshal(adapter);
Reader fail = new FilterReader(new StringReader(s)) {
@Override
public int read() throws IOException {
throw new IOException("testUnmarshalFromReader_WithException");
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
throw new IOException("testUnmarshalFromReader_WithException");
}
};
try (Reader in = fail) {
Adapter adapter2 = (Adapter) marshaller.unmarshal(in);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
// assertEquals(IOException.class, e.getCause().getClass());
assertRootCause("testUnmarshalFromReader_WithException", e);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromURLString.
@Test
public void testUnmarshalFromURLString() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
marshaller.marshal(adapter, f);
assertRoundtripEquality(adapter, marshaller.unmarshal(new URLString(f.toURI().toURL())));
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromUrlStringClasspath.
@Test
public void testUnmarshalFromUrlStringClasspath() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
StandaloneProducer o1 = (StandaloneProducer) marshaller.unmarshal(new URLString(getClasspathXmlFilename()));
assertEquals("unique-id", o1.getUniqueId());
String unknownLoc = "zzzz-does-not-exist.xml";
try {
o1 = (StandaloneProducer) marshaller.unmarshal(new URLString(unknownLoc));
fail("Success unmarshal of something that doesn't exist");
} catch (CoreException e) {
assertNotNull(e.getCause());
assertTrue(IOException.class.isAssignableFrom(e.getCause().getClass()));
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class JmsConnection method cloneForTesting.
@Override
public JmsConnection cloneForTesting() throws CoreException {
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
JmsConnection copy = (JmsConnection) m.unmarshal(m.marshal(this));
// Set the client id to be null.
copy.setClientId(null);
return copy;
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddAndBindSharedConnection.
@Test
public void testMBean_AddAndBindSharedConnection() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
amp.addAndBindSharedConnection(m.marshal(new NullConnection(getName())));
Adapter marshalledAdapter = (Adapter) m.unmarshal(amp.getConfiguration());
assertEquals(1, marshalledAdapter.getSharedComponents().getConnections().size());
assertEquals(getName(), marshalledAdapter.getSharedComponents().getConnections().get(0).getUniqueId());
assertTrue(amp.getSharedConnectionIds().contains(getName()));
assertTrue(amp.containsSharedConnection(getName()));
} finally {
adapterManager.requestClose();
}
}
Aggregations