Package org.switchyard

Examples of org.switchyard.HandlerException


    private Throwable detectHandlerException(Throwable throwable) {
        if (throwable instanceof HandlerException) {
            return (HandlerException) throwable;
        }
        return new HandlerException(throwable);
    }
View Full Code Here


*/
public class ErrorExchangeHandler implements ExchangeHandler {

    @Override
    public void handleMessage(Exchange exchange) throws HandlerException {
        throw new HandlerException("Service is not implemented");
    }
View Full Code Here

        assertNotNull(exchange.getContext().getProperty(Exchange.RELATES_TO));
    }

    protected static void assertCause(String message, Exchange exchange) {
        assertEquals(ExchangeState.FAULT, exchange.getState());
        HandlerException exception = exchange.getMessage().getContent(HandlerException.class);
        assertTrue(exception.isWrapper());
        assertNotNull("Cause should not be null", exception.getCause());
        assertEquals(message, exception.getCause().getMessage());
        // SWITCHYARD-1634
        assertNotNull(exchange.getContext().getProperty(Exchange.MESSAGE_ID));
        assertNotNull(exchange.getContext().getProperty(Exchange.RELATES_TO));
    }
View Full Code Here

        QName serviceName = new QName("testNoNPEOnNoConsumer");
        MockHandler provider = new MockHandler() {
            @Override
            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("explode");
            }
        };

        ServiceReference service = _domain.createInOutService(serviceName, provider);
View Full Code Here

        QName serviceName = new QName("testNoNPEOnNoConsumer");
        MockHandler provider = new MockHandler() {
            @Override
            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("explode");
            }
        };

        ServiceReference service = _domain.createInOnlyService(serviceName, provider);
View Full Code Here

        final QName serviceName = new QName("testFaultWithNoHandler");
        // Provide the service
        MockHandler provider = new MockHandler() {
            @Override
            public void handleMessage(Exchange exchange) throws HandlerException {
                throw new HandlerException("Fault With No Handler!");
            }
        };
        ServiceReference service = _domain.createInOnlyService(serviceName, provider);

        // Consume the service
View Full Code Here

                if (!result.isValid()) {
                    throw RuntimeMessages.MESSAGES.validatorFailed(validator.getClass().getName(), result.getDetail());
                }
            } catch (SwitchYardException syEx) {
                // Validators which throw SwitchYardException should be reported as HandlerException   
                throw new HandlerException(syEx.getMessage());
            }
        }
    }
View Full Code Here

    @Test
    public void testThrowableContent() throws Exception {
        // create hierarchy
        final Exception e_pre = new Exception("e");
        e_pre.fillInStackTrace();
        final HandlerException he1_pre = new HandlerException(e_pre);
        he1_pre.fillInStackTrace();
        final RuntimeException re_pre = new RuntimeException("re", he1_pre);
        re_pre.fillInStackTrace();
        final SwitchYardException sye_pre = new SwitchYardException("sye", re_pre);
        sye_pre.fillInStackTrace();
        final HandlerException he2_pre = new HandlerException("he", sye_pre);
        he2_pre.fillInStackTrace();
        // create message
        RemoteMessage msg = new RemoteMessage();
        msg.setContent(he2_pre);
        // serialize and deserialize
        msg = serDeser(msg, RemoteMessage.class);
        // get causes
        final HandlerException he2_post = (HandlerException)msg.getContent();
        final SwitchYardException sye_post = (SwitchYardException)he2_post.getCause();
        final RuntimeException re_post = (RuntimeException)sye_post.getCause();
        final HandlerException he1_post = (HandlerException)re_post.getCause();
        final Exception e_post = (Exception)he1_post.getCause();
        // test wrapper
        Assert.assertEquals(he2_pre.isWrapper(), he2_post.isWrapper());
        Assert.assertEquals(he1_pre.isWrapper(), he1_post.isWrapper());
        // test messages
        Assert.assertEquals(he2_pre.getMessage(), he2_post.getMessage());
        Assert.assertEquals(sye_pre.getMessage(), sye_post.getMessage());
        Assert.assertEquals(re_pre.getMessage(), re_post.getMessage());
        Assert.assertEquals(he1_pre.getMessage(), he1_post.getMessage());
        Assert.assertEquals(e_pre.getMessage(), e_post.getMessage());
        // test stack traces
        Assert.assertEquals(he2_pre.getStackTrace().length, he2_post.getStackTrace().length);
        Assert.assertEquals(sye_pre.getStackTrace().length, sye_post.getStackTrace().length);
        Assert.assertEquals(re_pre.getStackTrace().length, re_post.getStackTrace().length);
        Assert.assertEquals(he1_pre.getStackTrace().length, he1_post.getStackTrace().length);
        Assert.assertEquals(e_pre.getStackTrace().length, e_post.getStackTrace().length);
    }
View Full Code Here

                    e = ((PrivilegedActionException)e).getException();
                }
                if (e instanceof HandlerException) {
                    throw (HandlerException)e;
                } else {
                    throw new HandlerException(e);
                }
            }
        } else {
            service.getProviderHandler().handleMessage(exchange);
        }
View Full Code Here

    @Test
    public void testBasicExceptions() throws Exception {
        final IllegalStateException expectedIllegalStateException = new IllegalStateException("expectedIllegalStateException");
        expectedIllegalStateException.fillInStackTrace();
        final HandlerException expectedHandlerException = new HandlerException(expectedIllegalStateException);
        expectedHandlerException.fillInStackTrace();
        final Exception expectedException = new Exception("expectedException", expectedHandlerException);
        expectedException.fillInStackTrace();
        final Exception actualException = serDeser(expectedException, Exception.class);
        final HandlerException actualHandlerException = (HandlerException)actualException.getCause();
        final IllegalStateException actualIllegalStateException = (IllegalStateException)actualHandlerException.getCause();
        Assert.assertEquals(expectedException.getMessage(), actualException.getMessage());
        Assert.assertEquals(expectedHandlerException.getMessage(), actualHandlerException.getMessage());
        Assert.assertEquals(expectedIllegalStateException.getMessage(), actualIllegalStateException.getMessage());
        Assert.assertEquals(expectedException.getStackTrace().length, actualException.getStackTrace().length);
        Assert.assertEquals(expectedHandlerException.getStackTrace().length, actualHandlerException.getStackTrace().length);
        Assert.assertEquals(expectedIllegalStateException.getStackTrace().length, actualIllegalStateException.getStackTrace().length);
        Assert.assertEquals(expectedHandlerException.isWrapper(), actualHandlerException.isWrapper());
    }
View Full Code Here

TOP

Related Classes of org.switchyard.HandlerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.