SF.net SVN: mx4j: [2260] trunk/mx4j
[email protected] Tue, 20 Mar 2007 15:28:01 -0700
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 2260
http://svn.sourceforge.net/mx4j/?rev=2260&view=rev
Author: simonebordet
Date: 2007-03-20 15:28:00 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Tests package reorganization.
Modified Paths:
--------------
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/ComplianceTestCase.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/JMXComplianceTestCase.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/serialization/JMXSerializationTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/serialization/support/Comparator.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/serialization/support/Instantiator.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/serialization/support/SerializationVerifier.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/serialization/support/Serializer.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/JMXSignatureTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/FieldWrapper.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/MemberWrapper.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/MethodWrapper.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/NotCompliantException.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/NotCompliantWarningException.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/ObjectClass.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/ObjectMethod.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/signature/support/SignatureVerifier.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/loading/ClassLoaderRepositoryTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/loading/MLetTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/DescriptorSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/ModelMBeanAttributeInfoTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/ModelMBeanConstructorInfoTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/ModelMBeanInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/ModelMBeanNotificationInfoTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/ModelMBeanOperationInfoTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/RequiredModelMBeanTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/support/ModelMBeanTarget.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/CounterMonitorTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/CounterNotificationTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/GaugeMonitorTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/MonitorTestCase.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/StringMonitorTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/ArrayTypeTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/CompositeDataSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/CompositeTypeTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/OpenMBeanAttributeInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/OpenMBeanConstructorInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/OpenMBeanInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/OpenMBeanOperationInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/OpenMBeanParameterInfoSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/SimpleTypeTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/TabularDataSupportTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/TabularTypeTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/RelationServiceTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/RoleTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/SimpleRelationTestSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/SimpleRelationType.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/SimpleStandard.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/SimpleStandardMBean.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/ClassLoaderSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/ClassLoaderSupportMBean.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/ComplianceSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/ExceptionGeneratingDMB.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/MBeanDynamic.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/MBeanThrowingExceptions.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/MBeanThrowingExceptionsMBean.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/NotificationSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/NullMBeanInfoDMB.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/PostRegistrationSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/PostRegistrationSupportMBean.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/PrivateMBeanDynamic.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/QuerySupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/RegistrationSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/StandardMBeanSupport.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/timer/TimerTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/AbstractDynamicMBeanTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/MiscellaneousTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/log/LogRedirectionTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/server/BCELMBeanInvokerTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/server/MBeanPermissionTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/server/MX4JMBeanServerTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/server/NoOpMBeanServerInterceptor.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/server/NotificationListenerMBeanServerInterceptorTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/timer/TimeQueueTest.java
trunk/mx4j/jsr003/src/test/java/test/mx4j/util/WildcardMatchTest.java
trunk/mx4j/pom.xml
Added Paths:
-----------
trunk/mx4j/jsr003/src/test/java/test/
trunk/mx4j/jsr003/src/test/java/test/javax/
trunk/mx4j/jsr003/src/test/java/test/javax/management/
trunk/mx4j/jsr003/src/test/java/test/javax/management/BinaryOpValueExpTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/BinaryRelQueryExpTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/DynamicMBeanFunctionalityTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/LocalSecurityManagerTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanComplianceTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanIntrospectionTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanRegistrationTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanServerBuilderTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanServerFactoryTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanServerInvocationHandlerTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanServerPermissionTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanServerTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MBeanStarInfoTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/MultiThreadMBeanServerTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/NotificationListenerTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/ObjectNameTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/PermissionTestCase.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/QueryTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/SecurityManagerTestCase.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/StandardMBeanTest.java
trunk/mx4j/jsr003/src/test/java/test/javax/management/compliance/
trunk/mx4j/jsr003/src/test/java/test/javax/management/loading/
trunk/mx4j/jsr003/src/test/java/test/javax/management/modelmbean/
trunk/mx4j/jsr003/src/test/java/test/javax/management/monitor/
trunk/mx4j/jsr003/src/test/java/test/javax/management/openmbean/
trunk/mx4j/jsr003/src/test/java/test/javax/management/relation/
trunk/mx4j/jsr003/src/test/java/test/javax/management/support/
trunk/mx4j/jsr003/src/test/java/test/javax/management/timer/
trunk/mx4j/jsr003/src/test/java/test/mx4j/
Removed Paths:
-------------
trunk/mx4j/jsr003/src/test/java/javax/management/BinaryOpValueExpTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/BinaryRelQueryExpTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/DynamicMBeanFunctionalityTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/LocalSecurityManagerTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanComplianceTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanIntrospectionTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanRegistrationTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerBuilderTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerFactoryTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerInvocationHandlerTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerPermissionTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MBeanStarInfoTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/MultiThreadMBeanServerTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/NotificationListenerTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/ObjectNameTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/PermissionTestCase.java
trunk/mx4j/jsr003/src/test/java/javax/management/QueryTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/SecurityManagerTestCase.java
trunk/mx4j/jsr003/src/test/java/javax/management/StandardMBeanTest.java
trunk/mx4j/jsr003/src/test/java/javax/management/compliance/
trunk/mx4j/jsr003/src/test/java/javax/management/loading/
trunk/mx4j/jsr003/src/test/java/javax/management/modelmbean/
trunk/mx4j/jsr003/src/test/java/javax/management/monitor/
trunk/mx4j/jsr003/src/test/java/javax/management/openmbean/
trunk/mx4j/jsr003/src/test/java/javax/management/relation/
trunk/mx4j/jsr003/src/test/java/javax/management/support/
trunk/mx4j/jsr003/src/test/java/javax/management/timer/
trunk/mx4j/jsr003/src/test/java/mx4j/
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/BinaryOpValueExpTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/BinaryOpValueExpTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/BinaryOpValueExpTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import mx4j.MX4JTestCase;
-
-/**
- * @version $Revision$
- */
-public class BinaryOpValueExpTest extends MX4JTestCase
-{
- public void testLongOperations() throws Exception
- {
- ValueExp value1 = Query.value(new Integer(3));
- ValueExp value2 = Query.value(new Integer(4));
- ValueExp op = Query.plus(value1, value2);
- QueryExp result = Query.eq(Query.value(7L), op);
- assertTrue(result.apply(null));
-
- op = Query.minus(value1, value2);
- result = Query.eq(Query.value(-1L), op);
- assertTrue(result.apply(null));
-
- op = Query.times(value1, value2);
- result = Query.eq(Query.value(12L), op);
- assertTrue(result.apply(null));
-
- op = Query.div(value1, value2);
- result = Query.eq(Query.value(0L), op);
- assertTrue(result.apply(null));
- }
-
- public void testDoubleOperations() throws Exception
- {
- ValueExp value1 = Query.value(new Double(3.0D));
- ValueExp value2 = Query.value(new Double(4.0D));
- ValueExp op = Query.plus(value1, value2);
- QueryExp result = Query.eq(Query.value(7.0D), op);
- assertTrue(result.apply(null));
-
- op = Query.minus(value1, value2);
- result = Query.eq(Query.value(-1.0D), op);
- assertTrue(result.apply(null));
-
- op = Query.times(value1, value2);
- result = Query.eq(Query.value(12.0D), op);
- assertTrue(result.apply(null));
-
- op = Query.div(value1, value2);
- result = Query.eq(Query.value(3.0D / 4.0D), op);
- assertTrue(result.apply(null));
-
- sleep(10000);
- }
-}
-
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/BinaryRelQueryExpTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/BinaryRelQueryExpTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/BinaryRelQueryExpTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import mx4j.MX4JTestCase;
-
-/**
- * @version $Revision$
- */
-public class BinaryRelQueryExpTest extends MX4JTestCase
-{
- public void testExceptions() throws Exception
- {
- QueryExp operation = Query.eq(null, null);
- assertTrue(operation.apply(null));
-
- ValueExp value1 = Query.value(new Integer(3));
- operation = Query.eq(value1, null);
- assertTrue(!operation.apply(null));
-
- operation = Query.eq(null, value1);
- assertTrue(!operation.apply(null));
-
- ValueExp value2 = Query.value(new Long(3));
- ValueExp result = Query.plus(value1, value2);
- operation = Query.eq(Query.value(6), result);
- assertTrue(operation.apply(null));
-
- // Comparing apple and oranges
- ValueExp bvalue1 = Query.value(true);
- operation = Query.eq(bvalue1, value2);
- assertTrue(!operation.apply(null));
-
- // Adding 2 booleans
- ValueExp bvalue2 = Query.value(true);
- result = Query.plus(bvalue1, bvalue2);
- operation = Query.eq(Query.value(false), result);
- try
- {
- operation.apply(null);
- }
- catch (BadBinaryOpValueExpException ignored)
- {
- }
-
- StringValueExp svalue1 = new StringValueExp("a");
- StringValueExp svalue2 = new StringValueExp("b");
- operation = Query.eq(svalue1, null);
- assertTrue(!operation.apply(null));
- operation = Query.eq(svalue1, svalue2);
- assertTrue(!operation.apply(null));
- }
-
- public void testNumericals() throws Exception
- {
- ValueExp value1 = Query.value(new Integer(3));
- ValueExp value2 = Query.value(new Long(3));
- QueryExp operation = Query.eq(value1, value2);
- assertTrue(operation.apply(null));
-
- value1 = Query.value(new Integer(5));
- value2 = Query.value(new Long(4));
- operation = Query.gt(value1, value2);
- assertTrue(operation.apply(null));
-
- value1 = Query.value(new Integer(3));
- value2 = Query.value(new Long(4));
- operation = Query.lt(value1, value2);
- assertTrue(operation.apply(null));
-
- value1 = Query.value(new Double(3));
- value2 = Query.value(new Long(3));
- operation = Query.eq(value1, value2);
- assertTrue(operation.apply(null));
-
- value1 = Query.value(new Float(5));
- value2 = Query.value(new Double(4));
- operation = Query.gt(value1, value2);
- assertTrue(operation.apply(null));
-
- value1 = Query.value(new Double(3));
- value2 = Query.value(new Double(4));
- operation = Query.lt(value1, value2);
- assertTrue(operation.apply(null));
- }
-
- public void testBooleans() throws Exception
- {
- ValueExp value1 = Query.value(true);
- ValueExp value2 = Query.value(false);
- QueryExp operation = Query.eq(value1, value2);
- assertTrue(!operation.apply(null));
-
- operation = Query.or(Query.eq(value1, value1), Query.eq(value1, value2));
- assertTrue(operation.apply(null));
-
- operation = Query.or(Query.eq(value1, value2), Query.eq(value2, value2));
- assertTrue(operation.apply(null));
-
- operation = Query.and(Query.eq(value1, value2), Query.eq(value2, value2));
- assertTrue(!operation.apply(null));
-
- operation = Query.and(Query.eq(value1, value1), Query.eq(value1, value2));
- assertTrue(!operation.apply(null));
- }
-
- public void testStrings() throws Exception
- {
- StringValueExp value1 = new StringValueExp("a");
- StringValueExp value2 = new StringValueExp("a");
- QueryExp operation = Query.eq(value1, value2);
- assertTrue(operation.apply(null));
- operation = Query.geq(value1, value2);
- assertTrue(operation.apply(null));
- operation = Query.gt(value1, value2);
- assertTrue(!operation.apply(null));
- operation = Query.leq(value1, value2);
- assertTrue(operation.apply(null));
- operation = Query.lt(value1, value2);
- assertTrue(!operation.apply(null));
-
- value1 = new StringValueExp("a");
- value2 = new StringValueExp("b");
-
- operation = Query.geq(value1, value2);
- assertTrue(!operation.apply(null));
- operation = Query.geq(value2, value1);
- assertTrue(operation.apply(null));
- operation = Query.gt(value1, value2);
- assertTrue(!operation.apply(null));
- operation = Query.gt(value2, value1);
- assertTrue(operation.apply(null));
- operation = Query.leq(value1, value2);
- assertTrue(operation.apply(null));
- operation = Query.leq(value2, value1);
- assertTrue(!operation.apply(null));
- operation = Query.lt(value1, value2);
- assertTrue(operation.apply(null));
- operation = Query.lt(value2, value1);
- assertTrue(!operation.apply(null));
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/DynamicMBeanFunctionalityTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/DynamicMBeanFunctionalityTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/DynamicMBeanFunctionalityTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import javax.management.support.MBeanDynamic;
-
-import mx4j.MX4JTestCase;
-
-/**
- * @version $Revision$
- */
-public class DynamicMBeanFunctionalityTest extends MX4JTestCase
-{
- private MBeanServer m_server;
- private ObjectName m_name;
-
- protected void setUp() throws Exception
- {
- m_server = MBeanServerFactory.createMBeanServer("dynamic");
- m_name = new ObjectName(":type=dynamic");
- Object dynamic = new MBeanDynamic();
- m_server.registerMBean(dynamic, m_name);
- }
-
- protected void tearDown() throws Exception
- {
- m_server.unregisterMBean(m_name);
- MBeanServerFactory.releaseMBeanServer(m_server);
- }
-
- public void testGetAttributes() throws Exception
- {
- AttributeList list = m_server.getAttributes(m_name, new String[0]);
- assertEquals(list.size(), 0);
-
- list = m_server.getAttributes(m_name, new String[]{"doesNotExist"});
- if (list.size() != 0)
- {
- fail("Attribute does not exist");
- }
-
- String attributeName = "DynamicAttribute1";
-
- list = m_server.getAttributes(m_name, new String[]{attributeName});
- if (list.size() != 1 && ((Attribute)list.get(0)).getName().equals(attributeName))
- {
- fail("Attribute exists");
- }
- }
-
- public void testGetSetAttribute() throws Exception
- {
- String attributeName = "DynamicAttribute1";
-
- Object valueBefore = m_server.getAttribute(m_name, attributeName);
-
- Object newValue = "newValue";
- Attribute attribute = new Attribute(attributeName, newValue);
- m_server.setAttribute(m_name, attribute);
-
- Object valueAfter = m_server.getAttribute(m_name, attributeName);
- if (valueAfter.equals(valueBefore) || !valueAfter.equals(newValue))
- {
- fail("setAttribute does not work");
- }
- }
-
- public void testSetAttributes() throws Exception
- {
- String attributeName1 = "DynamicAttribute1";
- Object value1Before = m_server.getAttribute(m_name, attributeName1);
- String attributeName2 = "DynamicAttribute2";
- Object value2Before = m_server.getAttribute(m_name, attributeName2);
- AttributeList changeThese = new AttributeList();
- AttributeList list = m_server.setAttributes(m_name, changeThese);
- if (list.size() != 0)
- {
- fail("No Attributes were changed");
- }
- if (!value1Before.equals(m_server.getAttribute(m_name, attributeName1)) || !value2Before.equals(m_server.getAttribute(m_name, attributeName2)))
- {
- fail("Attribute was not changed");
- }
- Attribute attr = new Attribute(attributeName2, "Value2");
- changeThese.add(attr);
- list = m_server.setAttributes(m_name, changeThese);
- if (list.size() != 1)
- {
- fail("One attribute was changed");
- }
- if (!list.get(0).equals(attr))
- {
- fail("Wrong return value");
- }
- if (!value1Before.equals(m_server.getAttribute(m_name, attributeName1)) ||
- value2Before.equals(m_server.getAttribute(m_name, attributeName2)) ||
- !attr.getValue().equals(m_server.getAttribute(m_name, attributeName2)))
- {
- fail("Attribute was not changed");
- }
- }
-
- public void testInvoke() throws Exception
- {
- String attributeName1 = "DynamicAttribute1";
- Object value1 = m_server.getAttribute(m_name, attributeName1);
-
- Boolean result = (Boolean)m_server.invoke(m_name, "dynamicOperation", new Object[]{"dummy"}, new String[]{"java.lang.String"});
- if (result.booleanValue())
- {
- fail("Operation does not work");
- }
- result = (Boolean)m_server.invoke(m_name, "dynamicOperation", new Object[]{value1}, new String[]{"java.lang.String"});
- if (!result.booleanValue())
- {
- fail("Operation does not work");
- }
- }
-
- public void testGetMBeanInfoRegistrationException() throws Exception
- {
- try
- {
- m_server.createMBean("test.javax.management.support.ExceptionGeneratingDMB",
- new ObjectName(":register=no"),
- new Object[]{Boolean.FALSE},
- new String[]{"boolean"});
- fail("Expecting NotCompliantMBeanException");
- }
- catch (NotCompliantMBeanException x)
- {
- }
- }
-
- public void testGetMBeanInfoInvocationException() throws Exception
- {
- try
- {
- ObjectName objname = new ObjectName(":register=yes");
- m_server.createMBean("test.javax.management.support.ExceptionGeneratingDMB",
- objname,
- new Object[]{Boolean.TRUE},
- new String[]{"boolean"});
- m_server.getMBeanInfo(objname);
- fail("Expecting RuntimeMBeanException");
- }
- catch (RuntimeMBeanException x)
- {
- }
- }
-
- public void testNullMBeanInfo() throws Exception
- {
- try
- {
- ObjectName objname = new ObjectName(":id=testNullMBeanInfo");
- m_server.createMBean("test.javax.management.support.NullMBeanInfoDMB", objname);
- m_server.getMBeanInfo(objname);
- fail("Expecting JMRuntimeException");
- }
- catch (JMRuntimeException x)
- {
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/LocalSecurityManagerTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/LocalSecurityManagerTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/LocalSecurityManagerTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,547 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.loading.ClassLoaderRepository;
-import javax.management.loading.MLet;
-
-import junit.framework.TestCase;
-import mx4j.log.Log;
-import mx4j.server.MX4JMBeanServer;
-
-/**
- * @version $Revision$
- */
-public class LocalSecurityManagerTest extends SecurityManagerTestCase
-{
- static
- {
- // For the way JUnit works, we have one JVM per test class
- Policy.setPolicy(new LocalModifiablePolicy());
- System.setSecurityManager(new SecurityManager());
- }
-
- protected void setUp() throws Exception
- {
- // Be sure we have a security manager and the right policy
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) fail();
- Policy policy = Policy.getPolicy();
- if (!(policy instanceof LocalModifiablePolicy)) fail();
- ((LocalModifiablePolicy)policy).initialize();
- }
-
- protected void addPermission(Permission p)
- {
- LocalModifiablePolicy policy = (LocalModifiablePolicy)Policy.getPolicy();
- policy.addPermission(p);
- }
-
- protected void resetPermissions()
- {
- LocalModifiablePolicy policy = (LocalModifiablePolicy)Policy.getPolicy();
- policy.initialize();
- }
-
- public void testNewMBeanServer() throws Exception
- {
- try
- {
- MBeanServerFactory.newMBeanServer();
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServerFactory.newMBeanServer();
-
- try
- {
- MBeanServerFactory.createMBeanServer();
- fail();
- }
- catch (SecurityException ignored)
- {
- }
- }
-
- public void testCreateMBeanServer() throws Exception
- {
- try
- {
- MBeanServerFactory.createMBeanServer();
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanServerPermission("createMBeanServer"));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
- MBeanServerFactory.newMBeanServer();
-
- try
- {
- MBeanServerFactory.releaseMBeanServer(server);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- // Clean up
- addPermission(new MBeanServerPermission("releaseMBeanServer"));
- MBeanServerFactory.releaseMBeanServer(server);
- }
-
- public void testReleaseMBeanServer() throws Exception
- {
- addPermission(new MBeanServerPermission("createMBeanServer"));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
-
- try
- {
- MBeanServerFactory.releaseMBeanServer(server);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanServerPermission("releaseMBeanServer"));
- MBeanServerFactory.releaseMBeanServer(server);
- }
-
- public void testReleaseMBeanServer2() throws Exception
- {
- addPermission(new MBeanServerPermission("createMBeanServer, releaseMBeanServer"));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
- MBeanServerFactory.releaseMBeanServer(server);
- }
-
- public void testFindMBeanServer() throws Exception
- {
- addPermission(new MBeanServerPermission("createMBeanServer"));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
-
- try
- {
- MBeanServerFactory.findMBeanServer(null);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanServerPermission("findMBeanServer"));
- ArrayList list = MBeanServerFactory.findMBeanServer(null);
- if (!list.contains(server)) fail();
-
- // Clean up
- addPermission(new MBeanServerPermission("releaseMBeanServer"));
- MBeanServerFactory.releaseMBeanServer(server);
- }
-
- public void testAddRemoveNotificationListener() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testAddRemoveNotificationListener(server);
- }
-
- public void testCreateMBean4Params() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testCreateMBean4Params(server);
- }
-
- public void testCreateMBean5Params() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testCreateMBean5Params(server);
- }
-
- public void testGetAttribute() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetAttribute(server);
- }
-
- public void testGetAttributes() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetAttributes(server);
- }
-
- public void testGetDefaultDomain() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- String domain = "simon";
- MBeanServer server = MBeanServerFactory.newMBeanServer(domain);
- testGetDefaultDomain(server, domain);
- }
-
- public void testGetDomains() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetDomains(server);
- }
-
- public void testGetMBeanCount() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetMBeanCount(server);
- }
-
- public void testGetMBeanInfo() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetMBeanInfo(server);
- }
-
- public void testGetObjectInstance() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testGetObjectInstance(server);
- }
-
- public void testInstantiate() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
-
- String className = "java.lang.String";
-
- try
- {
- server.instantiate(className, null);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanPermission(className, "instantiate"));
- server.instantiate(className, null);
-
- // Check also the overloaded version, we need an MLet
- String mletClassName = "javax.management.loading.MLet";
- ObjectName name = new ObjectName(server.getDefaultDomain(), "mbean", "mlet");
- resetPermissions();
- addPermission(new MBeanPermission(mletClassName, "instantiate, registerMBean"));
- addPermission(new RuntimePermission("createClassLoader"));
- server.createMBean(mletClassName, name, null);
-
- try
- {
- server.instantiate(className, null);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanPermission(className, "instantiate"));
- server.instantiate(className, null);
- }
-
- public void testInvoke() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testInvoke(server);
- }
-
- public void testIsInstanceOf() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testIsInstanceOf(server);
- }
-
- public void testIsRegistered() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testIsRegistered(server);
- }
-
- public void testQueryMBeans() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testQueryMBeans(server);
- }
-
- public void testQueryNames() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testQueryNames(server);
- }
-
- public void testRegisterMBean() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
-
- MBeanServerDelegate mbean = new MBeanServerDelegate();
- ObjectName name = new ObjectName(server.getDefaultDomain(), "name", "test");
-
- try
- {
- server.registerMBean(mbean, name);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanPermission(mbean.getClass().getName() + "[" + name.getCanonicalName() + "]", "registerMBean"));
- server.registerMBean(mbean, name);
- }
-
- public void testSetAttribute() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testSetAttribute(server);
- }
-
- public void testSetAttributes() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testSetAttributes(server);
- }
-
- public void testUnregisterMBean() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- testUnregisterMBean(server);
- }
-
- public void testGetClassLoader() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
-
- // Needed to create an MLet, which is a ClassLoader
- addPermission(new RuntimePermission("createClassLoader"));
- ObjectName name = new ObjectName(server.getDefaultDomain(), "mbean", "mlet");
- MLet mlet = new MLet();
- addPermission(new MBeanPermission(mlet.getClass().getName(), "registerMBean"));
- server.registerMBean(mlet, name);
-
- try
- {
- server.getClassLoader(null);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- // Dummy class
- addPermission(new MBeanPermission("foo[" + name.getCanonicalName() + "]", "getClassLoader"));
-
- try
- {
- server.getClassLoader(name);
- fail();
- }
- catch (SecurityException ignored)
- {
- }
-
- addPermission(new MBeanPermission(mlet.getClass().getName() + "[" + name.getCanonicalName() + "]", "getClassLoader"));
- ClassLoader result = server.getClassLoader(name);
- assertSame(result, mlet);
- }
-
- public void testGetClassLoaderFor() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- ObjectName delegate = ObjectName.getInstance("JMImplementation", "type", "MBeanServerDelegate");
- try
- {
- server.getClassLoaderFor(delegate);
- fail();
- }
- catch (SecurityException x)
- {
- }
- addPermission(new MBeanPermission("[" + delegate.getCanonicalName() + "]", "getClassLoaderFor"));
- ClassLoader loader = server.getClassLoaderFor(delegate);
- assertNotNull(loader);
- }
-
- public void testGetClassLoaderRepository() throws Exception
- {
- addPermission(new MBeanServerPermission("newMBeanServer"));
- MBeanServer server = MBeanServerFactory.newMBeanServer();
- try
- {
- server.getClassLoaderRepository();
- fail();
- }
- catch (SecurityException x)
- {
- }
- addPermission(new MBeanPermission("*", "getClassLoaderRepository"));
- ClassLoaderRepository loader = server.getClassLoaderRepository();
- assertNotNull(loader);
- }
-
- /**
- * A modifiable policy that allow permissions to be added at runtime, used for tests purposes only.
- */
- public static class LocalModifiablePolicy extends Policy
- {
- private final ProtectionDomain testDomain;
- private final Map permissionsMap = new HashMap();
-
- public LocalModifiablePolicy()
- {
- // Here we still have no security manager installed
- testDomain = LocalModifiablePolicy.class.getProtectionDomain();
-
- // Add the permissions needed to run the tests
- CodeSource junitCodeSource = TestCase.class.getProtectionDomain().getCodeSource();
- permissionsMap.put(junitCodeSource, createAllPermissions());
-
- CodeSource mx4jCodeSource = MBeanServerFactory.class.getProtectionDomain().getCodeSource();
- permissionsMap.put(mx4jCodeSource, createAllPermissions());
-
- CodeSource implCodeSource = MX4JMBeanServer.class.getProtectionDomain().getCodeSource();
- permissionsMap.put(implCodeSource, createAllPermissions());
-
- // In the automated tests, the log classes may be taken from the JSR 160 jars.
- CodeSource logCodeSource = Log.class.getProtectionDomain().getCodeSource();
- permissionsMap.put(logCodeSource, createAllPermissions());
-
- ClassLoader loader = getClass().getClassLoader();
-
- // BCEL
- try
- {
- Class cls = loader.loadClass("org.apache.bcel.generic.Type");
- CodeSource bcelCodeSource = cls.getProtectionDomain().getCodeSource();
- permissionsMap.put(bcelCodeSource, createAllPermissions());
- }
- catch (ClassNotFoundException ignored)
- {
- }
-
-
- // When we run automated, we need also permissions for Ant jars
- try
- {
- Class cls = loader.loadClass("org.apache.tools.ant.Task");
- CodeSource antCodeSource = cls.getProtectionDomain().getCodeSource();
- permissionsMap.put(antCodeSource, createAllPermissions());
- cls = loader.loadClass("org.apache.tools.ant.taskdefs.optional.junit.JUnitTask");
- antCodeSource = cls.getProtectionDomain().getCodeSource();
- permissionsMap.put(antCodeSource, createAllPermissions());
- }
- catch (ClassNotFoundException ignored)
- {
- }
-
- initialize();
- }
-
- private Permissions createAllPermissions()
- {
- Permissions allPermissions = new Permissions();
- allPermissions.add(new AllPermission());
- return allPermissions;
- }
-
- public PermissionCollection getPermissions(CodeSource codesource)
- {
- Permissions permissions = (Permissions)permissionsMap.get(codesource);
- if (permissions == null)
- {
- permissions = new Permissions();
- permissionsMap.put(codesource, permissions);
- }
- return permissions;
- }
-
- public void refresh()
- {
- }
-
- /**
- * For JDK 1.4 overriding this method disables caching of Permissions done by the
- * standard Policy implementation.
- * This is done because we install this policy *before* installing the security manager.
- * By doing so, in JDK 1.4 the permissions granted at the moment of policy installation
- * (no security manager == AllPermission) are cached and will invalidate all tests, since
- * they will become unmodifiable.
- * <p/>
- * The stack trace is when checking a permission is:
- * <p/>
- * SecurityManager.checkPermission()
- * AccessController.checkPermission()
- * AccessControlContext.checkPermission()
- * ProtectionDomain.implies()
- * LocalModifiablePolicy.implies()
- */
- public boolean implies(ProtectionDomain domain, Permission permission)
- {
- PermissionCollection perms = getPermissions(domain.getCodeSource());
- return perms.implies(permission);
- }
-
- /**
- * Adds the given permission to the client (the test in this case) codesource
- */
- public void addPermission(Permission p)
- {
- Permissions permissions = (Permissions)getPermissions(testDomain.getCodeSource());
- permissions.add(p);
- }
-
- /**
- * Initializes the permissions for the client (the test in this case) codesource
- */
- public synchronized void initialize()
- {
- Permissions permissions = new Permissions();
- permissions.add(new SecurityPermission("getPolicy"));
- permissionsMap.put(testDomain.getCodeSource(), permissions);
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanComplianceTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanComplianceTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanComplianceTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.management.support.ComplianceSupport;
-
-import mx4j.MX4JSystemKeys;
-import mx4j.MX4JTestCase;
-import mx4j.server.MBeanIntrospector;
-import mx4j.server.MBeanMetaData;
-
-/**
- * @version $Revision$
- */
-public class MBeanComplianceTest extends MX4JTestCase
-{
- private MBeanIntrospector introspector;
-
- protected void setUp() throws Exception
- {
- String property = MX4JSystemKeys.MX4J_STRICT_MBEAN_INTERFACE;
- System.setProperty(property, "no");
- introspector = new MBeanIntrospector();
- }
-
- protected void tearDown() throws Exception
- {
- introspector = null;
- }
-
- private MBeanMetaData createMBeanMetaData(Object mbean) throws Exception
- {
- MBeanMetaData metadata = MBeanMetaData.Factory.create();
- metadata.setMBean(mbean);
- metadata.setClassLoader(mbean.getClass().getClassLoader());
- return metadata;
- }
-
- private boolean isCompliant(Object mbean) throws Exception
- {
- Object metadata = createMBeanMetaData(mbean);
- Method method = introspector.getClass().getDeclaredMethod("testCompliance", new Class[]{MBeanMetaData.class});
- method.setAccessible(true);
- Boolean value = (Boolean)method.invoke(introspector, new Object[]{metadata});
- return value.booleanValue();
- }
-
- private boolean isStandardCompliant(Object mbean) throws Exception
- {
- MBeanMetaData metadata = createMBeanMetaData(mbean);
- Method method = introspector.getClass().getDeclaredMethod("testCompliance", new Class[]{MBeanMetaData.class});
- method.setAccessible(true);
- Boolean value = (Boolean)method.invoke(introspector, new Object[]{metadata});
- return value.booleanValue() && metadata.isMBeanStandard() && !metadata.isMBeanDynamic() && metadata.getMBeanInterface() != null;
- }
-
- private boolean isDynamicCompliant(Object mbean) throws Exception
- {
- MBeanMetaData metadata = createMBeanMetaData(mbean);
- Method method = introspector.getClass().getDeclaredMethod("testCompliance", new Class[]{MBeanMetaData.class});
- method.setAccessible(true);
- Boolean value = (Boolean)method.invoke(introspector, new Object[]{metadata});
- return value.booleanValue() && !metadata.isMBeanStandard() && metadata.isMBeanDynamic();
- }
-
- private Class getStandardManagementInterface(Object mbean) throws Exception
- {
- MBeanMetaData metadata = createMBeanMetaData(mbean);
- introspector.introspect(metadata);
- return metadata.getMBeanInterface();
- }
-
- private Method[] getStandardManagementMethods(Object mbean) throws Exception
- {
- Class intf = getStandardManagementInterface(mbean);
- return intf.getMethods();
- }
-
- public void testNotCompliantNoManagement() throws Exception
- {
- Object bad = new ComplianceSupport.NoManagement();
- if (isCompliant(bad)) fail("MBean is not compliant");
- }
-
- public void testNotCompliantLexicalPatternNotRespected() throws Exception
- {
- Object bad = new ComplianceSupport.DoesntRespectLexicalPattern();
- if (isCompliant(bad)) fail("MBean is not compliant");
- }
-
- public void testNotCompliantOverloadedAttributeSetSet() throws Exception
- {
- Object bad = new ComplianceSupport.OverloadedAttributeSetSet();
- if (isCompliant(bad)) fail("MBean is not compliant");
- }
-
- public void testNotCompliantOverloadedAttributeGetGet() throws Exception
- {
- // This is guaranteed by the Java compiler: a class with 2 getters that return different types
- // does not compile
- }
-
- public void testNotCompliantOverloadedAttribute3() throws Exception
- {
- Object bad = new ComplianceSupport.OverloadedAttributeGetSet();
- if (isCompliant(bad)) fail("MBean is not compliant");
- }
-
- public void testNotCompliantOverloadedAttribute4() throws Exception
- {
- Object bad = new ComplianceSupport.OverloadedAttributeIsGet();
- if (isCompliant(bad)) fail("MBean is not compliant");
- }
-
- public void testCompliantBasicStandard() throws Exception
- {
- Object good = new ComplianceSupport.BasicStandard();
- if (!isStandardCompliant(good)) fail("MBean is compliant");
-
- Method[] methods = ComplianceSupport.BasicStandardMBean.class.getMethods();
- List list = Arrays.asList(methods);
- Method[] management = getStandardManagementMethods(good);
- List list2 = Arrays.asList(management);
- assertTrue("Different management interface", list.containsAll(list2) && list2.containsAll(list));
- }
-
- public void testCompliantDerived() throws Exception
- {
- Object good = new ComplianceSupport.Derived();
- if (!isStandardCompliant(good)) fail("MBean is compliant");
-
- Method[] methods = ComplianceSupport.BasicStandardMBean.class.getMethods();
- List list = Arrays.asList(methods);
- Method[] management = getStandardManagementMethods(good);
- List list2 = Arrays.asList(management);
- assertTrue("Different management interface", list.containsAll(list2) && list2.containsAll(list));
- }
-
- public void testCompliantInherited() throws Exception
- {
- Object good = new ComplianceSupport.Inherited();
- if (!isStandardCompliant(good)) fail("MBean is compliant");
-
- Method[] methods = ComplianceSupport.InheritedMBean.class.getMethods();
- List list = Arrays.asList(methods);
- Method[] management = getStandardManagementMethods(good);
- List list2 = Arrays.asList(management);
- assertTrue("Different management interface", list.containsAll(list2) && list2.containsAll(list));
- }
-
- public void testCompliantNotInherited() throws Exception
- {
- Object good = new ComplianceSupport.NotInherited();
- if (!isStandardCompliant(good)) fail("MBean is compliant");
-
- Method[] methods = ComplianceSupport.BasicStandardMBean.class.getMethods();
- List list = Arrays.asList(methods);
- Method[] management = getStandardManagementMethods(good);
- List list2 = Arrays.asList(management);
- assertTrue("Different management interface", list.containsAll(list2) && list2.containsAll(list));
- }
-
- public void testCompliantMulti() throws Exception
- {
- Object good = new ComplianceSupport.Multi();
- if (!isStandardCompliant(good)) fail("MBean is compliant");
-
- Method[] methods = ComplianceSupport.BasicStandardMBean.class.getMethods();
- List list = new ArrayList();
- list.addAll(Arrays.asList(methods));
- methods = ComplianceSupport.InheritedMBean.class.getMethods();
- list.addAll(Arrays.asList(methods));
- Method[] management = getStandardManagementMethods(good);
- List list2 = Arrays.asList(management);
- assertTrue("Different management interface", list.containsAll(list2) && list2.containsAll(list));
- }
-
- public void testCompliantPackagePrivate() throws Exception
- {
- String clsName = "test.javax.management.support.ComplianceSupport$PackagePrivate";
- Class cls = getClass().getClassLoader().loadClass(clsName);
- Constructor ctor = cls.getDeclaredConstructor(new Class[0]);
- ctor.setAccessible(true);
- Object good = ctor.newInstance(new Object[0]);
- if (!isStandardCompliant(good)) fail("MBean is compliant");
- }
-
- public void testNotCompliantDynamicNoClassName() throws Exception
- {
- // In JMX 1.2 it is not possible to create an MBeanInfo with null class name
- Object mbean = new ComplianceSupport.NoClassNameDynamicMBean();
- if (isCompliant(mbean)) fail();
- }
-
- public void testCompliantBasicDynamic() throws Exception
- {
- Object mbean = new ComplianceSupport.BasicDynamic();
- if (!isDynamicCompliant(mbean)) fail("MBean is compliant");
- }
-
- public void testCompliantStandardAndDynamic() throws Exception
- {
- // JMX 1.0, this is invalid. For JMX 1.1 this is a dynamic MBean
- Object mbean = new ComplianceSupport.StandardAndDynamic();
- if (!isDynamicCompliant(mbean)) fail("MBean is compliant");
-
- Class intf = getStandardManagementInterface(mbean);
- if (intf != null) fail("MBean is dynamic");
- }
-
- public void testCompliantStandardDynamic() throws Exception
- {
- // In JMX 1.0 this is an invalid MBean; in JMX 1.1 is a dynamic MBean
- Object mbean = new ComplianceSupport.StandardDynamic();
- if (!isDynamicCompliant(mbean)) fail("MBean is compliant");
-
- Class intf = getStandardManagementInterface(mbean);
- if (intf != null) fail("MBean is dynamic");
- }
-
- public void testDynamicFromStandard() throws Exception
- {
- // A standard mbean subclassed to be dynamic
- Object mbean = new ComplianceSupport.DynamicFromStandard();
- if (!isDynamicCompliant(mbean)) fail("MBean is compliant");
-
- Class intf = getStandardManagementInterface(mbean);
- if (intf != null) fail("MBean is dynamic");
- }
-
- public void testStandardFromDynamic() throws Exception
- {
- // A dynamic mbean subclassed to be standard, it remains a dynamic (as of JMX 1.1)
- Object mbean = new ComplianceSupport.StandardFromDynamic();
- if (!isDynamicCompliant(mbean)) fail("MBean is compliant");
-
- Class intf = getStandardManagementInterface(mbean);
- if (intf != null) fail("MBean is dynamic");
- }
-
- public void testStandardConstructorInfo() throws Exception
- {
- Object mbean = new ComplianceSupport.BasicStandard();
- MBeanMetaData md = createMBeanMetaData(mbean);
- introspector.introspect(md);
- MBeanConstructorInfo[] constructors = md.getMBeanInfo().getConstructors();
- assertEquals(1, constructors.length);
- MBeanConstructorInfo info = constructors[0];
- assertEquals(mbean.getClass().getName(), info.getName());
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanIntrospectionTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanIntrospectionTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanIntrospectionTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,58 +0,0 @@
-/* =====================================================================
- *
- * Copyright (c) 2004 Jeremy Boynes. All rights reserved.
- *
- * =====================================================================
- */
-package javax.management;
-
-import mx4j.MX4JTestCase;
-import mx4j.server.MBeanIntrospector;
-import mx4j.server.MBeanMetaData;
-
-/**
- * @version $Revision$ $Date$
- */
-public class MBeanIntrospectionTest extends MX4JTestCase
-{
- private MBeanIntrospector introspector;
-
- public void testOperationInfo() throws Exception
- {
- MBeanInfo info = introspect(new Basic());
- MBeanOperationInfo[] operations = info.getOperations();
- assertEquals(1, operations.length);
- }
-
- private MBeanMetaData createMBeanMetaData(Object mbean) throws Exception
- {
- MBeanMetaData metadata = MBeanMetaData.Factory.create();
- metadata.setMBean(mbean);
- metadata.setClassLoader(mbean.getClass().getClassLoader());
- return metadata;
- }
-
- private MBeanInfo introspect(Object mbean) throws Exception
- {
- MBeanMetaData md = createMBeanMetaData(mbean);
- introspector.introspect(md);
- return md.getMBeanInfo();
- }
-
- protected void setUp() throws Exception
- {
- introspector = new MBeanIntrospector();
- }
-
- public static interface BasicMBean
- {
- boolean is();
- }
-
- public static class Basic implements BasicMBean
- {
- public boolean is() {
- throw new UnsupportedOperationException();
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanRegistrationTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanRegistrationTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanRegistrationTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,496 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import javax.management.loading.MLet;
-import javax.management.support.RegistrationSupport;
-
-import mx4j.MX4JTestCase;
-import mx4j.MutableBoolean;
-import mx4j.MutableObject;
-
-/**
- * @version $Revision$
- */
-public class MBeanRegistrationTest extends MX4JTestCase
-{
- private MBeanServer newMBeanServer()
- {
- return MBeanServerFactory.newMBeanServer();
- }
-
- public void testNullObjectName() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- Object nullObjectName = new RegistrationSupport.NullObjectName();
- try
- {
- server.registerMBean(nullObjectName, null);
- fail("MBean cannot be registered");
- }
- catch (RuntimeOperationsException ignored)
- {
- }
- // Check that was not registered
- if (server.getMBeanCount().intValue() != count)
- {
- fail("MBean with null ObjectName was registered");
- }
- }
-
- public void testPreRegisterException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- Object preRegisterException = new RegistrationSupport.PreRegisterException();
- try
- {
- server.registerMBean(preRegisterException, null);
- fail("MBean cannot be registered");
- }
- catch (MBeanRegistrationException ignored)
- {
- }
- // Check that was not registered
- if (server.getMBeanCount().intValue() != count)
- {
- fail("MBean threw exception in preRegister, but was registered");
- }
- }
-
- public void testPostRegisterException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- Object postRegisterException = new RegistrationSupport.PostRegisterException();
- ObjectName name = new ObjectName(":test=postRegister");
- try
- {
- server.registerMBean(postRegisterException, name);
- fail("MBean must throw an exception");
- }
- catch (RuntimeMBeanException ignored)
- {
- }
- // Check that was registered
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean threw exception in postRegister, but was NOT registered");
- }
- }
-
- public void testPreDeregisterException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- Object preDeregisterException = new RegistrationSupport.PreDeregisterException();
- ObjectName name = new ObjectName("simon:mbean=test");
- server.registerMBean(preDeregisterException, name);
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
- try
- {
- server.unregisterMBean(name);
- fail("MBean cannot be unregistered");
- }
- catch (MBeanRegistrationException ignored)
- {
- }
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was unregistered");
- }
- }
-
- public void testPostDeregisterException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- Object postDeregisterException = new RegistrationSupport.PostDeregisterException();
- ObjectName name = new ObjectName("simon:mbean=test");
- server.registerMBean(postDeregisterException, name);
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
- try
- {
- server.unregisterMBean(name);
- fail("MBean must throw an exception");
- }
- catch (RuntimeMBeanException ignored)
- {
- }
- if (server.getMBeanCount().intValue() != count)
- {
- fail("MBean was NOT unregistered");
- }
- }
-
- public void testRegistration() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- final MutableBoolean bool1 = new MutableBoolean(false);
- final MutableBoolean bool2 = new MutableBoolean(false);
- Object empty = new RegistrationSupport.Empty(bool1, bool2);
- final ObjectName name = new ObjectName("simon:mbean=empty");
- server.registerMBean(empty, name);
- // Check registration
- if (!bool1.get())
- {
- fail("postRegister called with wrong argument value for successful registration");
- }
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
- }
-
- public void testDuplicateRegistration() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- final MutableBoolean bool1 = new MutableBoolean(false);
- final MutableBoolean bool2 = new MutableBoolean(false);
- Object empty = new RegistrationSupport.Empty(bool1, bool2);
- final ObjectName name = new ObjectName("simon:mbean=empty");
- server.registerMBean(empty, name);
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
-
- Object duplicate = new RegistrationSupport.EmptyDuplicate(name, bool1);
- try
- {
- server.registerMBean(duplicate, null);
- fail("MBean with same name cannot be registered");
- }
- catch (InstanceAlreadyExistsException ignored)
- {
- }
- // Check that postRegister was called correctly
- if (bool1.get())
- {
- fail("postRegister called with wrong argument value for unsuccessful registration");
- }
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was registered, and it shouldn't");
- }
- }
-
- public void testDeregistration() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- final MutableBoolean bool1 = new MutableBoolean(false);
- final MutableBoolean bool2 = new MutableBoolean(false);
- Object empty = new RegistrationSupport.Empty(bool1, bool2);
- final ObjectName name = new ObjectName("simon:mbean=empty");
- server.registerMBean(empty, name);
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
-
- bool1.set(true);
- bool2.set(true);
- server.unregisterMBean(name);
- if (server.getMBeanCount().intValue() != count)
- {
- fail("MBean was not unregistered");
- }
- if (bool1.get() || bool2.get())
- {
- fail("preDeregister or postDeregister are not called");
- }
- }
-
- public void testDuplicateDeregistration() throws Exception
- {
- MBeanServer server = newMBeanServer();
- int count = server.getMBeanCount().intValue();
- final MutableBoolean bool1 = new MutableBoolean(false);
- final MutableBoolean bool2 = new MutableBoolean(false);
- Object empty = new RegistrationSupport.Empty(bool1, bool2);
- final ObjectName name = new ObjectName("simon:mbean=empty");
- server.registerMBean(empty, name);
- if (server.getMBeanCount().intValue() != count + 1)
- {
- fail("MBean was not registered");
- }
-
- bool1.set(true);
- bool2.set(true);
- server.unregisterMBean(name);
- if (server.getMBeanCount().intValue() != count)
- {
- fail("MBean was not unregistered");
- }
- if (bool1.get() || bool2.get())
- {
- fail("preDeregister or postDeregister are not called");
- }
-
- // Try again
- try
- {
- server.unregisterMBean(name);
- fail("Already unregistered MBean can be unregistered");
- }
- catch (InstanceNotFoundException ignored)
- {
- }
- }
-
- public void testNotificationDuringRegistrationForStdMBean() throws Exception
- {
- final MBeanServer server = newMBeanServer();
- Object mbean = new RegistrationSupport.Std();
- final ObjectName name = new ObjectName(":mbean=std");
- server.addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), new NotificationListener()
- {
- public void handleNotification(Notification notification, Object handback)
- {
- invokeOperationsDuringRegistration(server, name, notification);
- }
- }, null, null);
-
- server.registerMBean(mbean, name);
- }
-
- public void testNotificationDuringRegistrationForDynMBean() throws Exception
- {
- final MBeanServer server = newMBeanServer();
- Object mbean = new RegistrationSupport.Dyn();
- final ObjectName name = new ObjectName(":mbean=dyn");
- server.addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), new NotificationListener()
- {
- public void handleNotification(Notification notification, Object handback)
- {
- invokeOperationsDuringRegistration(server, name, notification);
- }
- }, null, null);
-
- server.registerMBean(mbean, name);
- }
-
- private void invokeOperationsDuringRegistration(MBeanServer server, ObjectName name, Notification notification)
- {
- if (notification != null)
- {
- MBeanServerNotification notif = (MBeanServerNotification)notification;
- ObjectName registered = notif.getMBeanName();
- if (!registered.equals(name)) fail("Notification for the wrong MBean: " + registered + ", should be " + name);
- if (!MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notif.getType())) fail("Expecting a registration notification");
- }
-
- try
- {
- MBeanInfo info = server.getMBeanInfo(name);
- if (info.getClassName() == null) fail("MBeanInfo not initialized correctly");
- if (info.getOperations().length == 0) fail("MBeanInfo not initialized correctly");
-
- ObjectInstance instance = server.getObjectInstance(name);
- if (instance == null) fail("ObjectInstance should be already initialized");
-
- boolean isRegistered = server.isRegistered(name);
- if (!isRegistered) fail("MBean is registered");
-
- // Must be able to invoke it with no exceptions
- server.invoke(name, RegistrationSupport.StdMBean.class.getMethods()[0].getName(), null, null);
- }
- catch (Exception x)
- {
- fail("MBean metadata structures are not yet ready, but they should be: " + x);
- }
- }
-
- public void testInvokeMBeanServerOperationsInCallbacks() throws Exception
- {
- MBeanServer server = newMBeanServer();
- Object mbean = new InvokeDuringCallbacks();
- ObjectName name = ObjectName.getInstance(":name=invoke");
- server.registerMBean(mbean, name);
- server.unregisterMBean(name);
- }
-
- public void testDistinguishAttributesOperations() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName objname = new ObjectName("tests:id=distinguishAttributesOperations");
- Bar b = new Bar();
- server.registerMBean(b, objname);
- MBeanInfo info = server.getMBeanInfo(objname);
- assertTrue("Expecting one attribute", info.getAttributes().length == 1);
- try
- {
- assertTrue("No 'Beer' attribute", ((Integer)server.getAttribute(objname, "Beer")).intValue() == 0);
- String[] getresult = (String[])server.invoke(objname, "get", new Object[0], new String[0]);
- assertTrue("Expecting zero length result", getresult.length == 0);
- server.getAttribute(objname, "BEER");
- fail("Expecting AttributeNotFoundException");
- }
- catch (AttributeNotFoundException x)
- {
- assertTrue(true);
- }
- assertTrue("Expecting three operations", info.getOperations().length == 3);
- }
-
- public void testListenerRegistrationUnregistrationDuringCallbacks() throws Exception
- {
- MBeanServer server = newMBeanServer();
- MutableObject holder = new MutableObject(null);
- Object mbean = new RegistrationSupport.ListenerRegistrar(holder);
- ObjectName name = ObjectName.getInstance("test:type=notifications");
- server.registerMBean(mbean, name);
-
- // Register a new MBean, the holder must be notified
- ObjectName mlet = ObjectName.getInstance("test:type=mlet");
- server.createMBean(MLet.class.getName(), mlet, null);
-
- Notification notification = (Notification)holder.get();
- assertNotNull(notification);
- assertEquals(notification.getType(), MBeanServerNotification.REGISTRATION_NOTIFICATION);
- holder.set(null);
-
- server.unregisterMBean(mlet);
-
- notification = (Notification)holder.get();
- assertNotNull(notification);
- assertEquals(notification.getType(), MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
- holder.set(null);
-
- // Unregisters also the listeners (in postDeregister)
- server.unregisterMBean(name);
- notification = (Notification)holder.get();
- assertNotNull(notification);
- assertEquals(notification.getType(), MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
- holder.set(null);
-
- server.createMBean(MLet.class.getName(), mlet, null);
- notification = (Notification)holder.get();
- assertNull(notification);
-
- server.unregisterMBean(mlet);
- notification = (Notification)holder.get();
- assertNull(notification);
- }
-
- public void testAbstractClass() throws Exception
- {
- MBeanServer server = newMBeanServer();
- try
- {
- server.createMBean(Foo.class.getName(), null);
- fail();
- }
- catch (NotCompliantMBeanException e)
- {
- // ok
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- public static interface BarMBean
- {
- int getBeer();
-
- void getBEER();
-
- int getBeer(String name);
-
- String[] get();
- }
-
- public static class Bar implements BarMBean
- {
- public Bar()
- {
- }
-
- public String[] get()
- {
- return new String[0];
- }
-
- public int getBeer()
- {
- return 0;
- }
-
- public void getBEER()
- {
- throw new java.lang.Error("No BEER here");
- }
-
- public int getBeer(String name)
- {
- return 0;
- }
- }
-
- public interface InvokeDuringCallbacksMBean
- {
- public void method();
- }
-
- public class InvokeDuringCallbacks implements InvokeDuringCallbacksMBean, MBeanRegistration
- {
- private MBeanServer server;
- private ObjectName name;
-
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
- {
- this.server = server;
- this.name = name;
- return name;
- }
-
- public void postRegister(Boolean registrationDone)
- {
- invokeOperationsDuringRegistration(server, name, null);
- }
-
- public void preDeregister() throws Exception
- {
- invokeOperationsDuringRegistration(server, name, null);
- }
-
- public void postDeregister()
- {
- }
-
- public void method()
- {
- }
- }
-
- public static interface FooMBean
- {
- void something();
- }
-
- public static abstract class Foo implements FooMBean
- {
- public void something()
- {
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerBuilderTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerBuilderTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerBuilderTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.util.HashMap;
-
-import mx4j.MX4JTestCase;
-import mx4j.server.ChainedMBeanServer;
-import mx4j.server.ChainedMBeanServerBuilder;
-import mx4j.server.MX4JMBeanServer;
-import mx4j.server.MX4JMBeanServerBuilder;
-import mx4j.server.MX4JMBeanServerDelegate;
-
-/**
- * @version $Revision$
- */
-public class MBeanServerBuilderTest extends MX4JTestCase
-{
- private static final String INITIAL_BUILDER = "javax.management.builder.initial";
-
- private MBeanServer newMBeanServer()
- {
- return MBeanServerFactory.newMBeanServer();
- }
-
- public void testDefaultBuilder() throws Exception
- {
- System.getProperties().remove(INITIAL_BUILDER);
- MBeanServer server = newMBeanServer();
- if (!(server instanceof MX4JMBeanServer))
- fail("Wrong default server implementation");
- }
-
- public void testCustomBuilder() throws Exception
- {
- try
- {
- System.setProperty(INITIAL_BUILDER, CustomBuilder.class.getName());
- MBeanServer server = newMBeanServer();
- if (!(server instanceof CustomMBeanServer))
- fail("Wrong custom server implementation");
- if (!server.isInstanceOf(new ObjectName("JMImplementation", "type", "MBeanServerDelegate"), CustomDelegate.class.getName()))
- fail("wrong delegate implementation");
- }
- finally
- {
- System.getProperties().remove(INITIAL_BUILDER);
- }
- }
-/*
- public void testMX4JunderJMXRI() throws Exception
- {
- ClassLoader jmxriLoader = createJMXRIWithMX4JImplClassLoader();
-
- Class jmxri_c_mBeanServerFactory = jmxriLoader.loadClass("javax.management.MBeanServerFactory");
- Method jmxri_m_newMBeanServer = jmxri_c_mBeanServerFactory.getMethod("newMBeanServer", new Class[0]);
-
- System.getProperties().remove(INITIAL_BUILDER);
- Object jmxri_MBeanServer = jmxri_m_newMBeanServer.invoke(null, new Object[0]);
-
- boolean isJMXRImBeanServer = jmxri_MBeanServer.getClass().getName().startsWith("com.sun.jmx.");
- if (!isJMXRImBeanServer)
- fail("Failed to make use of JMXRI classes");
-
- final ClassLoader oldContextLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- System.setProperty(INITIAL_BUILDER, MX4JMBeanServerBuilder.class.getName());
- Thread.currentThread().setContextClassLoader(jmxriLoader);
- Object mx4j_MBeanServer = jmxri_m_newMBeanServer.invoke(null, new Object[0]);
- boolean isMX4JMBeanServer = mx4j_MBeanServer.getClass().getName().startsWith("mx4j.server.");
- if (!isMX4JMBeanServer)
- fail("Not using MX4J as specified by javax.management.builder.initial");
- }
- finally
- {
- System.getProperties().remove(INITIAL_BUILDER);
- Thread.currentThread().setContextClassLoader(oldContextLoader);
- }
- }
-*/
- public void testChainedMBeanServerBuilder() throws Exception
- {
- try
- {
- System.setProperty(INITIAL_BUILDER, ComplexBuilder.class.getName());
- MBeanServer server = newMBeanServer();
- if (!(server instanceof LoggingMBeanServer)) fail();
- server.registerMBean(new Simple(), new ObjectName(":mbean=simple"));
- Object vendor = server.getAttribute(new ObjectName("JMImplementation", "type", "MBeanServerDelegate"), "ImplementationVendor");
- if (!(vendor instanceof HashMap)) fail();
- if (((HashMap)vendor).size() != 4) fail();
- }
- finally
- {
- System.getProperties().remove(INITIAL_BUILDER);
- }
- }
-
- // Support classes
-
- /**
- * This is a simple terminal builder, that is a builder that creates a full MBeanServer implementation.
- * It cannot be used to chain other builders, it can only be used as the last builder in the chain.
- */
- public static class CustomBuilder extends MBeanServerBuilder
- {
- public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
- {
- return new CustomMBeanServer(defaultDomain, outer, delegate);
- }
-
- public MBeanServerDelegate newMBeanServerDelegate()
- {
- return new CustomDelegate();
- }
- }
-
- /**
- * Custom delegate class, for testing.
- */
- public static class CustomDelegate extends MX4JMBeanServerDelegate
- {
- }
-
- public static class CustomMBeanServer extends MX4JMBeanServer
- {
- public CustomMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
- {
- super(defaultDomain, outer, delegate);
- }
- }
-
- public static class ComplexBuilder extends ChainedMBeanServerBuilder
- {
- public ComplexBuilder()
- {
- super(new LoggingBuilder(new PerformanceBuilder(new MX4JMBeanServerBuilder())));
- }
- }
-
- public static class LoggingBuilder extends ChainedMBeanServerBuilder
- {
- public LoggingBuilder(MBeanServerBuilder chain)
- {
- super(chain);
- }
-
- public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
- {
- LoggingMBeanServer external = new LoggingMBeanServer();
- MBeanServer nested = getMBeanServerBuilder().newMBeanServer(defaultDomain, outer == null ? external : outer, delegate);
- external.setMBeanServer(nested);
- return external;
- }
- }
-
- public static class PerformanceBuilder extends ChainedMBeanServerBuilder
- {
- public PerformanceBuilder(MBeanServerBuilder chain)
- {
- super(chain);
- }
-
- public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
- {
- TimingMBeanServer external = new TimingMBeanServer();
- MBeanServer nested = getMBeanServerBuilder().newMBeanServer(defaultDomain, outer == null ? external : outer, delegate);
- external.setMBeanServer(new InvocationCounterMBeanServer(nested));
- return external;
- }
- }
-
- public static class LoggingMBeanServer extends ChainedMBeanServer
- {
- protected void setMBeanServer(MBeanServer server)
- {
- super.setMBeanServer(server);
- }
-
- public Object getAttribute(ObjectName objectName, String attribute)
- throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
- {
- HashMap map = (HashMap)super.getAttribute(objectName, attribute);
- map.put("logged", "logged");
- return map;
- }
- }
-
- public static class TimingMBeanServer extends ChainedMBeanServer
- {
- protected void setMBeanServer(MBeanServer server)
- {
- super.setMBeanServer(server);
- }
-
- public Object getAttribute(ObjectName objectName, String attribute)
- throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
- {
- long start = System.currentTimeMillis();
- HashMap ret = (HashMap)super.getAttribute(objectName, attribute);
- long end = System.currentTimeMillis();
- long elapsed = end - start;
- System.out.println("Elapsed: " + elapsed);
- ret.put("elapsed", new Long(elapsed));
- return ret;
- }
- }
-
- public static class InvocationCounterMBeanServer extends ChainedMBeanServer
- {
- private ThreadLocal getAttributeCount = new ThreadLocal()
- {
- protected Object initialValue()
- {
- return new Long(0);
- }
- };
-
- public InvocationCounterMBeanServer(MBeanServer server)
- {
- super(server);
- }
-
- public Object getAttribute(ObjectName objectName, String attribute)
- throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
- {
- Long count = (Long)getAttributeCount.get();
- count = new Long(count.longValue() + 1);
- getAttributeCount.set(count);
- System.out.println("Counted: " + count);
-
- HashMap map = new HashMap();
- map.put("result", super.getAttribute(objectName, attribute));
- map.put("count", count);
-
- return map;
- }
- }
-
- public interface SimpleMBean
- {
- }
-
- public static class Simple implements SimpleMBean, MBeanRegistration
- {
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
- {
- if (!(server instanceof LoggingMBeanServer)) fail();
- return name;
- }
-
- public void postRegister(Boolean registrationDone)
- {
- }
-
- public void preDeregister() throws Exception
- {
- }
-
- public void postDeregister()
- {
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerFactoryTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerFactoryTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerFactoryTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-/**
- * @version $Revision$
- */
-public class MBeanServerFactoryTest extends TestCase
-{
- public void testCreate() throws Exception
- {
- MBeanServer server1 = null;
- try
- {
- System.out.print("Creating MBeanServer 1 ... ");
- server1 = MBeanServerFactory.createMBeanServer();
- System.out.println("OK");
- System.out.print("Finding MBeanServer... ");
- List l = MBeanServerFactory.findMBeanServer(null);
- if (l.size() != 1)
- {
- fail("MBeanServer creation is not tracked");
- }
- if (!server1.equals(l.get(0)))
- {
- fail("MBeanServer found is different");
- }
- System.out.println("Found, OK");
- }
- finally
- {
- MBeanServerFactory.releaseMBeanServer(server1);
- }
- }
-
- public void testNew() throws Exception
- {
- MBeanServer server1 = null;
- try
- {
- System.out.print("Creating MBeanServer 1 ... ");
- server1 = MBeanServerFactory.createMBeanServer();
- System.out.println("OK");
-
- // newMBeanServer must not keep track of the MBeanServer it creates
- System.out.print("Newing MBeanServer 2 ... ");
- MBeanServer server2 = MBeanServerFactory.newMBeanServer();
- System.out.println("OK");
- System.out.print("Finding MBeanServer... ");
- List l = MBeanServerFactory.findMBeanServer(null);
- if (l.size() != 1)
- {
- fail("newMBeanServer tracks creation");
- }
- if (!server1.equals(l.get(0)))
- {
- fail("MBeanServer found is different");
- }
- System.out.println("Found number 1, OK");
- }
- finally
- {
- MBeanServerFactory.releaseMBeanServer(server1);
- }
- }
-
-
- public void testCreateWithDomain()
- {
- MBeanServer server1 = null;
- MBeanServer server3 = null;
- try
- {
- System.out.print("Creating MBeanServer 1 ... ");
- server1 = MBeanServerFactory.createMBeanServer();
- System.out.println("OK");
-
- String domain = "test";
-
- System.out.print("Creating MBeanServer 3 ... ");
- server3 = MBeanServerFactory.createMBeanServer(domain);
- System.out.println("OK");
- System.out.print("Finding MBeanServer... ");
- List l = MBeanServerFactory.findMBeanServer(null);
- if (l.size() != 2)
- {
- fail("MBeanServer creation is not tracked");
- }
- MBeanServer found1 = (MBeanServer)l.get(0);
- if (!found1.getDefaultDomain().equals(server1.getDefaultDomain()))
- {
- fail("MBeanServer found is different");
- }
- if (!server3.equals(l.get(1)))
- {
- fail("MBeanServer found is different");
- }
- if (!server3.getDefaultDomain().equals(domain))
- {
- fail("Domain is different");
- }
- System.out.println("Found number 1 & 3, OK");
- }
- finally
- {
- MBeanServerFactory.releaseMBeanServer(server1);
- MBeanServerFactory.releaseMBeanServer(server3);
- }
- }
-
-
- public void testRelease() throws Exception
- {
- System.out.print("Creating MBeanServer 1 ... ");
- MBeanServer server1 = MBeanServerFactory.createMBeanServer();
- System.out.println("OK");
-
- System.out.print("Creating MBeanServer 2 ... ");
- String domain = "test";
- MBeanServer server2 = MBeanServerFactory.createMBeanServer(domain);
- System.out.println("OK");
-
- System.out.print("Releasing MBeanServer 1 ... ");
- List l = MBeanServerFactory.findMBeanServer(null);
- MBeanServer found1 = (MBeanServer)l.get(0);
- MBeanServerFactory.releaseMBeanServer(found1);
- System.out.println("OK");
-
- System.out.print("Finding MBeanServer... ");
- l = MBeanServerFactory.findMBeanServer(null);
- if (l.size() != 1)
- {
- fail("Removed MBeanServer still present");
- }
- MBeanServer found2 = (MBeanServer)l.get(0);
- if (!found2.getDefaultDomain().equals(domain))
- {
- fail("Removed wrong MBeanServer");
- }
- System.out.println("Found number 2, OK");
-
- System.out.print("Releasing MBeanServer 2 ... ");
- MBeanServerFactory.releaseMBeanServer(found2);
- System.out.println("OK");
-
- System.out.print("Finding MBeanServer... ");
- l = MBeanServerFactory.findMBeanServer(null);
- if (l.size() != 0)
- {
- fail("Removed MBeanServer still present");
- }
- System.out.println("Found none, OK");
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerInvocationHandlerTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerInvocationHandlerTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerInvocationHandlerTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,521 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-
-import javax.naming.NamingException;
-
-import mx4j.MX4JTestCase;
-
-/**
- * @version $Revision$
- */
-public class MBeanServerInvocationHandlerTest extends MX4JTestCase
-{
- private MBeanServer newMBeanServer()
- {
- return MBeanServerFactory.newMBeanServer();
- }
-
- public void testBadArguments() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
-
- try
- {
- MBeanServerInvocationHandler.newProxyInstance(null, name, LocalServiceMBean.class, false);
- fail("MBeanServerConnection cannot be null");
- }
- catch (IllegalArgumentException x)
- {
- }
-
- try
- {
- MBeanServerInvocationHandler.newProxyInstance(server, null, LocalServiceMBean.class, false);
- fail("ObjectName cannot be null");
- }
- catch (IllegalArgumentException x)
- {
- }
-
- try
- {
- MBeanServerInvocationHandler.newProxyInstance(server, name, null, false);
- fail("Class cannot be null");
- }
- catch (IllegalArgumentException x)
- {
- }
-
- try
- {
- MBeanServerInvocationHandler.newProxyInstance(server, name, LocalService.class, false);
- fail("Class must be an interface");
- }
- catch (IllegalArgumentException x)
- {
- }
- }
-
- public void testMBeanNotAnEmitter() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter emitter = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, true);
-
- try
- {
- emitter.addNotificationListener(new TestListener(), null, null);
- fail("The MBean is not a NotificationEmitter");
- }
- catch (IllegalArgumentException x)
- {
- }
- }
-
- public void testDeregisteredMBean() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- // Check what the proxy throws if the ObjectName is removed from the server
- LocalServiceMBean proxy = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, false);
- server.unregisterMBean(name);
- try
- {
- proxy.throwCheckedException();
- fail();
- }
- catch (NamingException x)
- {
- fail("Expecting an InstanceNotFoundException");
- }
- catch (UndeclaredThrowableException x)
- {
- Throwable xx = x.getUndeclaredThrowable();
- if (!(xx instanceof InstanceNotFoundException))
- fail("Expecting an InstanceNotFoundException");
- }
- }
-
- public void testCheckedException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- LocalServiceMBean proxy = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, false);
- try
- {
- proxy.throwCheckedException();
- fail();
- }
- catch (NamingException x)
- {
- }
- }
-
- public void testMBeanException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- LocalServiceMBean proxy = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, false);
- try
- {
- proxy.throwMBeanException();
- fail();
- }
- catch (MBeanException x)
- {
- }
- }
-
- public void testRuntimeException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- LocalServiceMBean proxy = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, false);
- try
- {
- proxy.throwNullPointerException();
- fail();
- }
- catch (NullPointerException x)
- {
- }
- }
-
- public void testError() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- LocalServiceMBean proxy = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, LocalServiceMBean.class, false);
- try
- {
- proxy.throwError();
- fail();
- }
- catch (Error x)
- {
- }
- }
-
- public void testNotificationBroadcasterProxy() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalBroadcasterService mbean = new LocalBroadcasterService();
- server.registerMBean(mbean, name);
-
- // The returned interface should be NotificationEmitter, even though the MBean only implements NotificationBroadcaster
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationBroadcaster.class, true);
- assertNotNull(proxy);
- }
-
- public void testAddNotificationListener() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalEmitterService mbean = new LocalEmitterService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
- TestListener listener = new TestListener();
- proxy.addNotificationListener(listener, null, null);
- mbean.test();
- if (!listener.received) fail();
- }
-
- public void testGetNotificationInfo() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalEmitterService mbean = new LocalEmitterService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
- MBeanNotificationInfo[] infos = proxy.getNotificationInfo();
- if (!infos[0].getDescription().equals(LocalEmitterService.DESC)) fail();
- }
-
- public void testSimpleRemoveNotificationListener() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalEmitterService mbean = new LocalEmitterService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
- TestListener listener = new TestListener();
- proxy.addNotificationListener(listener, null, null);
- proxy.removeNotificationListener(listener);
- mbean.test();
- if (listener.received) fail();
- }
-
- public void testRemoveNotificationListener() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalEmitterService mbean = new LocalEmitterService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
- TestListener listener = new TestListener();
- TestFilter filter = new TestFilter();
- Object handback = new Object();
- proxy.addNotificationListener(listener, filter, handback);
- proxy.removeNotificationListener(listener, filter, handback);
- mbean.test();
- if (listener.received) fail();
- }
-
- public void testRemoveMultiNotificationListener() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalEmitterService mbean = new LocalEmitterService();
- server.registerMBean(mbean, name);
-
- NotificationEmitter proxy = (NotificationEmitter)MBeanServerInvocationHandler.newProxyInstance(server, name, NotificationEmitter.class, true);
- TestListener listener1 = new TestListener();
- TestFilter filter = new TestFilter();
- Object handback = new Object();
- proxy.addNotificationListener(listener1, filter, handback);
-
- TestListener listener2 = new TestListener();
- proxy.addNotificationListener(listener2, null, null);
-
- mbean.test();
- if (!listener1.received) fail();
- if (!listener2.received) fail();
-
- try
- {
- proxy.removeNotificationListener(listener2, filter, handback);
- fail("Listener is not registered");
- }
- catch (ListenerNotFoundException x)
- {
- }
-
- proxy.removeNotificationListener(listener2, null, null);
- listener1.received = false;
- listener2.received = false;
-
- mbean.test();
- if (!listener1.received) fail();
- if (listener2.received) fail();
- }
-/*
- public void testRemoteExceptionWithRemoteInterface() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost");
- JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
- cntorServer.start();
- JMXConnector cntor = JMXConnectorFactory.connect(cntorServer.getAddress());
- MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
-
- RemoteService remoteMBean = (RemoteService)MBeanServerInvocationHandler.newProxyInstance(mbsc, name, RemoteService.class, false);
-
- // Close everything to get IOException
- cntor.close();
- cntorServer.stop();
-
- try
- {
- remoteMBean.throwCheckedException();
- fail("Must not be able to connect");
- }
- catch (IOException x)
- {
- }
- }
-
- public void testRemoteExceptionWithLocalInterface() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost");
- JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
- cntorServer.start();
- JMXConnector cntor = JMXConnectorFactory.connect(cntorServer.getAddress());
- MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
-
- LocalServiceMBean remoteMBean = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(mbsc, name, LocalServiceMBean.class, false);
-
- // Close everything to get IOException
- cntor.close();
- cntorServer.stop();
-
- // Now try the local interface
- try
- {
- remoteMBean.throwCheckedException();
- fail("Must not be able to connect");
- }
- catch (UndeclaredThrowableException x)
- {
- Throwable xx = x.getUndeclaredThrowable();
- if (!(xx instanceof IOException)) fail();
- }
- }
-
- public void testRemoteCheckedException() throws Exception
- {
- MBeanServer server = newMBeanServer();
- ObjectName name = new ObjectName("domain:key=value");
- LocalService mbean = new LocalService();
- server.registerMBean(mbean, name);
-
- JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost");
- JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
- cntorServer.start();
- JMXConnector cntor = JMXConnectorFactory.connect(cntorServer.getAddress());
- MBeanServerConnection mbsc = cntor.getMBeanServerConnection();
-
- LocalServiceMBean remoteMBean = (LocalServiceMBean)MBeanServerInvocationHandler.newProxyInstance(mbsc, name, LocalServiceMBean.class, false);
- try
- {
- remoteMBean.throwCheckedException();
- fail();
- }
- catch (NamingException x)
- {
- }
- }
-*/
- public interface LocalServiceMBean
- {
- public void throwCheckedException() throws NamingException;
-
- public void throwMBeanException() throws MBeanException;
-
- public void throwNullPointerException();
-
- public void throwError();
- }
-
- public interface RemoteService
- {
- public void throwCheckedException() throws NamingException, IOException;
-
- public void throwMBeanException() throws MBeanException, IOException;
-
- public void throwNullPointerException() throws IOException;
-
- public void throwError() throws IOException;
- }
-
- public class LocalService implements LocalServiceMBean
- {
- public void throwCheckedException() throws NamingException
- {
- throw new NamingException();
- }
-
- public void throwMBeanException() throws MBeanException
- {
- throw new MBeanException(new Exception());
- }
-
- public void throwNullPointerException()
- {
- throw new NullPointerException();
- }
-
- public void throwError()
- {
- throw new Error();
- }
- }
-
- public class LocalBroadcasterService extends LocalService implements NotificationBroadcaster
- {
- private NotificationBroadcasterSupport support = new NotificationBroadcasterSupport();
- static final String TYPE = "test.notification";
- static final String DESC = "Test Notification";
- private long sequence;
-
- /**
- * @see javax.management.NotificationBroadcaster#addNotificationListener(NotificationListener,NotificationFilter,Object)
- */
- public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
- throws IllegalArgumentException
- {
- support.addNotificationListener(listener, filter, handback);
- }
-
- /**
- * @see javax.management.NotificationBroadcaster#getNotificationInfo()
- */
- public MBeanNotificationInfo[] getNotificationInfo()
- {
- return new MBeanNotificationInfo[]{
- new MBeanNotificationInfo(new String[]{TYPE}, Notification.class.getName(), DESC),
- };
- }
-
- /**
- * @see javax.management.NotificationBroadcaster#removeNotificationListener(NotificationListener)
- */
- public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
- {
- support.removeNotificationListener(listener);
- }
-
- public void test()
- {
- Notification notification = new Notification(TYPE, this, ++sequence, System.currentTimeMillis(), DESC);
- support.sendNotification(notification);
- }
- }
-
- public class LocalEmitterService extends LocalService implements NotificationEmitter
- {
- private NotificationBroadcasterSupport support = new NotificationBroadcasterSupport();
- static final String TYPE = "test.notification";
- static final String DESC = "Test Notification";
- private long sequence;
-
- public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
- throws IllegalArgumentException
- {
- support.addNotificationListener(listener, filter, handback);
- }
-
- public MBeanNotificationInfo[] getNotificationInfo()
- {
- return new MBeanNotificationInfo[]{
- new MBeanNotificationInfo(new String[]{TYPE}, Notification.class.getName(), DESC),
- };
- }
-
- public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
- {
- support.removeNotificationListener(listener);
- }
-
- public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
- {
- support.removeNotificationListener(listener, filter, handback);
- }
-
- public void test()
- {
- Notification notification = new Notification(TYPE, this, ++sequence, System.currentTimeMillis(), DESC);
- support.sendNotification(notification);
- }
- }
-
- public class TestListener implements NotificationListener
- {
- boolean received = false;
-
- public void handleNotification(Notification notification, Object handback)
- {
- received = true;
- }
- }
-
- public class TestFilter implements NotificationFilter
- {
- public boolean isNotificationEnabled(Notification notification)
- {
- return notification.getType().equals(LocalEmitterService.TYPE);
- }
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerPermissionTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerPermissionTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerPermissionTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-/**
- * @version $Revision$
- */
-public class MBeanServerPermissionTest extends PermissionTestCase
-{
- public void testInvalid() throws Exception
- {
- try
- {
- new MBeanServerPermission(null);
- fail("Invalid MBeanServerPermission");
- }
- catch (NullPointerException ignored)
- {
- }
-
- try
- {
- new MBeanServerPermission("");
- fail("Invalid MBeanServerPermission");
- }
- catch (IllegalArgumentException ignored)
- {
- }
-
- try
- {
- new MBeanServerPermission(" ");
- fail("Invalid MBeanServerPermission");
- }
- catch (IllegalArgumentException ignored)
- {
- }
-
- try
- {
- new MBeanServerPermission(" , ");
- fail("Invalid MBeanServerPermission");
- }
- catch (IllegalArgumentException ignored)
- {
- }
-
- try
- {
- new MBeanServerPermission("invalid");
- fail("Invalid MBeanServerPermission");
- }
- catch (IllegalArgumentException ignored)
- {
- }
-
- try
- {
- new MBeanServerPermission("*", "invalid");
- fail("Invalid MBeanServerPermission");
- }
- catch (IllegalArgumentException ignored)
- {
- }
- }
-
- public void testValid() throws Exception
- {
- new MBeanServerPermission("*");
- new MBeanServerPermission("*", "");
- new MBeanServerPermission("createMBeanServer");
- new MBeanServerPermission("releaseMBeanServer, findMBeanServer");
- new MBeanServerPermission("newMBeanServer, *");
- }
-
- public void testShuffledAreEquals() throws Exception
- {
- MBeanServerPermission mbsp1 = new MBeanServerPermission("createMBeanServer, releaseMBeanServer");
- MBeanServerPermission mbsp2 = new MBeanServerPermission("releaseMBeanServer, createMBeanServer");
-
- shouldBeEqual(mbsp1, mbsp2);
-
- MBeanServerPermission mbsp3 = new MBeanServerPermission("*");
- MBeanServerPermission mbsp4 = new MBeanServerPermission("releaseMBeanServer, *");
-
- shouldBeEqual(mbsp3, mbsp4);
- }
-
- public void testCreateImpliesNew() throws Exception
- {
- shouldImply(new MBeanServerPermission("createMBeanServer"), new MBeanServerPermission("newMBeanServer"));
- }
-
- public void testImplies() throws Exception
- {
- shouldImply(new MBeanServerPermission("*"), new MBeanServerPermission("createMBeanServer"));
- shouldImply(new MBeanServerPermission("*"), new MBeanServerPermission("newMBeanServer"));
- shouldImply(new MBeanServerPermission("*"), new MBeanServerPermission("findMBeanServer"));
- shouldImply(new MBeanServerPermission("*"), new MBeanServerPermission("releaseMBeanServer"));
- shouldImply(new MBeanServerPermission("*"), new MBeanServerPermission("createMBeanServer, releaseMBeanServer"));
- shouldImply(new MBeanServerPermission("createMBeanServer, releaseMBeanServer"), new MBeanServerPermission("createMBeanServer"));
- shouldImply(new MBeanServerPermission("createMBeanServer, releaseMBeanServer"), new MBeanServerPermission("releaseMBeanServer"));
- }
-
- public void testNotImplies()
- {
- shouldNotImply(new MBeanServerPermission("createMBeanServer"), new MBeanServerPermission("releaseMBeanServer"));
- shouldNotImply(new MBeanServerPermission("createMBeanServer"), new MBeanServerPermission("newMBeanServer, releaseMBeanServer"));
- }
-
- public void testSerializationDeserialization() throws Exception
- {
- MBeanServerPermission permission = new MBeanServerPermission("newMBeanServer, *");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(permission);
- oos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- MBeanServerPermission deserialized = (MBeanServerPermission)ois.readObject();
- ois.close();
-
- if (!(deserialized.equals(permission))) fail("Serialization/Deserialization failed");
- }
-}
Deleted: trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerTest.java
===================================================================
--- trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerTest.java 2007-03-20 21:13:52 UTC (rev 2259)
+++ trunk/mx4j/jsr003/src/test/java/javax/management/MBeanServerTest.java 2007-03-20 22:28:00 UTC (rev 2260)
@@ -1,358 +0,0 @@
-/*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
- * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
- */
-
-package javax.management;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Set;
-
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV