[jboss-cvs] JBossAS SVN: r80166 - in projects/ejb3/trunk: testsuite and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 28 17:45:41 EDT 2008


Author: galder.zamarreno at jboss.com
Date: 2008-10-28 17:45:40 -0400 (Tue, 28 Oct 2008)
New Revision: 80166

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTime.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTestCase.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsFieldInjector.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsMethodInjector.java
   projects/ejb3/trunk/testsuite/build-test.xml
Log:
[EJBTHREE-1504] Fixed and added standalone test that starts AS with previously problematic -Dcom.sun.management.jmxremote option and runs the corresponding test. The test has also been added to tests target so that it's run when the full testsuite runs. 

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsFieldInjector.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsFieldInjector.java	2008-10-28 19:44:49 UTC (rev 80165)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsFieldInjector.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -23,13 +23,14 @@
 
 import java.lang.reflect.Field;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 import org.jboss.ejb3.BeanContext;
 import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
 public class DependsFieldInjector implements Injector
@@ -61,7 +62,7 @@
       }
       else
       {
-         MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+         MBeanServer server = MBeanServerLocator.locateJBoss();
          value = MBeanProxyExt.create(clazz, on, server);
       }
 

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsMethodInjector.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsMethodInjector.java	2008-10-28 19:44:49 UTC (rev 80165)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/DependsMethodInjector.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -24,13 +24,14 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 import org.jboss.ejb3.BeanContext;
 import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.MBeanServerLocator;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
 public class DependsMethodInjector implements Injector
@@ -62,7 +63,7 @@
       }
       else
       {
-         MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+         MBeanServer server = MBeanServerLocator.locateJBoss();
          value = MBeanProxyExt.create(clazz, on, server);
       }
 

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2008-10-28 19:44:49 UTC (rev 80165)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2008-10-28 21:45:40 UTC (rev 80166)
@@ -132,6 +132,9 @@
   <!-- Define common JVM Arguments for all EJB3 JBossAS Runtimes -->
   <property name="ejb3.jboss.jvmargs" value="-Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Djava.net.preferIPv4Stack=true"/>
   
+  <!-- Extra options for ejbthree1504 -->
+  <property name="ejbthree1504.jboss.jvmargs" value="${ejb3.jboss.jvmargs} -Dcom.sun.management.jmxremote"/>  
+  
   <!-- Define JVM Arguments for specific EJB3 JBossAS Runtimes -->
   <property name="ssl-args" value="-Djavax.net.ssl.keyStore=${jboss.dist}/server/ejb3-ssl/conf/localhost.keystore -Djavax.net.ssl.keyStorePassword=opensource"/>
   
@@ -205,6 +208,11 @@
       <jvmarg value="${ejb3.jboss.jvmargs}" />
     </server>
     
+    <!-- ejbthree1504 -->
+    <server name="ejbthree1504" host="${node0}">
+      <jvmarg value="${ejbthree1504.jboss.jvmargs}" />
+    </server>  	    
+    
     <!-- node0 -->
     <server name="node0" host="${node0}">
       <jvmarg value="${ejb3.jboss.jvmargs}" />
@@ -2446,6 +2454,10 @@
       <build-simple-jar name="ejbthree1339"/>
    </target>
 
+   <target name="ejbthree1504">
+      <build-simple-jar name="ejbthree1504"/>
+   </target>  
+  
    <target name="jbas4489"
       description="Builds a simple jar files."
       >
@@ -4228,6 +4240,7 @@
       ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
       ejbthree1130, 
       ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
+      ejbthree1504,
    	  jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
       securitydomain, enventry, security5,
       jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -5248,7 +5261,28 @@
 
       <server:stop name="statefulproxyfactoryoverride" />
    </target>
+  
+   <target name="ejbthree1504-test" depends="init">
+      <delete dir="${jboss.dist}/server/ejbthree1504" failonerror="false"/>
+     
+      <create-config baseconf="all" newconf="ejbthree1504">
+         <patternset>
+            <include name="conf/**"/>
+            <include name="deploy*/**"/>
+            <include name="lib/**"/>
+          <include name="deployers/**"/>
+         </patternset>
+      </create-config>
+          
+      <server:start name="ejbthree1504"/>
 
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1504"/>
+      </antcall>
+
+      <server:stop name="ejbthree1504" />
+   </target>
+
    <target name="ssl-simple-test" depends="init">
      <create-config baseconf="all" newconf="ejb3-ssl">
          <patternset>

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTime.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTime.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTime.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejbthree1504;
+
+/**
+ * SystemTime.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface SystemTime
+{
+   long getCurrentTimeMillis();
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/SystemTimeService.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejbthree1504;
+
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.logging.Logger;
+
+/**
+ * SystemTimeService that returns the current time in milliseconds. It also 
+ * implements MBeanRegistration to set the object name with which the MBean is 
+ * registered dynamically. 
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ at Service(objectName=SystemTimeService.ORIGINAL_NAME)
+ at Management(SystemTime.class)
+public class SystemTimeService implements SystemTime
+{
+   public static final String ORIGINAL_NAME = "org.jboss.ejb3:service=SystemTime";
+   public static final String DYNAMIC_NAME = "org.jboss.ejb3:service=SystemTime,type=dynamic";
+   
+   private static final Logger log = Logger.getLogger(SystemTimeService.class);
+   
+   public long getCurrentTimeMillis()
+   {
+      long currentTimeMillis = System.currentTimeMillis();
+      
+      log.info("Current time millis is: " + currentTimeMillis);
+
+      return currentTimeMillis;      
+   }
+}
\ No newline at end of file

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTeller.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejbthree1504;
+
+import java.util.Date;
+
+/**
+ * TimeTeller.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public interface TimeTeller
+{
+   Date whatsTheTime(String origin) throws Exception;
+}
\ No newline at end of file

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/TimeTellerBean.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejbthree1504;
+
+import java.util.Date;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.Depends;
+import org.jboss.logging.Logger;
+
+/**
+ * TimeTellerBean.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ at Stateless
+ at Remote(TimeTeller.class)
+public class TimeTellerBean implements TimeTeller
+{
+   private static final Logger log = Logger.getLogger(TimeTellerBean.class);
+         
+   @Depends(SystemTimeService.ORIGINAL_NAME) private SystemTime systemTimeService;
+
+   public Date whatsTheTime(String origin) throws Exception
+   {
+      log.debug("Call via SystemTime EJB3 service implementation");
+      long currentTimeMillis = systemTimeService.getCurrentTimeMillis();
+      Date date = new Date(currentTimeMillis);
+      log.info("current time is: "+ date + " and origin: " + origin);      
+      return date;
+   }
+
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1504/unit/TimeTellerTestCase.java	2008-10-28 21:45:40 UTC (rev 80166)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejbthree1504.unit;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1504.TimeTeller;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * TimeTellerTest. To run this test, make sure -Dcom.sun.management.jmxremote
+ * has been added to AS/EAP startup VM options.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class TimeTellerTestCase extends JBossTestCase
+{
+   public TimeTellerTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testStandardCallViaLocalService() throws Exception
+   {
+      InitialContext ctx = new InitialContext();
+      TimeTeller timeTeller = (TimeTeller) ctx.lookup("TimeTellerBean/remote");
+      assertNotNull(timeTeller.whatsTheTime("boo"));
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(TimeTellerTestCase.class, "ejbthree1504.jar");
+   }
+}




More information about the jboss-cvs-commits mailing list