Package org.switchyard.test

Examples of org.switchyard.test.MockHandler


    private MockHandler _provider;
   
    @Before
    public void setUp() throws Exception {
        _domain = new MockDomain();
        _provider = new MockHandler();
    }
View Full Code Here


        // Serivce A is for app 1, Service B is for app 2
        final QName SERVICE_A = new QName("urn:test", "ServiceA");
        final QName SERVICE_B = new QName("urn:test", "ServiceB");
        ServiceReference referenceA = _domain.registerServiceReference(SERVICE_A, new InOnlyService());
        _domain.registerServiceReference(SERVICE_B, new InOnlyService());
        Service serviceA = _domain.registerService(SERVICE_A, new InOnlyService(), new MockHandler());
        _domain.registerService(SERVICE_B, new InOnlyService(), _provider);
       
        MockExchange ex = new MockExchange();
        Message msg = ex.createMessage().setContent("TEST");
        ex.setMessage(msg);
View Full Code Here

        // two domains
        MockDomain domain1 = _domain;
        MockDomain domain2 = new MockDomain(domain1.getServiceRegistry());

        ServiceReference referenceA = domain1.registerServiceReference(SERVICE_A, new InOnlyService());
        Service serviceA = domain1.registerService(SERVICE_A, new InOnlyService(), new MockHandler());
        domain2.registerServiceReference(SERVICE_B, new InOnlyService());
        domain2.registerService(SERVICE_B, new InOnlyService(), _provider);
       
        MockExchange ex = new MockExchange();
        Message msg = ex.createMessage().setContent("TEST");
View Full Code Here

        // urn:app1 is for app 1, urn:app2 is for app 2
        final QName SERVICE_A = new QName("urn:app1", "ServiceA");
        final QName SERVICE_B = new QName("urn:app2", "ServiceA");
        ServiceReference referenceA = _domain.registerServiceReference(SERVICE_A, new InOnlyService());
        _domain.registerServiceReference(SERVICE_B, new InOnlyService());
        Service serviceA = _domain.registerService(SERVICE_A, new InOnlyService(), new MockHandler());
        _domain.registerService(SERVICE_B, new InOnlyService(), _provider);
       
        MockExchange ex = new MockExchange();
        Message msg = ex.createMessage().setContent("TEST");
        ex.setMessage(msg);
View Full Code Here

    }
   
    @Test
    public void noOperationName() throws Exception {
        domain.registerServiceReference(TEST_SERVICE, new InOnlyService());
        domain.registerService(TEST_SERVICE, new InOnlyService(), new MockHandler());
        RemoteMessage msg = new RemoteMessage()
            .setService(TEST_SERVICE);
        setRequestMessage(msg);
        servlet.doPost(request, response);
    }
View Full Code Here

        servlet.doPost(request, response);
    }
   
    @Test
    public void noOperationNameMultipleOperations() throws Exception {
        MockHandler handler = new MockHandler();
        domain.registerServiceReference(TEST_SERVICE, JavaService.fromClass(MyInterface.class));
        domain.registerService(TEST_SERVICE, JavaService.fromClass(MyInterface.class), handler);
       
        RemoteMessage msg = new RemoteMessage()
            .setService(TEST_SERVICE);
View Full Code Here

        }
    }
   
    @Test
    public void operationNameMultipleOperations() throws Exception {
        MockHandler handler = new MockHandler();
        domain.registerServiceReference(TEST_SERVICE, JavaService.fromClass(MyInterface.class));
        domain.registerService(TEST_SERVICE, JavaService.fromClass(MyInterface.class), handler);
       
        RemoteMessage msg = new RemoteMessage()
            .setService(TEST_SERVICE)
            .setOperation("bar");
        setRequestMessage(msg);
        servlet.doPost(request, response);
       
        Exchange ex = handler.getMessages().poll(300, TimeUnit.MILLISECONDS);
        Assert.assertNotNull(ex);
        Assert.assertEquals("bar", ex.getContract().getConsumerOperation().getName());
    }
View Full Code Here

    }

    @Test
    public void sendToSwitchyardInOnly() throws Exception {
        final String payload = "bajja";
        final MockHandler mockService = new MockHandler();
        _serviceDomain.registerService(new QName(_serviceName), new InOnlyService(), mockService);
        _serviceDomain.registerServiceReference(new QName(_serviceName), new InOnlyService("process"));

        template.sendBody("direct:input", payload);

        assertThat(mockService.getMessages().size(), is(1));
        final String actualPayload = mockService.getMessages().iterator().next().getMessage().getContent(String.class);
        assertThat(actualPayload, is(equalTo(payload)));
    }
View Full Code Here

    public void sendToSwitchyardInOnlyFault() throws Exception {
        final String payload = "bajja";

        MockEndpoint endpoint = getMockEndpoint("mock:result");
        endpoint.expectedBodiesReceived(payload);
        final MockHandler mockService = new MockHandler().forwardInToOut();
        _serviceDomain.registerService(new QName(_serviceName), new InOnlyService(), mockService);
        _serviceDomain.registerServiceReference(new QName(_serviceName), new InOnlyService("process"));

        template.sendBody("direct:input", payload);

        assertThat(mockService.getMessages().size(), is(1));
        final String actualPayload = mockService.getMessages().iterator().next().getMessage().getContent(String.class);
        assertThat(actualPayload, is(equalTo(payload)));
        endpoint.assertIsSatisfied();
    }
View Full Code Here

    }

    @Test
    public void customBindingData() throws Exception {
        List<Policy> policies = Arrays.<Policy>asList(SecurityPolicy.CONFIDENTIALITY);
        final MockHandler mockService = new MockHandler();
        _serviceDomain.registerService(
                new QName(_serviceName),
                new InOnlyService(),
                mockService,
                ServiceMetadataBuilder.create().security(_serviceDomain.getServiceSecurity(null))
                        .requiredPolicies(policies).registrant(new Binding(new ArrayList<BindingModel>())).build());
        _serviceDomain.registerServiceReference(new QName(_serviceName), new InOnlyService("process"));
        _camelContext.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("netty://foo").to("switchyard://" + _serviceName + "?operationName=process");
            }
        });
        _camelContext.createProducerTemplate().sendBody("netty://foo", "baja");

        LinkedBlockingQueue<Exchange> msgs = mockService.getMessages();
        Exchange exchange = msgs.iterator().next();
        assertTrue(PolicyUtil.isProvided(exchange, SecurityPolicy.CONFIDENTIALITY));
    }
View Full Code Here

TOP

Related Classes of org.switchyard.test.MockHandler

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.