[jboss-cvs] JBossAS SVN: r58858 - in branches: Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader JBoss_4_0_5_GA_EJBTHREE-798/ejb3 JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/resources JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 6 01:21:13 EST 2006
Author: bstansberry at jboss.com
Date: 2006-12-06 01:21:08 -0500 (Wed, 06 Dec 2006)
New Revision: 58858
Added:
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/DBSetup.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityClassloaderTestBase.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryRedeployUnitTestCase.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryUnitTestCase.java
Modified:
branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/Account.java
branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/AccountHolderPK.java
branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTest.java
branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTestBean.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/build-test.xml
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/resources/ejb3-entity-cache-service.xml
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
Log:
Port EJBTHREE-798 changes to branch
Modified: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/Account.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/Account.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/Account.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -1,24 +1,3 @@
-/*
- * 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.clusteredentity.classloader;
import java.io.Serializable;
@@ -35,12 +14,6 @@
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
-/**
- * Entity used to test handling of @Lob fields in the second level cache.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
@Entity
@Cache (usage=CacheConcurrencyStrategy.TRANSACTIONAL)
@NamedQueries({
Modified: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/AccountHolderPK.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/AccountHolderPK.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/AccountHolderPK.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -1,24 +1,3 @@
-/*
- * 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.clusteredentity.classloader;
import java.io.IOException;
@@ -27,12 +6,6 @@
import javax.persistence.Embeddable;
-/**
- * Class used as an @Lob field in {@link Account}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
//@Embeddable
public class AccountHolderPK implements Serializable
{
Modified: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTest.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTest.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTest.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -1,32 +1,5 @@
-/*
- * 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.clusteredentity.classloader;
-/**
- * SFSB interface for {@link EntityQueryTestBean}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
public interface EntityQueryTest
{
Modified: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTestBean.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTestBean.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/classloader/EntityQueryTestBean.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -1,24 +1,3 @@
-/*
- * 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.clusteredentity.classloader;
import java.util.HashSet;
@@ -43,12 +22,6 @@
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.mx.util.MBeanServerLocator;
-/**
- * SFSB used for testing @Lob field replication in the second level test.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
@Stateful
@Remote(EntityQueryTest.class)
public class EntityQueryTestBean implements EntityQueryTest
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/build-test.xml
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/build-test.xml 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/build-test.xml 2006-12-06 06:21:08 UTC (rev 58858)
@@ -143,6 +143,7 @@
<path refid="quartz.quartz.classpath"/>
<path refid="jboss.microcontainer.classpath"/>
<path refid="jboss.jbossxb.classpath"/>
+ <path refid="hsqldb.hsqldb.classpath"/>
</path>
<!-- ======= -->
@@ -2574,6 +2575,29 @@
<include name="META-INF/persistence.xml"/>
</fileset>
</jar>
+
+ <jar jarfile="${build.lib}/clusteredentity-classloader-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/clusteredentity/classloader/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/clusteredentity/classloader">
+ <include name="META-INF/persistence.xml"/>
+ <!--include name="META-INF/jboss.xml"/-->
+ </fileset>
+ </jar>
+
+ <jar jarfile="${build.lib}/clusteredentity-classloader-test.ear">
+ <fileset dir="${build.lib}">
+ <include name="clusteredentity-classloader-test.jar"/>
+ </fileset>
+ <fileset dir="${resources}/test/clusteredentity/classloader">
+ <include name="META-INF/application.xml"/>
+ <include name="META-INF/jboss-app.xml"/>
+ <include name="clusteredentity-ds.xml"/>
+ </fileset>
+ </jar>
+
+
</target>
<target name="clusteredsession"
@@ -2698,6 +2722,9 @@
<!-- EJBTHREE-485 needs javassist -->
<path refid="javassist.classpath"/>
+
+ <!-- For clustered entities -->
+ <path refid="hsqldb.hsqldb.classpath"/>
</classpath>
<formatter type="plain" usefile="true"/>
Copied: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java (from rev 58855, branches/Branch_4_0/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java)
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -28,7 +28,6 @@
import org.hibernate.cache.Cache;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.CacheProvider;
-import org.hibernate.cache.TreeCache;
import org.jboss.cache.TreeCacheMBean;
import org.jboss.ejb3.tx.TxUtil;
import org.jboss.mx.util.MBeanProxyExt;
@@ -56,7 +55,7 @@
*/
public Cache buildCache(String regionName, Properties properties) throws CacheException
{
- return new TreeCache(cache, regionName, TxUtil.getTransactionManager());
+ return new JBCCache(cache, regionName, TxUtil.getTransactionManager());
}
public boolean isMinimalPutsEnabledByDefault()
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/resources/ejb3-entity-cache-service.xml
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/resources/ejb3-entity-cache-service.xml 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/resources/ejb3-entity-cache-service.xml 2006-12-06 06:21:08 UTC (rev 58858)
@@ -38,6 +38,11 @@
to find each other -->
<attribute name="ClusterName">EJB3-entity-cache</attribute>
+ <!-- Must be true if any entity deployment uses a scoped classloader -->
+ <attribute name="UseRegionBasedMarshalling">true</attribute>
+ <!-- Must match the value of "UseRegionBasedMarshalling" -->
+ <attribute name="InactiveOnStartup">true</attribute>
+
<attribute name="ClusterConfig">
<config>
<!-- UDP: if you have a multihomed machine,
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -36,4 +36,6 @@
Customer findByCustomerId(Integer id);
void loadedFromCache();
+
+ void cleanup();
}
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -22,9 +22,11 @@
package org.jboss.ejb3.test.clusteredentity;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import javax.ejb.Remote;
+import javax.ejb.Remove;
import javax.ejb.Stateless;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -154,6 +156,20 @@
}
}
+
+ @Remove
+ public void cleanup()
+ {
+ Customer c = findByCustomerId(1);
+ if (c != null)
+ {
+ Set contacts = c.getContacts();
+ for (Iterator it = contacts.iterator(); it.hasNext();)
+ manager.remove(it.next());
+ c.setContacts(null);
+ manager.remove(c);
+ }
+ }
private TreeCache getCache() throws Exception
{
Copied: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/DBSetup.java (from rev 58855, branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/DBSetup.java)
Copied: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityClassloaderTestBase.java (from rev 58855, branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityClassloaderTestBase.java)
Copied: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryRedeployUnitTestCase.java (from rev 58855, branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryRedeployUnitTestCase.java)
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryRedeployUnitTestCase.java 2006-12-05 23:03:14 UTC (rev 58855)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryRedeployUnitTestCase.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -0,0 +1,98 @@
+/*
+ * 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.clusteredentity.unit;
+
+import java.util.Properties;
+import javax.naming.InitialContext;
+
+import org.hibernate.cache.StandardQueryCache;
+import org.jboss.ejb3.test.clusteredentity.classloader.Account;
+import org.jboss.ejb3.test.clusteredentity.classloader.AccountHolderPK;
+import org.jboss.ejb3.test.clusteredentity.classloader.EntityQueryTest;
+import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * 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 EntityQueryRedeployUnitTestCase
+extends EntityClassloaderTestBase
+{
+ private static boolean firstNamedRegionTest = true;
+ private static final String EAR_NAME = "clusteredentity-classloader-test.ear";
+
+ public EntityQueryRedeployUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRedeploy() throws Exception
+ {
+ // Set things up with the default region
+ queryTest(true, true, false, true);
+ // Now get the named query regions active
+ queryTest(false, true, true, true);
+
+ // Don't set this false, as after redeploy it's as if its the first test
+// firstNamedRegionTest = false;
+
+ redeploy();
+
+ // Redo the test, but no entity creation
+ queryTest(false, true, false, true);
+ queryTest(false, true, true, true);
+ }
+
+ private void redeploy() throws Exception
+ {
+ RMIAdaptor[] adaptors = getAdaptors();
+ undeploy(adaptors[1], EAR_NAME);
+
+ sleep(2000);
+
+ deploy(adaptors[1], EAR_NAME);
+
+ sleep(2000);
+
+ // Get the SFSB again
+ sfsb1 = getEntityQueryTest(System.getProperty("jbosstest.cluster.node1"));
+ }
+
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ Test t1 = getDeploySetup(EntityQueryRedeployUnitTestCase.class, EAR_NAME);
+
+ suite.addTest(t1);
+
+ // Create an initializer for the test suite
+ DBSetup wrapper = new DBSetup(suite);
+ return wrapper;
+ }
+}
Copied: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryUnitTestCase.java (from rev 58855, branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryUnitTestCase.java)
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryUnitTestCase.java 2006-12-05 23:03:14 UTC (rev 58855)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityQueryUnitTestCase.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -0,0 +1,111 @@
+/*
+ * 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.clusteredentity.unit;
+
+import java.util.Properties;
+import javax.naming.InitialContext;
+
+import org.hibernate.cache.StandardQueryCache;
+import org.jboss.ejb3.test.clusteredentity.classloader.Account;
+import org.jboss.ejb3.test.clusteredentity.classloader.AccountHolderPK;
+import org.jboss.ejb3.test.clusteredentity.classloader.EntityQueryTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * 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 EntityQueryUnitTestCase
+extends EntityClassloaderTestBase
+{
+ private static boolean firstNamedRegionTest = true;
+
+ public EntityQueryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testManualQueryDefaultRegion() throws Exception
+ {
+ log.info("+++ start testManualQueryDefaultRegion");
+ queryTest(false, false);
+ log.info("+++ end testManualQueryDefaultRegion");
+ }
+
+ public void testManualQueryNamedRegion() throws Exception
+ {
+ log.info("+++ start testManualQueryNamedRegion");
+ try
+ {
+ queryTest(false, true);
+ }
+ finally
+ {
+ firstNamedRegionTest = false;
+ }
+ log.info("+++ end testManualQueryNamedRegion");
+ }
+
+ public void testNamedQueryDefaultRegion() throws Exception
+ {
+ log.info("+++ start testNamedQueryDefaultRegion");
+ queryTest(true, false);
+ log.info("+++ end testNamedQueryDefaultRegion");
+ }
+
+ public void testNamedQueryNamedRegion() throws Exception
+ {
+ log.info("+++ start testNamedQueryNamedRegion");
+ try
+ {
+ queryTest(true, true);
+ }
+ finally
+ {
+ firstNamedRegionTest = false;
+ }
+ log.info("+++ start testNamedQueryNamedRegion");
+ }
+
+ private void queryTest(boolean useNamedQuery, boolean useNamedRegion)
+ {
+ queryTest(true, useNamedQuery, useNamedRegion, firstNamedRegionTest);
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ Test t1 = getDeploySetup(EntityQueryUnitTestCase.class,
+ "clusteredentity-classloader-test.ear");
+
+ suite.addTest(t1);
+
+ // Create an initializer for the test suite
+ DBSetup wrapper = new DBSetup(suite);
+ return wrapper;
+ }
+}
Modified: branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2006-12-06 06:21:01 UTC (rev 58857)
+++ branches/JBoss_4_0_5_GA_EJBTHREE-798/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2006-12-06 06:21:08 UTC (rev 58858)
@@ -40,6 +40,8 @@
{
org.apache.log4j.Category log = getLog();
+ protected static final long SLEEP_TIME = 300L;
+
static boolean deployed = false;
static int test = 0;
@@ -77,31 +79,43 @@
System.out.println("Create node 0");
EntityTest tester0 = (EntityTest)ctx0.lookup("EntityTestBean/remote");
- Customer customer = tester0.createCustomer();
- //Call finder twice since Hibernate seems to not actually save collections
- //into cache on persist(), so make sure it is put into cache on find.
- System.out.println("Find node 0");
- customer = tester0.findByCustomerId(customer.getId());
- System.out.println("Find(2) node 0");
- customer = tester0.findByCustomerId(customer.getId());
-
- //Check everything was in cache
- System.out.println("Check cache 0");
- tester0.loadedFromCache();
-
- //Now connect to cache on node2 and make sure it is all there
- System.out.println("Lookup node 1");
- InitialContext ctx1 = new InitialContext(prop1);
-
- EntityTest tester1 = (EntityTest)ctx1.lookup("EntityTestBean/remote");
- System.out.println("Find node 1");
- customer = tester1.findByCustomerId(customer.getId());
-
- //Check everything was in cache
- System.out.println("Check cache 1");
- tester1.loadedFromCache();
-
+ try
+ {
+ Customer customer = tester0.createCustomer();
+
+ //Call finder twice since Hibernate seems to not actually save collections
+ //into cache on persist(), so make sure it is put into cache on find.
+ System.out.println("Find node 0");
+ customer = tester0.findByCustomerId(customer.getId());
+ System.out.println("Find(2) node 0");
+ customer = tester0.findByCustomerId(customer.getId());
+
+ //Check everything was in cache
+ System.out.println("Check cache 0");
+ tester0.loadedFromCache();
+
+ // The above placement of the collection in the cache is replicated async
+ // so pause a bit before checking node 1
+ sleep(SLEEP_TIME);
+
+ //Now connect to cache on node2 and make sure it is all there
+ System.out.println("Lookup node 1");
+ InitialContext ctx1 = new InitialContext(prop1);
+
+ EntityTest tester1 = (EntityTest)ctx1.lookup("EntityTestBean/remote");
+ System.out.println("Find node 1");
+ customer = tester1.findByCustomerId(customer.getId());
+
+ //Check everything was in cache
+ System.out.println("Check cache 1");
+ tester1.loadedFromCache();
+ }
+ finally
+ {
+ // cleanup the db so we can run this test multiple times w/o restarting the cluster
+ tester0.cleanup();
+ }
}
public static Test suite() throws Exception
More information about the jboss-cvs-commits
mailing list