[jboss-svn-commits] JBL Code SVN: r30459 - in labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java: org/jboss/jbossts/performance and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Dec 3 12:01:11 EST 2009


Author: whitingjr
Date: 2009-12-03 12:01:11 -0500 (Thu, 03 Dec 2009)
New Revision: 30459

Added:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java
Modified:
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/auction/test/basic/ProfiledStateTransitions.java
   labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/readonly/JPAExampleTests.java
Log:
Changed configuration to support a second resource.
Added warmup class.

Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/auction/test/basic/ProfiledStateTransitions.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/auction/test/basic/ProfiledStateTransitions.java	2009-12-03 17:00:19 UTC (rev 30458)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/auction/test/basic/ProfiledStateTransitions.java	2009-12-03 17:01:11 UTC (rev 30459)
@@ -34,7 +34,9 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 import javax.persistence.ColumnResult;
+import javax.persistence.EntityManagerFactory;
 import javax.persistence.SqlResultSetMapping;
+import javax.transaction.UserTransaction;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathException;
@@ -102,7 +104,12 @@
 
    private AbstractVendorControl vendorController;
 
-   protected String SESSION_FACTORY_JNDI;
+   protected String SESSION_FACTORY_JNDI_A;
+   protected String SESSION_FACTORY_JNDI_B;
+   protected String JNDI_DATASOURCE_B;
+   protected String  JNDI_NAME_USERTX_B;
+   protected String  JNDI_NAME_EMF_B;
+   protected boolean isOptionalWriteEnabled;
    
    @Override
    public void prepareDataSet(String location, String factory) throws Exception
@@ -111,8 +118,8 @@
    }
 
    @BeforeClass(groups = "integration-warmup")
-   @Parameters(
-   {"basedata_location", "datatype_factory", "integrity-constraint"})
+   @Parameters
+   ({"basedata_location", "datatype_factory", "integrity-constraint"})
    public void prepareDataSet(String location, String factory, String constraint) throws Exception
    {
       // Check if subclass has prepared everything
@@ -138,14 +145,23 @@
          this.vendorController = abconstraint;
       }
    }
+   
+   private SessionFactory getSessionFactoryA()
+   {
+      return getSessionFactory(SESSION_FACTORY_JNDI_A);
+   }
+   private SessionFactory getSessionFactoryB()
+   {
+      return getSessionFactory(SESSION_FACTORY_JNDI_B);
+   }
 
-   protected SessionFactory getSessionFactory()
+   private SessionFactory getSessionFactory(String jndiName)
    {
       SessionFactory returnValue = null;
       try
       {
-         logger.trace("Attempting to lookup session factory with jndi [" + this.SESSION_FACTORY_JNDI + "]");
-         returnValue = (SessionFactory) jndi.lookup(SESSION_FACTORY_JNDI);
+         logger.trace("Attempting to lookup session factory with jndi [" + jndiName + "]");
+         returnValue = (SessionFactory) jndi.lookup(jndiName);
       }
       catch (NameNotFoundException nnfe)
       {
@@ -174,11 +190,11 @@
       Profile.shutdown();
    }
 
-   protected IDatabaseConnection getConnection() throws Exception
+   private IDatabaseConnection getConnection(String jndiDataSource) throws Exception
    {
 
       // Get a JDBC connection from JNDI datasource
-      IDatabaseConnection dbUnitCon = new DatabaseDataSourceConnection(this.jndi, JNDI_DATASOURCE);
+      IDatabaseConnection dbUnitCon = new DatabaseDataSourceConnection(this.jndi, jndiDataSource);
 
       /* Relax the constraints for this connection allowing bulk imports of data */
       Connection con = dbUnitCon.getConnection();
@@ -187,17 +203,25 @@
       {
          DatabaseConfig config = dbUnitCon.getConfig();
          config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, this.datatypeFactory);
-         //config.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, "true");
       }
 
       return dbUnitCon;
    }
+   protected IDatabaseConnection getConnectionA() throws Exception
+   {
+      return this.getConnection(this.JNDI_DATASOURCE);
+   }
+   protected IDatabaseConnection getConnectionB() throws Exception
+   {
+      return this.getConnection(this.JNDI_DATASOURCE_B);
+   }
 
    protected void prepareSettings()
    {
          beforeTestOperations.add(DatabaseOperation.CLEAN_INSERT);
    }
 
+   /*
    @BeforeGroups(groups = "integration-warmup")
    @Parameters(
    {"session_jndi"})
@@ -206,6 +230,7 @@
       logger.debug("Setting Hibernate SessionFactory JNDI");
       this.SESSION_FACTORY_JNDI = jndiSessionFactory;
    }
+   */
    
    @Override
    public void startContainer(String deployBeansXml, String scanClasspath, String jndiDatasource, String jndiNameEMF,
@@ -214,15 +239,20 @@
    
    @BeforeTest(groups = "integration-warmup")
    @Parameters(
-   {"deploy_beans_xml", "scan_classpath", "jndi_datasource", "jndi_name_emf", "jndi_name_usertx", "session_jndi"})
-   public void startContainer(String deployBeansXml, String scanClasspath, String jndiDatasource, String jndiNameEMF,
-         String jndiNameUserTx, String jndiNameHSF) throws Exception
+   {"deploy_beans_xml", "scan_classpath", "jndi_datasource_A", "jndi_datasource_B", "jndi_name_emf_A", "jndi_name_emf_B", "jndi_name_usertx_A", "jndi_name_usertx_B", "session_jndi_A", "session_jndi_B", "invoke_optional_write"})
+   public void startContainer(String deployBeansXml, String scanClasspath, String jndiDatasourceA, String jndiDatasourceB, String jndiNameEMF_A, String jndiNameEMF_B,
+         String jndiNameUserTxA, String jndiNameUserTxB, String jndiNameHSF_A, String jndiNameHSF_B, String flag) throws Exception
    {
       // Set configuration options from TestNG parameters
-      JNDI_DATASOURCE = jndiDatasource;
-      JNDI_NAME_EMF = jndiNameEMF;
-      JNDI_NAME_USERTX = jndiNameUserTx;
-      this.SESSION_FACTORY_JNDI = jndiNameHSF;
+      JNDI_DATASOURCE = jndiDatasourceA;
+      JNDI_DATASOURCE_B = jndiDatasourceB;
+      JNDI_NAME_EMF = jndiNameEMF_A;
+      JNDI_NAME_EMF_B = jndiNameEMF_B;
+      JNDI_NAME_USERTX = jndiNameUserTxA;
+      JNDI_NAME_USERTX_B = jndiNameUserTxB;
+      this.SESSION_FACTORY_JNDI_A = jndiNameHSF_A;
+      this.SESSION_FACTORY_JNDI_B = jndiNameHSF_B;
+      this.isOptionalWriteEnabled = Boolean.parseBoolean(flag);
 
       // Boot the JBoss Microcontainer with EJB3 settings, automatically
       // loads ejb3-interceptors-aop.xml and embedded-jboss-beans.xml
@@ -248,10 +278,16 @@
    public void beforeTestMethod() throws Exception 
    {/* Override ancestor method as it is substituted */
    }
-   
    @BeforeGroups(groups = "integration-warmup")
    @Parameters ({"basedata_location"})
    public void beforeTestMethod(String basedataLocation) throws Exception {
+      this.beforeTestMethod(basedataLocation, getSessionFactoryA());
+      this.beforeTestMethod(basedataLocation, getSessionFactoryB());
+   }
+   
+   
+   
+   private void beforeTestMethod(String basedataLocation, SessionFactory hSessionFactory) throws Exception {
       Profile.stop();
       SessionFactoryImpl sessionFactory = null;
       Configuration configuration = null;
@@ -269,14 +305,13 @@
              }
              else
              {
-                sessionFactory = (SessionFactoryImpl) getSessionFactory();
+                sessionFactory = (SessionFactoryImpl) hSessionFactory;
                 configuration = getConfiguration();
                 dropStatements = configuration.generateDropSchemaScript(sessionFactory.getDialect());
                 this.vendorController.relax(connectionConstraintModify, dropStatements);
              }
              
               this.vendorController.purge(connectionConstraintModify);
-              //this.vendorController.synchronize(connectionConstraintModify);
           }
        }
        catch (SQLException sqle)
@@ -430,4 +465,14 @@
       returnValue.addAnnotatedClass(User.class);
       return returnValue;
    }
+   
+   protected UserTransaction getUserTransactionB() throws Exception {
+      return (UserTransaction)jndi.lookup(JNDI_NAME_USERTX_B);
+   }
+   
+   protected EntityManagerFactory getEntityManagerFactoryB() throws Exception{
+      return (EntityManagerFactory)jndi.lookup(JNDI_NAME_EMF_B);
+  }
 }
+
+

Added: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java	                        (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/WarmedUpTest.java	2009-12-03 17:01:11 UTC (rev 30459)
@@ -0,0 +1,71 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+
+package org.jboss.jbossts.performance;
+
+import org.apache.log4j.Logger;
+import org.testng.Assert;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+import com.mentorgen.tools.profile.runtime.Profile;
+
+import auction.test.basic.ProfiledStateTransitions;
+
+public abstract class WarmedUpTest extends ProfiledStateTransitions
+{
+   private static final Logger logger =Logger.getLogger(WarmedUpTest.class);
+   @Test(groups = "integration-warmup")
+   @Parameters ({"warmup_count"})
+   public void warmupTest(String warmupCount)
+   {
+      Profile.stop();
+      recurse(Integer.parseInt(warmupCount));
+      Profile.start();
+   }
+   
+   @Test(groups = "integration-persistence", dependsOnGroups="integration-warmup")
+   @Parameters ({"test_count"})
+   public void profiledTest(String testCount)
+   {
+      recurse(Integer.parseInt(testCount));
+   }
+   
+   private void recurse(int count)
+   {
+      for (int i = 0; i < count ; i += 1)
+      {
+         try
+         {
+            runTestBody();
+            logger.info("Executed profiled run of testbody.");
+         }
+         catch (Exception e)
+         {
+            Assert.fail(e.getMessage(), e);
+         }
+      }
+   }
+   
+   protected abstract void runTestBody() throws Exception;
+   
+}

Modified: labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/readonly/JPAExampleTests.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/readonly/JPAExampleTests.java	2009-12-03 17:00:19 UTC (rev 30458)
+++ labs/jbosstm/workspace/whitingjr/trunk/performance/src/test/java/org/jboss/jbossts/performance/readonly/JPAExampleTests.java	2009-12-03 17:01:11 UTC (rev 30459)
@@ -42,6 +42,8 @@
 import auction.dao.ejb3.GenericEJB3DAO;
 import auction.dao.ejb3.ItemDAOBean;
 import auction.dao.ejb3.UserDAOBean;
+import auction.dao.ejb3.persistence.ItemDAOBeanMultiResource;
+import auction.dao.ejb3.persistence.UserDAOBeanMultiResource;
 import auction.model.Item;
 import auction.model.MonetaryAmount;
 import auction.model.User;
@@ -78,6 +80,7 @@
    @Parameters ({"test_count"})
    public void runTest(String count)
    {
+      
       int co = Integer.parseInt(count);
       for (int i = 0; i < co ; i += 1)
       {
@@ -93,7 +96,6 @@
       }
    }
    
-   
    public void testBody() throws Exception {
 
        // Start a unit of work (manually, no container)
@@ -101,16 +103,16 @@
       EntityManagerImpl emImpl = null;
       try
       {
-         em = getEntityManagerFactory().createEntityManager();
+          em = getEntityManagerFactory().createEntityManager();
           emImpl = (EntityManagerImpl)em;
           emImpl.getSession().beginTransaction();
    
           // Prepare the DAOs (manually, no Seam)
-          ItemDAO itemDAO = new ItemDAOBean();
-          ((GenericEJB3DAO) itemDAO).setEntityManager(em);
+          ItemDAOBeanMultiResource itemDAO = new ItemDAOBeanMultiResource();
+          itemDAO.setEntityManagerA(em);
    
-          UserDAO userDAO = new UserDAOBean();
-          ((GenericEJB3DAO) userDAO).setEntityManager(em);
+          UserDAOBeanMultiResource userDAO = new UserDAOBeanMultiResource();
+          userDAO.setEntityManagerA(em);
    
           // Prepare a user object
           User user = userDAO.findById(1l, false);



More information about the jboss-svn-commits mailing list