Package org.switchyard

Examples of org.switchyard.MockHandler


    }
   
    @Test
    public void testInOutMessageTrace() throws Exception {
        ServiceReference service = _domain.createInOutService(
                new QName("InOutTrace"), new MockHandler().forwardInToOut());
        Exchange exchange = service.createExchange(new MockHandler());
        exchange.send(exchange.createMessage());
    }
View Full Code Here


    }

    @Test
    public void testInFaultMessageTrace() throws Exception {
        ServiceReference service = _domain.createInOutService(
                new QName("InFaultTrace"), new MockHandler().forwardInToOut());
        Exchange exchange = service.createExchange(new MockHandler());
        exchange.send(exchange.createMessage());
    }
View Full Code Here

    }
   
    @Test
    public void testStreamContent() throws Exception {
        String contentAsString = "abc-InputStream-xyz";
        MockHandler provider = new MockHandler();
        _domain.getTransformerRegistry().addTransformer(new StreamTransformer());
        ServiceReference service = _domain.createInOnlyService(new QName("StreamTest"), provider);
       
        InputStream contentAsStream = new ByteArrayInputStream(contentAsString.getBytes());
        Exchange ex = service.createExchange();
        Message msg = ex.createMessage();
        msg.setContent(contentAsStream);
        ex.send(msg);

        Message rcvdMsg = provider.getMessages().poll().getMessage();
        Assert.assertTrue(rcvdMsg.getContent(InputStream.class).available() > 0);
       
    }
View Full Code Here

    }

    private void sendMessage(final ServiceReference ref, final Object content) throws Exception {
        new Thread(new Runnable() {
            public void run() {
                Exchange exchange = ref.createExchange(new MockHandler());
                exchange.send(exchange.createMessage().setContent(content));
            }
        }).start();
    }
View Full Code Here

    }
   
    @Test
    public void testReaderContent() throws Exception {
        String contentAsString = "abc-Reader-xyz";
        MockHandler provider = new MockHandler();
        _domain.getTransformerRegistry().addTransformer(new ReaderTransformer());
        ServiceReference service = _domain.createInOnlyService(new QName("ReaderTest"), provider);
       
        StringReader contentAsReader = new StringReader(contentAsString);
        Exchange ex = service.createExchange();
        Message msg = ex.createMessage();
        msg.setContent(contentAsReader);
        ex.send(msg);

        Message rcvdMsg = provider.getMessages().poll().getMessage();
        Assert.assertTrue(rcvdMsg.getContent(Reader.class).read() != -1);
    }
View Full Code Here

        deployment.start();
       
        // we want to invoke a mock so we can check for messages received
        final ServiceReference reference = domain.getServiceReference(svcName);
        domain.getServices(svcName).get(0).unregister();
        final MockHandler service = new MockHandler();
        domain.registerService(svcName, new InOnlyService(), service);
       
               
        final int NUM_SENDS = 5;
        for (int i = 0; i < NUM_SENDS; i++) {
            new Thread(new Runnable() {
                public void run() {
                    Exchange exchange = reference.createExchange();
                    Message message = exchange.createMessage();
                    exchange.send(message);
                }
            }).start();
        }
       
        Thread.sleep(4000);
        Assert.assertEquals("Received more than one message per minute - throttling policy violated!",
                1, service.getMessages().size());
    }
View Full Code Here

TOP

Related Classes of org.switchyard.MockHandler

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.