User: cgjung  
  Date: 02/04/03 08:11:22

  Added:       jboss.net/testsuite/src/main/org/jboss/test/net/jmx
                        JMXTest.java JMXTestMBean.java
                        WSRJMXAccessUnitTestCase.java
  Log:
  On behalf of Peter Braswell who needs his rw back -
  made MBeanProvider JMX1.1 and hence JBossJMX compatible.
  
  Added additional testcase that is not yet completed in the
  testsuite/build.xml
  
  Revision  Changes    Path
  1.1                  
contrib/jboss.net/testsuite/src/main/org/jboss/test/net/jmx/JMXTest.java
  
  Index: JMXTest.java
  ===================================================================
  package jboss.test.net.jmx;
  
  
  
  /**
   * @version     1.0
   * @author
   */
  
  public class JMXTest
     implements JMXTestMBean
  {
  
     /**
      * Method getTestString
      *
      *
      * @return
      *
      */
  
     public String getTestString ()
     {
        return testString;
     }
  
     /**
      * Method setTestString
      *
      *
      * @param str
      *
      */
  
     public void setTestString (String str)
     {
        testString = str;
     }
  
     /**
      * Method noopOperation
      *
      *
      */
  
     public void noopOperation ()
     {
  
        /* doing nothing */
     }
  
     /* Member variables */
     private String testString = "JMX_TEST_STRING";
  }
  
  
  
  
  
  
  1.1                  
contrib/jboss.net/testsuite/src/main/org/jboss/test/net/jmx/JMXTestMBean.java
  
  Index: JMXTestMBean.java
  ===================================================================
  package jboss.test.net.jmx;
  
  
  
  /**
   * @version     1.0
   * @author     Peter Braswell
   */
  
  public interface JMXTestMBean
  {
  
     /**
      * Method getTestString
      *
      *
      * @return
      *
      */
  
     public String getTestString ();
  
     /**
      * Method setTestString
      *
      *
      * @param str
      *
      */
  
     public void setTestString (String str);
  
     /**
      * Method noopOperation
      *
      *
      */
  
     public void noopOperation ();
  }
  
  
  
  
  
  
  1.1                  
contrib/jboss.net/testsuite/src/main/org/jboss/test/net/jmx/WSRJMXAccessUnitTestCase.java
  
  Index: WSRJMXAccessUnitTestCase.java
  ===================================================================
  
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  // $Id: WSRJMXAccessUnitTestCase.java,v 1.1 2002/04/03 16:11:22 cgjung Exp $
  package jboss.test.net.jmx;
  
  
  
  import org.jboss.net.axis.AxisInvocationHandler;
  import org.jboss.net.jmx.MBeanInvocationHandler;
  import org.jboss.net.jmx.adaptor.RemoteAdaptor;
  import org.jboss.net.jmx.adaptor.RemoteAdaptorInvocationHandler;
  import org.jboss.net.jmx.MBeanInvocationHandler;
  import org.jboss.test.net.AxisTestCase;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  import javax.management.ObjectName;
  import java.net.URL;
  
  
  /**
   * Tests remote accessibility of JMX MBean through the web service
   * @created 29 March
   * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Braswell</a>
   * @version $Revision: 1.1 $
   */
  
  public class WSRJMXAccessUnitTestCase
     extends AxisTestCase
  {
  
     /**
      * Method setUp
      *
      *
      * @throws Exception
      *
      */
  
     public void setUp ()
        throws Exception
     {
        super.setUp();
  
     }
  
     public void testGetter( )
     {
         System.out.println("/* begin test: testGetter() */");
         System.out.println("Invoking MBean at ENDPOINT: " + JMX_END_POINT );
         try
         {
             MBeanInvocationHandler handler =
                createMBeanInvocationHandler(new URL(JMX_END_POINT));
             String str     =
                ( String ) handler.invoke("jboss.net:service=JMXTestMBean",   // 
serviceName
                                          "getTestString",   // methodName
                                      null,              // arguments
                                      null);             // classes           
             assertEquals( str,"JMX_TEST_STRING");
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
         System.out.println("/* end test: testGetter() */");
     }
  
     public void testSetter( )
     {
         System.out.println("/* begin test: testSetter() */");
         System.out.println("Invoking MBean at ENDPOINT: " + JMX_END_POINT );
         try
         {
             MBeanInvocationHandler handler =
                createMBeanInvocationHandler(new URL(JMX_END_POINT));
             handler.invoke("jboss.net:service=JMXTestMBean",         // serviceName
                                          "setTestString",            // methodName
                                      new String[] {"foo-dog"},  // arguments
                                      new Class[] {String.class});                     
// classes           
             // invoke the getter and compare the answer with the 
             // set string value
             String str = 
                  (String) handler.invoke("jboss.net:service=JMXTestMBean",         // 
serviceName
                                          "getTestString",            // methodName
                                      null,                      // arguments
                                      null);                     // classes           
             System.out.println("Checking: " + str + "==" + "'foo-dog'?");
             assertEquals( str, "foo-dog");   
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
         System.out.println("/* end test: testGetter() */");
     }
  
     public void testMethodInvoke( )
     {
         System.out.println("/* begin test: testMethodInvoke() */");
         System.out.println("Invoking MBean at ENDPOINT: " + JMX_END_POINT );
         try
         {
             MBeanInvocationHandler handler =
                createMBeanInvocationHandler(new URL(JMX_END_POINT));
             handler.invoke("jboss.net:service=JMXTestMBean",   // serviceName
                            "noopOperation",   // methodName
                          null,              // arguments
                          null);             // classes           
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
         System.out.println("/* end test: testMethodInvoke() */");
     }
  
     /**
      * Constructor WSRJMXAccessUnitTestCase
      *
      *
      * @param name
      *
      */
  
     public WSRJMXAccessUnitTestCase (String name)
     {
        super(name);
     }
  
     /**
      * Method suite
      *
      *
      * @return
      *
      * @throws Exception
      *
      */
  
     public static Test suite ()
        throws Exception
     {
        System.out.println("Deploying 'jmx-test.sar");
  
        return getDeploySetup(WSRJMXAccessUnitTestCase.class, "jmx-test.sar");
     }
  
     /* Member variables */
     protected String        JMX_END_POINT = END_POINT + "/JMXTest";
     protected static String AXIS_JMX_NAME = "jboss.net:service=Axis";
     private JMXTestMBean    mbean;
  }
  
  
  
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to