Package org.switchyard

Examples of org.switchyard.Message


    @Override
    public void handleMessage(Exchange exchange) throws HandlerException {
        if (exchange.getContract().getProviderOperation().getExchangePattern().equals(ExchangePattern.IN_OUT)) {
            String response = null;
            Message message = exchange.createMessage();
           
            Node request = exchange.getMessage().getContent(Node.class);
            Element orderId = XMLHelper.getFirstChildElementByName(request, "orderId");
           
            if(orderId != null && orderId.getFirstChild().getNodeValue().equals("PO-19838-XYZ")){
View Full Code Here


        Assert.assertEquals(202, status);
    }

    @Test
    public void httpGatewayReferenceTest() throws Exception {
        Message responseMsg = _consumerService.operation(METHOD_NAME).sendInOut(INPUT);
        //Test CRR - Composing an Reference Response
        Assert.assertEquals(String.class, responseMsg.getContent().getClass());
        Assert.assertEquals(INPUT, responseMsg.getContent());
    }
View Full Code Here

    @Test
    public void httpStatus() throws Exception {
        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());
    }
View Full Code Here

    @Test
    public void httpFault() throws Exception {
        MockHandler handler = new MockHandler();
        Exchange ex = _consumerService2.operation(METHOD_NAME).createExchange(handler);
        Message requestMsg = ex.createMessage().setContent(INPUT);
        ex.send(requestMsg);
        handler.waitForFaultMessage();
        Assert.assertEquals(404, ex.getContext().getProperty(HttpContextMapper.HTTP_RESPONSE_STATUS).getValue());
    }
View Full Code Here

                        Thread.sleep(10000);
                    } catch (InterruptedException ie) {
                        //Ignore
            }}});
        try {
            Message responseMsg = _consumerService5.operation(METHOD_NAME).sendInOut(INPUT);
        } catch (Exception e) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            Assert.assertTrue(baos.toString().contains("SocketTimeoutException: Read timed out"));
        }
View Full Code Here

        HttpServer httpServer = HttpServer.create(new InetSocketAddress(8100), 10);
        httpServer.setExecutor(null); // creates a default executor
        httpServer.start();
        HttpContext context = httpServer.createContext("/basic-secured-endpoint", new StandaloneHandler());
        context.setAuthenticator(new HttpBasicAuthenticator());
        Message responseMsg = _consumerService3.operation(METHOD_NAME).sendInOut(INPUT);
        Assert.assertEquals(OUTPUT, responseMsg.getContent(String.class));
        httpServer.stop(0);
    }
View Full Code Here

    }

    @Ignore // Exclusively for Magesh ;)
    @Test
    public void ntlmAuthentication() throws Exception {
        Message responseMsg = _consumerService4.operation(METHOD_NAME).sendInOut(INPUT);
        Assert.assertEquals(OUTPUT, responseMsg.getContent(String.class));
    }
View Full Code Here

    @Ignore // This can be tested only offline.
    @Test
    public void authenticationMissing() throws Exception {
        try {
            Message responseMsg = _authConsumerService1.operation(METHOD_NAME).sendInOut(input);
        } catch (Exception e) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            Assert.assertTrue(baos.toString().contains("401 Unauthorized"));
        }
View Full Code Here

    @Ignore // This can be tested only offline.
    @Test
    public void allIsWell() throws Exception {
        try {
            Message responseMsg = _authConsumerService2.operation(METHOD_NAME).sendInOut(input);
        } catch (Exception e) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            Assert.assertTrue(baos.toString().contains("Error status 501"));
        }
View Full Code Here

    @Ignore // This can be tested only offline.
    @Test
    public void authenticationMissing() throws Exception {
        try {
            Message responseMsg = _authConsumerService1.operation(METHOD_NAME).sendInOut(input);
        } catch (Exception e) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            Assert.assertTrue(baos.toString().contains("401: Unauthorized"));
        }
View Full Code Here

TOP

Related Classes of org.switchyard.Message

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.