[jboss-cvs] JBossAS SVN: r64084 - in trunk/ejb3/src: resources/test/entityoptimisticlocking and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 16 19:16:29 EDT 2007


Author: bdecoste
Date: 2007-07-16 19:16:29 -0400 (Mon, 16 Jul 2007)
New Revision: 64084

Added:
   trunk/ejb3/src/resources/test/entityoptimisticlocking/
   trunk/ejb3/src/resources/test/entityoptimisticlocking/META-INF/
   trunk/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml
   trunk/ejb3/src/resources/test/persistenceunits/
   trunk/ejb3/src/resources/test/persistenceunits/META-INF/
   trunk/ejb3/src/resources/test/persistenceunits/META-INF/persistence.xml
   trunk/ejb3/src/resources/test/persistenceunits/entity2-ds.xml
   trunk/ejb3/src/resources/test/propertyreplacement/
   trunk/ejb3/src/resources/test/propertyreplacement/META-INF/
   trunk/ejb3/src/resources/test/propertyreplacement/META-INF/jboss.xml
   trunk/ejb3/src/resources/test/propertyreplacement/propertyreplacement-service.xml
   trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/
   trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/unit/ConcurrentNamingTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity1.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity2.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTest.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTestBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/
   trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessRemote.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/unit/PropertyReplacementTestCase.java
Log:
[EJBTHREE-1009] merged in tests from 4.2

Added: trunk/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml
===================================================================
--- trunk/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/entityoptimisticlocking/META-INF/persistence.xml	2007-07-16 23:16:29 UTC (rev 64084)
@@ -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: trunk/ejb3/src/resources/test/persistenceunits/META-INF/persistence.xml
===================================================================
--- trunk/ejb3/src/resources/test/persistenceunits/META-INF/persistence.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/persistenceunits/META-INF/persistence.xml	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+   <persistence-unit name="Entity1">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <properties>
+          <property name="hibernate.hbm2ddl.auto" value="create"/>
+          <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+      </properties>
+      <class>org.jboss.ejb3.test.persistenceunits.Entity1</class>
+   </persistence-unit>
+   <persistence-unit name="Entity2">
+      <jta-data-source>java:/Entity2DS</jta-data-source>
+      <properties>
+          <property name="hibernate.hbm2ddl.auto" value="create"/>
+          <!--property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/-->
+          <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+      </properties>
+      <class>org.jboss.ejb3.test.persistenceunits.Entity2</class>
+   </persistence-unit>
+</persistence>

Added: trunk/ejb3/src/resources/test/persistenceunits/entity2-ds.xml
===================================================================
--- trunk/ejb3/src/resources/test/persistenceunits/entity2-ds.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/persistenceunits/entity2-ds.xml	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources>
+   <local-tx-datasource>
+      <jndi-name>Entity2DS</jndi-name>
+
+      <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic2${/}Entity2DS</connection-url>
+
+      <driver-class>org.hsqldb.jdbcDriver</driver-class>
+
+      <user-name>sa</user-name>
+      <password></password>
+
+      <min-pool-size>5</min-pool-size>
+
+      <max-pool-size>20</max-pool-size>
+
+      <idle-timeout-minutes>0</idle-timeout-minutes>
+
+      <metadata>
+         <type-mapping>Hypersonic SQL</type-mapping>
+      </metadata>
+      
+      <depends>jboss:service=Hypersonic,database=Entity2DS</depends>
+   </local-tx-datasource>
+
+   <mbean code="org.jboss.jdbc.HypersonicDatabase" 
+     name="jboss:service=Hypersonic,database=Entity2DS">
+     <attribute name="Database">Entity2DS</attribute>
+     <attribute name="InProcessMode">true</attribute>
+   </mbean>
+   
+   <!--local-tx-datasource> 
+ 
+	<jndi-name>Entity2DS</jndi-name> 
+ 
+    <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url> 
+    <driver-class>com.mysql.jdbc.Driver</driver-class> 
+ 
+    <user-name>jboss</user-name> 
+    <password>jboss</password> 
+ 
+    <connection-property name="autoReconnect">true</connection-property>
+ 
+    <metadata> 
+      <type-mapping>mySQL</type-mapping> 
+    </metadata> 
+ 
+  </local-tx-datasource-->
+</datasources>

Added: trunk/ejb3/src/resources/test/propertyreplacement/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/propertyreplacement/META-INF/jboss.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/propertyreplacement/META-INF/jboss.xml	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<jboss
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+        version="3.0">
+   <enterprise-beans>
+      <session>
+         <ejb-name>StatelessBean</ejb-name>
+         <jndi-name>${slsb-jndi-binding}</jndi-name>
+      </session>
+   </enterprise-beans>
+</jboss>

Added: trunk/ejb3/src/resources/test/propertyreplacement/propertyreplacement-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/propertyreplacement/propertyreplacement-service.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/propertyreplacement/propertyreplacement-service.xml	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE server>
+<!-- $Id: properties-service.xml 16662 2003-08-27 04:38:22Z patriot1burke $ -->
+
+<server>
+
+
+  <!-- ==================================================================== -->
+  <!-- System Properties Service                                            -->
+  <!-- ==================================================================== -->
+
+  <!--
+     | Allows rich access to system properties.
+   -->
+
+  <mbean code="org.jboss.varia.property.SystemPropertiesService" 
+	 name="jboss:type=Service,name=SystemPropertiesTest">
+
+    <!-- 
+       | Set raw properties file style properties.
+    -->
+    
+    <attribute name="Properties">
+      slsb-jndi-binding=ReplacedBinding
+    </attribute>
+  </mbean>
+
+</server>

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessBean.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,41 @@
+/*
+ * 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.concurrentnaming;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+public class StatelessBean implements StatelessRemote
+{
+   private static final Logger log = Logger.getLogger(StatelessBean.class);
+   
+   public void test() 
+   {
+      log.info("--- test ");
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/StatelessRemote.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,30 @@
+/*
+ * 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.concurrentnaming;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+   void test();
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/unit/ConcurrentNamingTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/unit/ConcurrentNamingTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/concurrentnaming/unit/ConcurrentNamingTestCase.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,78 @@
+/*
+ * 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.concurrentnaming.unit;
+
+import org.jboss.ejb3.test.concurrentnaming.StatelessRemote;
+
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class ConcurrentNamingTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(ConcurrentNamingTestCase.class);
+
+   public ConcurrentNamingTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testConcurrentNaming() throws Exception
+   {   
+      for (int i = 0 ; i < 20 ; ++i)
+      {
+          Runnable r = new Runnable()
+          {
+             public void run()
+             {
+                try
+                {
+                   InitialContext jndiContext = new InitialContext();
+                   for (int i = 0 ; i < 100 ; ++i)
+                   {                  
+                      StatelessRemote slsb = (StatelessRemote) jndiContext.lookup("StatelessBean/remote");              
+                      slsb.test();
+                   }
+                }
+                catch (Exception e)
+                {
+                   e.printStackTrace();
+                }
+             }
+          };
+          
+          new Thread(r).start();
+      }
+      System.out.println("Done!!");
+      Thread.sleep(1 * 60 * 1000);  
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ConcurrentNamingTestCase.class, "concurrentnaming-test.jar");
+   }
+}
\ No newline at end of file

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/entityoptimisticlocking/unit/EntityUnitTestCase.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import org.jboss.logging.Logger;
+
+/**
+ * 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
+{
+   private static final Logger log = Logger.getLogger(EntityUnitTestCase.class);
+
+   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");
+   }
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity1.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity1.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity1.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,61 @@
+/*
+ * 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.persistenceunits;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Entity
+ at Table(name = "ENTITY1")
+public class Entity1 implements java.io.Serializable
+{
+   private Long id;
+   private String data;
+
+   @Id
+   @GeneratedValue(strategy= GenerationType.IDENTITY)
+   public Long getId()
+   {
+      return id;
+   }
+
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+
+   public String getData()
+   {
+      return data;
+   }
+
+   public void setData(String data)
+   {
+      this.data = data;
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity2.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity2.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/Entity2.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,61 @@
+/*
+ * 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.persistenceunits;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Entity
+ at Table(name = "ENTITY2")
+public class Entity2 implements java.io.Serializable
+{
+   private Long id;
+   private String data;
+
+   @Id
+   @GeneratedValue(strategy= GenerationType.IDENTITY)
+   public Long getId()
+   {
+      return id;
+   }
+
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+
+   public String getData()
+   {
+      return data;
+   }
+
+   public void setData(String data)
+   {
+      this.data = data;
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTest.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTest.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,34 @@
+/*
+ * 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.persistenceunits;
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface EntityTest
+{
+   Long persistEntity1(Entity1 entity1);
+   Entity1 loadEntity1(Long id);
+   Long persistEntity2(Entity2 entity2);
+   Entity2 loadEntity2(Long id);
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTestBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/EntityTestBean.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,64 @@
+/*
+ * 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.persistenceunits;
+
+import org.jboss.logging.Logger;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(EntityTest.class)
+public class EntityTestBean implements EntityTest
+{
+   private static final Logger log = Logger.getLogger(EntityTestBean.class);
+   
+   private @PersistenceContext(unitName="Entity1") EntityManager manager1;
+   private @PersistenceContext(unitName="Entity2") EntityManager manager2;
+
+   public Long persistEntity1(Entity1 entity1)
+   {
+      manager1.persist(entity1);
+      return entity1.getId();
+   }
+
+   public Entity1 loadEntity1(Long id)
+   {
+      return manager1.find(Entity1.class, id);
+   }
+
+   public Long persistEntity2(Entity2 entity2)
+   {
+      manager2.persist(entity2);
+      return entity2.getId();
+   }
+
+   public Entity2 loadEntity2(Long id)
+   {
+      return manager2.find(Entity2.class, id);
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/persistenceunits/unit/EntityUnitTestCase.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,70 @@
+/*
+ * 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.persistenceunits.unit;
+
+import java.util.Set;
+import org.jboss.ejb3.test.persistenceunits.Entity1;
+import org.jboss.ejb3.test.persistenceunits.Entity2;
+import org.jboss.ejb3.test.persistenceunits.EntityTest;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class EntityUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(EntityUnitTestCase.class);
+
+   public EntityUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPersistenceUnits() throws Exception
+   {
+      EntityTest test = (EntityTest) getInitialContext().lookup("EntityTestBean/remote");
+      
+      Entity1 entity1 = new Entity1();
+      entity1.setData("ONE");
+      Long id1 = test.persistEntity1(entity1);
+      
+      Entity2 entity2 = new Entity2();
+      entity2.setData("TWO");
+      Long id2 = test.persistEntity2(entity2);
+      
+      entity1 = test.loadEntity1(id1);
+      assertEquals("ONE", entity1.getData());
+      
+      entity2 = test.loadEntity2(id2);
+      assertEquals("TWO", entity2.getData());
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(EntityUnitTestCase.class, "persistenceunits-test.jar");
+   }
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessBean.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessBean.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,41 @@
+/*
+ * 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.propertyreplacement;
+
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+public class StatelessBean implements StatelessRemote
+{
+   private static final Logger log = Logger.getLogger(StatelessBean.class);
+   
+   public void test()
+   {
+      
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessRemote.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/StatelessRemote.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,30 @@
+/*
+ * 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.propertyreplacement;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+   void test();
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/unit/PropertyReplacementTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/unit/PropertyReplacementTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/propertyreplacement/unit/PropertyReplacementTestCase.java	2007-07-16 23:16:29 UTC (rev 64084)
@@ -0,0 +1,53 @@
+/*
+ * 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.propertyreplacement.unit;
+
+import org.jboss.ejb3.test.propertyreplacement.StatelessRemote;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class PropertyReplacementTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(PropertyReplacementTestCase.class);
+
+   public PropertyReplacementTestCase(String name)
+   {
+      super(name);
+   }
+ 
+   public void testReplacement() throws Exception
+   {
+      StatelessRemote slsb = (StatelessRemote) getInitialContext().lookup("ReplacedBinding");
+      assertNotNull(slsb);
+      slsb.test();
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(PropertyReplacementTestCase.class, "propertyreplacement-service.xml, propertyreplacement-test.jar");
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list