Package org.apache.servicemix.soap.core

Examples of org.apache.servicemix.soap.core.MessageImpl


    private StaxOutInterceptor interceptor = new StaxOutInterceptor();
   
    public void testNullInput() {
        try {
            Message msg = new MessageImpl();
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown an NPE");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here


        } catch (NullPointerException e) {
        }
    }
   
    public void testBadNamespace() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

            log.info(e.getMessage(), e);
        }
    }
   
    public void testBadLocalName() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<test xmlns='http://www.w3.org/2003/05/soap-envelope'/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

        } catch (NullPointerException e) {
        }
    }
   
    public void testValidInput() throws Exception {
        Message msg = new MessageImpl();
        msg.setContent(OutputStream.class, new ByteArrayOutputStream());
        PhaseInterceptorChain chain = new PhaseInterceptorChain();
        chain.add(interceptor);
        chain.doIntercept(msg);
        XMLStreamWriter writer = msg.getContent(XMLStreamWriter.class);
        assertNotNull(writer);
    }
View Full Code Here

            log.info(e.getMessage(), e);
        }
    }
   
    public void testEmptyEnvelopeName() throws Exception {
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream("<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'/>".getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        try {
            interceptor.handleMessage(msg);
            fail("Interceptor should have thrown a SoapFault");
        } catch (SoapFault e) {
View Full Code Here

                     "  </s:Header>" +
                     "  <s:Body>" +
                     "    <hello>world</hello>" +
                     "  </s:Body>" +
                     "</s:Envelope>";
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream(str.getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        interceptor.handleMessage(msg);
       
        assertNotNull(msg.get(SoapVersion.class));
        assertEquals("s", msg.get(SoapVersion.class).getPrefix());
        assertNotNull(msg.getSoapHeaders().get(new QName("header1")));
        assertEquals(2, msg.getSoapHeaders().get(new QName("header1")).getChildNodes().getLength());
        assertNotNull(msg.getSoapHeaders().get(new QName("urn:y", "header2")));
        assertEquals(1, msg.getSoapHeaders().get(new QName("urn:y", "header2")).getChildNodes().getLength());
        assertNotNull(msg.getContent(XMLStreamReader.class));
        assertEquals(XMLStreamConstants.START_ELEMENT, msg.getContent(XMLStreamReader.class).getEventType());
        assertEquals(new QName("hello"), msg.getContent(XMLStreamReader.class).getName());
    }
View Full Code Here

    public void testValidInputWithEmptyBody() throws Exception {
        String str = "<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'>" +
                     "  <s:Body>" +
                     "  </s:Body>" +
                     "</s:Envelope>";
        Message msg = new MessageImpl();
        InputStream is = new ByteArrayInputStream(str.getBytes());
        msg.setContent(InputStream.class, is);
        new StaxInInterceptor().handleMessage(msg);
        interceptor.handleMessage(msg);
       
        assertNotNull(msg.get(SoapVersion.class));
        assertEquals("s", msg.get(SoapVersion.class).getPrefix());
        assertEquals(0, msg.getSoapHeaders().size());
        assertNull(msg.getContent(XMLStreamReader.class));
        //assertNotNull(msg.getContent(XMLStreamReader.class));
        //assertEquals(XMLStreamConstants.END_ELEMENT, msg.getContent(XMLStreamReader.class).getEventType());
        //assertEquals(msg.get(SoapVersion.class).getBody(), msg.getContent(XMLStreamReader.class).getName());
    }
View Full Code Here

    public void testGetPerson() throws Exception {
        PhaseInterceptorChain phaseIn = new PhaseInterceptorChain();
        phaseIn.add(binding.getInterceptors(Phase.ServerIn));
       
        Message message = new MessageImpl();
        message.put(Binding.class, binding);
        message.put(MessageExchangeFactory.class, new MockExchangeFactory());
        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312?code=abc");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_GET);
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());
View Full Code Here

   
    public void testUpdatePerson() throws Exception {
        PhaseInterceptorChain phaseIn = new PhaseInterceptorChain();
        phaseIn.add(binding.getInterceptors(Phase.ServerIn));
       
        Message message = new MessageImpl();
        message.put(Binding.class, binding);
        message.put(MessageExchangeFactory.class, new MockExchangeFactory());
        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_POST);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());
View Full Code Here

   
    public void testAddPerson() throws Exception {
        PhaseInterceptorChain phaseIn = new PhaseInterceptorChain();
        phaseIn.add(binding.getInterceptors(Phase.ServerIn));
       
        Message message = new MessageImpl();
        message.put(Binding.class, binding);
        message.put(MessageExchangeFactory.class, new MockExchangeFactory());
        message.getTransportHeaders().put(HttpConstants.REQUEST_URI, "http://localhost:8192/person/312");
        message.getTransportHeaders().put(HttpConstants.REQUEST_METHOD, HttpConstants.METHOD_PUT);
        message.setContent(InputStream.class, new ByteArrayInputStream("ssn=321&name=Nodet".getBytes()));
       
        phaseIn.doIntercept(message);

        MessageExchange me = message.getContent(MessageExchange.class);
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        Document doc = DomUtil.parse(nm.getContent());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
        log.info(baos.toString());
View Full Code Here

TOP

Related Classes of org.apache.servicemix.soap.core.MessageImpl

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.