Package org.infinispan.util.mocks

Examples of org.infinispan.util.mocks.ControlledCommandFactory


      waitForClusterToForm();
      advancedCache(2).addInterceptor(new RollbackBeforePrepareTest.FailPrepareInterceptor(), 1);
   }

   public void testTxCompletionNotSentForRollback() throws Throwable {
      ControlledCommandFactory cf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), null);

      tm(0).begin();
      Object k1 = getKeyForCache(1);
      Object k2 = getKeyForCache(2);
      cache(0).put(k1, k1);
      cache(0).put(k2, k2);
      try {
         tm(0).commit();
         fail();
      } catch (Throwable t) {
         //expected
      }

      assertNotLocked(k1);
      assertNotLocked(k2);
      assertNull(cache(0).get(k1));
      assertNull(cache(0).get(k2));

      assertEquals(cf.received(PrepareCommand.class), 1);
      assertEquals(cf.received(RollbackCommand.class), 2);
      assertEquals(cf.received(TxCompletionNotificationCommand.class), 0);
   }
View Full Code Here


      dcc.clustering().hash().numOwners(1);
      createClusteredCaches(2, dcc);
   }

   public void testBelatedTransactionDoesntLeak() throws Throwable {
      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), PrepareCommand.class);
      ccf.gate.close();

      Cache receiver = cache(1);
      BlockingPrepareInterceptor interceptor = new BlockingPrepareInterceptor();
      advancedCache(1).addInterceptor(interceptor, 1);
View Full Code Here

      createCluster(dcc, 2);
      waitForClusterToForm();
   }

   public void testTransactionStateNotLost() throws Throwable {
      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), CommitCommand.class);
      ccf.gate.close();

      final Map<Object, DummyTransaction> keys2Tx = new HashMap<Object, DummyTransaction>(TX_COUNT);

      int viewId = advancedCache(0).getRpcManager().getTransport().getViewId();
View Full Code Here

      dcc.clustering().hash().numOwners(1);
      createClusteredCaches(2, dcc);
   }

   public void testBelatedTransactionDoesntLeak() throws Throwable {
      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), PrepareCommand.class);
      ccf.gate.close();

      Cache receiver = cache(1);
      BlockingPrepareInterceptor interceptor = new BlockingPrepareInterceptor();
      advancedCache(1).addInterceptor(interceptor, 1);
View Full Code Here

      testLockReleasedCorrectly(TxCompletionNotificationCommand.class);
   }

   private void testLockReleasedCorrectly(Class<? extends  ReplicableCommand> toBlock ) throws Throwable {

      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), toBlock);
      ccf.gate.close();

      final Set<Object> keys = new HashSet<Object>(KEY_SET_SIZE);

      //fork it into another test as this is going to block in commit
View Full Code Here

      createCluster(dcc, 2);
      waitForClusterToForm();
   }

   public void testTransactionStateNotLost() throws Throwable {
      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), CommitCommand.class);
      ccf.gate.close();

      final Map<Object, DummyTransaction> keys2Tx = new HashMap<Object, DummyTransaction>(TX_COUNT);

      int viewId = advancedCache(0).getRpcManager().getTransport().getViewId();
View Full Code Here

   }

   protected void amend(ConfigurationBuilder dcc) {}

   public void testTxCompletionNotSentForRollback() throws Throwable {
      ControlledCommandFactory cf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), null);

      tm(0).begin();
      Object k = getKeyForCache(1);
      cache(0).put(k,"k");
      tm(0).rollback();

      assertNotLocked(k);
      assertNull(cache(0).get(k));

      assertEquals(cf.received(RollbackCommand.class), 1);
      assertEquals(cf.received(TxCompletionNotificationCommand.class), 0);
   }
View Full Code Here

      waitForClusterToForm();
      advancedCache(2).addInterceptor(new RollbackBeforePrepareTest.FailPrepareInterceptor(), 1);
   }

   public void testTxCompletionNotSentForRollback() throws Throwable {
      ControlledCommandFactory cf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), null);

      tm(0).begin();
      Object k1 = getKeyForCache(1);
      Object k2 = getKeyForCache(2);
      cache(0).put(k1, k1);
      cache(0).put(k2, k2);
      try {
         tm(0).commit();
         fail();
      } catch (Throwable t) {
         //expected
      }

      assertNotLocked(k1);
      assertNotLocked(k2);
      assertNull(cache(0).get(k1));
      assertNull(cache(0).get(k2));

      assertEquals(cf.received(PrepareCommand.class), 1);
      assertEquals(cf.received(RollbackCommand.class), 2);
      assertEquals(cf.received(TxCompletionNotificationCommand.class), 0);
   }
View Full Code Here

   }


   public void testCommitNotSentBeforeAllPrepareAreAck() throws Exception {

      ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(cache(1), PrepareCommand.class);
      ccf.gate.close();

      try {
         cache(0).put("k", "v");
         fail();
View Full Code Here

      dcc.clustering().hash().numOwners(1);
      createClusteredCaches(2, dcc);
   }

   public void testBelatedTransactionDoesntLeak() throws Throwable {
      final ControlledCommandFactory ccf = ControlledCommandFactory.registerControlledCommandFactory(advancedCache(1), PrepareCommand.class);
      ccf.gate.close();

      Cache receiver = cache(1);
      BlockingPrepareInterceptor interceptor = new BlockingPrepareInterceptor();
      advancedCache(1).addInterceptor(interceptor, 1);
View Full Code Here

TOP

Related Classes of org.infinispan.util.mocks.ControlledCommandFactory

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.