[jboss-cvs] JBossAS SVN: r63156 - in branches/Branch_4_2/ejb3: src/resources/test and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 18 15:14:12 EDT 2007


Author: bdecoste
Date: 2007-05-18 15:14:12 -0400 (Fri, 18 May 2007)
New Revision: 63156

Added:
   branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/
   branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/META-INF/
   branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
Modified:
   branches/Branch_4_2/ejb3/build-test.xml
Log:
[EJBTHREE-901] test for entity optimistic locking

Modified: branches/Branch_4_2/ejb3/build-test.xml
===================================================================
--- branches/Branch_4_2/ejb3/build-test.xml	2007-05-18 17:06:37 UTC (rev 63155)
+++ branches/Branch_4_2/ejb3/build-test.xml	2007-05-18 19:14:12 UTC (rev 63156)
@@ -2139,6 +2139,22 @@
       </jar>
    </target>
    
+   <target name="entityoptimisticlocking"
+      description="Builds all jar files."
+      depends="compile-classes">
+
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/entityoptimisticlocking-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/entity/*.class"/>
+         </fileset>
+         <fileset dir="${resources}/test/entityoptimisticlocking">
+            <include name="META-INF/persistence.xml"/>
+         </fileset>
+      </jar>
+   </target>
+   
    <target name="persistenceunits"
       description="Builds all jar files."
       depends="compile-classes">
@@ -2712,7 +2728,20 @@
          </fileset>
       </jar>
    </target>
+   
+   <target name="concurrentnaming"
+      description="Builds all jar files."
+      depends="compile-classes">
 
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/concurrentnaming-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/concurrentnaming/*.class"/>
+         </fileset>
+      </jar>
+   </target>
+
    <target name="propertyreplacement"
       description="Builds all jar files."
       depends="compile-classes">
@@ -3164,7 +3193,7 @@
 	  </copy>
    </target>
    
-   <target name="jars" depends="propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, jaxws,
@@ -3587,6 +3616,9 @@
          <param name="test" value="stateless"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="concurrentnaming"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="homeinterface"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
@@ -3747,6 +3779,9 @@
          <param name="test" value="entity"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="entityoptimisticlocking"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="persistenceunits"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Added: branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml	2007-05-18 19:14:12 UTC (rev 63156)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+   <persistence-unit name="tempdb">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <properties>
+          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+          <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.OptimisticTreeCacheProviderHook"/>
+          <property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java	2007-05-18 19:14:12 UTC (rev 63156)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.entityoptimisticlocking.unit;
+
+import java.util.Set;
+import org.jboss.ejb3.test.entity.Address;
+import org.jboss.ejb3.test.entity.Company;
+import org.jboss.ejb3.test.entity.Customer;
+import org.jboss.ejb3.test.entity.EntityTest;
+import org.jboss.ejb3.test.entity.FieldAddress;
+import org.jboss.ejb3.test.entity.FieldCompany;
+import org.jboss.ejb3.test.entity.FieldCustomer;
+import org.jboss.ejb3.test.entity.FieldFlight;
+import org.jboss.ejb3.test.entity.FieldTicket;
+import org.jboss.ejb3.test.entity.Flight;
+import org.jboss.ejb3.test.entity.Ticket;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Id: EntityUnitTestCase.java 57207 2006-09-26 12:06:13Z dimitris at jboss.org $
+ */
+
+public class EntityUnitTestCase
+extends JBossTestCase
+{
+   org.apache.log4j.Category log = getLog();
+
+   static boolean deployed = false;
+   static int test = 0;
+
+   public EntityUnitTestCase(String name)
+   {
+
+      super(name);
+
+   }
+
+   public void testOneToMany() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      Customer c = test.oneToManyCreate();
+      assertNotNull(c);
+      assertNotNull(c.getTickets());
+      Set<Ticket> tickets = c.getTickets();
+      assertTrue(tickets.size() > 0);
+
+      // test find
+      c = test.findCustomerById(c.getId());
+      assertNotNull(c);
+      assertNotNull(c.getTickets());
+      tickets = c.getTickets();
+      assertTrue(tickets.size() > 0);
+
+      // test 1-1
+      Address address = c.getAddress();
+      assertTrue(address != null);
+      assertTrue(address.getCity().equals("Boston"));
+   }
+
+   public void testManyToOne() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      Flight f = test.manyToOneCreate();
+      f = test.findFlightById(f.getId());
+      assertTrue(f.getName().equals("AF0101"));
+      assertTrue(f.getCompany().getName().equals("Air France"));
+
+      Company c = test.findCompanyById(f.getCompany().getId());
+      assertTrue(c != null);
+      assertTrue(c.getFlights().size() == 1);
+   }
+
+   public void testManyToMany() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      test.manyToManyCreate();
+
+      Flight one = test.findFlightById(new Long(1));
+      assertTrue(one.getCompany().getName().equals("Air France"));
+
+      Flight two = test.findFlightById(new Long(2));
+      assertTrue(two.getCompany().getName().equals("USAir"));
+
+      System.out.println("Air France customers");
+      for (Customer c : one.getCustomers())
+      {
+         System.out.println(c.getName());
+
+      }
+      System.out.println("USAir customers");
+
+      for (Customer c : two.getCustomers())
+      {
+         System.out.println(c.getName());
+      }
+
+   }
+
+   public void testFieldOneToMany() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      FieldCustomer c = test.fieldOneToManyCreate();
+      assertNotNull(c);
+      assertNotNull(c.getTickets());
+      Set<FieldTicket> tickets = c.getTickets();
+      assertTrue(tickets.size() > 0);
+
+      // test find
+      c = test.fieldFindCustomerById(c.getId());
+      assertNotNull(c);
+      assertNotNull(c.getTickets());
+      tickets = c.getTickets();
+      assertTrue(tickets.size() > 0);
+
+      // test 1-1
+      FieldAddress address = c.getAddress();
+      assertTrue(address != null);
+      assertTrue(address.getCity().equals("Boston"));
+   }
+
+   public void testFieldManyToOne() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      FieldFlight f = test.fieldManyToOneCreate();
+      f = test.fieldFindFlightById(f.getId());
+      assertTrue(f.getName().equals("AF0101"));
+      assertTrue(f.getCompany().getName().equals("Air France"));
+
+      FieldCompany c = test.fieldFindCompanyById(f.getCompany().getId());
+      assertTrue(c != null);
+      assertTrue(c.getFlights().size() == 1);
+   }
+
+   public void testFieldManyToMany() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      test.fieldManyToManyCreate();
+
+      FieldFlight one = test.fieldFindFlightById(new Long(1));
+      assertTrue(one.getCompany().getName().equals("Air France"));
+
+      FieldFlight two = test.fieldFindFlightById(new Long(2));
+      assertTrue(two.getCompany().getName().equals("USAir"));
+
+      System.out.println("Air France customers");
+      for (FieldCustomer c : one.getCustomers())
+      {
+         System.out.println(c.getName());
+
+      }
+      System.out.println("USAir customers");
+
+      for (FieldCustomer c : two.getCustomers())
+      {
+         System.out.println(c.getName());
+      }
+
+   }
+
+   public void testNamedQueries() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      test.testNamedQueries();      
+   }
+
+   public void testOutsideTx() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      test.testOutsideTransaction();      
+
+   }
+   
+   public void testFlush() throws Exception
+   {
+      EntityTest test = (EntityTest) this.getInitialContext().lookup("EntityTestBean/remote");
+      Customer c = test.createCustomer("Emmanuel");
+	  test.changeCustomer(c.getId(), "Bill");
+	  Customer c2 = test.loadCustomer(c.getId());
+	  assertEquals("Bill", c2.getName());
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(EntityUnitTestCase.class, "entityoptimisticlocking-test.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list