Package org.apache.cxf.binding.jbi

Examples of org.apache.cxf.binding.jbi.JBIMessage


    }
   
    @Test
    public void testUnknownOperation() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIOperationInInterceptor();
        JBIMessage msg = new JBIMessage(new MessageImpl());
        MessageExchange me = EasyMock.createMock(MessageExchange.class);
        EasyMock.expect(me.getOperation()).andReturn(new QName("urn:test", "SayHi")).times(4);
        EasyMock.replay(me);

        msg.put(MessageExchange.class, me);
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new JBIBindingInfo(null, JBIConstants.NS_JBI_BINDING));
        Bus bus = BusFactory.getThreadDefaultBus();
        bus.setExtension(this.getClass().getClassLoader(), ClassLoader.class);
        Endpoint ep = new EndpointImpl(bus, null, endpointInfo);
        msg.setExchange(new ExchangeImpl());
        msg.getExchange().put(Endpoint.class, ep);

        try {
            interceptor.handleMessage(msg);
            fail("shouldn't found SayHi operation");
        } catch (Fault fault) {
            assertEquals(fault.getMessage(), new Message("UNKNOWN_OPERATION", BUNDLE,
                                                 msg.getJbiExchange().getOperation().toString()).toString());
        }
    }
View Full Code Here


   
    @Test
    public void testNoWriter() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIFaultOutInterceptor();
        try {
            JBIMessage msg = new JBIMessage(new MessageImpl());
            interceptor.handleMessage(msg);
            fail("Should have thrown an exception");
        } catch (IllegalStateException e) {
            // ok
        }
View Full Code Here

    @Test
    public void testNoFault() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIFaultOutInterceptor();
        try {
            JBIMessage msg = new JBIMessage(new MessageImpl());
            msg.setContent(XMLStreamWriter.class,
                    XMLOutputFactory.newInstance().createXMLStreamWriter(new ByteArrayOutputStream()));
            interceptor.handleMessage(msg);
            fail("Should have thrown an exception");
        } catch (IllegalStateException e) {
            // ok
View Full Code Here

    @Test
    public void testEmptyFault() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIFaultOutInterceptor();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
        JBIMessage msg = new JBIMessage(new MessageImpl());
        msg.setContent(XMLStreamWriter.class, writer);
        msg.setContent(Exception.class, new Exception("My fault"));
        interceptor.handleMessage(msg);
        writer.close();
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(baos.toByteArray()));
        assertEquals("fault", doc.getDocumentElement().getFirstChild().getNodeName());
    }
View Full Code Here

    @Test
    public void testDetailedFault() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIFaultOutInterceptor();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
        JBIMessage msg = new JBIMessage(new MessageImpl());
        Fault f = new Fault(new Message("FAULT", (ResourceBundle) null));
        f.getOrCreateDetail();
        f.getDetail().appendChild(f.getDetail().getOwnerDocument().createElementNS("urn:test", "myDetails"));
        msg.setContent(XMLStreamWriter.class, writer);
        msg.setContent(Exception.class, f);
        interceptor.handleMessage(msg);
        writer.close();
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(baos.toByteArray()));
        assertEquals("urn:test", doc.getDocumentElement().getFirstChild().getNamespaceURI());
        assertEquals("myDetails", doc.getDocumentElement().getFirstChild().getNodeName());
View Full Code Here

    }
   
    @Test
    public void testUnknownOperation() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIOperationInInterceptor();
        JBIMessage msg = new JBIMessage(new MessageImpl());
        MessageExchange me = EasyMock.createMock(MessageExchange.class);
        EasyMock.expect(me.getOperation()).andReturn(new QName("urn:test", "SayHi")).times(4);
        EasyMock.replay(me);

        msg.put(MessageExchange.class, me);
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new JBIBindingInfo(null, JBIConstants.NS_JBI_BINDING));
        Bus bus = BusFactory.getThreadDefaultBus();
        bus.setExtension(this.getClass().getClassLoader(), ClassLoader.class);
        Endpoint ep = new EndpointImpl(bus, null, endpointInfo);
        msg.setExchange(new ExchangeImpl());
        msg.getExchange().put(Endpoint.class, ep);

        try {
            interceptor.handleMessage(msg);
            fail("shouldn't found SayHi operation");
        } catch (Fault fault) {
            assertEquals(fault.getMessage(), new Message("UNKNOWN_OPERATION", BUNDLE,
                                                 msg.getJbiExchange().getOperation().toString()).toString());
        }
    }
View Full Code Here

    }
   
    @Test
    public void testUnknownOperation() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIOperationInInterceptor();
        JBIMessage msg = new JBIMessage(new MessageImpl());
        MessageExchange me = EasyMock.createMock(MessageExchange.class);
        EasyMock.expect(me.getOperation()).andReturn(new QName("urn:test", "SayHi")).times(4);
        EasyMock.replay(me);
        msg.put(MessageExchange.class, me);
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new JBIBindingInfo(null, JBIConstants.NS_JBI_BINDING));
        Endpoint ep = new EndpointImpl(null, null, endpointInfo);
        msg.setExchange(new ExchangeImpl());
        msg.getExchange().put(Endpoint.class, ep);
        try {
            interceptor.handleMessage(msg);
            fail("shouldn't found SayHi operation");
        } catch (Fault fault) {
            assertEquals(fault.getMessage(), new Message("UNKNOWN_OPERATION", BUNDLE,
                                                 msg.getJbiExchange().getOperation().toString()).toString());
        }
    }
View Full Code Here

    }
   
    @Test
    public void testUnknownOperation() throws Exception {
        PhaseInterceptor<JBIMessage> interceptor = new JBIOperationInInterceptor();
        JBIMessage msg = new JBIMessage(new MessageImpl());
        MessageExchange me = EasyMock.createMock(MessageExchange.class);
        EasyMock.expect(me.getOperation()).andReturn(new QName("urn:test", "SayHi")).times(4);
        EasyMock.replay(me);
        msg.put(MessageExchange.class, me);
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new JBIBindingInfo(null, JBIConstants.NS_JBI_BINDING));
        Endpoint ep = new EndpointImpl(null, null, endpointInfo);
        msg.setExchange(new ExchangeImpl());
        msg.getExchange().put(Endpoint.class, ep);
        try {
            interceptor.handleMessage(msg);
            fail("shouldn't found SayHi operation");
        } catch (Fault fault) {
            assertEquals(fault.getMessage(), new Message("UNKNOWN_OPERATION", BUNDLE,
                                                 msg.getJbiExchange().getOperation().toString()).toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.binding.jbi.JBIMessage

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.