[jboss-cvs] JBossAS SVN: r110763 - in branches/JBPAPP_5_1: testsuite/src/main/org/jboss/test/ejb3 and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 24 09:39:43 EST 2011


Author: darran.lofthouse at jboss.com
Date: 2011-02-24 09:39:42 -0500 (Thu, 24 Feb 2011)
New Revision: 110763

Added:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
   branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/
   branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
Removed:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
   branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
Modified:
   branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml
   branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/MailService.java
   branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/SessionObjectFactory.java
Log:
[JBPAPP-5566] When multiple mail services are deployed they all share the same settings.

Modified: branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml	2011-02-24 14:38:20 UTC (rev 110762)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml	2011-02-24 14:39:42 UTC (rev 110763)
@@ -1,218 +1,229 @@
 <project name="tests-ejb3-jars">
-   <target name="ejb3iiop"
+	<target name="ejb3iiop"
       description="Builds iiop.jar."
       depends="compile">
 
-      <mkdir dir="${build.lib}"/>
+		<mkdir dir="${build.lib}"/>
 
-      <jar jarfile="${build.lib}/ejb3iiop.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/iiop/*.class"/>
-         </fileset>
-         <fileset dir="${source.resources}/ejb3/iiop">
-            <include name="users.properties"/>
-            <include name="roles.properties"/>
-         </fileset>
-      </jar>
-   </target>
-   
-   <target name="jbas5713" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <jar destfile="${build.lib}/jbas5713-ejb1.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/jbas5713/ejb1/**" />
-         </fileset>
-      </jar>
-      
-      <jar destfile="${build.lib}/jbas5713-ejb2.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/jbas5713/ejb2/**" />
-         </fileset>
-      </jar>
-      
-      <jar destfile="${build.lib}/jbas5713.ear">
-         <fileset dir="${build.lib}" includes="jbas5713-*.jar"/>
-      </jar>
-   </target>
-   
-   <target name="jbas6161" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <jar destfile="${build.lib}/jbas6161.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/jbas6161/**" />
-         </fileset>
-      </jar>
-      
-      <jar destfile="${build.lib}/jbas6161-A.ear">
-         <fileset dir="${build.lib}" includes="jbas6161.jar"/>
-      </jar>
-      
-      <jar destfile="${build.lib}/jbas6161-B.ear">
-         <fileset dir="${build.lib}" includes="jbas6161.jar"/>
-      </jar>
-   </target>
-   
-   <target name="jbas6239" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-    <jar destfile="${build.lib}/jbas6239.jar">
-       <fileset dir="${build.classes}">
-          <include name="org/jboss/test/ejb3/jbas6239/**" />
-       </fileset>
-       <fileset dir="${source.resources}/ejb3/jbas6239" includes="**">
-       </fileset>
-    </jar>
-    <jar destfile="${build.lib}/jbas6239hornetq.jar">
-       <fileset dir="${build.classes}">
-          <include name="org/jboss/test/ejb3/jbas6239hornetq/**" />
-       </fileset>
-       <fileset dir="${source.resources}/ejb3/jbas6239hornetq" includes="**">
-       </fileset>
-    </jar>
-   </target>
-   
-   <target name="jbpapp2260" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <jar destfile="${build.lib}/jbpapp2260.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/common/**" />
-            <include name="org/jboss/test/ejb3/jbpapp2260/**" />
-         </fileset>
-         <fileset dir="${source.resources}/ejb3/jbpapp2260" includes="**"/>
-      </jar>
-   </target>
-   
-   <target name="jbpapp2473" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <jar destfile="${build.lib}/jbpapp2473.jar">
-         <fileset dir="${build.classes}">
-            <!-- include name="org/jboss/test/ejb3/common/**" / -->
-            <include name="org/jboss/test/ejb3/jbpapp2473/**" />
-         </fileset>
-         
-         <fileset dir="${source.resources}/ejb3/jbpapp2473" includes="**"/>
-         
-      </jar>
-   </target>
-   
-   <target name="jbpapp3026" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <jar destfile="${build.lib}/createdestination-mdb.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/jbpapp3026/**" />
-         </fileset>
-         <fileset dir="${build.resources}/ejb3/jbpapp3026" includes="**"/>
-      </jar>
-   </target>
-   
-   <!-- This issue affected the ejb3 AS module -->
-   <target name="ejbthree1597" depends="compile">
-      <mkdir dir="${build.lib}"/>
-      <jar destfile="${build.lib}/ejbthree1597.jar">
-         <fileset dir="${build.classes}" includes="org/jboss/test/ejb3/ejbthree1597/*.class"></fileset>
-        <fileset dir="${source.resources}/ejb3/ejbthree1597" includes="**"></fileset>
-      </jar>
-   </target>
-   
-   <target name="ejb3-servlet" depends="compile"
+		<jar jarfile="${build.lib}/ejb3iiop.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/iiop/*.class"/>
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/iiop">
+				<include name="users.properties"/>
+				<include name="roles.properties"/>
+			</fileset>
+		</jar>
+	</target>
+
+	<target name="jbas5713" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jbas5713-ejb1.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbas5713/ejb1/**" />
+			</fileset>
+		</jar>
+
+		<jar destfile="${build.lib}/jbas5713-ejb2.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbas5713/ejb2/**" />
+			</fileset>
+		</jar>
+
+		<jar destfile="${build.lib}/jbas5713.ear">
+			<fileset dir="${build.lib}" includes="jbas5713-*.jar"/>
+		</jar>
+	</target>
+
+	<target name="jbas6161" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jbas6161.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbas6161/**" />
+			</fileset>
+		</jar>
+
+		<jar destfile="${build.lib}/jbas6161-A.ear">
+			<fileset dir="${build.lib}" includes="jbas6161.jar"/>
+		</jar>
+
+		<jar destfile="${build.lib}/jbas6161-B.ear">
+			<fileset dir="${build.lib}" includes="jbas6161.jar"/>
+		</jar>
+	</target>
+
+	<target name="jbas6239" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jbas6239.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbas6239/**" />
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/jbas6239" includes="**">
+			</fileset>
+		</jar>
+		<jar destfile="${build.lib}/jbas6239hornetq.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbas6239hornetq/**" />
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/jbas6239hornetq" includes="**">
+			</fileset>
+		</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>
+
+	<target name="jbpapp2260" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jbpapp2260.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/common/**" />
+				<include name="org/jboss/test/ejb3/jbpapp2260/**" />
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/jbpapp2260" includes="**" />
+		</jar>
+	</target>
+
+	<target name="jbpapp2473" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jbpapp2473.jar">
+			<fileset dir="${build.classes}">
+				<!-- include name="org/jboss/test/ejb3/common/**" / -->
+				<include name="org/jboss/test/ejb3/jbpapp2473/**" />
+			</fileset>
+
+			<fileset dir="${source.resources}/ejb3/jbpapp2473" includes="**"/>
+
+		</jar>
+	</target>
+
+	<target name="jbpapp3026" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/createdestination-mdb.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbpapp3026/**" />
+			</fileset>
+			<fileset dir="${build.resources}/ejb3/jbpapp3026" includes="**"/>
+		</jar>
+	</target>
+
+	<!-- This issue affected the ejb3 AS module -->
+	<target name="ejbthree1597" depends="compile">
+		<mkdir dir="${build.lib}"/>
+		<jar destfile="${build.lib}/ejbthree1597.jar">
+			<fileset dir="${build.classes}" includes="org/jboss/test/ejb3/ejbthree1597/*.class">
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/ejbthree1597" includes="**">
+			</fileset>
+		</jar>
+	</target>
+
+	<target name="ejb3-servlet" depends="compile"
       description="Builds all jar files."
       >
 
-      <mkdir dir="${build.lib}"/>
+		<mkdir dir="${build.lib}"/>
 
-      <jar jarfile="${build.lib}/ejb3-servlet-ejbs.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/servlet/*.class"/>
-            <exclude name="org/jboss/test/ejb3/servlet/War*.class"/>
-         </fileset>
-         <fileset dir="${source.resources}/ejb3/servlet">
-            <include name="*.properties"/>
-            <include name="META-INF/jboss.xml"/>
-         </fileset>
-      </jar>
+		<jar jarfile="${build.lib}/ejb3-servlet-ejbs.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/servlet/*.class"/>
+				<exclude name="org/jboss/test/ejb3/servlet/War*.class"/>
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/servlet">
+				<include name="*.properties"/>
+				<include name="META-INF/jboss.xml"/>
+			</fileset>
+		</jar>
 
-      <jar jarfile="${build.lib}/ejb3-servlet-client.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/servlet/War*.class"/>
-         </fileset>
-      </jar>
+		<jar jarfile="${build.lib}/ejb3-servlet-client.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/servlet/War*.class"/>
+			</fileset>
+		</jar>
 
-      <war warfile="${build.lib}/ejb3-servlet.war"
+		<war warfile="${build.lib}/ejb3-servlet.war"
          webxml="${source.resources}/ejb3/servlet/WEB-INF/test-web.xml">
-         <webinf dir="${source.resources}/ejb3/servlet/WEB-INF">
-            <include name="jboss-web.xml"/>
-         </webinf>
-         <classes dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/servlet/servlets/**"/>
-         </classes>
-      </war>
+			<webinf dir="${source.resources}/ejb3/servlet/WEB-INF">
+				<include name="jboss-web.xml"/>
+			</webinf>
+			<classes dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/servlet/servlets/**"/>
+			</classes>
+		</war>
 
-      <ear earfile="${build.lib}/ejb3-servlet.ear"
+		<ear earfile="${build.lib}/ejb3-servlet.ear"
          appxml="${source.resources}/ejb3/servlet/META-INF/application.xml"
          manifest="${source.resources}/ejb3/servlet/META-INF/MANIFEST.MF">
-         <fileset dir="${build.lib}">
-            <include name="ejb3-servlet-ejbs.jar"/>
-            <include name="ejb3-servlet.war"/>
-            <include name="ejb3-servlet-client.jar"/>
-         </fileset>
-         <fileset dir="${source.resources}/ejb3/servlet">
-            <include name="META-INF/jboss-app.xml"/>
-            <include name="servlet-security-service.xml"/>
-         </fileset>
-      </ear>
+			<fileset dir="${build.lib}">
+				<include name="ejb3-servlet-ejbs.jar"/>
+				<include name="ejb3-servlet.war"/>
+				<include name="ejb3-servlet-client.jar"/>
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/servlet">
+				<include name="META-INF/jboss-app.xml"/>
+				<include name="servlet-security-service.xml"/>
+			</fileset>
+		</ear>
 
-      <copy todir="${build.lib}">
-         <fileset dir="${source.resources}/ejb3/servlet">
-            <include name="servlet-security-service.xml"/>
-         </fileset>
-      </copy>
-   </target>
-   
-   <target name="ejb3-webservice" depends="compile">
-      <mkdir dir="${build.lib}" />
-      
-      <!-- A bit fragile, because token replacement can happen only once -->
-      <replace file="${build.resources}/ejb3/webservice/META-INF/wsdl/WebServiceContextEndpointBean.wsdl"
+		<copy todir="${build.lib}">
+			<fileset dir="${source.resources}/ejb3/servlet">
+				<include name="servlet-security-service.xml"/>
+			</fileset>
+		</copy>
+	</target>
+
+	<target name="ejb3-webservice" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<!-- A bit fragile, because token replacement can happen only once -->
+		<replace file="${build.resources}/ejb3/webservice/META-INF/wsdl/WebServiceContextEndpointBean.wsdl"
          token="@jboss.bind.address@"
          value="${node0}"/>
-      
-      <jar destfile="${build.lib}/ejb3-webservice.jar">
-         <fileset dir="${build.classes}">
-            <!-- include name="org/jboss/test/ejb3/common/**" / -->
-            <include name="org/jboss/test/ejb3/webservice/**" />
-         </fileset>
-         <fileset dir="${build.resources}/ejb3/webservice" includes="**"/>
-      </jar>
-   </target>
-    
+
+		<jar destfile="${build.lib}/ejb3-webservice.jar">
+			<fileset dir="${build.classes}">
+				<!-- include name="org/jboss/test/ejb3/common/**" / -->
+				<include name="org/jboss/test/ejb3/webservice/**" />
+			</fileset>
+			<fileset dir="${build.resources}/ejb3/webservice" includes="**"/>
+		</jar>
+	</target>
+
 	<target name="jbpapp4681" depends="compile">
-	      <mkdir dir="${build.lib}" />
-	      
-	      <jar destfile="${build.lib}/jbpapp4681.jar">
-	         <fileset dir="${build.classes}">
-	            <include name="org/jboss/test/ejb3/jbpapp4681/**" />
-	         </fileset>
-	      </jar>
-	</target>    
-   
-   <target name="jboss51xsd" depends="compile">
-	   <mkdir dir="${build.lib}" />
-	   
-	   <jar destfile="${build.lib}/jboss51xsd.jar">
-		   <fileset dir="${build.classes}">
-			   <include name="org/jboss/test/ejb3/jboss51xsd/**" />
-		   </fileset>
-		   <fileset dir="${source.resources}/ejb3/jboss51xsd" includes="**">
-		   </fileset>
-	   </jar>
-   </target>
+		<mkdir dir="${build.lib}" />
 
-   <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,jbas5713,
+		<jar destfile="${build.lib}/jbpapp4681.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jbpapp4681/**" />
+			</fileset>
+		</jar>
+	</target>
+
+	<target name="jboss51xsd" depends="compile">
+		<mkdir dir="${build.lib}" />
+
+		<jar destfile="${build.lib}/jboss51xsd.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/jboss51xsd/**" />
+			</fileset>
+			<fileset dir="${source.resources}/ejb3/jboss51xsd" includes="**">
+			</fileset>
+		</jar>
+	</target>
+
+	<target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,jbas5713,
+		    jbas7883,
 			ejb3iiop,
 			ejb3-webservice,
 			jbpapp2260,
@@ -220,14 +231,14 @@
 			jbpapp3026,
 			jbpapp4681,
 			jboss51xsd">
-      <mkdir dir="${build.lib}" />
+		<mkdir dir="${build.lib}" />
 
-      <!-- A jar with a simple ejb3 session -->
-      <jar destfile="${build.lib}/simple-session.jar">
-         <fileset dir="${build.classes}">
-            <include name="org/jboss/test/ejb3/basic/**" />
-         </fileset>
-      </jar>
-   </target>
-  
+		<!-- A jar with a simple ejb3 session -->
+		<jar destfile="${build.lib}/simple-session.jar">
+			<fileset dir="${build.classes}">
+				<include name="org/jboss/test/ejb3/basic/**" />
+			</fileset>
+		</jar>
+	</target>
+
 </project>

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	2011-02-24 13:12:58 UTC (rev 110760)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -1,64 +0,0 @@
-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");
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java (from rev 110760, trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestBean.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -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");
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	2011-02-24 13:12:58 UTC (rev 110760)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -1,41 +0,0 @@
-/*
- * 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);
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java (from rev 110760, trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/TestRemote.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -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);
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	2011-02-24 13:12:58 UTC (rev 110760)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -1,110 +0,0 @@
-/*
- * 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");
-   }
-
-}

Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java (from rev 110760, trunk/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbas7883/unit/MailQueryUnitTestCase.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -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");
+   }
+
+}

Deleted: branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml
===================================================================
--- trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	2011-02-24 13:12:58 UTC (rev 110760)
+++ branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	2011-02-24 14:39:42 UTC (rev 110763)
@@ -1,30 +0,0 @@
-<?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

Copied: branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml (from rev 110760, trunk/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	                        (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbas7883/jbas7883-service.xml	2011-02-24 14:39:42 UTC (rev 110763)
@@ -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

Modified: branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/MailService.java
===================================================================
--- branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/MailService.java	2011-02-24 14:38:20 UTC (rev 110762)
+++ branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/MailService.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -41,12 +41,14 @@
 import javax.mail.Authenticator;
 
 import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.naming.NonSerializableFactory;
+
 import org.jboss.util.naming.Util;
 
 /**
  * MBean that gives support for JavaMail. Object of class javax.mail.Session will be bound
  * in JNDI with the name provided with method {@link #setJNDIName}.
+ * 
+ * Portions copyright 2010 Mark Lowe (mlowe at ebilling.it) - JBAS-7883
  *
  * @jmx:mbean name="jboss:type=Service,service=Mail"
  *            extends="org.jboss.system.ServiceMBean"
@@ -55,6 +57,7 @@
  * @author  <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
  * @author  <a href="mailto:jason at planet57.com">Jason Dillon</a>
  * @author Scott.Stark at jboss.org
+ * @author  <a href="mailto:mlowe at ebilling.it">Mark Lowe</a>
  */
 public class MailService
    extends ServiceMBeanSupport
@@ -326,8 +329,7 @@
    private void bind(Properties props, Authenticator auth) throws NamingException
    {
       String bindName = getJNDIName();
-      SessionObjectFactory.setSessionFactoryInfo(props, auth);
-      SessionObjectFactory.setShareSessionInstance(sharedSession);
+      SessionObjectFactory.setSessionFactoryInfo(bindName,props, auth,sharedSession);
 
       InitialContext ctx = new InitialContext();
       try
@@ -363,7 +365,7 @@
             ctx.close();
          }
 
-         SessionObjectFactory.setSessionFactoryInfo(null, null);
+         SessionObjectFactory.remove(bindName);
          log.info("Mail service '" + getJNDIName() + "' removed from JNDI");
       }
    }

Modified: branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/SessionObjectFactory.java
===================================================================
--- branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/SessionObjectFactory.java	2011-02-24 14:38:20 UTC (rev 110762)
+++ branches/JBPAPP_5_1/varia/src/main/org/jboss/mail/SessionObjectFactory.java	2011-02-24 14:39:42 UTC (rev 110763)
@@ -21,7 +21,9 @@
  */
 package org.jboss.mail;
 
+import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.mail.Authenticator;
@@ -33,49 +35,98 @@
 /**
  * A jndi ObjectFactory implementation that creates a new Session from the
  * static class information on each getObjectInstance call.
+ *
+ * Portions copyright 2010 Mark Lowe (mlowe at ebilling.it) - JBAS-7883
  * 
  * @author Scott.Stark at jboss.org
+ * @author  <a href="mailto:mlowe at ebilling.it">Mark Lowe</a>
  * @version $Revision$
  */
 public class SessionObjectFactory implements ObjectFactory
 {
-   private static Properties props;
-   private static Authenticator auth;
-   private static Session instance;
-   private static boolean shareSessionInstance;
 
-   static void setSessionFactoryInfo(Properties props, Authenticator auth)
+   private static final Map<String, MailSessionConfig> mailSessions = new HashMap<String, MailSessionConfig>();
+
+   static void setSessionFactoryInfo(String bindName, Properties props, Authenticator auth, boolean shareSessionInstance)
    {
-      SessionObjectFactory.props = props;
-      SessionObjectFactory.auth = auth;
+      mailSessions.put(bindName, new MailSessionConfig(props, auth, shareSessionInstance));
    }
-   
-   static void setShareSessionInstance(boolean shareSessionInstance)
+
+   static void remove(String bindName)
    {
-      SessionObjectFactory.shareSessionInstance = shareSessionInstance;
+      mailSessions.remove(bindName);
    }
 
-   public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-         Hashtable<?, ?> environment) throws Exception
+   public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
+         throws Exception
    {
-      Session session = null;
-      if(shareSessionInstance)
+      if (name == null)
       {
-         initSession();
-         session = instance;
+         MailSessionConfig defaultConfig = mailSessions.get(MailService.JNDI_NAME);
+
+         if (defaultConfig == null)
+         {
+            throw new IllegalStateException("No default mail session found and no alternative jndi name provided.");
+         }
+         return defaultConfig;
       }
-      else
-      {
-         session = Session.getInstance(props, auth);
-      }
-      return session;
+
+      MailSessionConfig config = mailSessions.get(name.toString());
+
+      return config.getSession();
    }
 
-   static synchronized void initSession()
+   /**
+    * 
+    */
+   private static class MailSessionConfig
    {
-      if(instance == null)
+
+      private Properties properties;
+
+      private Authenticator auth;
+
+      private boolean shareSessionInstance = false;
+
+      private Session session;
+
+      protected MailSessionConfig(Properties properties, Authenticator auth, boolean shareSessionInstance)
       {
-         instance = Session.getInstance(props, auth);
+         this.properties = properties;
+         this.auth = auth;
+         this.shareSessionInstance = shareSessionInstance;
       }
+
+      public Authenticator getAuth()
+      {
+         return auth;
+      }
+
+      public Properties getProperties()
+      {
+         return properties;
+      }
+
+      public Session getSession()
+      {
+         //when share session instance is set return a cached session
+         if (isShareSessionInstance())
+         {
+            if (session == null)
+            {
+               session = Session.getInstance(getProperties(), getAuth());
+            }
+            return session;
+         }
+
+         return Session.getInstance(getProperties(), getAuth());
+      }
+
+      public boolean isShareSessionInstance()
+      {
+         return shareSessionInstance;
+      }
+
    }
+
 }



More information about the jboss-cvs-commits mailing list