Package org.jboss.test.jca.jdbc

Examples of org.jboss.test.jca.jdbc.TestConnection


    * @ejb:interface-method
    * @ejb:transaction type="NotSupported"
    */
   public void testConnectionObtainable()
   {
      TestConnection tc = null;
      try
      {
         DataSource ds = (DataSource) new InitialContext().lookup("java:StatementTestsConnectionDS");
         Connection c = ds.getConnection();
         WrappedConnection wc = (WrappedConnection) c;
         Connection uc = wc.getUnderlyingConnection();
         tc = (TestConnection) Proxy.getInvocationHandler(uc);
         c.close();
         tc.setFail(true);
         int closeCount1 = tc.getClosedCount();
         c = ds.getConnection();
         if (closeCount1 == tc.getClosedCount())
         {
            throw new EJBException("no connections closed!, closedCount: " + closeCount1);
         }
         c.close();
         for (int i = 0; i < 10; i++)
         {

            int closeCount = tc.getClosedCount();
            c = ds.getConnection();
            if (closeCount == tc.getClosedCount())
            {
               throw new EJBException("no connections closed! at iteration: " + i + ", closedCount: " + closeCount);
            }
            c.close();
         }

      }
      catch (SQLException e)
      {
         throw new EJBException(e);
      }
      catch (NamingException e)
      {
         throw new EJBException(e);
      }
      finally
      {
         if (tc != null)
            tc.setFail(false);
      }
   }
View Full Code Here


      }
   }
  
   public void testRollbackOnCloseNoTx()
   {
      TestConnection tc = null;
      try
      {
         DataSource ds = (DataSource) new InitialContext().lookup("java:NoTxStatementTestsConnectionDS");
         Connection c = ds.getConnection();
         try
         {
            c.setAutoCommit(false);
            WrappedConnection wc = (WrappedConnection) c;
            Connection uc = wc.getUnderlyingConnection();
            tc = (TestConnection) Proxy.getInvocationHandler(uc);

            try
            {
               c.nativeSQL("ERROR");
            }
            catch (SQLException expected)
            {
            }
         }
         finally
         {
            try
            {
               c.close();
            }
            catch (SQLException ignored)
            {
            }
         }
        
         if (tc.isClosed() == false)
            throw new RuntimeException("Connection was not closed");
         if (tc.isRolledBack() == false)
            throw new RuntimeException("Connection was not rolled back");
      }
      catch (SQLException e)
      {
         throw new EJBException(e);
View Full Code Here

      }
   }
  
   public void testRollbackOnCloseManagedTx()
   {
      TestConnection tc = null;
      try
      {
         DataSource ds = (DataSource) new InitialContext().lookup("java:StatementTestsConnectionDS");
         Connection c = ds.getConnection();
         try
         {
            WrappedConnection wc = (WrappedConnection) c;
            Connection uc = wc.getUnderlyingConnection();
            tc = (TestConnection) Proxy.getInvocationHandler(uc);

            try
            {
               c.nativeSQL("ERROR");
            }
            catch (SQLException expected)
            {
            }
         }
         finally
         {
            try
            {
               c.close();
            }
            catch (SQLException ignored)
            {
            }
         }
        
         if (tc.isClosed() == false)
            throw new RuntimeException("Connection was not closed");
         if (tc.isRolledBack() == false)
            throw new RuntimeException("Connection was not rolled back");
      }
      catch (SQLException e)
      {
         throw new EJBException(e);
View Full Code Here

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
      try
      {
         conn.createStatement().execute("blah");
        
View Full Code Here

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
      try
      {
         conn.createStatement().execute("blah");
        
View Full Code Here

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
      try
      {
         conn.createStatement().execute("blah");
        
View Full Code Here

TOP

Related Classes of org.jboss.test.jca.jdbc.TestConnection

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.