Package org.apache.servicemix.nmr.api

Examples of org.apache.servicemix.nmr.api.Channel


         *
         * @param message the message to be sent.
         */
        public void prepare(Message message) throws IOException {
            // setup the message to be send back
            Channel dc = channel;
            message.put(Exchange.class, inMessage.get(Exchange.class));
            message.setContent(OutputStream.class, new NMRDestinationOutputStream(inMessage, dc));
        }       
View Full Code Here


        exchange.setInMessage(message);
        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
        BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);
        EasyMock.expect(boi.getOutput()).andReturn(bmi);
        exchange.put(BindingOperationInfo.class, boi);
        Channel channel = control.createMock(Channel.class);
        EasyMock.expect(nmr.createChannel()).andReturn(channel);
        Exchange xchg = control.createMock(Exchange.class);
        EasyMock.expect(channel.createExchange(Pattern.InOut)).andReturn(xchg);
        org.apache.servicemix.nmr.api.Message inMsg = control.createMock(org.apache.servicemix.nmr.api.Message.class);
        EasyMock.expect(xchg.getIn()).andReturn(inMsg);
        EndpointRegistry endpoints = control.createMock(EndpointRegistry.class);
        EasyMock.expect(channel.getNMR()).andReturn(nmr);
        EasyMock.expect(nmr.getEndpointRegistry()).andReturn(endpoints);
        org.apache.servicemix.nmr.api.Message outMsg = control.createMock(org.apache.servicemix.nmr.api.Message.class);
        EasyMock.expect(xchg.getOut()).andReturn(outMsg);
       
        Source source = new StreamSource(new ByteArrayInputStream(
View Full Code Here

   
    @Test
    public void testOutputStreamSubstitutionDoesntCauseExceptionInDoClose() throws Exception {
        //Create enough of the object structure to get through the code.
        org.apache.servicemix.nmr.api.Message normalizedMessage = control.createMock(org.apache.servicemix.nmr.api.Message.class);
        Channel channel = control.createMock(Channel.class);
        Exchange exchange = new ExchangeImpl();
        exchange.setOneWay(false);
        Message message = new MessageImpl();
        message.setExchange(exchange);
       
       
        org.apache.servicemix.nmr.api.Exchange messageExchange = control.createMock(org.apache.servicemix.nmr.api.Exchange.class);
        EasyMock.expect(messageExchange.getOut()).andReturn(normalizedMessage);
        message.put(org.apache.servicemix.nmr.api.Exchange.class, messageExchange);
        channel.send(messageExchange);
        EasyMock.replay(channel);
       
        NMRDestinationOutputStream jbiOS = new NMRDestinationOutputStream(message, channel);
       
        //Create array of more than what is in threshold in CachedOutputStream,
View Full Code Here

        waitOnContextCreation("org.apache.servicemix.examples.itests.cxf-nmr-osgi");
        Thread.sleep(5000);
        NMR nmr = getOsgiService(NMR.class);
        assertNotNull(nmr);
       
        Channel client = nmr.createChannel();
        Exchange e = client.createExchange(Pattern.InOut);
        for (Endpoint ep : nmr.getEndpointRegistry().getServices()) {
          e.setTarget(nmr.getEndpointRegistry().lookup(nmr.getEndpointRegistry().getProperties(ep)));
          e.getIn().setBody(new StringSource("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:sayHi xmlns:ns2=\"http://cxf.examples.servicemix.apache.org/\"><arg0>Bonjour</arg0></ns2:sayHi></soap:Body></soap:Envelope>"));
          boolean res = client.sendSync(e);
          assertTrue(res);
        }
   
    }
View Full Code Here

   
    @Test
    public void testOutputStreamSubstitutionDoesntCauseExceptionInDoClose() throws Exception {
        //Create enough of the object structure to get through the code.
        org.apache.servicemix.nmr.api.Message normalizedMessage = control.createMock(org.apache.servicemix.nmr.api.Message.class);
        Channel channel = control.createMock(Channel.class);
        Exchange exchange = new ExchangeImpl();
        exchange.setOneWay(false);
        Message message = new MessageImpl();
        message.setExchange(exchange);
       
       
        org.apache.servicemix.nmr.api.Exchange messageExchange = control.createMock(org.apache.servicemix.nmr.api.Exchange.class);
        EasyMock.expect(messageExchange.getOut()).andReturn(normalizedMessage).times(2);
        message.put(org.apache.servicemix.nmr.api.Exchange.class, messageExchange);
        channel.send(messageExchange);
        EasyMock.replay(channel);
       
        NMRDestinationOutputStream jbiOS = new NMRDestinationOutputStream(message, new MessageImpl(), channel);
       
        //Create array of more than what is in threshold in CachedOutputStream,
View Full Code Here

        assertNotNull(destination);
       
        Subject subject = new Subject();
        subject.getPrincipals().add(new UserPrincipal("ffang"));

        Channel channel = nmr.createChannel();
        org.apache.servicemix.nmr.api.Exchange exchange = channel.createExchange(Pattern.InOut);
        exchange.setTarget(
                nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "dumy")));
        exchange.getIn().setSecuritySubject(subject);
        Source source = new StreamSource(new ByteArrayInputStream(
                "<message>TestHelloWorld</message>".getBytes()));
        exchange.getIn().setBody(source);
        observer = new MessageObserver() {
            public void onMessage(Message m) {                   
                inMessage = m;
                Subject receivedSubject =
                  (Subject)inMessage.get(NMRTransportFactory.NMR_SECURITY_SUBJECT);
                assertNotNull(receivedSubject);
                assertEquals(receivedSubject.getPrincipals().size(), 1);
                assertEquals(receivedSubject.getPrincipals().iterator().next().getName(), "ffang");
                Subject onBefalfsubject = Subject.getSubject(AccessController.getContext());
                assertNotNull(onBefalfsubject);
                assertEquals(onBefalfsubject, receivedSubject);
            }
        };
        destination.setMessageObserver(observer);
        channel.send(exchange);      
        Thread.sleep(2000);
        assertNotNull(inMessage);
    }
View Full Code Here

         *
         * @param message the message to be sent.
         */
        public void prepare(Message message) throws IOException {
            // setup the message to be send back
            Channel dc = channel;
            message.put(Exchange.class, inMessage.get(Exchange.class));
            NMRTransportFactory.removeUnusedInterceptprs(message);   
            message.setContent(OutputStream.class, new NMRDestinationOutputStream(inMessage, message, dc));
           
        }       
View Full Code Here

   
    @Test
    public void testOutputStreamSubstitutionDoesntCauseExceptionInDoClose() throws Exception {
        //Create enough of the object structure to get through the code.
        org.apache.servicemix.nmr.api.Message normalizedMessage = control.createMock(org.apache.servicemix.nmr.api.Message.class);
        Channel channel = control.createMock(Channel.class);
        Exchange exchange = new ExchangeImpl();
        exchange.setOneWay(false);
        Message message = new MessageImpl();
        message.setExchange(exchange);
       
       
        org.apache.servicemix.nmr.api.Exchange messageExchange = control.createMock(org.apache.servicemix.nmr.api.Exchange.class);
        EasyMock.expect(messageExchange.getOut()).andReturn(normalizedMessage).times(2);
        message.put(org.apache.servicemix.nmr.api.Exchange.class, messageExchange);
        channel.send(messageExchange);
        EasyMock.replay(channel);
       
        NMRDestinationOutputStream jbiOS = new NMRDestinationOutputStream(message, new MessageImpl(), channel);
       
        //Create array of more than what is in threshold in CachedOutputStream,
View Full Code Here

        assertNotNull(destination);
       
        Subject subject = new Subject();
        subject.getPrincipals().add(new UserPrincipal("ffang"));

        Channel channel = nmr.createChannel();
        org.apache.servicemix.nmr.api.Exchange exchange = channel.createExchange(Pattern.InOut);
        exchange.setTarget(
                nmr.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, "dumy")));
        exchange.getIn().setSecuritySubject(subject);
        Source source = new StreamSource(new ByteArrayInputStream(
                "<message>TestHelloWorld</message>".getBytes()));
        exchange.getIn().setBody(source);
        observer = new MessageObserver() {
            public void onMessage(Message m) {                   
                inMessage = m;
                Subject receivedSubject =
                  (Subject)inMessage.get(NMRTransportFactory.NMR_SECURITY_SUBJECT);
                assertNotNull(receivedSubject);
                assertEquals(receivedSubject.getPrincipals().size(), 1);
                assertEquals(receivedSubject.getPrincipals().iterator().next().getName(), "ffang");
                Subject onBefalfsubject = Subject.getSubject(AccessController.getContext());
                assertNotNull(onBefalfsubject);
                assertEquals(onBefalfsubject, receivedSubject);
            }
        };
        destination.setMessageObserver(observer);
        channel.send(exchange);      
        Thread.sleep(2000);
        assertNotNull(inMessage);
    }
View Full Code Here

         *
         * @param message the message to be sent.
         */
        public void prepare(Message message) throws IOException {
            // setup the message to be send back
            Channel dc = channel;
            message.put(Exchange.class, inMessage.get(Exchange.class));
            NMRTransportFactory.removeUnusedInterceptprs(message);
            message.setContent(OutputStream.class, new NMRDestinationOutputStream(inMessage, message, dc));

        }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.nmr.api.Channel

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.