[jboss-cvs] JBossAS SVN: r110760 - in trunk/testsuite: src/main/org/jboss/test/ejb3 and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 24 08:12:58 EST 2011


Author: darran.lofthouse at jboss.com
Date: 2011-02-24 08:12:58 -0500 (Thu, 24 Feb 2011)
New Revision: 110760

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/
   trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
   trunk/testsuite/src/resources/ejb3/jbas7883/
   trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
Modified:
   trunk/testsuite/imports/sections/ejb3.xml
Log:
[JBAS-7883] Test Case - When multiple mail services are deployed they all share the same settings.


Modified: trunk/testsuite/imports/sections/ejb3.xml
===================================================================
--- trunk/testsuite/imports/sections/ejb3.xml	2011-02-24 13:11:40 UTC (rev 110759)
+++ trunk/testsuite/imports/sections/ejb3.xml	2011-02-24 13:12:58 UTC (rev 110760)
@@ -45,6 +45,14 @@
       </jar>
    </target>
 
+   <target name="jbas7883" depends="compile">
+      <mkdir dir="${build.lib}" />
+      <jar destfile="${build.lib}/jbas7883.jar">
+         <fileset dir="${build.classes}" includes="org/jboss/test/ejb3/jbas7883/*"/>
+      </jar>
+   	  <copy file="${source.resources}/ejb3/jbas7883/jbas7883-service.xml" todir="${build.lib}" />
+   </target>	
+	
    <!-- This issue affected the ejb3 AS module -->
    <target name="ejbthree1597" depends="compile">
       <mkdir dir="${build.lib}"/>
@@ -226,6 +234,7 @@
    <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,
       jbas7526,
       jbas7556,
+   	  jbas7883,
       ejbthree1597,ejbthree7376, jboss51xsd, ejb31nointerface, ejb3war, jbpapp3026, ejb31singleton,ejb31async, 
       ejb3-portable-jndi-names">
       <mkdir dir="${build.lib}" />

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	2011-02-24 13:12:58 UTC (rev 110760)
@@ -0,0 +1,64 @@
+package org.jboss.test.ejb3.jbas7883;
+
+import java.util.Properties;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.mail.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+/**
+ * 
+ * @author Darran Lofthouse darran.lofthouse at jboss.com
+ * @see https://issues.jboss.org/browse/JBAS-7883
+ */
+ at Stateless
+public class TestBean implements TestRemote
+{
+
+   @Resource(name = "mail1", mappedName = "mail/Mail1")
+   private Session resourceOne;
+
+   @Resource(name = "mail2", mappedName = "mail/Mail2")
+   private Session resourceTwo;
+
+   public String testResourceOne()
+   {
+      return getHost(resourceOne);
+   }
+
+   public String testResourceTwo()
+   {
+      return getHost(resourceTwo);
+   }
+
+   @Override
+   public String testCall(String contextName, String jndiName)
+   {
+      try
+      {
+         Context ctx = new InitialContext();
+         if (contextName != null && contextName.length() > 0)
+         {
+            ctx = (Context) ctx.lookup(contextName);
+         }
+
+         Session s = (Session) PortableRemoteObject.narrow(ctx.lookup(jndiName), Session.class);
+         return getHost(s);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Test Failed", e);
+      }
+   }
+
+   private String getHost(final Session session)
+   {
+      Properties props = session.getProperties();
+      
+      return props.getProperty("mail.smtp.host");
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + LF

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	2011-02-24 13:12:58 UTC (rev 110760)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.jbas7883;
+
+import javax.ejb.Remote;
+
+/**
+ * 
+ * @author Darran Lofthouse darran.lofthouse at jboss.com
+ * @see https://issues.jboss.org/browse/JBAS-7883
+ */
+ at Remote
+public interface TestRemote
+{
+
+   public String testResourceOne();
+   
+   public String testResourceTwo();
+   
+   public String testCall(final String contextName, final String jndiName);
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + LF

Added: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	2011-02-24 13:12:58 UTC (rev 110760)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.test.ejb3.jbas7883.unit;
+
+import junit.framework.Test;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.ejb3.jbas7883.TestRemote;
+
+/**
+ * 
+ * @author Darran Lofthouse darran.lofthouse at jboss.com
+ * @see https://issues.jboss.org/browse/JBAS-7883
+ */
+public class MailQueryUnitTestCase extends JBossTestCase
+{
+
+   public MailQueryUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testResourceOne() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testResourceOne();
+
+      assertEquals("Expected host name", "1.1.1.1", host);
+   }
+
+   public void testResourceTwo() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testResourceTwo();
+      
+      assertEquals("Expected host name", "2.2.2.2", host);
+   }
+
+   public void testLookupOne() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall(null, "mail/Mail1");
+
+      assertEquals("Expected host name", "1.1.1.1", host);
+   }
+   
+   public void testLookupOne_Env() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall(null, "java:/comp/env/mail1");
+
+      assertEquals("Expected host name", "1.1.1.1", host);
+   }   
+
+   public void testLookupTwo() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall(null, "mail/Mail2");
+
+      assertEquals("Expected host name", "2.2.2.2", host);
+   }
+
+   public void testLookupTwo_Env() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall(null, "java:/comp/env/mail2");
+
+      assertEquals("Expected host name", "2.2.2.2", host);
+   }
+   
+   public void testLookupOne_Context() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall("mail", "Mail1");
+
+      assertEquals("Expected host name", "1.1.1.1", host);
+   }
+
+   public void testLookupTwo_Context() throws Exception
+   {
+      TestRemote bean = (TestRemote) getInitialContext().lookup("TestBean/remote");
+      String host = bean.testCall("mail", "Mail2");
+
+      assertEquals("Expected host name", "2.2.2.2", host);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MailQueryUnitTestCase.class, "jbas7883-service.xml, jbas7883.jar");
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + LF

Added: trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
===================================================================
--- trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	2011-02-24 13:12:58 UTC (rev 110760)
@@ -0,0 +1,30 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+  
+<!DOCTYPE server
+    PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
+    "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
+
+<server>
+
+
+  <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail1">
+    <attribute name="JNDIName">mail/Mail1</attribute>
+    <attribute name="Configuration">
+      <configuration>
+        <property name="mail.transport.protocol" value="smtp" />
+        <property name="mail.smtp.host" value="1.1.1.1" />
+      </configuration>
+    </attribute>
+  </mbean>
+
+  <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail2">
+    <attribute name="JNDIName">mail/Mail2</attribute>
+    <attribute name="Configuration">
+      <configuration>
+        <property name="mail.transport.protocol" value="smtp" />
+        <property name="mail.smtp.host" value="2.2.2.2" />
+      </configuration>
+    </attribute>
+  </mbean>
+
+</server>    
\ No newline at end of file


Property changes on: trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + LF



More information about the jboss-cvs-commits mailing list