Examples of NMRMessage


Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

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

        TestApplicationContext ctx = new TestApplicationContext(new String[] {
                S1, S2 });
        ConfigurerImpl cfg = new ConfigurerImpl(ctx);
        Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
        bus.setExtension(cfg, Configurer.class);
        assertNotNull(bus.getExtension(BindingFactoryManager.class).getBindingFactory(NMRConstants.NS_NMR_BINDING));
       
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new NMRBindingInfo(null, NMRConstants.NS_NMR_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.getNmrExchange().getOperation().toString()).toString());
        }
    }
View Full Code Here

Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

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

Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

    @Test
    public void testNoFault() throws Exception {
        PhaseInterceptor<NMRMessage> interceptor = new NMRFaultOutInterceptor();
        try {
            NMRMessage msg = new NMRMessage(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

Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

    @Test
    public void testEmptyFault() throws Exception {
        PhaseInterceptor<NMRMessage> interceptor = new NMRFaultOutInterceptor();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
        NMRMessage msg = new NMRMessage(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

Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

    @Test
    public void testDetailedFault() throws Exception {
        PhaseInterceptor<NMRMessage> interceptor = new NMRFaultOutInterceptor();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
        NMRMessage msg = new NMRMessage(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

Examples of org.apache.servicemix.cxf.binding.nmr.NMRMessage

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

        TestApplicationContext ctx = new TestApplicationContext(new String[] {
                S1, S2 });
        ConfigurerImpl cfg = new ConfigurerImpl(ctx);
        Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
        bus.setExtension(cfg, Configurer.class);
        assertNotNull(bus.getExtension(BindingFactoryManager.class).getBindingFactory(NMRConstants.NS_NMR_BINDING));
       
        EndpointInfo endpointInfo = new EndpointInfo();
        endpointInfo.setBinding(new NMRBindingInfo(null, NMRConstants.NS_NMR_BINDING));
        Endpoint ep = new EndpointImpl(BusFactory.getDefaultBus(), 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.getNmrExchange().getOperation().toString()).toString());
        }
    }
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.