Example usage for java.lang.reflect UndeclaredThrowableException getCause

List of usage examples for java.lang.reflect UndeclaredThrowableException getCause

Introduction

In this page you can find the example usage for java.lang.reflect UndeclaredThrowableException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.resthub.rpc.hessian.SpringAMQPProxyTest.java

@Test(groups = "hessian-serialization")
public void testTimeout() throws Exception {
    try {//w ww. ja  v  a2  s.c  o m
        testTimeout.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    }
}

From source file:org.resthub.rpc.java.SpringAMQPProxyTest.java

@Test(groups = "java-serialization")
public void testTimeout() throws Exception {
    try {//from w ww  .j a  v a  2s  . c om
        testTimeout.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    }
}

From source file:org.resthub.rpc.SpringAMQPHessianProxyTest.java

@Test
public void testTimeout() throws Exception {
    try {//from  w  w  w.j  a v  a 2  s. co  m
        testTimeout.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    }
}

From source file:com.wisemapping.rest.BaseController.java

@ExceptionHandler(java.lang.reflect.UndeclaredThrowableException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)/*w  w  w. jav a 2  s  .  c o  m*/
public RestErrors handleSecurityErrors(@NotNull UndeclaredThrowableException ex) {
    final Throwable cause = ex.getCause();
    RestErrors result;
    if (cause instanceof ClientException) {
        result = handleClientErrors((ClientException) cause);
    } else {
        result = new RestErrors(ex.getMessage(), Severity.INFO);
    }
    return result;
}

From source file:org.apache.servicemix.camel.nmr.AttachmentTest.java

public void testAttachment() throws Exception {
    TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true);
    try {/*from   www.j  av  a2 s . co  m*/

        Holder<DataHandler> param = new Holder<DataHandler>();

        param.value = new DataHandler(new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream"));

        Holder<String> name = new Holder<String>("call detail");
        mtomPort.testXop(name, param);
        assertEquals("call detailfoobar", name.value);
        assertNotNull(param.value);
        InputStream bis = param.value.getDataSource().getInputStream();
        byte b[] = new byte[10];
        bis.read(b, 0, 10);
        String attachContent = new String(b);
        assertEquals(attachContent, "testfoobar");
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }

}

From source file:io.hops.tensorflow.TimelineHandler.java

public void startClient(final Configuration conf) throws YarnException, IOException, InterruptedException {
    try {/*  w  w w  . j  a va 2s  .c o m*/
        ugi.doAs(new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED,
                        YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
                    // Creating the Timeline Client
                    timelineClient = TimelineClient.createTimelineClient();
                    timelineClient.init(conf);
                    timelineClient.start();
                } else {
                    timelineClient = null;
                    LOG.warn("Timeline service is not enabled");
                }
                return null;
            }
        });
    } catch (UndeclaredThrowableException e) {
        throw new YarnException(e.getCause());
    }
}

From source file:org.resthub.rpc.AMQPHessianProxyTest.java

@Test
public void testTimeout() throws Exception {
    FailingServiceEndpoint endpoint = new FailingServiceEndpoint();
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.run();//  w  w w .j av  a 2s.  c o  m

    AMQPHessianProxyFactory factory = new AMQPHessianProxyFactory();
    factory.setReadTimeout(3000);
    factory.setConnectionFactory(connectionFactory);
    FailingService service = factory.create(FailingService.class);

    try {
        service.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    } finally {
        endpoint.destroy();
    }
}

From source file:org.resthub.rpc.hessian.AMQPProxyTest.java

@Test(groups = "hessian-serialization")
public void testTimeout() throws Exception {
    FailingServiceRPCEndpoint endpoint = new FailingServiceRPCEndpoint();
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.setSerializationHandler(serializationHandler);
    endpoint.run();/*from   ww w  .  j  a  v  a  2 s .  c om*/

    AMQPProxyFactory factory = new AMQPProxyFactory();
    factory.setReadTimeout(3000);
    factory.setConnectionFactory(connectionFactory);
    factory.setSerializationHandler(new HessianSerializationHandler());
    FailingService service = factory.create(FailingService.class);

    try {
        service.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    } finally {
        endpoint.destroy();
    }
}

From source file:org.resthub.rpc.java.AMQPProxyTest.java

@Test(groups = "java-serialization")
public void testTimeout() throws Exception {
    FailingServiceRPCEndpoint endpoint = new FailingServiceRPCEndpoint();
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.setSerializationHandler(serializationHandler);
    endpoint.run();/*from  w  w w . jav a  2  s  . c o m*/

    AMQPProxyFactory factory = new AMQPProxyFactory();
    factory.setReadTimeout(3000);
    factory.setConnectionFactory(connectionFactory);
    factory.setSerializationHandler(new DefaultSerializationHandler());
    FailingService service = factory.create(FailingService.class);

    try {
        service.timeout(5000);
        fail("UndeclaredThrowableException expected");
    } catch (UndeclaredThrowableException e) {
        Throwable cause = e.getCause();
        assertTrue(cause instanceof TimeoutException);
        Thread.sleep(3000);
    } finally {
        endpoint.destroy();
    }
}

From source file:org.apache.servicemix.camel.nmr.ws.addressing.WSAddressingTest.java

public void testOneway() throws Exception {
    try {//w w  w  .  j ava  2  s.  c o m
        greeter.greetMeOneWay("implicit_oneway1");
        checkVerification();
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}