[jboss-cvs] JBossAS SVN: r61892 - in trunk/embedded: src/main/java/org/jboss/embedded and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Mar 30 11:43:00 EDT 2007
Author: bill.burke at jboss.com
Date: 2007-03-30 11:43:00 -0400 (Fri, 30 Mar 2007)
New Revision: 61892
Added:
trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java
trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/
trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/EjbTestCase.java
trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/MdbTestCase.java
trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/
trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/ExampleMDB.java
trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/unit/
trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/unit/MdbTestCase.java
trunk/embedded/src/test/resources/mdb/
trunk/embedded/src/test/resources/mdb/mdbtest-service.xml
Modified:
trunk/embedded/build-test.xml
trunk/embedded/build.xml
trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroup.java
trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java
Log:
turn off automatic queue/topic creation
Modified: trunk/embedded/build-test.xml
===================================================================
--- trunk/embedded/build-test.xml 2007-03-30 15:34:54 UTC (rev 61891)
+++ trunk/embedded/build-test.xml 2007-03-30 15:43:00 UTC (rev 61892)
@@ -168,6 +168,14 @@
<include name="META-INF/persistence.xml"/>
</fileset>
</jar>
+ <jar jarfile="${build.lib}/mdb-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/embedded/test/mdb/**/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/mdb">
+ <include name="mdbtest-service.xml"/>
+ </fileset>
+ </jar>
<jar jarfile="${build.lib}/remote-test.jar">
<fileset dir="${build.classes}">
<include name="org/jboss/embedded/test/remote/**/*.class"/>
Modified: trunk/embedded/build.xml
===================================================================
--- trunk/embedded/build.xml 2007-03-30 15:34:54 UTC (rev 61891)
+++ trunk/embedded/build.xml 2007-03-30 15:43:00 UTC (rev 61892)
@@ -298,14 +298,17 @@
<mkdir dir="${build.lib}/embedded-jboss/bootstrap/deploy/messaging"/>
<copy todir="${build.lib}/embedded-jboss/bootstrap/deploy/messaging">
- <fileset dir="../messaging/output/etc/deploy">
+ <fileset dir="../messaging/output/etc/deploy/common">
<include name="*.xml"/>
</fileset>
+ <fileset dir="../messaging/output/etc/deploy/non-clustered">
+ <include name="*.xml"/>
+ </fileset>
</copy>
<mkdir dir="${build.lib}/embedded-jboss/bootstrap/conf/props"/>
<copy todir="${build.lib}/embedded-jboss/bootstrap/conf/props">
- <fileset dir="../messaging/output/etc/deploy">
+ <fileset dir="../messaging/output/etc/deploy/common">
<include name="*.properties"/>
</fileset>
</copy>
Modified: trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroup.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroup.java 2007-03-30 15:34:54 UTC (rev 61891)
+++ trunk/embedded/src/main/java/org/jboss/embedded/DeploymentGroup.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -147,7 +147,9 @@
{
IncompleteDeployments incomplete = IncompleteDeploymentsBuilder.build(mainDeployer, kernel.getController());
if (incomplete.isIncomplete())
+ {
throw new IncompleteDeploymentException(incomplete);
+ }
}
/**
@@ -286,7 +288,7 @@
boolean found = false;
for (String wantedPath : split)
{
- if (path.endsWith(System.getProperty("file.separator") + wantedPath))
+ if (path.endsWith(File.separator + wantedPath))
{
found = true;
break;
Added: trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java (rev 0)
+++ trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,183 @@
+/*
+* 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.embedded.junit;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.embedded.DeploymentGroup;
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class EmbeddedTestSetup extends TestSetup
+{
+ public EmbeddedTestSetup(Test test)
+ {
+ super(test);
+ }
+
+ protected void setUp()
+ {
+ if (Bootstrap.getInstance().isStarted()) return;
+
+ try
+ {
+ Bootstrap.getInstance().bootstrap();
+ }
+ catch (Exception error)
+ {
+ throw new RuntimeException("Failed to bootstrap", error);
+ }
+ }
+
+ protected void tearDown()
+ {
+ }
+
+
+ /**
+ * Returns a wrapper that will only bootstrap embedded if VM hasn't already bootstrapped
+ *
+ * @param testClass
+ * @return
+ */
+ public static Test getWrapper(Class testClass)
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(testClass);
+
+ // setup test so that embedded JBoss is started/stopped once for all tests here.
+ return new EmbeddedTestSetup(suite);
+ }
+
+ /**
+ * Returns a wrapper that will only bootstrap embedded if VM hasn't already bootstrapped
+ * Deploys items represented in classpath as staed in DeploymentGroup.addClasspath
+ *
+ * @param testClass
+ * @param classpaths
+ * @return
+ */
+ public static Test deployClasspath(Class testClass, final String classpaths)
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(testClass);
+
+ return new EmbeddedTestSetup(suite)
+ {
+ DeploymentGroup group;
+
+ @Override
+ protected void setUp()
+ {
+ super.setUp();
+ try
+ {
+ group = Bootstrap.getInstance().createDeploymentGroup();
+ group.addClasspath(classpaths);
+ group.process();
+ }
+ catch (DeploymentException e)
+ {
+ throw new RuntimeException("Unable to deploy classpath: " + classpaths, e);
+ }
+ }
+
+ @Override
+ protected void tearDown()
+ {
+ try
+ {
+ group.undeploy();
+ }
+ catch (DeploymentException e)
+ {
+ throw new RuntimeException("Unable to undeploy classpath: " + classpaths, e);
+ }
+ super.tearDown();
+ }
+ };
+ }
+
+ /**
+ * Returns a wrapper that will only bootstrap embedded if VM hasn't already bootstrapped
+ * Deploys items represented in resource list
+ *
+ * @param testClass
+ * @param resources
+ * @return
+ */
+ public static Test deployResource(Class testClass, final String... resources)
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(testClass);
+
+ return new EmbeddedTestSetup(suite)
+ {
+ DeploymentGroup group;
+
+ @Override
+ protected void setUp()
+ {
+ super.setUp();
+ try
+ {
+ group = Bootstrap.getInstance().createDeploymentGroup();
+ for (String resource : resources)
+ {
+ group.addResource(resource);
+ }
+ group.process();
+ }
+ catch (DeploymentException e)
+ {
+ String message = "Unable to deploy resources:";
+ for (String resource : resources)
+ {
+ message += " " + resource;
+ }
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ @Override
+ protected void tearDown()
+ {
+ try
+ {
+ group.undeploy();
+ }
+ catch (DeploymentException e)
+ {
+ throw new RuntimeException("Unable to undeploy resources: " + resources, e);
+ }
+ super.tearDown();
+ }
+ };
+ }
+}
Modified: trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java 2007-03-30 15:34:54 UTC (rev 61891)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/ejb/unit/EjbTestCase.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -137,4 +137,22 @@
}
+ public void testSimpleEjb2() throws Exception
+ {
+ DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+ group.addClasspath("ejb-test.jar");
+ group.process();
+
+ outputJNDI();
+ InitialContext ctx = new InitialContext();
+ DAO dao = (DAO)ctx.lookup("DAOBean/local");
+ Customer cust = dao.createCustomer("Bill");
+ cust = dao.findCustomer("Bill");
+ assert cust != null;
+ assert cust.getName().equals("Bill");
+
+ group.undeploy();
+
+
+ }
}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/EjbTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/EjbTestCase.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/EjbTestCase.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,140 @@
+/*
+* 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.embedded.test.idetesting;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.extensions.TestSetup;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.embedded.DeploymentGroup;
+import org.jboss.embedded.test.ejb.DAO;
+import org.jboss.embedded.test.ejb.Customer;
+import org.jboss.embedded.adapters.JMXKernel;
+import org.jboss.deployers.spi.DeploymentException;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ReflectionException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42757 $
+ */
+public class EjbTestCase extends TestCase
+{
+ public EjbTestCase()
+ {
+ super("BootstrapTestCase");
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(EjbTestCase.class);
+
+
+ // setup test so that embedded JBoss is started/stopped once for all tests here.
+ TestSetup wrapper = new TestSetup(suite)
+ {
+ protected void setUp()
+ {
+ if (Bootstrap.getInstance().isStarted()) return;
+
+ try
+ {
+ Bootstrap.getInstance().bootstrap();
+ }
+ catch (Exception error)
+ {
+ throw new RuntimeException("Failed to bootstrap", error);
+ }
+ }
+
+ protected void tearDown()
+ {
+ }
+ };
+
+ return wrapper;
+ }
+
+ private static void outputJNDI()
+ throws InstanceNotFoundException, MBeanException, ReflectionException, MalformedObjectNameException
+ {
+ MBeanServer server = getMBeanServer();
+ String xml = (String)server.invoke(new ObjectName("jboss:service=JNDIView"), "listXML", null, null);
+ System.out.println(xml);
+ }
+
+ private static MBeanServer getMBeanServer()
+ {
+ JMXKernel jmxKernel = (JMXKernel)Bootstrap.getInstance().getKernel().getRegistry().getEntry("JMXKernel").getTarget();
+ MBeanServer server = jmxKernel.getMbeanServer();
+ return server;
+ }
+
+
+ public void testSimpleEjb() throws Exception
+ {
+ DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+ group.addClasspath("ejb-test.jar");
+ group.process();
+
+ outputJNDI();
+ InitialContext ctx = new InitialContext();
+ DAO dao = (DAO)ctx.lookup("DAOBean/local");
+ Customer cust = dao.createCustomer("Bill");
+ cust = dao.findCustomer("Bill");
+ assert cust != null;
+ assert cust.getName().equals("Bill");
+
+ group.undeploy();
+
+
+ }
+
+ public void testSimpleEjb2() throws Exception
+ {
+ DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+ group.addClasspath("ejb-test.jar");
+ group.process();
+
+ outputJNDI();
+ InitialContext ctx = new InitialContext();
+ DAO dao = (DAO)ctx.lookup("DAOBean/local");
+ Customer cust = dao.createCustomer("Bill");
+ cust = dao.findCustomer("Bill");
+ assert cust != null;
+ assert cust.getName().equals("Bill");
+
+ group.undeploy();
+
+
+ }
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/MdbTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/MdbTestCase.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/MdbTestCase.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,86 @@
+/*
+* 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.embedded.test.idetesting;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.extensions.TestSetup;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.embedded.DeploymentGroup;
+import org.jboss.embedded.junit.EmbeddedTestSetup;
+import org.jboss.embedded.test.mdb.ExampleMDB;
+import org.jboss.deployers.spi.DeploymentException;
+
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.jms.JMSException;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.MessageProducer;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42757 $
+ */
+public class MdbTestCase extends TestCase
+{
+ public MdbTestCase()
+ {
+ super("BootstrapTestCase");
+ }
+
+ public static Test suite() throws Exception
+ {
+ return EmbeddedTestSetup.deployClasspath(MdbTestCase.class, "mdb-test.jar");
+ }
+
+ public void testSimpleEjb() throws Exception
+ {
+ sendMessage();
+ }
+
+ private static void sendMessage()
+ throws DeploymentException, NamingException, JMSException, InterruptedException
+ {
+ ExampleMDB.executed = false;
+
+ InitialContext ctx = new InitialContext();
+ ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
+ Destination destination = (Destination) ctx.lookup("queue/example");
+ assertNotNull(destination);
+ Connection conn = factory.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TextMessage message = session.createTextMessage("hello");
+ MessageProducer producer = session.createProducer(destination);
+ producer.send(message);
+ session.close();
+ conn.close();
+ Thread.sleep(1000);
+ }
+
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/ExampleMDB.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/ExampleMDB.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/ExampleMDB.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,49 @@
+/*
+* 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.embedded.test.mdb;
+
+import org.jboss.annotation.ejb.Depends;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.ActivationConfigProperty;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+
+ at MessageDriven(activationConfig =
+ {
+ @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName="destination", propertyValue="queue/example")
+ })
+ at Depends("jboss.mq.destination:name=example,service=Queue")
+public class ExampleMDB implements MessageListener
+{
+ public static boolean executed = false;
+
+ public void onMessage(Message recvMsg)
+ {
+ System.out.println("----------------");
+ System.out.println("Received message");
+ executed = true;
+ System.out.println("----------------");
+ }
+
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/unit/MdbTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/unit/MdbTestCase.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/mdb/unit/MdbTestCase.java 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,134 @@
+/*
+* 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.embedded.test.mdb.unit;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.embedded.DeploymentGroup;
+import org.jboss.embedded.test.mdb.ExampleMDB;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42757 $
+ */
+public class MdbTestCase extends TestCase
+{
+ public MdbTestCase()
+ {
+ super("BootstrapTestCase");
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(MdbTestCase.class);
+
+ // setup test so that embedded JBoss is started/stopped once for all tests here.
+ TestSetup wrapper = new TestSetup(suite)
+ {
+ protected void setUp()
+ {
+ long start = System.currentTimeMillis();
+ try
+ {
+ startupEmbeddedJboss();
+ }
+ finally
+ {
+ System.out.println("Bootstrap took " + (System.currentTimeMillis() - start) + " (ms)");
+ }
+
+ }
+
+ protected void tearDown()
+ {
+ shutdownEmbeddedJboss();
+ }
+ };
+
+ return wrapper;
+ }
+
+ public static void startupEmbeddedJboss()
+ {
+ try
+ {
+ Bootstrap.getInstance().bootstrap();
+ }
+ catch (DeploymentException e)
+ {
+ throw new RuntimeException("Failed to bootstrap", e);
+ }
+ }
+
+ public static void shutdownEmbeddedJboss()
+ {
+ Bootstrap.getInstance().shutdown();
+ }
+
+ public void testSimpleEjb() throws Exception
+ {
+ sendMessage();
+ }
+
+ private static void sendMessage()
+ throws DeploymentException, NamingException, JMSException, InterruptedException
+ {
+ DeploymentGroup group = Bootstrap.getInstance().createDeploymentGroup();
+ //group.addResource("mdbtest-service.xml");
+ group.addClasspath("mdb-test.jar");
+ group.process();
+
+ ExampleMDB.executed = false;
+
+ InitialContext ctx = new InitialContext();
+ ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
+ Destination destination = (Destination) ctx.lookup("queue/example");
+ assertNotNull(destination);
+ Connection conn = factory.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TextMessage message = session.createTextMessage("hello");
+ MessageProducer producer = session.createProducer(destination);
+ producer.send(message);
+ session.close();
+ conn.close();
+ Thread.sleep(5000);
+ assertTrue(ExampleMDB.executed);
+ }
+
+}
Added: trunk/embedded/src/test/resources/mdb/mdbtest-service.xml
===================================================================
--- trunk/embedded/src/test/resources/mdb/mdbtest-service.xml (rev 0)
+++ trunk/embedded/src/test/resources/mdb/mdbtest-service.xml 2007-03-30 15:43:00 UTC (rev 61892)
@@ -0,0 +1,17 @@
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=example">
+ <attribute name="JNDIName">queue/example</attribute>
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ </mbean>
+
+<!--
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.messaging.destination:service=Queue,name=example"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ -->
+
+</server>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list