Search in sources :

Example 1 with ReplyCallerDirectory

use of io.joynr.dispatching.rpc.ReplyCallerDirectory in project joynr by bmwcarit.

the class RequestReplyManagerTest method setUp.

@Before
public void setUp() throws NoSuchMethodException, SecurityException, JsonGenerationException, IOException {
    requestCallerFactory = new RequestCallerFactory();
    testOneWayRecipientParticipantId = "testOneWayRecipientParticipantId";
    testOneWayRecipientDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
    testOneWayRecipientDiscoveryEntry.setParticipantId(testOneWayRecipientParticipantId);
    testOneWayRecipientDiscoveryEntries = Sets.newHashSet(testOneWayRecipientDiscoveryEntry);
    testMessageResponderParticipantId = "testMessageResponderParticipantId";
    testMessageResponderDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
    testMessageResponderDiscoveryEntry.setParticipantId(testMessageResponderParticipantId);
    testSenderParticipantId = "testSenderParticipantId";
    testResponderUnregisteredParticipantId = "testResponderUnregisteredParticipantId";
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            install(new JoynrMessageScopeModule());
            bind(MessageSender.class).toInstance(messageSenderMock);
            bind(MessageRouter.class).toInstance(messageRouterMock);
            bind(RequestReplyManager.class).to(RequestReplyManagerImpl.class);
            requestStaticInjection(RpcUtils.class, Request.class, JoynrMessagingConnectorFactory.class);
            ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("joynr.Cleanup-%d").build();
            ScheduledExecutorService cleanupExecutor = Executors.newSingleThreadScheduledExecutor(namedThreadFactory);
            bind(ScheduledExecutorService.class).annotatedWith(Names.named(JOYNR_SCHEDULER_CLEANUP)).toInstance(cleanupExecutor);
            Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
            });
        }
    });
    objectMapper = injector.getInstance(ObjectMapper.class);
    objectMapper.registerSubtypes(Request.class, OneWayRequest.class);
    requestReplyManager = injector.getInstance(RequestReplyManager.class);
    providerDirectory = injector.getInstance(ProviderDirectory.class);
    replyCallerDirectory = injector.getInstance(ReplyCallerDirectory.class);
    requestReplyManager = injector.getInstance(RequestReplyManager.class);
    // dispatcher.addListener(testOneWayRecipientParticipantId, testListener);
    // jsonRequestString1 = "{\"_typeName\":\"Request\", \"methodName\":\"respond\",\"params\":{\"payload\": \""
    // + payload1 + "\"}}";
    // jsonRequestString2 = "{\"_typeName\":\"Request\", \"methodName\":\"respond\",\"params\":{\"payload\": \""
    // + payload2 + "\"}}";
    Object[] params1 = new Object[] { payload1 };
    Object[] params2 = new Object[] { payload2 };
    // MethodMetaInformation methodMetaInformation = new
    // MethodMetaInformation(TestRequestCaller.class.getMethod("respond", new Class[]{ Object.class }));
    Method method = TestProvider.class.getMethod("methodWithStrings", new Class[] { String.class });
    request1 = new Request(method.getName(), params1, method.getParameterTypes());
    request2 = new Request(method.getName(), params2, method.getParameterTypes());
    request3 = new Request("unknownMethodName", params2, method.getParameterTypes());
    Method fireAndForgetMethod = TestOneWayRecipient.class.getMethod("fireAndForgetMethod", new Class[] { String.class });
    oneWay1 = new OneWayRequest(fireAndForgetMethod.getName(), new Object[] { payload1 }, fireAndForgetMethod.getParameterTypes());
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) RpcUtils(io.joynr.dispatching.rpc.RpcUtils) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OneWayRequest(joynr.OneWayRequest) Request(joynr.Request) Method(java.lang.reflect.Method) AbstractModule(com.google.inject.AbstractModule) JoynrMessageScopeModule(io.joynr.context.JoynrMessageScopeModule) OneWayRequest(joynr.OneWayRequest) TypeLiteral(com.google.inject.TypeLiteral) ReplyCallerDirectory(io.joynr.dispatching.rpc.ReplyCallerDirectory) Injector(com.google.inject.Injector) JoynrMessagingConnectorFactory(io.joynr.proxy.JoynrMessagingConnectorFactory) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 TypeLiteral (com.google.inject.TypeLiteral)1 JoynrMessageScopeModule (io.joynr.context.JoynrMessageScopeModule)1 ReplyCallerDirectory (io.joynr.dispatching.rpc.ReplyCallerDirectory)1 RpcUtils (io.joynr.dispatching.rpc.RpcUtils)1 JoynrMessagingConnectorFactory (io.joynr.proxy.JoynrMessagingConnectorFactory)1 Method (java.lang.reflect.Method)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 OneWayRequest (joynr.OneWayRequest)1 Request (joynr.Request)1 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)1 Before (org.junit.Before)1