Search in sources :

Example 1 with InterlokException

use of com.adaptris.interlok.InterlokException in project interlok by adaptris.

the class InterlokJmxClientTest method testConnectFailure.

@Test
public void testConnectFailure() throws Exception {
    InterlokJmxClient client = new InterlokJmxClient(new JMXServiceURL(String.format(JMXMP_LOCALHOST, "1234")));
    try {
        client.connect();
        fail();
    } catch (InterlokException expected) {
    } finally {
        client.disconnect();
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) InterlokException(com.adaptris.interlok.InterlokException) Test(org.junit.Test)

Example 2 with InterlokException

use of com.adaptris.interlok.InterlokException in project interlok by adaptris.

the class BlobListRendererTest method testWrapException.

@Test
public void testWrapException() {
    InterlokException ex = new InterlokException("exception");
    assertEquals(ex, BlobListRenderer.wrapInterlokException(ex));
    assertNotEquals(ex, BlobListRenderer.wrapInterlokException(new Exception("exception")));
}
Also used : InterlokException(com.adaptris.interlok.InterlokException) InterlokException(com.adaptris.interlok.InterlokException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with InterlokException

use of com.adaptris.interlok.InterlokException in project interlok by adaptris.

the class BlobListRendererTest method testRender_Fail.

@Test
public void testRender_Fail() throws Exception {
    InterlokMessage msg = Mockito.mock(InterlokMessage.class);
    StringWriter writer = new StringWriter();
    Mockito.when(msg.getWriter()).thenThrow(new IOException());
    BlobListRenderer render = new BlobListRenderer() {
    };
    Collection<RemoteBlob> blobs = createBlobs(10);
    try {
        render.render(blobs, msg);
        fail();
    } catch (InterlokException expected) {
    }
}
Also used : InterlokException(com.adaptris.interlok.InterlokException) StringWriter(java.io.StringWriter) InterlokMessage(com.adaptris.interlok.types.InterlokMessage) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with InterlokException

use of com.adaptris.interlok.InterlokException in project interlok by adaptris.

the class FilesystemRetryStore method report.

@Override
public Iterable<RemoteBlob> report() throws InterlokException {
    List<RemoteBlob> result = new ArrayList<>();
    try {
        File target = validateDir(FsHelper.toFile(getBaseUrl()), false);
        File[] files = fsWorker.listFiles(target, DirectoryFileFilter.DIRECTORY);
        for (File msgId : files) {
            Optional.ofNullable(createForReport(msgId)).ifPresent((blob) -> result.add(blob));
        }
    } catch (Exception e) {
        throw ExceptionHelper.wrapInterlokException(e);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RemoteBlob(com.adaptris.interlok.cloud.RemoteBlob) File(java.io.File) InterlokException(com.adaptris.interlok.InterlokException) CoreException(com.adaptris.core.CoreException)

Example 5 with InterlokException

use of com.adaptris.interlok.InterlokException in project interlok by adaptris.

the class InterlokJmxClient method findWorkflow.

private MessageProcessor findWorkflow(MessageTarget target) throws InterlokException {
    MessageProcessor workflowProxy = null;
    try {
        ObjectName queryName = ObjectName.getInstance(String.format(JMX_WORKFLOW_MANAGER_NAME, target.getAdapter(), target.getChannel(), target.getWorkflow()));
        MBeanServerConnection mbeanServer = getConnection();
        ArrayList<ObjectName> names = new ArrayList(mbeanServer.queryNames(queryName, null));
        if (names.size() == 0 || names.size() > 1) {
            throw new InterlokException(queryName + " does not narrow to a single workflow");
        }
        workflowProxy = JMX.newMBeanProxy(mbeanServer, names.get(0), MessageProcessor.class);
    } catch (Exception e) {
        rethrowInterlokException(e);
    }
    return workflowProxy;
}
Also used : InterlokException(com.adaptris.interlok.InterlokException) ExceptionHelper.rethrowInterlokException(com.adaptris.interlok.client.jmx.ExceptionHelper.rethrowInterlokException) MessageProcessor(com.adaptris.interlok.management.MessageProcessor) ArrayList(java.util.ArrayList) MBeanServerConnection(javax.management.MBeanServerConnection) InterlokException(com.adaptris.interlok.InterlokException) IOException(java.io.IOException) ExceptionHelper.rethrowInterlokException(com.adaptris.interlok.client.jmx.ExceptionHelper.rethrowInterlokException) ObjectName(javax.management.ObjectName)

Aggregations

InterlokException (com.adaptris.interlok.InterlokException)11 Test (org.junit.Test)6 CoreException (com.adaptris.core.CoreException)5 File (java.io.File)4 IOException (java.io.IOException)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 MessageTarget (com.adaptris.interlok.client.MessageTarget)2 DefaultSerializableMessage (com.adaptris.interlok.types.DefaultSerializableMessage)2 InterlokMessage (com.adaptris.interlok.types.InterlokMessage)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 ServiceException (com.adaptris.core.ServiceException)1 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)1 FileBackedMessage (com.adaptris.core.lms.FileBackedMessage)1 ExceptionHelper.rethrowInterlokException (com.adaptris.interlok.client.jmx.ExceptionHelper.rethrowInterlokException)1 RemoteBlob (com.adaptris.interlok.cloud.RemoteBlob)1 DataOutputParameter (com.adaptris.interlok.config.DataOutputParameter)1 MessageProcessor (com.adaptris.interlok.management.MessageProcessor)1 FileOutputStream (java.io.FileOutputStream)1