Package org.openengsb.core.api.remote

Examples of org.openengsb.core.api.remote.MethodCall


        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        String result = (String) filterChain.filter(input, new HashMap<String, Object>());
        MethodResultMessage returnValue = objectMapper.readValue(result, MethodResultMessage.class);
        assertThat((String) returnValue.getResult().getArg(), is("foo"));
View Full Code Here


                .asList(new Object[]{ XmlDecoderFilter.class, XmlMethodCallMarshalFilter.class, requestMapperFilter, });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" }, Arrays.asList(String.class.getName()));
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");

        JAXBContext jaxbContext = JAXBContext.newInstance(MethodCallMessage.class, MethodResultMessage.class);
        final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        final Marshaller marshaller = jaxbContext.createMarshaller();
View Full Code Here

        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        HashMap<String, Object> metaData = new HashMap<String, Object>();
        filterChain.filter(input, metaData);
        assertThat((String) metaData.get("callId"), is("bar"));
View Full Code Here

    @Test
    public void testMethodCallWithNullParameters_shouldBeSerialized() throws Exception {
        Object[] args = { 1, null, 2 };
        String[] classes = { "java.lang.Integer", "java.lang.Integer", "java.lang.Integer" };
        MethodCall methodCall = new MethodCall("test", args, Arrays.asList(classes));

        ObjectMapper objectMapper = new ObjectMapper();
        String writeValueAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(methodCall);
        MethodCall readValue = objectMapper.readValue(writeValueAsString, MethodCall.class);
        assertThat(readValue, is(methodCall));
    }
View Full Code Here

    public void testCallByServiceId_shouldCallService() throws Exception {
        TestInterface mockService = mockService(TestInterface.class, "testid");
        when(mockService.test(anyInt())).thenReturn(21);

        Map<String, String> metaData = ImmutableMap.of("serviceId", "testid");
        MethodCall c = new MethodCall("test", new Object[]{ 42 }, metaData);
        MethodResult result = requestHandler.handleCall(c);

        verify(mockService).test(42);
        assertThat(result.getClassName(), is(Integer.class.getName()));
        assertThat((Integer) result.getArg(), is(21));
View Full Code Here

        Map<String, Object> propData = ImmutableMap.of("testprop", (Object) new String[]{ "bla", "bleh", });
        TestInterface mockService = mockServiceWithProps(propData);
        when(mockService.test(anyInt())).thenReturn(21);

        Map<String, String> metaData = ImmutableMap.of("serviceFilter", "(testprop=bla)");
        MethodCall c = new MethodCall("test", new Object[]{ 42 }, metaData);
        MethodResult result = requestHandler.handleCall(c);

        verify(mockService).test(42);
        assertThat(result.getClassName(), is(Integer.class.getName()));
        assertThat((Integer) result.getArg(), is(21));
View Full Code Here

            ImmutableMap.of("testprop", (Object) new String[]{ "bla", "bleh", }, Constants.SERVICE_PID, "xxx");
        TestInterface mockService = mockServiceWithProps(propData);
        when(mockService.test(anyInt())).thenReturn(21);

        Map<String, String> metaData = ImmutableMap.of("serviceFilter", "(testprop=bla)", "serviceId", "xxx");
        MethodCall c = new MethodCall("test", new Object[]{ 42 }, metaData);
        MethodResult result = requestHandler.handleCall(c);

        verify(mockService).test(42);
        assertThat(result.getClassName(), is(Integer.class.getName()));
        assertThat((Integer) result.getArg(), is(21));
View Full Code Here

            }
        };
        registerServiceWithProps(realObject, propData);

        Map<String, String> metaData = ImmutableMap.of("serviceFilter", "(testprop=blub)", "serviceId", "xxx");
        MethodCall c = new MethodCall("test", new Object[]{ 42 }, metaData);
        MethodResult result = requestHandler.handleCall(c);

        assertThat(result.getClassName(), is(Integer.class.getName()));
        assertThat((Integer) result.getArg(), is(43));
    }
View Full Code Here

    public void testCallButBothAttrsNull_shouldThrowException() throws Exception {
        Map<String, Object> propData =
            ImmutableMap.of("testprop", (Object) new String[]{ "bla", "bleh", });
        TestInterface mockService = mockServiceWithProps(propData);

        MethodCall c = new MethodCall("test", new Object[]{ 42 });
        try {
            requestHandler.handleCall(c);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            verifyZeroInteractions(mockService);
View Full Code Here

     */
    public static void main(String[] args) throws Exception {
        LOGGER.info("initializing");
        init();
        LOGGER.info("initialized");
        MethodCall methodCall = new MethodCall("doSomething", new Object[] { "Hello World!" }, ImmutableMap.of(
                "serviceId", "example+example+testlog", "contextId", "foo"));
        LOGGER.info("calling method");
        MethodResult methodResult = call(methodCall, "admin", "password");
        System.out.println(methodResult);
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.remote.MethodCall

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.