[jboss-cvs] JBossAS SVN: r96759 - in projects/embedded/trunk: core and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 23 16:19:01 EST 2009
Author: ALRubinger
Date: 2009-11-23 16:18:59 -0500 (Mon, 23 Nov 2009)
New Revision: 96759
Added:
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsUnitTest.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTest.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationUnitTest.java
projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerIntegrationTest.java
Removed:
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsTestCase.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTestCase.java
projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationTestCase.java
projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerTestCase.java
Modified:
projects/embedded/trunk/build/pom.xml
projects/embedded/trunk/core/pom.xml
projects/embedded/trunk/testsuite/pom.xml
Log:
[EMB-70] Make separate executions for Unit and Integration Tests:
* Test renaming
* AS Preinstallation no longer required, brought in via Maven lifecycle
* Related POM changes
Modified: projects/embedded/trunk/build/pom.xml
===================================================================
--- projects/embedded/trunk/build/pom.xml 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/build/pom.xml 2009-11-23 21:18:59 UTC (rev 96759)
@@ -81,22 +81,13 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <additionalClasspathElements>
- <additionalClasspathElement>${JBOSS_HOME}/client/jbossws-native-client.jar</additionalClasspathElement>
- </additionalClasspathElements>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<trimStackTrace>false</trimStackTrace>
<printSummary>true</printSummary>
<includes>
- <include>**/*TestCase.java</include>
- <include>**/*TestSuite.java</include>
+ <include>**/*UnitTest.java</include>
</includes>
<forkMode>always</forkMode>
- <!--
- MaxPermSize Required to bump the space for relective data like classes,
- methods, etc. EMB-41. Endorsed required for things like WS support (EMB-61)
- -->
- <argLine>-XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed</argLine>
</configuration>
</plugin>
Modified: projects/embedded/trunk/core/pom.xml
===================================================================
--- projects/embedded/trunk/core/pom.xml 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/core/pom.xml 2009-11-23 21:18:59 UTC (rev 96759)
@@ -21,7 +21,6 @@
<name>JBoss Embedded AS Implementation Core</name>
<description>JBoss Embedded AS Implementation Core</description>
-
<!-- Properties -->
<properties>
Deleted: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsTestCase.java 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsTestCase.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.embedded.core.deployable;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.jboss.embedded.api.Deployable;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-
-/**
- * Test Cases to ensure that the implementations for
- * {@link Deployable} types are working as expected
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class DeployableImplementationsTestCase
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Name of the first test file
- */
- private static final String NAME_FILE1 = "file1";
-
- /**
- * Name of the second test file
- */
- private static final String NAME_FILE2 = "file2";
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that {@link Deployable} types backed by an
- * {@link Archive} are working
- */
- @Test
- public void testDeployableArchive() throws Exception
- {
- // Create an archive
- final JavaArchive archive = Archives.create("archive.jar", JavaArchive.class);
-
- // Make a Deployable
- final Deployable deployable = new DeployableArchive(archive);
-
- // Get the Deployable target
- final URL target = deployable.getTarget();
-
- // Test the streams for equal contents
- final InputStream expectedStream = archive.as(ZipExporter.class).exportZip();
- final InputStream roundtripStream = target.openStream();
- this.assertEqualStreamContents(expectedStream, roundtripStream);
-
- // Test Equality
- final JavaArchive unequalArchive = Archives.create("unequal.jar", JavaArchive.class);
- final Deployable unequalDeployable = new DeployableArchive(unequalArchive);
- final Deployable equalDeployable = new DeployableArchive(archive);
- this.assertEquality(deployable, equalDeployable, unequalDeployable);
-
- }
-
- /**
- * Ensures that {@link Deployable} types backed by a
- * {@link File} are working
- */
- @Test
- public void testDeployableFile() throws Exception
- {
- // Create a File
- final File file = new File(this.getUrl(NAME_FILE1).toURI());
-
- // Make a Deployable
- final Deployable deployable = new DeployableFile(file);
-
- // Get the Deployable target
- final URL target = deployable.getTarget();
-
- // Test the streams for equal contents
- final InputStream expectedStream = file.toURI().toURL().openStream();
- final InputStream roundtripStream = target.openStream();
- this.assertEqualStreamContents(expectedStream, roundtripStream);
-
- // Test Equality
- final File unequalFile = new File(this.getUrl(NAME_FILE2).toURI());
- final Deployable unequalDeployable = new DeployableFile(unequalFile);
- final Deployable equalDeployable = new DeployableFile(file);
- this.assertEquality(deployable, equalDeployable, unequalDeployable);
-
- // Test preconditions
- try
- {
- new DeployableFile(null);
- TestCase.fail("New deployable file with null backing file should be invalid");
- }
- catch (final IllegalArgumentException iae)
- {
- // Expected
- }
- try
- {
- final File nonExistantFile = new File("made_up_file");
- TestCase.assertTrue("Test file should not exist", !nonExistantFile.exists());
- new DeployableFile(nonExistantFile);
- TestCase.fail("New deployable file with nonexistant backing file should be invalid");
- }
- catch (final IllegalArgumentException iae)
- {
- // Expected
- }
- }
-
- /**
- * Ensures that {@link Deployable} types backed by a
- * {@link URL} are working
- */
- @Test
- public void testDeployableUrl() throws Exception
- {
- // Create a URL
- final URL url = this.getUrl(NAME_FILE1);
-
- // Make a Deployable
- final Deployable deployable = new DeployableUrl(url);
-
- // Get the Deployable target
- final URL target = deployable.getTarget();
-
- // Test the streams for equal contents
- final InputStream expectedStream = url.openStream();
- final InputStream roundtripStream = target.openStream();
- this.assertEqualStreamContents(expectedStream, roundtripStream);
-
- // Test Equality
- final URL unequalUrl = this.getUrl(NAME_FILE2);
- final Deployable unequalDeployable = new DeployableUrl(unequalUrl);
- final Deployable equalDeployable = new DeployableUrl(url);
- this.assertEquality(deployable, equalDeployable, unequalDeployable);
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that the {@link Object#equals(Object)} and {@link Object#hashCode()}
- * methods are working as contracted
- *
- * @param original The original deployable
- * @param expectedEqual A deployable expected to be equal to the original
- * @param expectedUnequal A deployable expected to be unequal to the original
- */
- private void assertEquality(final Deployable original, final Deployable expectedEqual,
- final Deployable expectedUnequal)
- {
- TestCase.assertEquals("Deployable archives with equal backing archives should be equal", original, expectedEqual);
- TestCase.assertNotSame("Deployable archives with inequal backing archives should not be equal", original,
- expectedUnequal);
- TestCase.assertEquals("Hash codes of equal objects mus tbe equal", original.hashCode(), expectedEqual.hashCode());
- }
-
- /**
- * Ensures that the contents of the given streams are equal
- * @param expected
- * @param deployable
- * @throws IOException
- */
- private void assertEqualStreamContents(final InputStream expected, final InputStream deployable) throws IOException
- {
- int read = 0;
- while ((read = expected.read()) != -1)
- {
- int readFromRoundtrip = deployable.read();
- TestCase.assertEquals("Contents of streams are not equal", read, readFromRoundtrip);
- }
- // Also ensure we're at the end of the second stream
- TestCase.assertEquals(-1, deployable.read());
- }
-
- /**
- * Obtains the resource of the given name
- * @param fileName
- * @return
- * @throws IllegalArgumentException If the name is not specified
- */
- private URL getUrl(final String resourceName) throws IllegalArgumentException
- {
- // Precondition check
- if (resourceName == null || resourceName.length() == 0)
- {
- throw new IllegalArgumentException("name must be specified");
- }
- // Return
- return this.getClass().getClassLoader().getResource(resourceName);
- }
-
-}
Copied: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsUnitTest.java (from rev 96742, projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsTestCase.java)
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsUnitTest.java (rev 0)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/deployable/DeployableImplementationsUnitTest.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.embedded.core.deployable;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.embedded.api.Deployable;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+
+/**
+ * Test Cases to ensure that the implementations for
+ * {@link Deployable} types are working as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployableImplementationsUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Name of the first test file
+ */
+ private static final String NAME_FILE1 = "file1";
+
+ /**
+ * Name of the second test file
+ */
+ private static final String NAME_FILE2 = "file2";
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that {@link Deployable} types backed by an
+ * {@link Archive} are working
+ */
+ @Test
+ public void testDeployableArchive() throws Exception
+ {
+ // Create an archive
+ final JavaArchive archive = Archives.create("archive.jar", JavaArchive.class);
+
+ // Make a Deployable
+ final Deployable deployable = new DeployableArchive(archive);
+
+ // Get the Deployable target
+ final URL target = deployable.getTarget();
+
+ // Test the streams for equal contents
+ final InputStream expectedStream = archive.as(ZipExporter.class).exportZip();
+ final InputStream roundtripStream = target.openStream();
+ this.assertEqualStreamContents(expectedStream, roundtripStream);
+
+ // Test Equality
+ final JavaArchive unequalArchive = Archives.create("unequal.jar", JavaArchive.class);
+ final Deployable unequalDeployable = new DeployableArchive(unequalArchive);
+ final Deployable equalDeployable = new DeployableArchive(archive);
+ this.assertEquality(deployable, equalDeployable, unequalDeployable);
+
+ }
+
+ /**
+ * Ensures that {@link Deployable} types backed by a
+ * {@link File} are working
+ */
+ @Test
+ public void testDeployableFile() throws Exception
+ {
+ // Create a File
+ final File file = new File(this.getUrl(NAME_FILE1).toURI());
+
+ // Make a Deployable
+ final Deployable deployable = new DeployableFile(file);
+
+ // Get the Deployable target
+ final URL target = deployable.getTarget();
+
+ // Test the streams for equal contents
+ final InputStream expectedStream = file.toURI().toURL().openStream();
+ final InputStream roundtripStream = target.openStream();
+ this.assertEqualStreamContents(expectedStream, roundtripStream);
+
+ // Test Equality
+ final File unequalFile = new File(this.getUrl(NAME_FILE2).toURI());
+ final Deployable unequalDeployable = new DeployableFile(unequalFile);
+ final Deployable equalDeployable = new DeployableFile(file);
+ this.assertEquality(deployable, equalDeployable, unequalDeployable);
+
+ // Test preconditions
+ try
+ {
+ new DeployableFile(null);
+ TestCase.fail("New deployable file with null backing file should be invalid");
+ }
+ catch (final IllegalArgumentException iae)
+ {
+ // Expected
+ }
+ try
+ {
+ final File nonExistantFile = new File("made_up_file");
+ TestCase.assertTrue("Test file should not exist", !nonExistantFile.exists());
+ new DeployableFile(nonExistantFile);
+ TestCase.fail("New deployable file with nonexistant backing file should be invalid");
+ }
+ catch (final IllegalArgumentException iae)
+ {
+ // Expected
+ }
+ }
+
+ /**
+ * Ensures that {@link Deployable} types backed by a
+ * {@link URL} are working
+ */
+ @Test
+ public void testDeployableUrl() throws Exception
+ {
+ // Create a URL
+ final URL url = this.getUrl(NAME_FILE1);
+
+ // Make a Deployable
+ final Deployable deployable = new DeployableUrl(url);
+
+ // Get the Deployable target
+ final URL target = deployable.getTarget();
+
+ // Test the streams for equal contents
+ final InputStream expectedStream = url.openStream();
+ final InputStream roundtripStream = target.openStream();
+ this.assertEqualStreamContents(expectedStream, roundtripStream);
+
+ // Test Equality
+ final URL unequalUrl = this.getUrl(NAME_FILE2);
+ final Deployable unequalDeployable = new DeployableUrl(unequalUrl);
+ final Deployable equalDeployable = new DeployableUrl(url);
+ this.assertEquality(deployable, equalDeployable, unequalDeployable);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the {@link Object#equals(Object)} and {@link Object#hashCode()}
+ * methods are working as contracted
+ *
+ * @param original The original deployable
+ * @param expectedEqual A deployable expected to be equal to the original
+ * @param expectedUnequal A deployable expected to be unequal to the original
+ */
+ private void assertEquality(final Deployable original, final Deployable expectedEqual,
+ final Deployable expectedUnequal)
+ {
+ TestCase.assertEquals("Deployable archives with equal backing archives should be equal", original, expectedEqual);
+ TestCase.assertNotSame("Deployable archives with inequal backing archives should not be equal", original,
+ expectedUnequal);
+ TestCase.assertEquals("Hash codes of equal objects mus tbe equal", original.hashCode(), expectedEqual.hashCode());
+ }
+
+ /**
+ * Ensures that the contents of the given streams are equal
+ * @param expected
+ * @param deployable
+ * @throws IOException
+ */
+ private void assertEqualStreamContents(final InputStream expected, final InputStream deployable) throws IOException
+ {
+ int read = 0;
+ while ((read = expected.read()) != -1)
+ {
+ int readFromRoundtrip = deployable.read();
+ TestCase.assertEquals("Contents of streams are not equal", read, readFromRoundtrip);
+ }
+ // Also ensure we're at the end of the second stream
+ TestCase.assertEquals(-1, deployable.read());
+ }
+
+ /**
+ * Obtains the resource of the given name
+ * @param fileName
+ * @return
+ * @throws IllegalArgumentException If the name is not specified
+ */
+ private URL getUrl(final String resourceName) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (resourceName == null || resourceName.length() == 0)
+ {
+ throw new IllegalArgumentException("name must be specified");
+ }
+ // Return
+ return this.getClass().getClassLoader().getResource(resourceName);
+ }
+
+}
Copied: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTest.java (from rev 96742, projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTestCase.java)
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTest.java (rev 0)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTest.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.embedded.core.server;
+
+import junit.framework.TestCase;
+
+import org.jboss.embedded.api.server.JBossASEmbeddedServer;
+import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
+import org.junit.Test;
+
+/**
+ * Tests to ensure that the API's Server Factory is working as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASEmbeddedServerFactoryUnitTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that a new server instance may be created from the API's Server Factory
+ */
+ @Test
+ public void testServerFactory() throws Exception
+ {
+ final JBossASEmbeddedServer server = JBossASEmbeddedServerFactory.createServer();
+ // Ensure we have a non-null type (because the compiler will ensure that the runtime type is OK from this end)
+ TestCase.assertNotNull("Server factory returned a null server instance", server);
+ }
+}
Deleted: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTestCase.java 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/JBossASEmbeddedServerFactoryUnitTestCase.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.embedded.core.server;
-
-import junit.framework.TestCase;
-
-import org.jboss.embedded.api.server.JBossASEmbeddedServer;
-import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
-import org.junit.Test;
-
-/**
- * JBossASEmbeddedServerFactoryUnitTestCase
- *
- * Tests to ensure that the API's Server Factory is working as expected
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class JBossASEmbeddedServerFactoryUnitTestCase
-{
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that a new server instance may be created from the API's Server Factory
- */
- @Test
- public void testServerFactory() throws Exception
- {
- final JBossASEmbeddedServer server = JBossASEmbeddedServerFactory.createServer();
- // Ensure we have a non-null type (because the compiler will ensure that the runtime type is OK from this end)
- TestCase.assertNotNull("Server factory returned a null server instance", server);
- }
-}
Deleted: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationTestCase.java
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationTestCase.java 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationTestCase.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.embedded.core.server;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.spi.server.ServerProvider;
-import org.jboss.embedded.api.server.JBossASEmbeddedServer;
-import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
-import org.jboss.logging.Logger;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * ServerInitializationTestCase
- *
- * Test Cases to ensure that the Server Initialization contracts
- * hold
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ServerInitializationTestCase
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(ServerInitializationTestCase.class);
-
- /**
- * Server for testing
- */
- private static JBossASEmbeddedServer server;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Creates and initializes the server
- */
- @BeforeClass
- public static void createAndInitServer() throws Exception
- {
- // Create
- server = JBossASEmbeddedServerFactory.createServer();
- // Don't do any validation of JBOSS_HOME or related environment
- ((ServerProvider<?, ?>) server).setValidator(null);
- // Init
- server.initialize();
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that JBossXB is configured to use the unordered sequence in parsing
- */
- @Test
- public void testXbUnorderedSequence() throws Exception
- {
- this.assertSysProp("xb.builder.useUnorderedSequence", Boolean.TRUE.toString());
- }
-
- /**
- * Ensures that the RMI server hostname is set to localhost
- */
- @Test
- public void testRmiServerHostnameLocalhost() throws Exception
- {
- this.assertSysProp("java.rmi.server.hostname", "localhost");
- }
-
- /**
- * Ensures that the Log Manager is set to JBoss LogManager
- */
- @Test
- public void testLogManagerIsJBossLogManager() throws Exception
- {
- this.assertSysProp("java.util.logging.manager", "org.jboss.logmanager.LogManager");
- }
-
- /**
- * Ensures that the system property for IPv4 Stack is set
- */
- @Test
- public void testIpv4() throws Exception
- {
- this.assertSysProp("java.net.preferIPv4Stack", "true");
- }
-
- //-------------------------------------------------------------------------------------||
- // Helper Methods ---------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures the system property of specified name has the specified value,
- * else fails the test
- */
- private void assertSysProp(final String propName, final String expectedValue)
- {
- // Get the prop value
- final String propValue = AccessController.doPrivileged(new PrivilegedAction<String>()
- {
- @Override
- public String run()
- {
- return System.getProperty(propName);
- }
-
- });
- // Ensure expected
- TestCase.assertEquals("Required system property was not set as expected", expectedValue, propValue);
- }
-
-}
Copied: projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationUnitTest.java (from rev 96742, projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationTestCase.java)
===================================================================
--- projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationUnitTest.java (rev 0)
+++ projects/embedded/trunk/core/src/test/java/org/jboss/embedded/core/server/ServerInitializationUnitTest.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.embedded.core.server;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.spi.server.ServerProvider;
+import org.jboss.embedded.api.server.JBossASEmbeddedServer;
+import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
+import org.jboss.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Cases to ensure that the Server Initialization contracts
+ * hold
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServerInitializationUnitTest
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ServerInitializationUnitTest.class);
+
+ /**
+ * Server for testing
+ */
+ private static JBossASEmbeddedServer server;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates and initializes the server
+ */
+ @BeforeClass
+ public static void createAndInitServer() throws Exception
+ {
+ // Create
+ server = JBossASEmbeddedServerFactory.createServer();
+ // Don't do any validation of JBOSS_HOME or related environment
+ ((ServerProvider<?, ?>) server).setValidator(null);
+ // Init
+ server.initialize();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that JBossXB is configured to use the unordered sequence in parsing
+ */
+ @Test
+ public void testXbUnorderedSequence() throws Exception
+ {
+ this.assertSysProp("xb.builder.useUnorderedSequence", Boolean.TRUE.toString());
+ }
+
+ /**
+ * Ensures that the RMI server hostname is set to localhost
+ */
+ @Test
+ public void testRmiServerHostnameLocalhost() throws Exception
+ {
+ this.assertSysProp("java.rmi.server.hostname", "localhost");
+ }
+
+ /**
+ * Ensures that the Log Manager is set to JBoss LogManager
+ */
+ @Test
+ public void testLogManagerIsJBossLogManager() throws Exception
+ {
+ this.assertSysProp("java.util.logging.manager", "org.jboss.logmanager.LogManager");
+ }
+
+ /**
+ * Ensures that the system property for IPv4 Stack is set
+ */
+ @Test
+ public void testIpv4() throws Exception
+ {
+ this.assertSysProp("java.net.preferIPv4Stack", "true");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Helper Methods ---------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures the system property of specified name has the specified value,
+ * else fails the test
+ */
+ private void assertSysProp(final String propName, final String expectedValue)
+ {
+ // Get the prop value
+ final String propValue = AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ @Override
+ public String run()
+ {
+ return System.getProperty(propName);
+ }
+
+ });
+ // Ensure expected
+ TestCase.assertEquals("Required system property was not set as expected", expectedValue, propValue);
+ }
+
+}
Modified: projects/embedded/trunk/testsuite/pom.xml
===================================================================
--- projects/embedded/trunk/testsuite/pom.xml 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/testsuite/pom.xml 2009-11-23 21:18:59 UTC (rev 96759)
@@ -21,6 +21,9 @@
<!-- Properties -->
<properties>
+ <!-- JBOSS_HOME (We'll unpack into here -->
+ <JBOSS_HOME>${project.build.directory}/jboss-as-distribution-${version.org.jboss.jbossas}</JBOSS_HOME>
+
<!-- Versioning -->
<version.org.apache.httpcomponents_httpclient>4.0-beta2</version.org.apache.httpcomponents_httpclient>
<version.org.jboss.javaee_jboss.jms.api>1.1.0.GA</version.org.jboss.javaee_jboss.jms.api>
@@ -33,19 +36,72 @@
<!-- Build Configuration -->
<build>
- <!-- Make a Test JAR (used by testsuite-fulldep component) -->
+
<plugins>
+
+ <!-- Surefire -->
<plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+
+ <configuration>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${JBOSS_HOME}/client/jbossws-native-client.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*IntegrationTest.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+
+ <!--
+ MaxPermSize Required to bump the space for relective
+ data like classes, methods, etc. EMB-41. Endorsed
+ required for things like WS support (EMB-61)
+ -->
+ <argLine>-XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed -Djboss.home=${JBOSS_HOME}</argLine>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Get AS and put into "target" -->
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
+ <artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
+ <id>unpack</id>
+ <phase>pre-integration-test</phase> <!-- So run before testing -->
<goals>
- <goal>test-jar</goal>
+ <goal>unpack</goal>
</goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-distribution</artifactId>
+ <version>${version.org.jboss.jbossas}</version>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
</execution>
</executions>
</plugin>
+
+
</plugins>
</build>
Copied: projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerIntegrationTest.java (from rev 96742, projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerTestCase.java)
===================================================================
--- projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerIntegrationTest.java (rev 0)
+++ projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerIntegrationTest.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -0,0 +1,605 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.embedded.testsuite;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.embedded.api.server.JBossASEmbeddedServer;
+import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
+import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
+import org.jboss.embedded.testsuite.ejb3.entity.Jbossian;
+import org.jboss.embedded.testsuite.ejb3.entity.JbossianRegistrarBean;
+import org.jboss.embedded.testsuite.ejb3.entity.JbossianRegistrarLocalBusiness;
+import org.jboss.embedded.testsuite.ejb3.mdb.MessageStoringMdb;
+import org.jboss.embedded.testsuite.ejb3.slsb.OutputBean;
+import org.jboss.embedded.testsuite.ejb3.slsb.OutputLocalBusiness;
+import org.jboss.embedded.testsuite.mc.StateReportingBean;
+import org.jboss.embedded.testsuite.servlet.JspForwardingServlet;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * End-user view of the Embedded Server. Tests here should include lifecycle
+ * to start/stop the server, and checks to ensure that
+ * subsystems are working as expected.
+ *
+ * This is a high-level integration test for the Application
+ * Server running in Embedded mode
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServerIntegrationTest
+{
+
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ServerIntegrationTest.class.getName());
+
+ /**
+ * The server instance
+ */
+ private static JBossASEmbeddedServer server;
+
+ /**
+ * Path, relative to the resources base, of the directory containing web.xml descriptor for tests
+ */
+ private static final String PATH_RESOURCE_WEB_XML = "webxml/";
+
+ /**
+ * Path, relative to the resources base, of a test web.xml
+ */
+ private static final String PATH_ACTUAL_WEB_XML = PATH_RESOURCE_WEB_XML + "servletForwardingToJsp.xml";
+
+ /**
+ * Filename of a test queue *-service.xml
+ */
+ private static final String FILENAME_QUEUE_SERVICE_XML = "mdb-queue-service.xml";
+
+ /**
+ * Path, relative to the resources base, of a test queue *-service.xml
+ */
+ private static final String PATH_QUEUE_SERVICE_XML = "queues/" + FILENAME_QUEUE_SERVICE_XML;
+
+ /**
+ * Path, relative to the resources base, of a test JSP
+ */
+ private static final String PATH_JSP = "jsp/requestParamEcho.jsp";
+
+ /**
+ * Path, relative to the resources base, of a persistence.xml file for Embedded DataSource
+ */
+ private static final String PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED = "persistence/persistenceEmbedded.xml";
+
+ /**
+ * Path, relative to the deployment root, of a persistence.xml file
+ */
+ private static final String PATH_DESTINATION_PERSISTENCE_XML = "persistence.xml";
+
+ /**
+ * Path, relative to the resources base, of the directory containing DataSource resources
+ */
+ private static final String PATH_RESOURCE_DS_XMLs = "datasources/";
+
+ /**
+ * Filename of the Embedded DataSource deployment XML
+ */
+ private static final String FILENAME_EMBEDDED_DS = "embedded-ds.xml";
+
+ /**
+ * Path, relative to the resources base, of the directory containing DataSource resources
+ */
+ private static final String PATH_RESOURCE_DS_XML_EMBEDDED = PATH_RESOURCE_DS_XMLs + FILENAME_EMBEDDED_DS;
+
+ /**
+ * Separator character within archives
+ */
+ private static final char SEPARATOR = '/';
+
+ /**
+ * The JNDI Context
+ */
+ private static Context NAMING_CONTEXT;
+
+ /**
+ * Name of the Queue Connection Factory in JNDI
+ */
+ private static final String JNDI_NAME_CONNECTION_FACTORY = "ConnectionFactory";
+
+ /**
+ * JNDI name suffix appended to local business EJB3 views
+ */
+ private static final String JNDI_SUFFIX_LOCAL_BUSINESS = "/local";
+
+ /**
+ * Name of the server configuration to use
+ */
+ private static final String NAME_SERVER_CONFIG = "all";
+
+ /**
+ * Path, relative to test resources of web.xml used to deploy a werservice war
+ */
+ private static final String PATH_ACTUAL_WEB_XML_WS = PATH_RESOURCE_WEB_XML + "webservice-web.xml";
+
+ private static final String WS_REQUEST_PARAMETER = "jboss embedded user";
+
+ private static final String WS_RESPONSE = "hello " + WS_REQUEST_PARAMETER;
+
+ /**
+ * Relative path to the MC Descriptor for the State Reporting Bean
+ */
+ private static final String PATH_STATEREPORTING_BEAN = "mc/statereporter-jboss-beans.xml";
+
+ /**
+ * MC Name (Context) of the State Reporting Bean
+ */
+ private static final String MC_NAME_STATEREPORTING_BEAN = "org.jboss.embedded.test.StateReporter";
+
+ //-------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Starts up the Application Server. Relies upon either Environment
+ * Variable "JBOSS_HOME" or System Property "jboss.home" being set, with
+ * precedence to the system property
+ */
+ @BeforeClass
+ public static void startEmbedddedASAndSetNamingContext() throws Exception
+ {
+ // Make Server (will pull JBOSS_HOME from env var or sys prop)
+ server = JBossASEmbeddedServerFactory.createServer();
+ log.info("Created: " + server);
+
+ // Start
+ log.info("Starting Server: " + server);
+ server.getConfiguration().serverName(NAME_SERVER_CONFIG);
+ server.start();
+ log.info("...started.");
+
+ // Set Naming Context
+ NAMING_CONTEXT = new InitialContext();
+ }
+
+ /**
+ * Shuts down the Application Server after the suite ends
+ */
+ @AfterClass
+ public static void stopEmbeddedAS() throws Exception
+ {
+ // If exists and started
+ if (server != null && server.getState().equals(LifecycleState.STARTED))
+ {
+ // Shutdown
+ log.info("Shutting down server: " + server);
+ server.shutdown();
+ }
+
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Tests EJB3 Stateless Session Beans via a virtual archive
+ * deployment
+ */
+ @Test
+ public void testSlsb() throws Exception
+ {
+ // Log
+ log.info("testSlsb");
+
+ // Make a deployment
+ final String name = "slsb.jar";
+ final JavaArchive archive = Archives.create(name, JavaArchive.class).addClasses(OutputBean.class,
+ OutputLocalBusiness.class);
+ log.info(archive.toString(true));
+ // Deploy
+ server.deploy(archive);
+
+ // Test
+ final OutputLocalBusiness bean = (OutputLocalBusiness) NAMING_CONTEXT.lookup(OutputBean.class.getSimpleName()
+ + JNDI_SUFFIX_LOCAL_BUSINESS);;
+ final String output = bean.getOutput();
+ log.info("Got output: " + output);
+ Assert.assertEquals(OutputLocalBusiness.OUTPUT, output);
+
+ // Undeploy
+ server.undeploy(archive);
+
+ }
+
+ /**
+ * Tests deployment of a virtual WAR containing a servlet
+ * and JSP.
+ *
+ * The Servlet will forward to the JSP path denoted by request param
+ * "jsp". The JSP will echo the value of request param "echo".
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWarServletJsp() throws Exception
+ {
+ // Log
+ log.info("testWarServletJsp");
+
+ // Make a deployment
+ final String appName = "testServletJsp";
+ final String name = appName + ".war";
+ final Class<?> servletClass = JspForwardingServlet.class;
+ final WebArchive archive = Archives.create(name, WebArchive.class);
+ final Path targetPathWebXml = new BasicPath("web.xml");
+ archive.addWebResource(PATH_ACTUAL_WEB_XML, targetPathWebXml).addResource(PATH_JSP).addClass(servletClass);
+ log.info(archive.toString(true));
+
+ // Deploy
+ server.deploy(archive);
+
+ // Get an HTTP Client
+ final HttpClient client = new DefaultHttpClient();
+
+ // Make an HTTP Request
+ final String echoValue = "EmbeddedBiatch";
+ final List<NameValuePair> params = new ArrayList<NameValuePair>();
+ params.add(new BasicNameValuePair("jsp", PATH_JSP));
+ params.add(new BasicNameValuePair("echo", echoValue));
+ final URI uri = URIUtils.createURI("http", "localhost", 8080, appName + SEPARATOR + servletClass.getSimpleName(),
+ URLEncodedUtils.format(params, "UTF-8"), null);
+ final HttpGet request = new HttpGet(uri);
+
+ // Execute the request
+ log.info("Executing request to: " + request.getURI());
+ final HttpResponse response = client.execute(request);
+ final HttpEntity entity = response.getEntity();
+ if (entity == null)
+ {
+ TestCase.fail("Request returned no entity");
+ }
+
+ // Read the result, ensure it's what we're expecting (should be the value of request param "echo")
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ final String line = reader.readLine();
+ log.info("Got response: " + line);
+ Assert.assertEquals(echoValue, line);
+
+ // Undeploy
+ server.undeploy(archive);
+ }
+
+ /**
+ * Tests deployment of a JMS Queue with EJB3 MDB Listener
+ *
+ * The MDB will simply store the text of the message in a publicly-accessible
+ * static field
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testJmsAndMdb() throws Exception
+ {
+ // Log
+ log.info("testJmsAndMdb");
+
+ // Create a virtual archive for the MDB deployment
+ final String name = "jms-mdb-test.jar";
+ final JavaArchive archive = Archives.create(name, JavaArchive.class);
+ final Path queuesTargetPath = new BasicPath(FILENAME_QUEUE_SERVICE_XML);
+ archive.addClass(MessageStoringMdb.class).addResource(PATH_QUEUE_SERVICE_XML, queuesTargetPath);
+
+ // Deploy
+ log.info(archive.toString(true));
+ server.deploy(archive);
+
+ // Define a String message to send
+ final String message = "From in-JVM Test Message";
+
+ // Send the message
+ this.sendTextMessageToQueue(message, MessageStoringMdb.NAME_QUEUE);
+
+ // Wait on the MDB to process
+ try
+ {
+ MessageStoringMdb.BARRIER.await(10, TimeUnit.SECONDS);
+ }
+ catch (final InterruptedException e)
+ {
+ // Clear the flag
+ Thread.interrupted();
+ // Throw up
+ throw e;
+ }
+ catch (final TimeoutException e)
+ {
+ TestCase.fail("The MDB did not process the message in the allotted time");
+ }
+
+ // Get the contents of the String from the MDB
+ final String received = MessageStoringMdb.LAST_MESSAGE_CONTENTS;
+
+ // Ensure equal
+ Assert.assertEquals("The test message received was not as expected", message, received);
+
+ // Undeploy
+ server.undeploy(archive);
+
+ }
+
+ /**
+ * Tests deployment of a JCA DataSource and EJB3 Entity Bean (JPA)
+ *
+ * A test SLSB will also be used to create a few rows in the DB,
+ * then obtain all.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDataSourceAndEntity() throws Exception
+ {
+ // Log
+ log.info("testDataSourceAndEntity");
+
+ // Create a virtual archive for DS, persistence.xml, Entity, and SLSB
+ final String name = "datasource-entity-test.jar";
+ final Path targetDsPath = new BasicPath(FILENAME_EMBEDDED_DS); //TODO Use factory when available
+ final Path targetPersistencePath = new BasicPath(PATH_DESTINATION_PERSISTENCE_XML); //TODO Use factory when available
+ final JavaArchive archive = Archives.create(name, JavaArchive.class);
+ archive.addClasses(Jbossian.class, JbossianRegistrarLocalBusiness.class, JbossianRegistrarBean.class)
+ .addResource(PATH_RESOURCE_DS_XML_EMBEDDED, targetDsPath).addManifestResource(
+ PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED, targetPersistencePath);
+
+ // Deploy
+ log.info(archive.toString(true));
+ server.deploy(archive);
+
+ // Make some JBossians
+ final Jbossian jgreene = new Jbossian("Jason T. Greene", "AS Hole", 12);
+ final Jbossian jpederse = new Jbossian("Jesper Pedersen", "Professional Tattletale", 21);
+ final Jbossian dmlloyd = new Jbossian("David M. Lloyd", "???????", 15);
+ final Jbossian wolfc = new Jbossian("Carlo de Wolf", "Superlead", 13);
+ final Jbossian alr = new Jbossian("Andew Lee Rubinger", "The New Fluery", 58);
+ final Jbossian asaldhan = new Jbossian("Anil Saldhana", "Karma Police", 23);
+
+ // Get an SLSB to interact w/ the DB
+ final JbossianRegistrarLocalBusiness slsb = (JbossianRegistrarLocalBusiness) NAMING_CONTEXT
+ .lookup(JbossianRegistrarBean.class.getSimpleName() + JNDI_SUFFIX_LOCAL_BUSINESS);
+
+ // Add the JBossians
+ slsb.add(jgreene);
+ slsb.add(jpederse);
+ slsb.add(dmlloyd);
+ slsb.add(wolfc);
+ slsb.add(alr);
+ slsb.add(asaldhan);
+
+ // Get all
+ final Collection<Jbossian> jbossians = slsb.getAllJbossians();
+ log.info("Got all JBossians: " + jbossians);
+
+ // Test
+ Assert.assertEquals(6, jbossians.size());
+
+ // Undeploy
+ server.undeploy(archive);
+ }
+
+ /**
+ * Ensures WS is working as expected
+ *
+ * EMB-61
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWs() throws Exception
+ {
+
+ // Make a deployment
+ final String appName = "webservice";
+ final String name = appName + ".war";
+ final WebArchive archive = Archives.create(name, WebArchive.class);
+ final String targetPathWebXml = "web.xml";
+ archive.addWebResource(PATH_ACTUAL_WEB_XML_WS, targetPathWebXml).addClass(
+ org.jboss.embedded.testsuite.ws.EmbeddedWs.class);
+ // Deploy
+ log.info(archive.toString(true));
+ server.deploy(archive);
+
+ // consume the webservice
+ org.jboss.embedded.testsuite.wsclient.Embedded embeddedService = new org.jboss.embedded.testsuite.wsclient.Embedded();
+ log.info("Create Web Service client...");
+ org.jboss.embedded.testsuite.wsclient.EmbeddedWs port = embeddedService.getEmbeddedWsPort();
+ log.info("Call Web Service Operation...");
+ String wsResponse = port.hello("jboss embedded user");
+ log.info("Web service response: " + wsResponse);
+ Assert.assertEquals(WS_RESPONSE, wsResponse);
+
+ // Undeploy
+ server.undeploy(archive);
+ }
+
+ /**
+ * Ensures that a URL may be deployed and undeployed
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testUrlDeployment() throws Exception
+ {
+ // Get a URL
+ final URL url = this.getMcBeanDescriptor();
+
+ // Deploy it
+ server.deploy(url);
+
+ // Lookup the bean
+ final String context = MC_NAME_STATEREPORTING_BEAN;
+ final StateReportingBean bean = (StateReportingBean) ((JBossASEmbeddedServerImpl) server).getKernel()
+ .getController().getInstalledContext(context).getTarget();
+ TestCase.assertNotNull("Bean was not found installed in expected context: " + context, bean);
+
+ // Ensure started
+ TestCase.assertEquals("Bean should be started after installation", StateReportingBean.State.STARTED, bean
+ .getState());
+
+ // Undeploy
+ server.undeploy(url);
+
+ // Ensure stopped
+ TestCase.assertEquals("Bean should be stopped after undeploy", StateReportingBean.State.STOPPED, bean.getState());
+ }
+
+ /**
+ * Ensures that a File may be deployed and undeployed
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFileDeployment() throws Exception
+ {
+ // Get a File
+ final File file = new File(this.getMcBeanDescriptor().toURI());
+
+ // Deploy it
+ server.deploy(file);
+
+ // Lookup the bean
+ final String context = MC_NAME_STATEREPORTING_BEAN;
+ final StateReportingBean bean = (StateReportingBean) ((JBossASEmbeddedServerImpl) server).getKernel()
+ .getController().getInstalledContext(context).getTarget();
+ TestCase.assertNotNull("Bean was not found installed in expected context: " + context, bean);
+
+ // Ensure started
+ TestCase.assertEquals("Bean should be started after installation", StateReportingBean.State.STARTED, bean
+ .getState());
+
+ // Undeploy
+ server.undeploy(file);
+
+ // Ensure stopped
+ TestCase.assertEquals("Bean should be stopped after undeploy", StateReportingBean.State.STOPPED, bean.getState());
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the URL of the MC Bean Descriptor for
+ * the State Reporting Bean
+ */
+ private URL getMcBeanDescriptor()
+ {
+ return this.getClass().getClassLoader().getResource(PATH_STATEREPORTING_BEAN);
+ }
+
+ /**
+ * Sends a JMS {@link TextMessage} containing the specified contents to the
+ * queue of the specified name
+ *
+ * @param contents
+ * @param queueName
+ * @throws Exception
+ * @throws IllegalArgumentException If either argument is not provided
+ */
+ private void sendTextMessageToQueue(final String contents, final String queueName) throws Exception,
+ IllegalArgumentException
+ {
+ // Precondition check
+ if (contents == null || contents.length() == 0)
+ {
+ throw new IllegalArgumentException("contents must be provided");
+ }
+ if (queueName == null || queueName.length() == 0)
+ {
+ throw new IllegalArgumentException("queueName must be provided");
+ }
+
+ // Get the queue from JNDI
+ final Queue queue = (Queue) NAMING_CONTEXT.lookup(queueName);
+
+ // Get the ConnectionFactory from JNDI
+ final QueueConnectionFactory factory = (QueueConnectionFactory) NAMING_CONTEXT
+ .lookup(JNDI_NAME_CONNECTION_FACTORY);
+
+ // Make a Connection
+ final QueueConnection connection = factory.createQueueConnection();
+ final QueueSession sendSession = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+ // Make the message
+ final TextMessage message = sendSession.createTextMessage(contents);
+
+ // Send the message
+ final QueueSender sender = sendSession.createSender(queue);
+ sender.send(message);
+ log.info("Sent message " + message + " with contents: " + contents);
+
+ // Clean up
+ sendSession.close();
+ connection.close();
+ }
+}
Deleted: projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerTestCase.java
===================================================================
--- projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerTestCase.java 2009-11-23 21:17:04 UTC (rev 96758)
+++ projects/embedded/trunk/testsuite/src/test/java/org/jboss/embedded/testsuite/ServerTestCase.java 2009-11-23 21:18:59 UTC (rev 96759)
@@ -1,607 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.embedded.testsuite;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Logger;
-
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIUtils;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.message.BasicNameValuePair;
-import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.embedded.api.server.JBossASEmbeddedServer;
-import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
-import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
-import org.jboss.embedded.testsuite.ejb3.entity.Jbossian;
-import org.jboss.embedded.testsuite.ejb3.entity.JbossianRegistrarBean;
-import org.jboss.embedded.testsuite.ejb3.entity.JbossianRegistrarLocalBusiness;
-import org.jboss.embedded.testsuite.ejb3.mdb.MessageStoringMdb;
-import org.jboss.embedded.testsuite.ejb3.slsb.OutputBean;
-import org.jboss.embedded.testsuite.ejb3.slsb.OutputLocalBusiness;
-import org.jboss.embedded.testsuite.mc.StateReportingBean;
-import org.jboss.embedded.testsuite.servlet.JspForwardingServlet;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.Path;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * ServerTestCase
- *
- * End-user view of the Embedded Server. Tests here should include lifecycle
- * to start/stop the server, and checks to ensure that
- * subsystems are working as expected.
- *
- * This is a high-level integration test for the Application
- * Server running in Embedded mode
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ServerTestCase
-{
-
- //-------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(ServerTestCase.class.getName());
-
- /**
- * The server instance
- */
- private static JBossASEmbeddedServer server;
-
- /**
- * Path, relative to the resources base, of the directory containing web.xml descriptor for tests
- */
- private static final String PATH_RESOURCE_WEB_XML = "webxml/";
-
- /**
- * Path, relative to the resources base, of a test web.xml
- */
- private static final String PATH_ACTUAL_WEB_XML = PATH_RESOURCE_WEB_XML + "servletForwardingToJsp.xml";
-
- /**
- * Filename of a test queue *-service.xml
- */
- private static final String FILENAME_QUEUE_SERVICE_XML = "mdb-queue-service.xml";
-
- /**
- * Path, relative to the resources base, of a test queue *-service.xml
- */
- private static final String PATH_QUEUE_SERVICE_XML = "queues/" + FILENAME_QUEUE_SERVICE_XML;
-
- /**
- * Path, relative to the resources base, of a test JSP
- */
- private static final String PATH_JSP = "jsp/requestParamEcho.jsp";
-
- /**
- * Path, relative to the resources base, of a persistence.xml file for Embedded DataSource
- */
- private static final String PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED = "persistence/persistenceEmbedded.xml";
-
- /**
- * Path, relative to the deployment root, of a persistence.xml file
- */
- private static final String PATH_DESTINATION_PERSISTENCE_XML = "persistence.xml";
-
- /**
- * Path, relative to the resources base, of the directory containing DataSource resources
- */
- private static final String PATH_RESOURCE_DS_XMLs = "datasources/";
-
- /**
- * Filename of the Embedded DataSource deployment XML
- */
- private static final String FILENAME_EMBEDDED_DS = "embedded-ds.xml";
-
- /**
- * Path, relative to the resources base, of the directory containing DataSource resources
- */
- private static final String PATH_RESOURCE_DS_XML_EMBEDDED = PATH_RESOURCE_DS_XMLs + FILENAME_EMBEDDED_DS;
-
- /**
- * Separator character within archives
- */
- private static final char SEPARATOR = '/';
-
- /**
- * The JNDI Context
- */
- private static Context NAMING_CONTEXT;
-
- /**
- * Name of the Queue Connection Factory in JNDI
- */
- private static final String JNDI_NAME_CONNECTION_FACTORY = "ConnectionFactory";
-
- /**
- * JNDI name suffix appended to local business EJB3 views
- */
- private static final String JNDI_SUFFIX_LOCAL_BUSINESS = "/local";
-
- /**
- * Name of the server configuration to use
- */
- private static final String NAME_SERVER_CONFIG = "all";
-
- /**
- * Path, relative to test resources of web.xml used to deploy a werservice war
- */
- private static final String PATH_ACTUAL_WEB_XML_WS = PATH_RESOURCE_WEB_XML + "webservice-web.xml";
-
- private static final String WS_REQUEST_PARAMETER = "jboss embedded user";
-
- private static final String WS_RESPONSE = "hello " + WS_REQUEST_PARAMETER;
-
- /**
- * Relative path to the MC Descriptor for the State Reporting Bean
- */
- private static final String PATH_STATEREPORTING_BEAN = "mc/statereporter-jboss-beans.xml";
-
- /**
- * MC Name (Context) of the State Reporting Bean
- */
- private static final String MC_NAME_STATEREPORTING_BEAN = "org.jboss.embedded.test.StateReporter";
-
- //-------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Starts up the Application Server. Relies upon either Environment
- * Variable "JBOSS_HOME" or System Property "jboss.home" being set, with
- * precedence to the system property
- */
- @BeforeClass
- public static void startEmbedddedASAndSetNamingContext() throws Exception
- {
- // Make Server (will pull JBOSS_HOME from env var or sys prop)
- server = JBossASEmbeddedServerFactory.createServer();
- log.info("Created: " + server);
-
- // Start
- log.info("Starting Server: " + server);
- server.getConfiguration().serverName(NAME_SERVER_CONFIG);
- server.start();
- log.info("...started.");
-
- // Set Naming Context
- NAMING_CONTEXT = new InitialContext();
- }
-
- /**
- * Shuts down the Application Server after the suite ends
- */
- @AfterClass
- public static void stopEmbeddedAS() throws Exception
- {
- // If exists and started
- if (server != null && server.getState().equals(LifecycleState.STARTED))
- {
- // Shutdown
- log.info("Shutting down server: " + server);
- server.shutdown();
- }
-
- }
-
- //-------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Tests EJB3 Stateless Session Beans via a virtual archive
- * deployment
- */
- @Test
- public void testSlsb() throws Exception
- {
- // Log
- log.info("testSlsb");
-
- // Make a deployment
- final String name = "slsb.jar";
- final JavaArchive archive = Archives.create(name, JavaArchive.class).addClasses(OutputBean.class,
- OutputLocalBusiness.class);
- log.info(archive.toString(true));
- // Deploy
- server.deploy(archive);
-
- // Test
- final OutputLocalBusiness bean = (OutputLocalBusiness) NAMING_CONTEXT.lookup(OutputBean.class.getSimpleName()
- + JNDI_SUFFIX_LOCAL_BUSINESS);;
- final String output = bean.getOutput();
- log.info("Got output: " + output);
- Assert.assertEquals(OutputLocalBusiness.OUTPUT, output);
-
- // Undeploy
- server.undeploy(archive);
-
- }
-
- /**
- * Tests deployment of a virtual WAR containing a servlet
- * and JSP.
- *
- * The Servlet will forward to the JSP path denoted by request param
- * "jsp". The JSP will echo the value of request param "echo".
- *
- * @throws Exception
- */
- @Test
- public void testWarServletJsp() throws Exception
- {
- // Log
- log.info("testWarServletJsp");
-
- // Make a deployment
- final String appName = "testServletJsp";
- final String name = appName + ".war";
- final Class<?> servletClass = JspForwardingServlet.class;
- final WebArchive archive = Archives.create(name, WebArchive.class);
- final Path targetPathWebXml = new BasicPath("web.xml");
- archive.addWebResource(PATH_ACTUAL_WEB_XML, targetPathWebXml).addResource(PATH_JSP).addClass(servletClass);
- log.info(archive.toString(true));
-
- // Deploy
- server.deploy(archive);
-
- // Get an HTTP Client
- final HttpClient client = new DefaultHttpClient();
-
- // Make an HTTP Request
- final String echoValue = "EmbeddedBiatch";
- final List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new BasicNameValuePair("jsp", PATH_JSP));
- params.add(new BasicNameValuePair("echo", echoValue));
- final URI uri = URIUtils.createURI("http", "localhost", 8080, appName + SEPARATOR + servletClass.getSimpleName(),
- URLEncodedUtils.format(params, "UTF-8"), null);
- final HttpGet request = new HttpGet(uri);
-
- // Execute the request
- log.info("Executing request to: " + request.getURI());
- final HttpResponse response = client.execute(request);
- final HttpEntity entity = response.getEntity();
- if (entity == null)
- {
- TestCase.fail("Request returned no entity");
- }
-
- // Read the result, ensure it's what we're expecting (should be the value of request param "echo")
- final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
- final String line = reader.readLine();
- log.info("Got response: " + line);
- Assert.assertEquals(echoValue, line);
-
- // Undeploy
- server.undeploy(archive);
- }
-
- /**
- * Tests deployment of a JMS Queue with EJB3 MDB Listener
- *
- * The MDB will simply store the text of the message in a publicly-accessible
- * static field
- *
- * @throws Exception
- */
- @Test
- public void testJmsAndMdb() throws Exception
- {
- // Log
- log.info("testJmsAndMdb");
-
- // Create a virtual archive for the MDB deployment
- final String name = "jms-mdb-test.jar";
- final JavaArchive archive = Archives.create(name, JavaArchive.class);
- final Path queuesTargetPath = new BasicPath(FILENAME_QUEUE_SERVICE_XML);
- archive.addClass(MessageStoringMdb.class).addResource(PATH_QUEUE_SERVICE_XML, queuesTargetPath);
-
- // Deploy
- log.info(archive.toString(true));
- server.deploy(archive);
-
- // Define a String message to send
- final String message = "From in-JVM Test Message";
-
- // Send the message
- this.sendTextMessageToQueue(message, MessageStoringMdb.NAME_QUEUE);
-
- // Wait on the MDB to process
- try
- {
- MessageStoringMdb.BARRIER.await(10, TimeUnit.SECONDS);
- }
- catch (final InterruptedException e)
- {
- // Clear the flag
- Thread.interrupted();
- // Throw up
- throw e;
- }
- catch (final TimeoutException e)
- {
- TestCase.fail("The MDB did not process the message in the allotted time");
- }
-
- // Get the contents of the String from the MDB
- final String received = MessageStoringMdb.LAST_MESSAGE_CONTENTS;
-
- // Ensure equal
- Assert.assertEquals("The test message received was not as expected", message, received);
-
- // Undeploy
- server.undeploy(archive);
-
- }
-
- /**
- * Tests deployment of a JCA DataSource and EJB3 Entity Bean (JPA)
- *
- * A test SLSB will also be used to create a few rows in the DB,
- * then obtain all.
- *
- * @throws Exception
- */
- @Test
- public void testDataSourceAndEntity() throws Exception
- {
- // Log
- log.info("testDataSourceAndEntity");
-
- // Create a virtual archive for DS, persistence.xml, Entity, and SLSB
- final String name = "datasource-entity-test.jar";
- final Path targetDsPath = new BasicPath(FILENAME_EMBEDDED_DS); //TODO Use factory when available
- final Path targetPersistencePath = new BasicPath(PATH_DESTINATION_PERSISTENCE_XML); //TODO Use factory when available
- final JavaArchive archive = Archives.create(name, JavaArchive.class);
- archive.addClasses(Jbossian.class, JbossianRegistrarLocalBusiness.class, JbossianRegistrarBean.class)
- .addResource(PATH_RESOURCE_DS_XML_EMBEDDED, targetDsPath).addManifestResource(
- PATH_RESOURCE_PERSISTENCE_XML_EMBEDDED, targetPersistencePath);
-
- // Deploy
- log.info(archive.toString(true));
- server.deploy(archive);
-
- // Make some JBossians
- final Jbossian jgreene = new Jbossian("Jason T. Greene", "AS Hole", 12);
- final Jbossian jpederse = new Jbossian("Jesper Pedersen", "Professional Tattletale", 21);
- final Jbossian dmlloyd = new Jbossian("David M. Lloyd", "???????", 15);
- final Jbossian wolfc = new Jbossian("Carlo de Wolf", "Superlead", 13);
- final Jbossian alr = new Jbossian("Andew Lee Rubinger", "The New Fluery", 58);
- final Jbossian asaldhan = new Jbossian("Anil Saldhana", "Karma Police", 23);
-
- // Get an SLSB to interact w/ the DB
- final JbossianRegistrarLocalBusiness slsb = (JbossianRegistrarLocalBusiness) NAMING_CONTEXT
- .lookup(JbossianRegistrarBean.class.getSimpleName() + JNDI_SUFFIX_LOCAL_BUSINESS);
-
- // Add the JBossians
- slsb.add(jgreene);
- slsb.add(jpederse);
- slsb.add(dmlloyd);
- slsb.add(wolfc);
- slsb.add(alr);
- slsb.add(asaldhan);
-
- // Get all
- final Collection<Jbossian> jbossians = slsb.getAllJbossians();
- log.info("Got all JBossians: " + jbossians);
-
- // Test
- Assert.assertEquals(6, jbossians.size());
-
- // Undeploy
- server.undeploy(archive);
- }
-
- /**
- * Ensures WS is working as expected
- *
- * EMB-61
- *
- * @throws Exception
- */
- @Test
- public void testWs() throws Exception
- {
-
- // Make a deployment
- final String appName = "webservice";
- final String name = appName + ".war";
- final WebArchive archive = Archives.create(name, WebArchive.class);
- final String targetPathWebXml = "web.xml";
- archive.addWebResource(PATH_ACTUAL_WEB_XML_WS, targetPathWebXml).addClass(
- org.jboss.embedded.testsuite.ws.EmbeddedWs.class);
- // Deploy
- log.info(archive.toString(true));
- server.deploy(archive);
-
- // consume the webservice
- org.jboss.embedded.testsuite.wsclient.Embedded embeddedService = new org.jboss.embedded.testsuite.wsclient.Embedded();
- log.info("Create Web Service client...");
- org.jboss.embedded.testsuite.wsclient.EmbeddedWs port = embeddedService.getEmbeddedWsPort();
- log.info("Call Web Service Operation...");
- String wsResponse = port.hello("jboss embedded user");
- log.info("Web service response: " + wsResponse);
- Assert.assertEquals(WS_RESPONSE, wsResponse);
-
- // Undeploy
- server.undeploy(archive);
- }
-
- /**
- * Ensures that a URL may be deployed and undeployed
- *
- * @throws Exception
- */
- @Test
- public void testUrlDeployment() throws Exception
- {
- // Get a URL
- final URL url = this.getMcBeanDescriptor();
-
- // Deploy it
- server.deploy(url);
-
- // Lookup the bean
- final String context = MC_NAME_STATEREPORTING_BEAN;
- final StateReportingBean bean = (StateReportingBean) ((JBossASEmbeddedServerImpl) server).getKernel()
- .getController().getInstalledContext(context).getTarget();
- TestCase.assertNotNull("Bean was not found installed in expected context: " + context, bean);
-
- // Ensure started
- TestCase.assertEquals("Bean should be started after installation", StateReportingBean.State.STARTED, bean
- .getState());
-
- // Undeploy
- server.undeploy(url);
-
- // Ensure stopped
- TestCase.assertEquals("Bean should be stopped after undeploy", StateReportingBean.State.STOPPED, bean.getState());
- }
-
- /**
- * Ensures that a File may be deployed and undeployed
- *
- * @throws Exception
- */
- @Test
- public void testFileDeployment() throws Exception
- {
- // Get a File
- final File file = new File(this.getMcBeanDescriptor().toURI());
-
- // Deploy it
- server.deploy(file);
-
- // Lookup the bean
- final String context = MC_NAME_STATEREPORTING_BEAN;
- final StateReportingBean bean = (StateReportingBean) ((JBossASEmbeddedServerImpl) server).getKernel()
- .getController().getInstalledContext(context).getTarget();
- TestCase.assertNotNull("Bean was not found installed in expected context: " + context, bean);
-
- // Ensure started
- TestCase.assertEquals("Bean should be started after installation", StateReportingBean.State.STARTED, bean
- .getState());
-
- // Undeploy
- server.undeploy(file);
-
- // Ensure stopped
- TestCase.assertEquals("Bean should be stopped after undeploy", StateReportingBean.State.STOPPED, bean.getState());
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the URL of the MC Bean Descriptor for
- * the State Reporting Bean
- */
- private URL getMcBeanDescriptor()
- {
- return this.getClass().getClassLoader().getResource(PATH_STATEREPORTING_BEAN);
- }
-
- /**
- * Sends a JMS {@link TextMessage} containing the specified contents to the
- * queue of the specified name
- *
- * @param contents
- * @param queueName
- * @throws Exception
- * @throws IllegalArgumentException If either argument is not provided
- */
- private void sendTextMessageToQueue(final String contents, final String queueName) throws Exception,
- IllegalArgumentException
- {
- // Precondition check
- if (contents == null || contents.length() == 0)
- {
- throw new IllegalArgumentException("contents must be provided");
- }
- if (queueName == null || queueName.length() == 0)
- {
- throw new IllegalArgumentException("queueName must be provided");
- }
-
- // Get the queue from JNDI
- final Queue queue = (Queue) NAMING_CONTEXT.lookup(queueName);
-
- // Get the ConnectionFactory from JNDI
- final QueueConnectionFactory factory = (QueueConnectionFactory) NAMING_CONTEXT
- .lookup(JNDI_NAME_CONNECTION_FACTORY);
-
- // Make a Connection
- final QueueConnection connection = factory.createQueueConnection();
- final QueueSession sendSession = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-
- // Make the message
- final TextMessage message = sendSession.createTextMessage(contents);
-
- // Send the message
- final QueueSender sender = sendSession.createSender(queue);
- sender.send(message);
- log.info("Sent message " + message + " with contents: " + contents);
-
- // Clean up
- sendSession.close();
- connection.close();
- }
-}
More information about the jboss-cvs-commits
mailing list