Package org.switchyard.test

Examples of org.switchyard.test.MockHandler.waitForOKMessage()


        MockHandler handler = new MockHandler();
        Exchange ex = _consumerService.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        requestMsg.getContext().setProperty("SomeRequestHeader", "BAR");
        ex.send(requestMsg);
        handler.waitForOKMessage();
        Assert.assertEquals(200, ex.getContext().getProperty(HttpContextMapper.HTTP_RESPONSE_STATUS).getValue());
    }

    @Test
    public void httpFault() throws Exception {
View Full Code Here


        InboundHandler<?> handler = createInboundHandler(_serviceName, "direct:input", "input",
                new V1MessageComposerModel(SwitchYardNamespace.DEFAULT.uri()).setClazz(Composer.class.getName()));
        handler.start();

        sendBody("direct:input", PAYLOAD);
        mock.waitForOKMessage();
        List<Exchange> exchanges = new ArrayList<Exchange>();
        mock.getMessages().drainTo(exchanges);
        assertEquals(1, exchanges.size());
        assertEquals(Composer.COMPOSE_PREFIX + PAYLOAD, exchanges.get(0).getMessage().getContent());
View Full Code Here

        InboundHandler<?> handler = createInboundHandler(_serviceName, "direct:input", "direct",
                new V1ContextMapperModel(SwitchYardNamespace.DEFAULT.uri()).setClazz(Mapper.class.getName()));
        handler.start();

        sendBody("direct:input", PAYLOAD);
        mock.waitForOKMessage();
        List<Exchange> exchanges = new ArrayList<Exchange>();
        mock.getMessages().drainTo(exchanges);
        assertEquals(1, exchanges.size());
        Exchange exchange = exchanges.get(0);
        Property property = exchange.getContext().getProperty(Mapper.PROPERTY);
View Full Code Here

        InboundHandler<?> handler = createInboundHandler(_serviceName, "direct:input", "input",
                new V1StaticOperationSelectorModel(SwitchYardNamespace.DEFAULT.uri()).setOperationName(OPERATION_NAME));
        handler.start();

        sendBody("direct:input", PAYLOAD);
        mock.waitForOKMessage();
        List<Exchange> exchanges = new ArrayList<Exchange>();
        mock.getMessages().drainTo(exchanges);
        assertEquals(1, exchanges.size());
        assertEquals(OPERATION_NAME, exchanges.get(0).getContract().getProviderOperation().getName());
View Full Code Here

    public void sendReply() throws Exception {
        MockHandler handler = new MockHandler();
        handler.setWaitTimeout(3000);
        Exchange ex = sendReply.createExchange(handler);
        ex.send(ex.createMessage().setContent(TEST_IN_CONTENT));
        Assert.assertEquals(1, handler.waitForOKMessage().getMessages().size());
        Assert.assertEquals(TEST_OUT_CONTENT,
                handler.getMessages().poll().getMessage().getContent());
    }
   
    @Test
View Full Code Here

        handler.setWaitTimeout(3000);
        Exchange ex = attachments.createExchange(handler);
        ex.send(ex.createMessage()
                .setContent(TEST_IN_CONTENT)
                .addAttachment(TEST_IN_ATTACHMENT, new DummyDataSource(TEST_IN_ATTACHMENT)));
        Assert.assertEquals(1, handler.waitForOKMessage().getMessages().size());
        Message reply = handler.getMessages().poll().getMessage();
        DataSource attachOut = reply.getAttachment(TEST_OUT_ATTACHMENT);
        Assert.assertNotNull(attachOut);
        Assert.assertEquals(TEST_OUT_ATTACHMENT, attachOut.getName());
    }
View Full Code Here

        // sleep a bit to receive message on camel side
        Thread.sleep(50);
        clientSocket.close();

        greetingService.waitForOKMessage();
        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        assertThat(PAYLOAD, is(equalTo(recievedExchange.getMessage().getContent(String.class))));
    }
View Full Code Here

        clientSocket.send(packet);

        // sleep a bit to receive message on camel side
        clientSocket.close();

        greetingService.waitForOKMessage();
        final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
        assertThat(recievedMessages, is(notNullValue()));
        final Exchange recievedExchange = recievedMessages.iterator().next();
        String content = recievedExchange.getMessage().getContent(String.class);
        // the receive content is trimmed because extra bytes appended to frame by receiver
View Full Code Here

        //replace existing implementation for testing purposes
        _testKit.removeService("GreetingService");
        final MockHandler greetingService = _testKit.registerInOnlyService("GreetingService");

        sentTextToQueue(PAYLOAD);
        greetingService.waitForOKMessage();

        final LinkedBlockingQueue<Exchange> receivedMessages = greetingService.getMessages();
        assertThat(receivedMessages, is(notNullValue()));
        final Exchange receivedExchange = receivedMessages.iterator().next();
        assertThat(receivedExchange.getMessage().getContent(String.class), is(equalTo(PAYLOAD)));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.