[jboss-cvs] JBossAS SVN: r103919 - in trunk/testsuite: src/main/org/jboss/test/jmx/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 13 12:35:08 EDT 2010


Author: smarlow at redhat.com
Date: 2010-04-13 12:35:06 -0400 (Tue, 13 Apr 2010)
New Revision: 103919

Added:
   trunk/testsuite/src/resources/test-configs/jacc-security-allstarrole/deploy/
   trunk/testsuite/src/resources/test-configs/jacc-security-allstarrole/deploy/jmx-jboss-beans.xml
Modified:
   trunk/testsuite/build.xml
   trunk/testsuite/src/main/org/jboss/test/jmx/test/SecureJMXInvokerUnitTestCase.java
   trunk/testsuite/src/resources/jmx/invoker/sar/META-INF/jboss-service.xml
Log:
JBAS-7874 moved SecureJMXInvokerTest to run as part of jacc-security-allstarrole and use jsr-160 security

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2010-04-13 16:32:31 UTC (rev 103918)
+++ trunk/testsuite/build.xml	2010-04-13 16:35:06 UTC (rev 103919)
@@ -967,6 +967,7 @@
    </patternset>
    <patternset id="jacc.allstarrole.includes">
       <include name="org/jboss/test/jacc/test/allstarrole/*TestCase.class"/>
+      <include name="org/jboss/test/jmx/test/SecureJMXInvokerUnitTestCase.class"/>
    </patternset>
    <patternset id="ldap.includes">
       <include name="**/test/security/test/opends/*TestCase.class"/>
@@ -1029,7 +1030,7 @@
       <include name="**/test/security/test/mapping/**/*TestCase.class"/>
       <include name="**/test/web/security/authorization/XACML*UnitTestCase.class"/>
       <include name="**/test/jca/test/SecurityContextUnitTestCase.class"/>
-      <include name="**/test/jmx/test/Secure*TestCase.class"/>
+      <include name="**/test/jmx/test/SecureRMIAdaptorUnitTestCase.class"/>
       <include name="**/test/jmx/test/RMIAdaptorAuthorizationUnitTestCase.class"/>
       <include name="**/test/perf/test/SecurePerfStressTestCase.class"/>
       <include name="**/test/timer/test/SecureTimerUnitTestCase.class"/>

Modified: trunk/testsuite/src/main/org/jboss/test/jmx/test/SecureJMXInvokerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jmx/test/SecureJMXInvokerUnitTestCase.java	2010-04-13 16:32:31 UTC (rev 103918)
+++ trunk/testsuite/src/main/org/jboss/test/jmx/test/SecureJMXInvokerUnitTestCase.java	2010-04-13 16:35:06 UTC (rev 103919)
@@ -21,18 +21,30 @@
  */
 package org.jboss.test.jmx.test;
 
+import java.util.HashMap;
+
+import javax.management.Attribute;
 import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanInfo;
 import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.jmx.invoker.CustomClass;
+
 /** Tests for the jmx invoker adaptor with a secured xmbean.
  *
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public class SecureJMXInvokerUnitTestCase extends JMXInvokerUnitTestCase
+public class SecureJMXInvokerUnitTestCase extends JBossTestCase
 {
    public SecureJMXInvokerUnitTestCase(String name)
    {
@@ -55,20 +67,120 @@
       return getDeploySetup(suite, "invoker-adaptor-test.ear");
    }
 
+   /**
+    * The jmx object name name of the mbean under test
+    * @return The name of the mbean under test
+    * @throws MalformedObjectNameException
+    */
    ObjectName getObjectName() throws MalformedObjectNameException
    {
       return new ObjectName("jboss.test:service=InvokerTest,secured=true");
    }
-   
+
+   static final String TARGET_SERVER = System.getProperty("jbosstest.server.host", "localhost");
+   private MBeanServerConnection getJMXServer() throws Exception
+   {
+      HashMap env = new HashMap();
+      String username = "admin";
+      String password = "admin";
+
+      if (username != null && password != null)
+      {
+         String[] creds = new String[2];
+         creds[0] = username;
+         creds[1] = password;
+         env.put(JMXConnector.CREDENTIALS, creds);
+      }
+
+      JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+TARGET_SERVER+":1090/jmxrmi");
+      JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
+      MBeanServerConnection adaptor = jmxc.getMBeanServerConnection();
+      return adaptor;
+   }
+
+   public void testGetSomething()
+      throws Exception
+   {
+      log.info("+++ testGetSomething");
+      assertEquals("something", getJMXServer().getAttribute(getObjectName(), "Something"));
+   }
+
+   public void testGetCustom()
+      throws Exception
+   {
+      log.info("+++ testGetCustom");
+      CustomClass custom = (CustomClass) getJMXServer().getAttribute(getObjectName(), "Custom");
+      assertEquals("InitialValue", custom.getValue());
+   }
+
+   public void testGetCustomXMBean()
+      throws Exception
+   {
+      log.info("+++ testGetCustomXMBean");
+      ObjectName xmbean = new ObjectName("jboss.test:service=InvokerTest,type=XMBean");
+      CustomClass custom = (CustomClass) getJMXServer().getAttribute(xmbean, "Custom");
+      assertEquals("InitialValue", custom.getValue());
+   }
+   public void testGetXMBeanInfo()
+      throws Exception
+   {
+      log.info("+++ testGetXMBeanInfo");
+      ObjectName xmbean = new ObjectName("jboss.test:service=InvokerTest,type=XMBean");
+      MBeanInfo info = getJMXServer().getMBeanInfo(xmbean);
+      log.info("MBeanInfo: "+info);
+   }
+   public void testXMBeanDoSomething()
+      throws Exception
+   {
+      log.info("+++ testXMBeanDoSomething");
+      ObjectName xmbean = new ObjectName("jboss.test:service=InvokerTest,type=XMBean");
+      Object[] args = {};
+      String[] sig = {};
+      CustomClass custom = (CustomClass) getJMXServer().invoke(xmbean, "doSomething", args, sig);
+      log.info("doSomething: "+custom);
+   }
+
+   public void testSetCustom()
+      throws Exception
+   {
+      log.info("+++ testSetCustom");
+      MBeanServerConnection server = getJMXServer();
+      server.setAttribute(getObjectName(), new Attribute("Custom", new CustomClass("changed")));
+      CustomClass custom = (CustomClass) server.getAttribute(getObjectName(), "Custom");
+      assertEquals("changed", custom.getValue());
+   }
+
+   /**
+    * Create an mbean whose class does not exist to test that the exception
+    * seen from the adaptor is a ClassNotFoundException wrapped in a
+    * ReflectionException
+    * @throws Exception
+    */
+   public void testClassNotFoundException() throws Exception
+   {
+      log.info("+++ testClassNotFoundException");
+      MBeanServerConnection server = getJMXServer();
+      ObjectName name = new ObjectName("jboss.test:test=testClassNotFoundException");
+      try
+      {
+         server.createMBean("org.jboss.text.jmx.DoesNotExist", name);
+         fail("Was able to create org.jboss.text.jmx.DoesNotExist mbean");
+      }
+      catch (ReflectionException e)
+      {
+         Exception ex = e.getTargetException();
+         assertTrue("ReflectionException.target is ClassNotFoundException",
+            ex instanceof ClassNotFoundException);
+      }
+   }
+
    protected void setUp() throws Exception
    {
       super.setUp();
-      delegate.login();
    }
    
    protected void tearDown() throws Exception
    {
       super.tearDown();
-      delegate.logout();
    }
 }

Modified: trunk/testsuite/src/resources/jmx/invoker/sar/META-INF/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/jmx/invoker/sar/META-INF/jboss-service.xml	2010-04-13 16:32:31 UTC (rev 103918)
+++ trunk/testsuite/src/resources/jmx/invoker/sar/META-INF/jboss-service.xml	2010-04-13 16:35:06 UTC (rev 103919)
@@ -62,7 +62,6 @@
       <xmbean>
          <descriptors>
             <interceptors>
-               <interceptor code="org.jboss.test.jmx.interceptors.PrincipalInterceptor" />
                <interceptor code="org.jboss.mx.interceptor.PersistenceInterceptor2" />
                <interceptor code="org.jboss.mx.interceptor.ModelMBeanInterceptor" />
                <interceptor code="org.jboss.mx.interceptor.ObjectReferenceInterceptor" />

Added: trunk/testsuite/src/resources/test-configs/jacc-security-allstarrole/deploy/jmx-jboss-beans.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/jacc-security-allstarrole/deploy/jmx-jboss-beans.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/test-configs/jacc-security-allstarrole/deploy/jmx-jboss-beans.xml	2010-04-13 16:35:06 UTC (rev 103919)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- 
+      Configure JSR-160 style JMX connector for use with jconsole and other remote access programs such as twiddle.
+      
+      To invoke jconsole with this JMX connector, issue:
+         jconsole service:jmx:rmi:///jndi/rmi://hostname:rmiRegistryPort/jmxrmi
+       or
+         jconsole service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi
+
+ -->
+
+  <bean name="InitialContext" class="javax.naming.InitialContext"/>
+ 
+  <bean name="JMXConnector" class="org.jboss.system.server.jmx.JMXConnector">
+
+      <!-- configuration properties -->
+
+      <property name="securityDomain">jmx-console</property>
+
+      <!--  specify the NIC that will run the JMX connector --> 
+      <property name="hostname">
+         <value-factory bean="ServiceBindingManager" method="getStringBinding" 
+            parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmi"/>
+      </property>
+
+      <!-- specify the port that the JMX connector is looked up through (used in JMXServiceURL) -->
+      <!-- commenting this out, will use 1090 as default -->
+          <property name="rmiRegistryPort" class="int">
+          <!-- Get the port from the ServiceBindingManager -->
+          <value-factory bean="ServiceBindingManager" method="getIntBinding" 
+          parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmi"/>
+       </property>
+
+
+      <!-- specify the port that the RMI server listens to  -->
+      <!-- commenting this out, will use 1091 as default -->
+      <property name="rmiServerPort" class="int">
+      <!-- Get the port from the ServiceBindingManager -->
+      <value-factory bean="ServiceBindingManager" method="getIntBinding"
+      parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmiServer"/>
+      </property>
+
+
+      <!-- specify the mbean server that is used internally, this shouldn't be changed here. -->
+      <property name="mbeanServer" class="javax.management.MBeanServer"><inject bean="JMXKernel" property="mbeanServer" /></property>
+      <property name="context" class="javax.naming.InitialContext"><inject bean="InitialContext"/></property>
+  </bean>
+</deployment>




More information about the jboss-cvs-commits mailing list