Examples of TestStep


Examples of org.helidb.test.support.concurrent.TestStep

      populateDb(db);
      Map<String, Object> m = new HashMap<String, Object>();
      m.put("db", db);
      m.put("latch1", new CountDownLatch(2));
      m.put("flag1", new AtomicBoolean(false));
      new ConcurrentTestRunner(new TestStep[][] { new TestStep[] { new TestStep() {
        public void runStep(Map<String, Object> mp) throws Exception
        {
          CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
          try
          {
            TransactionalDatabase<?, ?> tdb = (TransactionalDatabase<?, ?>) mp.get("db");
            // Start a transaction and count down the latch
            Transaction txn = Transaction.startTransaction(false);
            try
            {
              // Let the database join the transaction
              tdb.joinTransaction(false);
              l1.countDown();
              l1.await();
              l1 = null;

              // Sleep awhile to give the other thread plenty of
              // time to set the flag
              Thread.sleep(1000);
              // Still not set
              assertFalse(((AtomicBoolean) mp.get("flag1")).get());
            }
            finally
            {
              txn.rollback();
            }
          }
          finally
          {
            if (l1 != null)
            {
              l1.countDown();
            }
          }
        }
      } }, new TestStep[] { new TestStep() {
        public void runStep(Map<String, Object> mp) throws Exception
        {
          CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
          try
          {
View Full Code Here

Examples of org.helidb.test.support.concurrent.TestStep

        Map<String, Object> m = new HashMap<String, Object>();
        m.put("db1", db1);
        m.put("db2", db2);
        m.put("latch1", new CountDownLatch(2));
        m.put("flag1", new AtomicBoolean(false));
        new ConcurrentTestRunner(new TestStep[][] { new TestStep[] { new TestStep() {
          public void runStep(Map<String, Object> mp) throws Exception
          {
            CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
            try
            {
              TransactionalDatabase<?, ?> tdb1 = (TransactionalDatabase<?, ?>) mp.get("db1");
              TransactionalDatabase<?, ?> tdb2 = (TransactionalDatabase<?, ?>) mp.get("db2");
              // Start a transaction and count down the latch
              Transaction txn = Transaction.startTransaction(false);
              try
              {
                // Let the databases join the transaction
                tdb1.joinTransaction(false);
                tdb2.joinTransaction(false);
                l1.countDown();
                l1.await();
                l1 = null;

                // Sleep awhile to give the other thread plenty
                // of time to
                // set the flag
                Thread.sleep(1000);
                // Still not set
                assertFalse(((AtomicBoolean) mp.get("flag1")).get());
              }
              finally
              {
                txn.rollback();
              }
            }
            finally
            {
              if (l1 != null)
              {
                l1.countDown();
              }
            }
          }
        } }, new TestStep[] { new TestStep() {
          public void runStep(Map<String, Object> mp) throws Exception
          {
            CountDownLatch l1 = (CountDownLatch) mp.get("latch1");
            try
            {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.