User: juhalindfors
Date: 02/03/13 13:18:49
Modified: src/main/test/compliance/server Tag: BranchMX_1_0
MBeanServerTEST.java
Log:
couple more registration tests
Revision Changes Path
No revision
No revision
1.6.2.2 +79 -1 jmx/src/main/test/compliance/server/MBeanServerTEST.java
Index: MBeanServerTEST.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/test/compliance/server/MBeanServerTEST.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- MBeanServerTEST.java 12 Mar 2002 14:33:28 -0000 1.6.2.1
+++ MBeanServerTEST.java 13 Mar 2002 21:18:49 -0000 1.6.2.2
@@ -32,6 +32,12 @@
import test.compliance.server.support.Test;
import test.compliance.server.support.TestMBean;
+import test.compliance.server.support.Test2;
+import test.compliance.server.support.Test2MBean;
+import test.compliance.server.support.Test3;
+import test.compliance.server.support.Test3MBean;
+import test.compliance.server.support.Test4;
+import test.compliance.server.support.Test4MBean;
import test.compliance.server.support.LockedTest;
import test.compliance.server.support.LockedTestMBean;
import test.compliance.server.support.LockedTest2;
@@ -46,7 +52,7 @@
* Tests the MBean server impl. through the <tt>MBeanServer</tt> interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.6.2.1 $
+ * @version $Revision: 1.6.2.2 $
*
*/
public class MBeanServerTEST
@@ -973,6 +979,78 @@
if (caught == false)
fail("Allowed to register into JMImplementation");
}
+
+
+ /**
+ * Tests register for an MBean that throws unchecked exception from preRegister()
+ */
+ public void testRegisterMBeanOnExceptionFromPreRegister() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ try
+ {
+ server.registerMBean(new Test2(), name);
+
+ // should not reach here
+ fail("Test2 registered despite of throwing an exception from the
preRegister() method.");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(!server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof java.lang.RuntimeException);
+ }
+ }
+
+ /**
+ * Tests register for an MBean that throws checked exception from preRegister()
+ */
+ public void testRegisterMBeanOnExceptionFromPreRegister2() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ try
+ {
+ server.registerMBean(new Test3(), name);
+
+ // should not reach here
+ fail("Test3 registered despite of throwin an exception from the
preRegister() method");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(!server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ /**
+ * Tests register for an MBean that throws an MBeanRegistrationException from
+ * preRegister() method.
+ */
+ public void testRegisterMBeanOnExceptionFromPreRegister3() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ try
+ {
+ server.registerMBean(new Test4(), name);
+
+ // should not reach here
+ fail("Test4 registered despite of throwing an exception from the
preRegister() method.");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(!server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
// MBeanServer unregisterMBean ----------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development