[jboss-cvs] JBossAS SVN: r59571 - in trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 11 22:21:18 EST 2007
Author: bstansberry at jboss.com
Date: 2007-01-11 22:21:16 -0500 (Thu, 11 Jan 2007)
New Revision: 59571
Modified:
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
Log:
Add a db cleanup method so test can be run repeatedly
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2007-01-12 03:19:58 UTC (rev 59570)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTest.java 2007-01-12 03:21:16 UTC (rev 59571)
@@ -1,24 +1,24 @@
/*
- * 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.
- */
+ * 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;
@@ -36,4 +36,6 @@
Customer findByCustomerId(Integer id);
void loadedFromCache();
+
+ void cleanup();
}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2007-01-12 03:19:58 UTC (rev 59570)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/EntityTestBean.java 2007-01-12 03:21:16 UTC (rev 59571)
@@ -1,30 +1,32 @@
/*
- * 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.
- */
+ * 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;
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;
@@ -155,6 +157,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 Cache getCache() throws Exception
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2007-01-12 03:19:58 UTC (rev 59570)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2007-01-12 03:21:16 UTC (rev 59571)
@@ -1,24 +1,24 @@
/*
- * 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.
- */
+ * 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;
@@ -40,6 +40,8 @@
{
org.jboss.logging.Logger log = getLog();
+ private static final long SLEEP_TIME = 300l;
+
static boolean deployed = false;
static int test = 0;
@@ -77,31 +79,57 @@
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");
+ try
+ {
+ tester0.loadedFromCache();
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+
+ // 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");
+ try
+ {
+ tester1.loadedFromCache();
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ 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