use of com.adaptris.core.CoreException in project interlok by adaptris.
the class JndiHelperTest method testBindObject_AlreadyBound.
@Test
public void testBindObject_AlreadyBound() throws Exception {
NullConnection connection = new NullConnection();
connection.setUniqueId(getName());
InitialContext initialContext = new InitialContext(env);
JndiHelper.bind(initialContext, connection, false);
try {
JndiHelper.bind(initialContext, connection, true);
fail();
} catch (CoreException expected) {
;
}
try {
JndiHelper.bind(initialContext, connection, false);
fail();
} catch (CoreException expected) {
;
}
JndiHelper.unbindQuietly(initialContext, connection, false);
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class JndiHelperTest method testUnbindCollection_WithContext.
@Test
public void testUnbindCollection_WithContext() throws Exception {
NullConnection connection = new NullConnection();
connection.setUniqueId(getName());
ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
connectionList.add(connection);
InitialContext initialContext = new InitialContext(env);
JndiHelper.bind(initialContext, connectionList, true);
JndiHelper.unbind(initialContext, connectionList, true);
try {
JndiHelper.unbind(initialContext, connectionList, true);
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class JndiHelperTest method testUnbindUnboundTransactionManager_Debug.
@Test
public void testUnbindUnboundTransactionManager_Debug() throws Exception {
TransactionManager transactionManager = new DummyTransactionManager(getName());
try {
JndiHelper.unbind(transactionManager, true);
fail();
} catch (CoreException expected) {
// not previously bound, so should error.
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToWriter_WithException.
@Test
public void testMarshalToWriter_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
Writer fail = new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
throw new IOException("testMarshalToWriter_WithException");
}
@Override
public void flush() throws IOException {
throw new IOException("testMarshalToWriter_WithException");
}
@Override
public void close() throws IOException {
}
};
try (Writer out = fail) {
marshaller.marshal(adapter, out);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
// assertEquals(IOException.class, e.getCause().getClass());
assertRootCause("testMarshalToWriter_WithException", e);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromUrlWithException.
@Test
public void testUnmarshalFromUrlWithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
// Ha, anonymous URLStreamHandler to the rescue.
URL failingUrl = new URL("http", "development.adaptris.com", 80, "index.html", new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
throw new IOException("testUnmarshalFromUrl");
}
});
try {
marshaller.unmarshal(failingUrl);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
assertEquals(IOException.class, e.getCause().getClass());
assertEquals("testUnmarshalFromUrl", e.getCause().getMessage());
}
}
Aggregations