Package org.infinispan.remoting.transport.jgroups

Examples of org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$FutureCollator


                  return handler.handle(command, source);
               }
            });
      TestingUtil.replaceComponent(manager, InboundInvocationHandler.class, mockHandler, true);
      Transport transport = TestingUtil.extractGlobalComponent(manager, Transport.class);
      CommandAwareRpcDispatcher dispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(transport, "dispatcher");
      TestingUtil.replaceField(mockHandler, "inboundInvocationHandler", dispatcher, CommandAwareRpcDispatcher.class);
   }
View Full Code Here


   }

   private void injectListeningHandler(CacheContainer ecm, ListeningHandler lh) {
      replaceComponent(ecm, InboundInvocationHandler.class, lh, true);
      JGroupsTransport t = (JGroupsTransport) extractComponent(cache(0), Transport.class);
      CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
      replaceField(lh, "inboundInvocationHandler", card, CommandAwareRpcDispatcher.class);
   }
View Full Code Here

   public void testInvokeAndExceptionWhileUnmarshalling() throws Exception {
      Cache cache1 = cache(0, "replSync");
      Cache cache2 = cache(1, "replSync");
      JGroupsTransport transport1 = (JGroupsTransport) TestingUtil.extractComponent(cache1, Transport.class);
      CommandAwareRpcDispatcher dispatcher1 = transport1.getCommandAwareRpcDispatcher();
      RpcDispatcher.Marshaller originalMarshaller1 = dispatcher1.getMarshaller();
      JGroupsTransport transport2 = (JGroupsTransport) TestingUtil.extractComponent(cache2, Transport.class);
      CommandAwareRpcDispatcher dispatcher2 = transport2.getCommandAwareRpcDispatcher();
      RpcDispatcher.Marshaller originalMarshaller = dispatcher2.getMarshaller();
      try {
         RpcDispatcher.Marshaller mockMarshaller1 = mock(RpcDispatcher.Marshaller.class);
         RpcDispatcher.Marshaller mockMarshaller = mock(RpcDispatcher.Marshaller.class);
         PutKeyValueCommand putCommand = new PutKeyValueCommand();
         putCommand.setKey(key);
         putCommand.setValue(value);
         SingleRpcCommand rpcCommand = new SingleRpcCommand("replSync");
         Object[] params = new Object[]{putCommand};
         rpcCommand.setParameters(SingleRpcCommand.COMMAND_ID, params);
         when(mockMarshaller1.objectToBuffer(anyObject())).thenReturn(originalMarshaller1.objectToBuffer(rpcCommand));
         when(mockMarshaller.objectFromBuffer((byte[]) anyObject(), anyInt(), anyInt())).thenThrow(new EOFException());
         dispatcher1.setRequestMarshaller(mockMarshaller1);
         dispatcher2.setRequestMarshaller(mockMarshaller);
         cache1.put(key, value);
         assert false : "Should have thrown an exception";
      } catch (RemoteException ce) {
         assert !(ce.getCause() instanceof ClassCastException) : "No way a ClassCastException must be sent back to user!";
         assert ce.getCause() instanceof CacheException;
         assert ce.getCause().getCause() instanceof EOFException;
      } finally {
         dispatcher1.setMarshaller(originalMarshaller1);
         dispatcher2.setMarshaller(originalMarshaller);
      }
   }
View Full Code Here

   }

   private void injectListeningHandler(CacheContainer ecm, ListeningHandler lh) {
      replaceComponent(ecm, InboundInvocationHandler.class, lh, true);
      JGroupsTransport t = (JGroupsTransport) extractComponent(cache(0), Transport.class);
      CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
      Field f = null;
      try {
         f = card.getClass().getDeclaredField("inboundInvocationHandler");
         f.setAccessible(true);
         f.set(card, lh);
      } catch (NoSuchFieldException e) {
         e.printStackTrace();
      } catch (IllegalAccessException e) {
View Full Code Here

   public void testInvokeAndExceptionWhileUnmarshalling() throws Exception {
      Cache cache1 = cache(0, "replSync");
      Cache cache2 = cache(1, "replSync");
      JGroupsTransport transport1 = (JGroupsTransport) TestingUtil.extractComponent(cache1, Transport.class);
      CommandAwareRpcDispatcher dispatcher1 = transport1.getCommandAwareRpcDispatcher();
      RpcDispatcher.Marshaller originalMarshaller1 = dispatcher1.getMarshaller();
      JGroupsTransport transport2 = (JGroupsTransport) TestingUtil.extractComponent(cache2, Transport.class);
      CommandAwareRpcDispatcher dispatcher2 = transport2.getCommandAwareRpcDispatcher();
      RpcDispatcher.Marshaller originalMarshaller = dispatcher2.getMarshaller();
      try {
         RpcDispatcher.Marshaller mockMarshaller1 = mock(RpcDispatcher.Marshaller.class);
         RpcDispatcher.Marshaller mockMarshaller = mock(RpcDispatcher.Marshaller.class);
         PutKeyValueCommand putCommand = new PutKeyValueCommand();
         putCommand.setKey(key);
         putCommand.setValue(value);
         SingleRpcCommand rpcCommand = new SingleRpcCommand("replSync");
         Object[] params = new Object[]{putCommand};
         rpcCommand.setParameters(SingleRpcCommand.COMMAND_ID, params);
         when(mockMarshaller1.objectToBuffer(anyObject())).thenReturn(originalMarshaller1.objectToBuffer(rpcCommand));
         when(mockMarshaller.objectFromBuffer((byte[]) anyObject(), anyInt(), anyInt())).thenThrow(new EOFException());
         dispatcher1.setRequestMarshaller(mockMarshaller1);
         dispatcher2.setRequestMarshaller(mockMarshaller);
         cache1.put(key, value);
         assert false : "Should have thrown an exception";
      } catch(CacheException ce) {
         assert !(ce.getCause() instanceof ClassCastException) : "No way a ClassCastException must be sent back to user!";
         assert ce.getCause() instanceof EOFException;
      } finally {
         dispatcher1.setMarshaller(originalMarshaller1);
         dispatcher2.setMarshaller(originalMarshaller);
      }
   }
View Full Code Here

   }

   private void injectListeningHandler(CacheContainer ecm, ListeningHandler lh) {
      replaceComponent(ecm, InboundInvocationHandler.class, lh, true);
      JGroupsTransport t = (JGroupsTransport) extractComponent(cache(0), Transport.class);
      CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
      replaceField(lh, "inboundInvocationHandler", card, CommandAwareRpcDispatcher.class);
   }
View Full Code Here

                  return null;
               }
            }).when(mockHandler).handle(any(commandClass), any(Address.class), any(Response.class), anyBoolean());
      TestingUtil.replaceComponent(manager, InboundInvocationHandler.class, mockHandler, true);
      Transport transport = TestingUtil.extractGlobalComponent(manager, Transport.class);
      CommandAwareRpcDispatcher dispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(transport, "dispatcher");
      TestingUtil.replaceField(mockHandler, "inboundInvocationHandler", dispatcher, CommandAwareRpcDispatcher.class);
   }
View Full Code Here

   }

   private void injectListeningHandler(CacheContainer ecm, ListeningHandler lh) {
      replaceComponent(ecm, InboundInvocationHandler.class, lh, true);
      JGroupsTransport t = (JGroupsTransport) extractComponent(cache(0), Transport.class);
      CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
      Field f = null;
      try {
         f = card.getClass().getDeclaredField("inboundInvocationHandler");
         f.setAccessible(true);
         f.set(card, lh);
      } catch (NoSuchFieldException e) {
         e.printStackTrace();
      } catch (IllegalAccessException e) {
View Full Code Here

      public static BackupReceiverRepositoryWrapper replaceInCache(CacheContainer cacheContainer, BackupListener listener) {
         BackupReceiverRepository delegate = extractGlobalComponent(cacheContainer, BackupReceiverRepository.class);
         BackupReceiverRepositoryWrapper wrapper = new BackupReceiverRepositoryWrapper(delegate, listener);
         replaceComponent(cacheContainer, BackupReceiverRepository.class, wrapper, true);
         JGroupsTransport t = (JGroupsTransport) extractGlobalComponent(cacheContainer, Transport.class);
         CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
         replaceField(wrapper, "backupReceiverRepository", card, CommandAwareRpcDispatcher.class);
         return wrapper;
      }
View Full Code Here

   private InboundInvocationHandler spyInvocationHandler(Cache cache) {
      InboundInvocationHandler spy = Mockito.spy(extractComponent(cache, InboundInvocationHandler.class));
      replaceComponent(cache.getCacheManager(), InboundInvocationHandler.class, spy, true);
      JGroupsTransport t = (JGroupsTransport) extractComponent(cache, Transport.class);
      CommandAwareRpcDispatcher card = t.getCommandAwareRpcDispatcher();
      replaceField(spy, "inboundInvocationHandler", card, CommandAwareRpcDispatcher.class);
      return spy;
   }
View Full Code Here

TOP

Related Classes of org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$FutureCollator

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.