[jboss-cvs] JBossAS SVN: r59665 - in trunk/ejb3: src/resources/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 15 22:31:43 EST 2007
Author: bill.burke at jboss.com
Date: 2007-01-15 22:31:39 -0500 (Mon, 15 Jan 2007)
New Revision: 59665
Added:
trunk/ejb3/src/resources/test/initial/
trunk/ejb3/src/resources/test/initial/roles.properties
trunk/ejb3/src/resources/test/initial/users.properties
trunk/ejb3/src/test/org/jboss/ejb3/test/bmt/unit/BMTUnitEmbeddedTest.java
trunk/ejb3/src/test/org/jboss/ejb3/test/circulardependency/unit/IgnoreDependencyEmbeddedTest.java
trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/LocalUnitEmbeddedTest.java
trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/RemoteUnitEmbeddedTest.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitEmbeddedTest.java
Modified:
trunk/ejb3/build-test.xml
Log:
Adapt existing tests so that we can test embedded jboss
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/build-test.xml 2007-01-16 03:31:39 UTC (rev 59665)
@@ -193,6 +193,7 @@
<path refid="jboss.mq.classpath"/>
<path refid="jboss.test.classpath"/>
<path refid="jboss.ejb3.classpath"/>
+ <path refid="jboss.embedded.classpath"/>
<path refid="arjuna.classpath"/>
<!--path refid="jboss.webservice.classpath"/-->
</path>
@@ -394,7 +395,7 @@
<include name="org/jboss/ejb3/test/initial/ClassInjected.class"/>
<include name="org/jboss/ejb3/test/initial/ClassInjectedBean.class"/>
</fileset>
- <fileset dir="${resources}/test">
+ <fileset dir="${resources}/test/initial">
<include name="users.properties"/>
<include name="roles.properties"/>
</fileset>
@@ -485,7 +486,7 @@
<include name="quartzmdb.jar"/>
</fileset>
</copy>
-
+
<copy todir="${build.ejb3.lib}/embeddable/lib">
<fileset dir="${build.lib}">
<include name="jcainflow.jar"/>
@@ -3296,6 +3297,51 @@
</junit>
</target>
+ <target name="embedded-test" depends="init" if="test"
+ description="Execute all tests in the given test directory.">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.testlog}"/>
+ <!-- Remove the test.log so each run has a fresh log -->
+ <delete file="${build.testlog}/test.log"/>
+ <path id="test.classpath">
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${resources}/test/${test}"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="jboss.test.classpath"/>
+ <path refid="jboss.embedded.classpath"/>
+ </path>
+ <junit dir="${module.output}"
+ printsummary="yes"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <sysproperty key="jbosstest.deploy.dir" value="${build.lib}"/>
+ <sysproperty key="build.testlog" value="${build.testlog}"/>
+ <sysproperty key="jbosstest.threadcount" value="${jbosstest.threadcount}"/>
+ <sysproperty key="jbosstest.iterationcount" value="${jbosstest.iterationcount}"/>
+ <sysproperty key="jbosstest.beancount" value="${jbosstest.beancount}"/>
+
+ <classpath>
+ <path refid="test.classpath"/>
+ </classpath>
+
+ <formatter type="plain" usefile="true"/>
+ <formatter type="xml" usefile="true"/>
+
+ <batchtest todir="${build.reports}"
+ haltonerror="false"
+ haltonfailure="false"
+ fork="true">
+
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/${test}/unit/*EmbeddedTest.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+
<target name="standalone-test" depends="init" if="test"
description="Execute all tests in the given test directory.">
<mkdir dir="${build.reports}"/>
Added: trunk/ejb3/src/resources/test/initial/roles.properties
===================================================================
--- trunk/ejb3/src/resources/test/initial/roles.properties 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/resources/test/initial/roles.properties 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,2 @@
+rolefail=willfail
+somebody=allowed
Added: trunk/ejb3/src/resources/test/initial/users.properties
===================================================================
--- trunk/ejb3/src/resources/test/initial/users.properties 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/resources/test/initial/users.properties 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,2 @@
+somebody=password
+rolefail=password
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/bmt/unit/BMTUnitEmbeddedTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/bmt/unit/BMTUnitEmbeddedTest.java 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/bmt/unit/BMTUnitEmbeddedTest.java 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.ejb3.test.bmt.unit;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.ejb3.test.bmt.TesterRemote;
+import org.jboss.ejb3.test.bmt.DeploymentDescriptorTesterRemote;
+import org.jboss.embedded.junit.EmbeddedTestCase;
+import junit.framework.Test;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ */
+
+public class BMTUnitEmbeddedTest
+ extends BMTUnitTestCase
+{
+ public BMTUnitEmbeddedTest(String name)
+ {
+
+ super(name);
+
+ }
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestCase.getAdaptedSetup(BMTUnitEmbeddedTest.class, "bmt-test.jar");
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/circulardependency/unit/IgnoreDependencyEmbeddedTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/circulardependency/unit/IgnoreDependencyEmbeddedTest.java 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/circulardependency/unit/IgnoreDependencyEmbeddedTest.java 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.ejb3.test.circulardependency.unit;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.logging.Logger;
+import org.jboss.ejb3.test.circulardependency.StatelessRemote;
+import org.jboss.embedded.junit.EmbeddedTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version $Revision: 44507 $
+ */
+public class IgnoreDependencyEmbeddedTest extends IgnoreDependencyTestCase
+{
+
+ public IgnoreDependencyEmbeddedTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestCase.getAdaptedSetup(IgnoreDependencyEmbeddedTest.class, "circulardependency-test.jar");
+ }
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/LocalUnitEmbeddedTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/LocalUnitEmbeddedTest.java 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/LocalUnitEmbeddedTest.java 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.ejb3.test.initial.unit;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.logging.Logger;
+import org.jboss.embedded.junit.EmbeddedTestCase;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Id: LocalUnitTestCase.java 58418 2006-11-15 21:54:30Z anil.saldhana at jboss.com $
+ */
+
+public class LocalUnitEmbeddedTest
+ extends LocalUnitTestCase
+{
+ public LocalUnitEmbeddedTest(String name)
+ {
+
+ super(name);
+
+ }
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestCase.getAdaptedSetup(LocalUnitEmbeddedTest.class, "initial-ejb3-test.sar");
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/RemoteUnitEmbeddedTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/RemoteUnitEmbeddedTest.java 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/initial/unit/RemoteUnitEmbeddedTest.java 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.ejb3.test.initial.unit;
+
+import junit.framework.Test;
+import org.jboss.embedded.junit.EmbeddedTestCase;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteUnitEmbeddedTest extends RemoteUnitTestCase
+{
+
+ public RemoteUnitEmbeddedTest(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestCase.getAdaptedSetup(RemoteUnitEmbeddedTest.class, "initial-ejb3-test.sar");
+ }
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitEmbeddedTest.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitEmbeddedTest.java 2007-01-16 03:28:08 UTC (rev 59664)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitEmbeddedTest.java 2007-01-16 03:31:39 UTC (rev 59665)
@@ -0,0 +1,180 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.ejb3.test.mdb.unit;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.logging.Logger;
+import org.jboss.ejb3.ClientKernelAbstraction;
+import org.jboss.ejb3.KernelAbstractionFactory;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.test.mdb.TestStatus;
+import org.jboss.ejb3.test.mdb.Stateless;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.util.collection.CollectionsUtil;
+import org.jboss.embedded.junit.EmbeddedTestCase;
+import org.jboss.embedded.Bootstrap;
+
+import javax.management.ObjectName;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Queue;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TextMessage;
+import javax.jms.DeliveryMode;
+import javax.jms.TopicConnection;
+import javax.jms.MessageProducer;
+import javax.jms.TopicSession;
+import javax.jms.Topic;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueBrowser;
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Enumeration;
+
+import junit.framework.Test;
+
+/**
+ * Sample client for the jboss container.
+ *
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Id: MDBUnitTestCase.java 59422 2007-01-08 23:18:40Z bdecoste $
+ */
+public class MDBUnitEmbeddedTest extends JBossTestCase
+{
+ public MDBUnitEmbeddedTest(String name)
+ {
+
+ super(name);
+
+ }
+
+ protected void setSecurity(String user, String password)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(user));
+ SecurityAssociation.setCredential(password.toCharArray());
+
+ InitialContextFactory.setSecurity(user, password);
+ }
+
+ protected void clear(TestStatus status)
+ {
+ status.clear();
+ assertEquals(0, status.bmtQueueRan());
+ assertEquals(0, status.defaultedQueueFired());
+ assertEquals(0, status.messageCount());
+ assertEquals(0, status.nondurableQueueFired());
+ assertEquals(0, status.overrideDefaultedQueueFired());
+ assertEquals(0, status.overrideQueueFired());
+ assertEquals(0, status.queueFired());
+ assertEquals(0, status.topicFired());
+ assertFalse(status.interceptedQueue());
+ assertFalse(status.interceptedTopic());
+ assertFalse(status.postConstruct());
+ assertFalse(status.preDestroy());
+ }
+
+ protected QueueConnectionFactory getQueueConnectionFactory()
+ throws Exception
+ {
+ try
+ {
+ return (QueueConnectionFactory) getInitialContext().lookup(
+ "ConnectionFactory");
+ } catch (NamingException e)
+ {
+ return (QueueConnectionFactory) getInitialContext().lookup(
+ "java:/ConnectionFactory");
+ }
+ }
+
+ protected TopicConnectionFactory getTopicConnectionFactory()
+ throws Exception
+ {
+ try
+ {
+ return (TopicConnectionFactory) getInitialContext().lookup(
+ "ConnectionFactory");
+ } catch (NamingException e)
+ {
+ return (TopicConnectionFactory) getInitialContext().lookup(
+ "java:/ConnectionFactory");
+ }
+ }
+
+
+
+ public void testQueue() throws Exception
+ {
+ setSecurity("anyone", "password");
+
+ TestStatus status = (TestStatus) getInitialContext().lookup(
+ "TestStatusBean/remote");
+ clear(status);
+ QueueConnection cnn = null;
+ QueueSender sender = null;
+ QueueSession session = null;
+
+ Queue queue = (Queue) getInitialContext().lookup("queue/mdbtest");
+ QueueConnectionFactory factory = getQueueConnectionFactory();
+ cnn = factory.createQueueConnection();
+ session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+ TextMessage msg = session.createTextMessage("Hello World");
+
+ sender = session.createSender(queue);
+ sender.send(msg);
+ sender.send(msg);
+ sender.send(msg);
+ sender.send(msg);
+ sender.send(msg);
+ session.close();
+ cnn.close();
+
+ Thread.sleep(2000);
+ assertEquals(5, status.queueFired());
+ assertTrue(status.interceptedQueue());
+ assertTrue(status.postConstruct());
+ assertEquals(5, status.messageCount());
+
+ // TODO: Figure out how to test preDestroy gets invoked
+ // assertTrue(status.preDestroy());
+
+ setSecurity("anyone", "password");
+ Stateless stateless = (Stateless) getInitialContext().lookup("Stateless");
+ assertNotNull(stateless);
+ String state = stateless.getState();
+ assertEquals("Set", state);
+ Bootstrap.getInstance().setIgnoreShutdownErrors(true);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestCase.getAdaptedSetup(MDBUnitEmbeddedTest.class,
+ "mdbtest-service.xml, mdb-test.jar");
+ }
+
+}
+
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list