[jboss-cvs] JBossAS SVN: r65034 - in trunk/ejb3: src/test/org/jboss/ejb3/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 4 04:20:58 EDT 2007
Author: ALRubinger
Date: 2007-09-04 04:20:57 -0400 (Tue, 04 Sep 2007)
New Revision: 65034
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStateless1040Remote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/unit/RequireDeploymentDescriptorFlagUnitTestCase.java
Modified:
trunk/ejb3/build-test.xml
Log:
EJBTHREE-1040: Unit Tests (Incomplete)
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-09-04 05:32:22 UTC (rev 65033)
+++ trunk/ejb3/build-test.xml 2007-09-04 08:20:57 UTC (rev 65034)
@@ -2123,6 +2123,12 @@
<build-simple-jar name="ejbthree1025"/>
</target>
+
+ <target name="ejbthree1040"
+ description="Builds a simple jar files."
+ depends="compile-classes">
+ <build-simple-jar name="ejbthree1040"/>
+ </target>
<target name="jbas4489"
description="Builds a simple jar files."
@@ -3627,7 +3633,7 @@
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921, ejbthree936,
ejbthree939,
ejbthree953, ejbthree957, ejbthree959, ejbthree963, ejbthree967, ejbthree971, ejbthree973, ejbthree985, ejbthree986,
- ejbthree989, ejbthree1020, ejbthree1023, ejbthree1025,
+ ejbthree989, ejbthree1020, ejbthree1023, ejbthree1025, ejbthree1040,
jaxws,
aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry, security5,
@@ -4558,6 +4564,9 @@
<param name="test" value="ejbthree1025"/>
</antcall>
<antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree1040"/>
+ </antcall>
+ <antcall target="test" inheritRefs="true">
<param name="test" value="statelesscreation"/>
</antcall>
<antcall target="test" inheritRefs="true">
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStateless1040Remote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStateless1040Remote.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStateless1040Remote.java 2007-09-04 08:20:57 UTC (rev 65034)
@@ -0,0 +1,6 @@
+package org.jboss.ejb3.test.ejbthree1040;
+
+public interface TestStateless1040Remote
+{
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStatelessBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/TestStatelessBean.java 2007-09-04 08:20:57 UTC (rev 65034)
@@ -0,0 +1,24 @@
+package org.jboss.ejb3.test.ejbthree1040;
+
+import java.io.Serializable;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+
+ at Stateless
+ at Remote(TestStateless1040Remote.class)
+ at RemoteBinding(jndiBinding = TestStatelessBean.JNDI_BINDING_REMOTE)
+public class TestStatelessBean implements TestStateless1040Remote, Serializable
+{
+
+ // Class Members
+ private static final long serialVersionUID = -5772694054091690784L;
+
+ /**
+ * Expose the JNDI Binding for this Bean
+ */
+ public static final String JNDI_BINDING_REMOTE = "TestStatelessBean/remote";
+
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/unit/RequireDeploymentDescriptorFlagUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/unit/RequireDeploymentDescriptorFlagUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree1040/unit/RequireDeploymentDescriptorFlagUnitTestCase.java 2007-09-04 08:20:57 UTC (rev 65034)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.test.ejbthree1040.unit;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1040.TestStateless1040Remote;
+import org.jboss.ejb3.test.ejbthree1040.TestStatelessBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Unit Tests for EJBTHREE-1040
+ *
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
+ * @version $Revision:64940 $
+ *
+ */
+public final class RequireDeploymentDescriptorFlagUnitTestCase extends JBossTestCase
+{
+
+ // Class Members
+ private static final String TEST_JAR_NAME = "ejbthree1040.jar";
+
+ //TODO Incorrect; available in JMX?
+ private static final String OBJECT_NAME_EJB3_DEPLOYER = "jboss.ejb3:service=EJB3Deployer";
+
+ private static final String ATTRIBUTE_REQUIRE_DEPLOYMENT_DESCRIPTOR = "requireDeploymentDescriptor";
+
+ // Instance Members
+
+ private MBeanServerConnection server = null;
+
+ private ObjectName on = null;
+
+ // Constructor
+ /**
+ * Calls upon super implementation
+ *
+ * @param name Name of the test case
+ */
+ public RequireDeploymentDescriptorFlagUnitTestCase(String name) throws Exception
+ {
+ super(name);
+ }
+
+ // Test Suite
+ /**
+ * Static initializer for the Test Suite
+ */
+ public static Test suite() throws Exception
+ {
+ return JBossTestCase.getDeploySetup(RequireDeploymentDescriptorFlagUnitTestCase.class, null);
+ }
+
+ /**
+ * Undeploys the test JAR, calls super implementation
+ */
+ @Override
+ protected void tearDown() throws Exception
+ {
+ this.undeploy(RequireDeploymentDescriptorFlagUnitTestCase.TEST_JAR_NAME);
+ super.tearDown();
+ }
+
+ /**
+ * Obtains a reference to the server and EJB3 Deployer
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ // Call super implementation
+ super.setUp();
+ // Obtain a reference to the server
+ this.server = this.getServer();
+ // Obtain the EJB3 Deployer
+ this.on = new ObjectName(RequireDeploymentDescriptorFlagUnitTestCase.OBJECT_NAME_EJB3_DEPLOYER);
+ }
+
+ /**
+ * Ensures that deployment of a JAR with no Deployment Descriptors
+ * succeeds in default deployer configuration
+ *
+ * @throws Exception
+ */
+ public void testDeploymentSuccessWithDefaultConfiguration() throws Exception
+ {
+ try
+ {
+ // Attempt to redeploy the JAR
+ this.redeploy(RequireDeploymentDescriptorFlagUnitTestCase.TEST_JAR_NAME);
+
+ // Lookup EJB, attempt cast
+ TestStateless1040Remote stateless = (TestStateless1040Remote) this.getInitialContext().lookup(
+ TestStatelessBean.JNDI_BINDING_REMOTE);
+
+ // If we've reached here, we're good
+ log.info("TEST SUCCESSFUL: testDeploymentSuccessWithDefaultConfiguration, received deployed "
+ + stateless.toString());
+ }
+ // Handle unexpected error and fail the test
+ catch (Throwable t)
+ {
+ log.error(t);
+ JBossTestCase.fail("Exception received: " + t.getClass().getName() + ", with message \"" + t.getMessage()
+ + "\"");
+ }
+ finally
+ {
+ // Remove the Deployment
+ this.undeploy(RequireDeploymentDescriptorFlagUnitTestCase.TEST_JAR_NAME);
+ }
+ }
+
+ /**
+ * Ensures that deployment of a JAR with no Deployment Descriptors
+ * fails when deployer is configured to require either ejb-jar.xml or jboss.xml
+ *
+ * @throws Exception
+ */
+ public void testDeploymentFailureWithRequiredFlagSet() throws Exception
+ {
+
+ // Configure the deployer to require a DD
+ this.setDeployerToRequireDd(true);
+
+ try
+ {
+ // Attempt to redeploy the JAR
+ this.redeploy(RequireDeploymentDescriptorFlagUnitTestCase.TEST_JAR_NAME);
+
+ // Lookup EJB, attempt cast, and determine if deployed
+ TestStateless1040Remote stateless = (TestStateless1040Remote) this.getInitialContext().lookup(
+ TestStatelessBean.JNDI_BINDING_REMOTE);
+
+ // Deployment should have failed
+ JBossTestCase.fail("Expected " + NameNotFoundException.class.getName() + " not encountered for deployment "
+ + stateless.toString());
+ }
+ // Handle unexpected error and fail the test
+ catch (Throwable t)
+ {
+ if (t instanceof NameNotFoundException)
+ {
+ log.info("TEST SUCCESSFUL: " + NameNotFoundException.class.getName()
+ + " encountered as expected for deployment without DD when required by deployer");
+ }
+ }
+ // Regardless of pass/fail, perform the following
+ finally
+ {
+ // Reset the deployer to default configuration
+ this.setDeployerToRequireDd(false);
+
+ // Remove the Deployment
+ this.undeploy(RequireDeploymentDescriptorFlagUnitTestCase.TEST_JAR_NAME);
+ }
+ }
+
+ /**
+ * Ensures that a deployable unit with a jboss.xml file will deploy when the
+ * deployer is configured to require a desployment descriptor
+ */
+ public void testDeploySuccessWithRequiredDdAndJbossXml() throws Exception
+ {
+ throw new RuntimeException("IMPLEMENT");
+ }
+
+ /**
+ * Ensures that a deployable unit with an ejb-jar.xml file will deploy when the
+ * deployer is configured to require a desployment descriptor
+ */
+ public final void testDeploySuccessWithRequiredDdAndEjbJarXml() throws Exception
+ {
+ throw new RuntimeException("IMPLEMENT");
+ }
+
+ // Internal Helper Methods
+
+ /**
+ * Configures the deployer to require or not require a deployment descriptor for deployable units
+ *
+ * @param required If the DD is required
+ */
+ private void setDeployerToRequireDd(boolean required) throws Exception
+ {
+ // Set the flag for the deployer to require a deployment descriptor
+ this.server.setAttribute(this.on, new Attribute(
+ RequireDeploymentDescriptorFlagUnitTestCase.ATTRIBUTE_REQUIRE_DEPLOYMENT_DESCRIPTOR, required
+ ? Boolean.TRUE
+ : Boolean.FALSE));
+ }
+
+}
More information about the jboss-cvs-commits
mailing list