Package org.jboss.resource.connectionmanager

Examples of org.jboss.resource.connectionmanager.ConnectionListener


      log.info("------------------------");
      log.info("testGetManagedConnection");
      log.info("------------------------");


      ConnectionListener cl = null;
      try
      {
         assertNotNull(tm);
         tm.begin();

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());

         cl = cm.getManagedConnection(subject, cri);

         assertEquals(1, cm.getPoolingStrategy().getInUseConnectionCount());
        
         assertNotNull(cl);
         cl.enlist();
        
         assertNotNull(tm);
         tm.commit();
        
         cl.delist();
         cm.returnManagedConnection(cl, false);
         cl = null;

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());
      }
View Full Code Here


      log.info("-------------------------------");
      log.info("testGetManagedConnectionTimeout");
      log.info("-------------------------------");


      ConnectionListener cl = null;
      try
      {
         assertNotNull(tm);
         tm.setTransactionTimeout(2);
         tm.begin();

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());

         cl = cm.getManagedConnection(subject, cri);

         assertEquals(1, cm.getPoolingStrategy().getInUseConnectionCount());
        
         assertNotNull(cl);
         cl.enlist();
        
         Thread.sleep(2500L);

         cl.delist();
         cm.returnManagedConnection(cl, false);

         cl = null;

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());
View Full Code Here

      log.info("---------------------------------");

      // track-by-tx = true
      cm.setTrackConnectionByTx(true);

      ConnectionListener cl = null;
      try
      {
         assertNotNull(tm);
         tm.begin();

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());

         cl = cm.getManagedConnection(subject, cri);

         assertEquals(1, cm.getPoolingStrategy().getInUseConnectionCount());

         assertNotNull(cl);
         cl.enlist();
        
         assertNotNull(tm);
         tm.commit();
        
         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());
View Full Code Here

      log.info("----------------------------------------");

      // track-by-tx = true
      cm.setTrackConnectionByTx(true);

      ConnectionListener cl = null;
      try
      {
         assertNotNull(tm);
         tm.setTransactionTimeout(2);
         tm.begin();

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());

         cl = cm.getManagedConnection(subject, cri);

         assertEquals(1, cm.getPoolingStrategy().getInUseConnectionCount());

         assertNotNull(cl);
         cl.enlist();

         Thread.sleep(2500L);

         assertEquals(0, cm.getPoolingStrategy().getInUseConnectionCount());
        
View Full Code Here

         ManagedConnectionPool ps = cm.getPoolingStrategy();

         assertTrue("0: Initial check", ps.getConnectionCount() == 0);

         // Get a connection
         ConnectionListener cl = cm.getManagedConnection(null, null);
         assertTrue("1: Got a null connection!", cl.getManagedConnection() != null);
         assertTrue("1: One connection", ps.getConnectionCount() == 1);

         // Get another connection
         ConnectionListener cl2 = cm.getManagedConnection(null, null);
         assertTrue("2: Got a null connection!", cl2.getManagedConnection() != null);
         assertTrue("2: Two connections", ps.getConnectionCount() == 2);

         // Return first
         cm.returnManagedConnection(cl, true);
         assertTrue("3: One connection", ps.getConnectionCount() == 1);
View Full Code Here

                  long getConnection = 0;
                  long returnConnection = 0;
                  long heldConnection = 0;
                  for (int j = 0; j < reps; j++)
                  {
                     ConnectionListener cl = null;
                     try
                     {
                        if (tm == null)
                           throw new SystemException("TM is null");

                        tm.begin();

                        long startGetConnection = System.currentTimeMillis();
                        cl = cm.getManagedConnection(subject, cri);
                        cl.enlist();
                        long endGetConnection = System.currentTimeMillis();

                        TxConnectionManagerStressTestCase.this.connectionCount.incrementAndGet();

                        Thread.sleep(sleepTime);

                        if (tm == null)
                           throw new SystemException("TM is null");

                        tm.commit();

                        long startReturnConnection = System.currentTimeMillis();
                        if (!trackByTx)
                        {
                           cl.delist();
                           cm.returnManagedConnection(cl, false);
                        }
                        cl = null;
                        long endReturnConnection = System.currentTimeMillis();
                       
View Full Code Here

      {
         id = startedThreadCount.getAndIncrement();

         for (int j = 0; j < reps; j++)
         {
            ConnectionListener cl = null;
            try
            {
               assertNotNull(tm);

               tm.setTransactionTimeout(2);
               tm.begin();
               Transaction tx = tm.getTransaction();
               tx.registerSynchronization(this);

               cl = cm.getManagedConnection(subject, cri);
               cl.enlist();

               latch.await(20, TimeUnit.SECONDS);

               assertNotNull(tm);

               tx = tm.getTransaction();
               if (tx != null && TxUtils.isActive(tx))
                  failed = true;

               if (!trackByTx)
               {
                  cl.delist();
                  cm.returnManagedConnection(cl, false);
               }
               cl = null;

             }
View Full Code Here

      ((PreFillPoolSupport)mcp).prefill();
     
      //Let prefiller run
      Thread.sleep(5000);
     
      ConnectionListener cl = noTxn.getManagedConnection(null, null);
      noTxn.returnManagedConnection(cl, false);
     
      assertTrue(mcp.getConnectionDestroyedCount() == 0);

     
View Full Code Here

      ((PreFillPoolSupport)mcp).prefill();
     
      //Let prefiller run
      Thread.sleep(5000);
     
      ConnectionListener cl = noTxn.getManagedConnection(null, null);
      noTxn.returnManagedConnection(cl, false);
     
      assertTrue(mcp.getConnectionDestroyedCount() > 0);
     
   }
View Full Code Here

      pp.backgroundInterval = 2000;
      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
     
      ConnectionListener cl = noTxn.getManagedConnection(null, null);
      noTxn.returnManagedConnection(cl, false);
     
      Thread.sleep(pp.backgroundInterval);
      assertTrue(mcp.getConnectionDestroyedCount() == 0);
     
View Full Code Here

TOP

Related Classes of org.jboss.resource.connectionmanager.ConnectionListener

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.