[jboss-cvs] JBossAS SVN: r88864 - in projects/jbossmx/trunk/mbeanserver: src and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 14 08:23:59 EDT 2009
Author: adrian at jboss.org
Date: 2009-05-14 08:23:58 -0400 (Thu, 14 May 2009)
New Revision: 88864
Added:
projects/jbossmx/trunk/mbeanserver/src/test/
projects/jbossmx/trunk/mbeanserver/src/test/org/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTestDelegate.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/ComplianceSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/support/Resource.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructor.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructorMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandard.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandardMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblems.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsSuperMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/NullDynamic.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryMBeansObjectNameOnlyTestCase.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QuerySUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryTestCase.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/Trivial.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/TrivialMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAware.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAwareMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/DefaultDomainTestCase.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanDelegateTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerBuilderTestCase.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerFactoryTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerInvocationHandlerTestCase.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/ServerSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/AClass.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BabarError.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Base.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BaseMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Broadcaster.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterInvocationHandlerTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest2.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest3.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest4.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest5.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest6.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest7.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/DelegateListener.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Derived.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Dynamic.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/EmitterInvocationHandlerTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ExceptionOnTheRun.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Listener.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ListenerMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListener.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListenerMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerReplaced.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerWrapper.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MyScreamingException.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTest.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerBuilder.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerDelegate.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Unrelated.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/UnrelatedMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/AttributeInfoTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/ConstructorInfoTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoTortureSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoUtil.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InheritanceSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/OperationInfoTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/SpuriousAttributeTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardMBeanTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardSUITE.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/TrivialTEST.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/ArbitraryInterface.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/DynamicDerived1.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MBeanRunnable.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyManagementInterface.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyRunnable.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyStandardMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/NoConstructorsStandardMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived1.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3MBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParent.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParentMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Torture.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TortureMBean.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Trivial.java
projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TrivialMBean.java
Modified:
projects/jbossmx/trunk/mbeanserver/.classpath
projects/jbossmx/trunk/mbeanserver/pom.xml
projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/DelegateMBeanServer.java
projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServer.java
projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServerBuilder.java
Log:
Unit tests for wrapping the JDK MBeanServer
Modified: projects/jbossmx/trunk/mbeanserver/.classpath
===================================================================
--- projects/jbossmx/trunk/mbeanserver/.classpath 2009-05-14 11:35:17 UTC (rev 88863)
+++ projects/jbossmx/trunk/mbeanserver/.classpath 2009-05-14 12:23:58 UTC (rev 88864)
@@ -1,5 +1,17 @@
<classpath>
<classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/test" output="target/test-classes"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.10.GA/jboss-common-core-2.2.10.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/0.1.1.GA/jboss-server-manager-0.1.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.1.GA/jboss-test-1.1.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
</classpath>
\ No newline at end of file
Modified: projects/jbossmx/trunk/mbeanserver/pom.xml
===================================================================
--- projects/jbossmx/trunk/mbeanserver/pom.xml 2009-05-14 11:35:17 UTC (rev 88863)
+++ projects/jbossmx/trunk/mbeanserver/pom.xml 2009-05-14 12:23:58 UTC (rev 88864)
@@ -13,16 +13,20 @@
<description>JBossMX (mbeanserver module)</description>
<build>
<sourceDirectory>src/main</sourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
+ <testSourceDirectory>src/test</testSourceDirectory>
</build>
+ <dependencies>
+ <!-- Compile (global dependencies) -->
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
Modified: projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/DelegateMBeanServer.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/DelegateMBeanServer.java 2009-05-14 11:35:17 UTC (rev 88863)
+++ projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/DelegateMBeanServer.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -368,6 +368,7 @@
return getNext().getClassLoaderRepository();
}
+ @Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException,
OperationsException
@@ -375,6 +376,7 @@
return getNext().deserialize(name, data);
}
+ @Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException,
ReflectionException
@@ -382,6 +384,7 @@
return getNext().deserialize(className, data);
}
+ @Deprecated
public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
throws InstanceNotFoundException,
OperationsException,
Modified: projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServer.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServer.java 2009-05-14 11:35:17 UTC (rev 88863)
+++ projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServer.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -467,7 +467,9 @@
MBeanException,
InstanceNotFoundException
{
- ClassLoader cl = getOuter().getClassLoader(loaderName);
+ ClassLoader cl = null;
+ if (loaderName != null)
+ cl = getOuter().getClassLoader(loaderName);
ClassLoader previous = null;
if (cl != null)
previous = SecurityActions.setContextClassLoader(cl);
@@ -850,7 +852,11 @@
entry = null;
}
if (entry == null)
+ {
+ if ("JMImplementation".equals(name.getDomain()))
+ return null;
throw new InstanceNotFoundException(name + " is not registered");
+ }
return entry.getClassLoader();
}
Modified: projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServerBuilder.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServerBuilder.java 2009-05-14 11:35:17 UTC (rev 88863)
+++ projects/jbossmx/trunk/mbeanserver/src/main/org/jboss/jmx/mbeanserver/JBossMBeanServerBuilder.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -33,6 +33,9 @@
*/
public class JBossMBeanServerBuilder extends MBeanServerBuilder
{
+ /** The system property for the builder */
+ public final static String MBEAN_SERVER_BUILDER_CLASS_PROPERTY = "javax.management.builder.initial";
+
/**
* Construct an MBeanServerBuilder
*/
@@ -57,11 +60,11 @@
{
DelegateState state = new DelegateState(outer, delegate);
MBeanServerChain chain = new MBeanServerChain(state);
+ JBossMBeanServer result = new JBossMBeanServer(state);
- MBeanServer server = super.newMBeanServer(defaultDomain, chain.getOuter(), delegate);
+ MBeanServer server = super.newMBeanServer(defaultDomain, result, delegate);
chain.setTarget(server);
- JBossMBeanServer result = new JBossMBeanServer(state);
chain.addLast(result);
return result;
}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jmx;
+
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * A JBossJMXTest
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 78885 $
+ */
+public class JBossJMXTest extends AbstractTestCaseWithSetup
+{
+ /**
+ * Get the test delegate
+ *
+ * @param clazz the test class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new JBossJMXTestDelegate(clazz);
+ }
+
+ /**
+ * Create a new JBossJMX test
+ *
+ * @param name the test name
+ */
+ public JBossJMXTest(String name)
+ {
+ super(name);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTestDelegate.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTestDelegate.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/JBossJMXTestDelegate.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jmx;
+
+import java.util.ArrayList;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.jmx.mbeanserver.JBossMBeanServerBuilder;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * A JBossJMXestDelegate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 70576 $
+ */
+public class JBossJMXTestDelegate extends AbstractTestDelegate
+{
+ /**
+ * Create a new JBossJMXTestDelegate.
+ *
+ * @param clazz the test class
+ * @throws Exception for any error
+ */
+ public JBossJMXTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ System.setProperty(JBossMBeanServerBuilder.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, JBossMBeanServerBuilder.class.getName());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void tearDown() throws Exception
+ {
+ ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
+ for (MBeanServer server : servers)
+ {
+ log.warn("Removed unreleased mbeanserver " + server);
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ super.tearDown();
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/ComplianceSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/ComplianceSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/ComplianceSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Everything under test.compliance is a set of unit tests
+ * which should pass as much as possible against the JMX RI
+ *
+ * Additions to this package are welcome/encouraged - adding a
+ * test that fails is a great way to communicate a bug ;-)
+ *
+ * Anyone contributing to the JBoss JMX impl should seriously
+ * consider providing a testcase prior to making code changes
+ * in the impl itself - ala XP.
+ *
+ * The only restriction is that if the tests don't succeed against
+ * the RI, the test error message should indicate that the test
+ * will fail on the RI (preferred way) or at least comment the testcase
+ * stating expected failures. Either way, you should comment the code
+ * justifying why the test is valid despite failing against the RI.
+ *
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class ComplianceSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ try
+ {
+ // Support for RI tracing, use -Dcom.sun.jmx.trace.level=x where x is one of 0, 1 or 2
+ Class<?> trace = Thread.currentThread().getContextClassLoader().loadClass("com.sun.jmx.trace.TraceImplementation");
+ java.lang.reflect.Method init = trace.getMethod("init", new Class[] { Integer.TYPE });
+ init.invoke(null, new Object[] { new Integer(System.getProperty("com.sun.jmx.trace.level")) });
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All Compliance Tests");
+
+ suite.addTest(org.jboss.test.jmx.compliance.standard.StandardSUITE.suite());
+ suite.addTest(org.jboss.test.jmx.compliance.registration.RegistrationSUITE.suite());
+ suite.addTest(org.jboss.test.jmx.compliance.server.ServerSUITE.suite());
+ suite.addTest(org.jboss.test.jmx.compliance.modelmbean.ModelMBeanSUITE.suite());
+ suite.addTest(org.jboss.test.jmx.compliance.notcompliant.NCMBeanSUITE.suite());
+ suite.addTest(org.jboss.test.jmx.compliance.query.QuerySUITE.suite());
+ return suite;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.modelmbean;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ModelMBeanSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All ModelMBean Related Tests");
+
+ suite.addTest(ModelMBeanTEST.suite());
+
+ return suite;
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/ModelMBeanTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.modelmbean;
+
+import javax.management.Descriptor;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.modelmbean.DescriptorSupport;
+import javax.management.modelmbean.ModelMBean;
+import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfoSupport;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+import javax.management.modelmbean.RequiredModelMBean;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.modelmbean.support.Resource;
+
+
+public class ModelMBeanTEST extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(ModelMBeanTEST.class);
+ }
+
+ static class RMMListener implements NotificationListener
+ {
+ public void handleNotification(Notification msg, Object handback)
+ {
+ System.out.println("handleNotification, msg="+msg);
+ }
+ }
+
+ public ModelMBeanTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testRequiredModelMBeanConstructors()
+ {
+ try
+ {
+ new RequiredModelMBean();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail("Creating Required ModelMBean instance with default constructor failed: " + t.toString());
+ }
+ }
+
+ public void testRMMSetManagedResource()
+ {
+ try
+ {
+ ModelMBean modelmbean = new RequiredModelMBean();
+ Resource resource = new Resource();
+ modelmbean.setManagedResource(resource, "ObjectReference");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail("Setting resource object with 'ObjectReference' type failed: " + t.toString());
+ }
+ }
+
+ public void testRMMSetManagedResourceAfterRegister()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ Resource resource = new Resource();
+ ModelMBean modelmbean = new RequiredModelMBean();
+ modelmbean.setModelMBeanInfo(getModelMBeanInfo());
+
+ ObjectName name = new ObjectName("rmm:invocationTest=true");
+ server.registerMBean(modelmbean, name);
+
+ modelmbean.setManagedResource(resource, "ObjectReference");
+
+ MBeanInfo info = server.getMBeanInfo(name);
+ assertTrue("MBeanInfo != null", info != null);
+
+ Object[] args = {};
+ String[] sig = {};
+ Boolean flag = (Boolean) server.invoke(name, "isActive", args, sig);
+ assertTrue("isActive", flag.booleanValue());
+ }
+
+ /* ???
+ public void testRMMSetManagedResourceAfterRegisterViaServer()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ Resource resource = new Resource();
+ ModelMBean modelmbean = new RequiredModelMBean();
+ modelmbean.setModelMBeanInfo(getModelMBeanInfo());
+
+ ObjectName name = new ObjectName("rmm:invocationTest=true");
+ server.registerMBean(modelmbean, name);
+
+ Object[] args = {resource, "ObjectReference"};
+ String[] sig = {"java.lang.Object", "java.lang.String"};
+ server.invoke(name, "setManagedResource", args, sig);
+
+ MBeanInfo info = server.getMBeanInfo(name);
+ assertTrue("MBeanInfo != null", info != null);
+
+ args = new Object[]{};
+ sig = new String[]{};
+ Boolean flag = (Boolean) server.invoke(name, "isActive", args, sig);
+ assertTrue("isActive", flag.booleanValue());
+ }
+
+ public void testCreatedRMMSetManagedResourceAfterRegisterViaServer()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ ObjectName name = new ObjectName("rmm:invocationTest=true");
+ ModelMBeanInfo info = getModelMBeanInfo();
+ Object[] ctorArgs = { info };
+ String[] ctorSig = { "javax.management.modelmbean.ModelMBeanInfo" };
+ server.createMBean(RequiredModelMBean.class.getName(),
+ name, ctorArgs, ctorSig);
+
+ Resource resource = new Resource();
+
+ Object[] args = {resource, "ObjectReference"};
+ String[] sig = {"java.lang.Object", "java.lang.String"};
+ server.invoke(name, "setManagedResource", args, sig);
+
+ info = (ModelMBeanInfo) server.getMBeanInfo(name);
+ assertTrue("MBeanInfo != null", info != null);
+
+ args = new Object[]{};
+ sig = new String[]{};
+ Boolean flag = (Boolean) server.invoke(name, "isActive", args, sig);
+ assertTrue("isActive", flag.booleanValue());
+ }
+
+ public void testCreatedRMMSetManagedResourceAfterRegisterViaServerListener()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ ObjectName name = new ObjectName("rmm:invocationTest=true");
+ ModelMBeanInfo info = getModelMBeanInfo();
+ Object[] ctorArgs = { info };
+ String[] ctorSig = { "javax.management.modelmbean.ModelMBeanInfo" };
+ server.createMBean(RequiredModelMBean.class.getName(),
+ name, ctorArgs, ctorSig);
+
+ Resource resource = new Resource();
+
+ Object[] args = {resource, "objectReference"};
+ String[] sig = {"java.lang.Object", "java.lang.String"};
+ server.invoke(name, "setManagedResource", args, sig);
+
+ RMMListener listener = new RMMListener();
+ server.addNotificationListener(name, listener, null, null);
+ } */
+
+ public void testRMMSetModelMBeanInfo()
+ throws Exception
+ {
+ ModelMBean modelmbean = new RequiredModelMBean();
+ modelmbean.setModelMBeanInfo(getModelMBeanInfo());
+ }
+
+ public void testRMMInvocation()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ Resource resource = new Resource();
+ ModelMBean modelmbean = new RequiredModelMBean();
+ modelmbean.setModelMBeanInfo(getModelMBeanInfo());
+ modelmbean.setManagedResource(resource, "ObjectReference");
+
+ ObjectName name = new ObjectName("rmm:invocationTest=true");
+ server.registerMBean(modelmbean, name);
+
+ MBeanInfo info = server.getMBeanInfo(name);
+ assertTrue("MBeanInfo != null", info != null);
+
+ assertTrue(((Boolean)server.invoke(name, "isActive", new Object[] {}, new String[] {})).booleanValue());
+ }
+
+ public void testRMMDefault()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ Resource resource = new Resource();
+ ModelMBean modelmbean = new RequiredModelMBean();
+ modelmbean.setManagedResource(resource, "ObjectReference");
+ modelmbean.setModelMBeanInfo(getModelMBeanInfo());
+
+ ObjectName name = new ObjectName("rmm:test=default");
+ server.registerMBean(modelmbean, name);
+
+ assertTrue("Should be the default room", server.getAttribute(name, "Room").equals("D325"));
+ }
+
+ public ModelMBeanInfo getModelMBeanInfo()
+ {
+ final boolean READABLE = true;
+ final boolean WRITABLE = true;
+ final boolean BOOLEAN = true;
+
+ // build 'RoomName' read-write attribute
+ Descriptor descr1 = new DescriptorSupport();
+ descr1.setField("name", "Room");
+ descr1.setField("descriptorType", "attribute");
+ descr1.setField("displayName", "Room Number");
+ descr1.setField("default", "D325");
+
+ ModelMBeanAttributeInfo roomNameInfo =
+ new ModelMBeanAttributeInfo(
+ "Room", // attribute name
+ String.class.getName(), // attribute type
+ "Room name or number.", // description
+ READABLE, WRITABLE, !BOOLEAN, // read write
+ descr1 // descriptor
+ );
+
+ // build 'Active' read-only attribute
+ Descriptor descr2 = new DescriptorSupport();
+ descr2.setField("name", "Active");
+ descr2.setField("descriptorType", "attribute");
+ descr2.setField("getMethod", "isActive");
+ descr2.setField("currencyTimeLimit", "10");
+
+ ModelMBeanAttributeInfo activeInfo =
+ new ModelMBeanAttributeInfo(
+ "Active",
+ boolean.class.getName(),
+ "Printer state.",
+ READABLE, !WRITABLE, !BOOLEAN,
+ descr2
+ );
+
+ // build 'isActive' getter operation
+ Descriptor descr3 = new DescriptorSupport();
+ descr3.setField("name", "isActive");
+ descr3.setField("descriptorType", "operation");
+ descr3.setField("role", "getter");
+
+ ModelMBeanOperationInfo isActiveInfo =
+ new ModelMBeanOperationInfo(
+ "isActive", // name & description
+ "Checks if the printer is currently active.",
+ null, // signature
+ boolean.class.getName(), // return type
+ MBeanOperationInfo.INFO, // impact
+ descr3 // descriptor
+ );
+
+ // MBean descriptor
+ Descriptor descr4 = new DescriptorSupport();
+ descr4.setField("name", RequiredModelMBean.class.getName());
+ descr4.setField("descriptorType", "MBean");
+
+ // create ModelMBeanInfo
+ ModelMBeanInfo info = new ModelMBeanInfoSupport(
+ RequiredModelMBean.class.getName(), // class name
+ "Printer", // description
+ new ModelMBeanAttributeInfo[] { // attributes
+ roomNameInfo,
+ activeInfo
+ },
+ null, // constructors
+ new ModelMBeanOperationInfo[] { // operations
+ isActiveInfo
+ },
+ null, // notifications
+ descr4 // descriptor
+ );
+
+ return info;
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/support/Resource.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/support/Resource.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/modelmbean/support/Resource.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.modelmbean.support;
+
+public class Resource {
+
+ public boolean isActive() {
+ return true;
+ }
+
+
+
+}
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class NCMBeanSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All Not Compliant MBean Tests");
+
+ suite.addTest(NCMBeanTEST.suite());
+
+ return suite;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NCMBeanTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.notcompliant.support.DynamicAndStandard;
+import org.jboss.test.jmx.compliance.notcompliant.support.InterfaceProblems;
+import org.jboss.test.jmx.compliance.notcompliant.support.NullDynamic;
+import org.jboss.test.jmx.compliance.notcompliant.support.OverloadedAttribute1;
+import org.jboss.test.jmx.compliance.notcompliant.support.OverloadedAttribute2;
+import org.jboss.test.jmx.compliance.notcompliant.support.OverloadedAttribute3;
+import org.jboss.test.jmx.compliance.notcompliant.support.OverloadedAttribute4;
+import org.jboss.test.jmx.compliance.notcompliant.support.OverloadedAttribute5;
+
+
+public class NCMBeanTEST extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(NCMBeanTEST.class);
+ }
+
+ public NCMBeanTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testOverloadedAttribute1()
+ {
+ registerAndTest(new OverloadedAttribute1());
+ }
+
+ public void testOverloadedAttribute2()
+ {
+ registerAndTest(new OverloadedAttribute2());
+ }
+
+ public void testOverloadedAttribute3()
+ {
+ registerAndTest(new OverloadedAttribute3());
+ }
+
+ public void testOverloadedAttribute4()
+ {
+ registerAndTest(new OverloadedAttribute4());
+ }
+
+ public void testOverloadedAttribute5()
+ {
+ registerAndTest(new OverloadedAttribute5());
+ }
+
+ public void testMixedDynamicStandard()
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ try
+ {
+ server.registerMBean(new DynamicAndStandard(), new ObjectName("test:foo=bar"));
+ MBeanInfo info = server.getMBeanInfo(new ObjectName("test:foo=bar"));
+ assertTrue("A mixed dynamic and standard mbean should be dynamic",
+ info.getDescription().equals(DynamicAndStandard.DESCRIPTION));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ fail("A mixed dynamic and standardmbean is allowed from jmx 1.1");
+ }
+ catch (Exception e)
+ {
+ fail("unexpected exception when registering " + DynamicAndStandard.class.getName() + ": " + e.getMessage());
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+
+ public void testNoConstructor()
+ {
+ try
+ {
+ registerAndDontTest(NoConstructor.getInstance());
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ fail("An MBean without a public constructor is allowed from jmx 1.1");
+ }
+ }
+
+ public void testInterfaceProblems()
+ {
+ try
+ {
+ registerAndDontTest(new InterfaceProblems());
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ fail("FAILS IN RI: Cannot cope with overriden get/is in interfaces");
+ }
+ }
+
+ public void testNullDynamic()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ boolean caught = false;
+ try
+ {
+ server.registerMBean(new NullDynamic(), name);
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ caught = true;
+ }
+ assertTrue("Expected NCME for null MBeanInfo", caught);
+ }
+
+ private void registerAndTest(Object mbean)
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ try
+ {
+ server.registerMBean(mbean, new ObjectName("test:foo=bar"));
+ fail("expected a NotCompliantMBeanException for " + mbean.getClass().getName());
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ // this is what we want
+ }
+ catch (Exception e)
+ {
+ fail("unexpected exception when registering " + mbean.getClass().getName() + ": " + e);
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+
+ private void registerAndDontTest(Object mbean)
+ throws NotCompliantMBeanException
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ try
+ {
+ server.registerMBean(mbean, new ObjectName("test:foo=bar"));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ fail("unexpected exception when registering " + mbean.getClass().getName() + ": " + e.getMessage());
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructor.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructor.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructor.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant;
+
+public class NoConstructor
+ implements NoConstructorMBean
+{
+ private NoConstructor()
+ {
+ }
+
+ public static NoConstructor getInstance()
+ {
+ return new NoConstructor();
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructorMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructorMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/NoConstructorMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant;
+
+public interface NoConstructorMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandard.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandard.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandard.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ReflectionException;
+
+/**
+ * just a minimal dynamic mbean
+ */
+public class DynamicAndStandard implements DynamicMBean, DynamicAndStandardMBean
+{
+ public static final String DESCRIPTION = "dynamic mbeaninfo";
+
+ public Object getAttribute(String attribute)
+ throws AttributeNotFoundException, MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException
+ {
+ }
+
+ public AttributeList getAttributes(String[] attributes)
+ {
+ return new AttributeList();
+ }
+
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ return new AttributeList();
+ }
+
+ public Object invoke(String actionName,
+ Object[] params,
+ String[] signature)
+ throws MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public MBeanInfo getMBeanInfo()
+ {
+ return new MBeanInfo(this.getClass().getName(), DESCRIPTION, new MBeanAttributeInfo[0],
+ new MBeanConstructorInfo[0], new MBeanOperationInfo[0], new MBeanNotificationInfo[0]);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandardMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandardMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/DynamicAndStandardMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface DynamicAndStandardMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblems.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblems.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblems.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class InterfaceProblems
+ implements InterfaceProblemsMBean
+{
+ public void setSet(boolean something)
+ {
+ }
+
+ public Boolean getGet()
+ {
+ return null;
+ }
+
+ public Boolean isIs()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface InterfaceProblemsMBean
+ extends InterfaceProblemsSuperMBean
+{
+ void setSet(boolean something);
+ Boolean getGet();
+ Boolean isIs();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsSuperMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsSuperMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/InterfaceProblemsSuperMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface InterfaceProblemsSuperMBean
+{
+ void setSet(boolean something);
+ Boolean getGet();
+ Boolean isIs();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/NullDynamic.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/NullDynamic.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/NullDynamic.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.ReflectionException;
+
+/**
+ * A dynamic mbean with Null MBeanInfo
+ */
+public class NullDynamic implements DynamicMBean
+{
+ public Object getAttribute(String attribute)
+ throws AttributeNotFoundException, MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException
+ {
+ }
+
+ public AttributeList getAttributes(String[] attributes)
+ {
+ return new AttributeList();
+ }
+
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ return new AttributeList();
+ }
+
+ public Object invoke(String actionName,
+ Object[] params,
+ String[] signature)
+ throws MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public MBeanInfo getMBeanInfo()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class OverloadedAttribute1 implements OverloadedAttribute1MBean
+{
+ public void setSomething(boolean something)
+ {
+ }
+
+ public Boolean getSomething()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute1MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface OverloadedAttribute1MBean
+{
+ void setSomething(boolean something);
+ Boolean getSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class OverloadedAttribute2 implements OverloadedAttribute2MBean
+{
+ public void setSomething(boolean something)
+ {
+ }
+
+ public Boolean getSomething()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute2MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface OverloadedAttribute2MBean
+{
+ void setSomething(boolean something);
+ Boolean getSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class OverloadedAttribute3 implements OverloadedAttribute3MBean
+{
+ public void setSomething(boolean something)
+ {
+ }
+
+ public void setSomething(Boolean something)
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute3MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface OverloadedAttribute3MBean
+{
+ void setSomething(boolean something);
+ void setSomething(Boolean something);
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class OverloadedAttribute4 implements OverloadedAttribute4MBean
+{
+ public void setSomething(boolean something)
+ {
+ }
+
+ public Boolean isSomething()
+ {
+ return null;
+ }
+
+ public Boolean getSomething()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute4MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface OverloadedAttribute4MBean
+{
+ void setSomething(boolean something);
+ Boolean isSomething();
+ Boolean getSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public class OverloadedAttribute5 implements OverloadedAttribute5MBean
+{
+ public void setSomething(boolean something)
+ {
+ }
+
+ public Boolean getSomething()
+ {
+ return null;
+ }
+
+ public Boolean isSomething()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/notcompliant/support/OverloadedAttribute5MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.notcompliant.support;
+
+public interface OverloadedAttribute5MBean
+{
+ void setSomething(boolean something);
+ Boolean getSomething();
+ Boolean isSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryMBeansObjectNameOnlyTestCase.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryMBeansObjectNameOnlyTestCase.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryMBeansObjectNameOnlyTestCase.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,765 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.query.support.Trivial;
+
+
+/**
+ * Object Name Query tests.<p>
+ *
+ * TODO: More tests, more systematic?
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+ at SuppressWarnings("unchecked")
+public class QueryMBeansObjectNameOnlyTestCase
+ extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(QueryMBeansObjectNameOnlyTestCase.class);
+ }
+
+ /**
+ * The number of objects registered in a server
+ */
+ int implSize;
+
+ // Constructor ---------------------------------------------------------------
+
+ public QueryMBeansObjectNameOnlyTestCase(String s)
+ {
+ super(s);
+ }
+
+ // Tests ---------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Determine the number of objects in the implementation
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ implSize = server.getMBeanCount().intValue();
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test single bean found.
+ */
+ public void testExactFound()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName("Domain1:type=instance1"), null);
+ resultNames = server.queryNames(new ObjectName("Domain1:type=instance1"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test single bean not found.
+ */
+ public void testExactNotFound()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName("Domain2:type=instance2"), null);
+ resultNames = server.queryNames(new ObjectName("Domain2:type=instance2"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Get All.
+ */
+ public void testGetAllMBeans()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1")));
+ resultMBeans = server.queryMBeans(new ObjectName("*:*"), null);
+ resultNames = server.queryNames(new ObjectName("*:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, implSize);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Get All.
+ */
+ public void testGetAllMBeans2()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1")));
+ resultMBeans = server.queryMBeans(new ObjectName(""), null);
+ resultNames = server.queryNames(new ObjectName(""), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, implSize);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Get All.
+ */
+ public void testGetAllMBeans3()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1")));
+ resultMBeans = server.queryMBeans(null, null);
+ resultNames = server.queryNames(null, null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, implSize);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test one domain.
+ */
+ public void testGetOneDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName("Domain1:*"), null);
+ resultNames = server.queryNames(new ObjectName("Domain1:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test default domain.
+ */
+ public void testGetDefaultDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("Domain1");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName(":*"), null);
+ resultNames = server.queryNames(new ObjectName(":*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test one property.
+ */
+ public void testGetOneProperty()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance1")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain1:type=instance2"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain2:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Domain3:type=instance1")));
+ resultMBeans = server.queryMBeans(new ObjectName("*:type=instance1"), null);
+ resultNames = server.queryNames(new ObjectName("*:type=instance1"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecAll()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1")));
+ resultMBeans = server.queryMBeans(new ObjectName("*:*"), null);
+ resultNames = server.queryNames(new ObjectName("*:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, implSize);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecDefault()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1")));
+ resultMBeans = server.queryMBeans(new ObjectName(":*"), null);
+ resultNames = server.queryNames(new ObjectName(":*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecMyDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1"));
+ resultMBeans = server.queryMBeans(new ObjectName("MyDomain:*"), null);
+ resultNames = server.queryNames(new ObjectName("MyDomain:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecAnyAnyDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1"));
+ resultMBeans = server.queryMBeans(new ObjectName("??Domain:*"), null);
+ resultNames = server.queryNames(new ObjectName("??Domain:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testAsteriskDomAsterisk()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993"));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1")));
+ resultMBeans = server.queryMBeans(new ObjectName("*Dom*:*"), null);
+ resultNames = server.queryNames(new ObjectName("*Dom*:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecLaserPrinters()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=1"));
+ resultMBeans = server.queryMBeans(new ObjectName("*:description=Printer,type=laser,*"), null);
+ resultNames = server.queryNames(new ObjectName("*:description=Printer,type=laser,*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * This one is from the spec.
+ */
+ public void testSpecPrinters()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Printer,type=laser")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=laser,date=1993")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("Socrates:description=Printer,type=laser,date=1993")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Printer,type=ink")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("MyDomain:description=Disk,capacity=2"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("DefaultDomain:description=Disk,capacity=2"));
+ resultMBeans = server.queryMBeans(new ObjectName("*:description=Printer,*"), null);
+ resultNames = server.queryNames(new ObjectName("*:description=Printer,*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test suffix asterisk on domain.
+ */
+ public void testSuffixMatchManyDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DomainA123:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DomainA321:type=instance2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DomainA2224:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DomainA3:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("DomainA:type=instance1")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Dom:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName("DomainA*:*"), null);
+ resultNames = server.queryNames(new ObjectName("DomainA*:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test prefix asterisk on domain.
+ */
+ public void testPrefixMatchManyDomain()
+ {
+ MBeanServer server = null;
+ HashSet instances = new HashSet();
+ Set resultMBeans = null;
+ Set resultNames = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("QueryMBeans");
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("123ADomain:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("321ADomain:type=instance2")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("2224ADomain:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("3ADomain:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("3ADomai123ADomain:type=instance1")));
+ instances.add(server.registerMBean(new Trivial(),
+ new ObjectName("ADomain:type=instance1")));
+ server.registerMBean(new Trivial(),
+ new ObjectName("Domain:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("ADomai:type=instance1"));
+ server.registerMBean(new Trivial(),
+ new ObjectName("main:type=instance1"));
+ resultMBeans = server.queryMBeans(new ObjectName("*ADomain:*"), null);
+ resultNames = server.queryNames(new ObjectName("*ADomain:*"), null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ checkit(resultMBeans, resultNames, instances, 0);
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ // Support ----------------------------------------------------------------
+
+ /**
+ * Check the resultMBeans
+ */
+ private void checkit(Set resultMBeans, Set resultNames, HashSet expected,
+ int others)
+ {
+ // Quick tests
+ assertEquals(expected.size() + others, resultMBeans.size());
+ assertEquals(expected.size() + others, resultNames.size());
+
+ // Get the expected ObjectNames
+ HashSet expectedNames = new HashSet();
+ Iterator iterator = expected.iterator();
+ while (iterator.hasNext())
+ {
+ expectedNames.add(((ObjectInstance) iterator.next()).getObjectName());
+ }
+
+ // Check resultMBeans
+ iterator = resultMBeans.iterator();
+ while (iterator.hasNext())
+ {
+ ObjectInstance instance = (ObjectInstance) iterator.next();
+ Iterator iterator2 = expected.iterator();
+ boolean found = false;
+ while (iterator2.hasNext())
+ {
+ if (iterator2.next().equals(instance))
+ {
+ iterator2.remove();
+ found = true;
+ break;
+ }
+ }
+ if (found == false &&
+ instance.getObjectName().getDomain().equals("JMImplementation") == false &&
+ instance.getObjectName().getDomain().equals("org.jboss.jmx") == false)
+ fail("Unexpected instance " + instance.getObjectName());
+ }
+
+ // Check resultNames
+ iterator = resultNames.iterator();
+ while (iterator.hasNext())
+ {
+ ObjectName name = (ObjectName) iterator.next();
+ Iterator iterator2 = expectedNames.iterator();
+ boolean found = false;
+ while (iterator2.hasNext())
+ {
+ if (iterator2.next().equals(name))
+ {
+ iterator2.remove();
+ found = true;
+ break;
+ }
+ }
+ if (found == false &&
+ name.getDomain().equals("JMImplementation") == false &&
+ name.getDomain().equals("org.jboss.jmx") == false)
+ fail("Unexpected name " + name);
+ }
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QuerySUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QuerySUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QuerySUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Query tests.
+ *
+ * @author <a href="mailto:AdrianBrock at HappeningTimes.com">Adrian Brock</a>.
+ */
+public class QuerySUITE
+ extends TestSuite
+{
+ /**
+ * Run the tests
+ *
+ * @param args the arguments for the test
+ */
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Get a list of tests.
+ *
+ * @return the tests
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Query tests");
+
+ suite.addTest(QueryMBeansObjectNameOnlyTestCase.suite());
+ suite.addTest(QueryTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryTestCase.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryTestCase.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/QueryTestCase.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,1632 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.AttributeValueExp;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
+import javax.management.ValueExp;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.query.support.NumberTest;
+import org.jboss.test.jmx.compliance.query.support.StringTest;
+import org.jboss.test.jmx.compliance.query.support.Trivial;
+
+
+/**
+ * Query unit tests
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+public class QueryTestCase
+ extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(QueryTestCase.class);
+ }
+
+ public QueryTestCase(String s)
+ {
+ super(s);
+ }
+
+ // Tests ---------------------------------------------------------------------
+
+ /**
+ * Test a double
+ *
+ * @throws Exception for any error
+ */
+ public void testDouble() throws Exception
+ {
+ ValueExp one = Query.value(10d);
+ ValueExp two = Query.value(20d);
+ ValueExp div = Query.value(2d);
+ ValueExp minus = Query.value(-10d);
+ ValueExp mult = Query.value(200d);
+ ValueExp plus = Query.value(30d);
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(10d), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(10d), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a Double
+ *
+ * @throws Exception for any error
+ */
+ public void testDoubleObject() throws Exception
+ {
+ ValueExp one = Query.value(new Double(10d));
+ ValueExp two = Query.value(new Double(20d));
+ ValueExp div = Query.value(new Double(2d));
+ ValueExp minus = Query.value(new Double(-10d));
+ ValueExp mult = Query.value(new Double(200d));
+ ValueExp plus = Query.value(new Double(30d));
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(new Double(10d)), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(new Double(10d)), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a float
+ *
+ * @throws Exception for any error
+ */
+ public void testFloat() throws Exception
+ {
+ ValueExp one = Query.value(10f);
+ ValueExp two = Query.value(20f);
+ ValueExp div = Query.value(2f);
+ ValueExp minus = Query.value(-10f);
+ ValueExp mult = Query.value(200f);
+ ValueExp plus = Query.value(30f);
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(10f), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(10f), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a Float
+ *
+ * @throws Exception for any error
+ */
+ public void testFloatObject() throws Exception
+ {
+ ValueExp one = Query.value(new Float(10f));
+ ValueExp two = Query.value(new Float(20f));
+ ValueExp div = Query.value(new Double(2f));
+ ValueExp minus = Query.value(new Double(-10f));
+ ValueExp mult = Query.value(new Double(200f));
+ ValueExp plus = Query.value(new Double(30f));
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(new Float(10f)), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(new Float(10f)), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a int
+ *
+ * @throws Exception for any error
+ */
+ public void testInteger() throws Exception
+ {
+ ValueExp one = Query.value(10);
+ ValueExp two = Query.value(20);
+ ValueExp div = Query.value(2);
+ ValueExp minus = Query.value(-10);
+ ValueExp mult = Query.value(200);
+ ValueExp plus = Query.value(30);
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(10), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(10), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a Integer
+ *
+ * @throws Exception for any error
+ */
+ public void testIntegerObject() throws Exception
+ {
+ ValueExp one = Query.value(new Integer(10));
+ ValueExp two = Query.value(new Integer(20));
+ ValueExp div = Query.value(new Double(2));
+ ValueExp minus = Query.value(new Double(-10));
+ ValueExp mult = Query.value(new Double(200));
+ ValueExp plus = Query.value(new Double(30));
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(new Integer(10)), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(new Integer(10)), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a long
+ *
+ * @throws Exception for any error
+ */
+ public void testLong() throws Exception
+ {
+ ValueExp one = Query.value(10l);
+ ValueExp two = Query.value(20l);
+ ValueExp div = Query.value(2l);
+ ValueExp minus = Query.value(-10l);
+ ValueExp mult = Query.value(200l);
+ ValueExp plus = Query.value(30l);
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(10l), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(10l), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a Long
+ *
+ * @throws Exception for any error
+ */
+ public void testLongObject() throws Exception
+ {
+ ValueExp one = Query.value(new Long(10l));
+ ValueExp two = Query.value(new Long(20l));
+ ValueExp div = Query.value(new Double(2l));
+ ValueExp minus = Query.value(new Double(-10l));
+ ValueExp mult = Query.value(new Double(200l));
+ ValueExp plus = Query.value(new Double(30l));
+ equalsTEST(one, two);
+ operationTEST(one, two, div, minus, mult, plus);
+ comparisonTEST(one, two);
+ betweenTEST(one, two, plus);
+ attrTEST(new NumberTest(new Long(10l)), Query.attr("Number"), one, two);
+ attrTEST(new NumberTest(new Long(10l)), Query.attr(NumberTest.class.getName(), "Number"), one, two);
+ inTEST(one, two, div, minus, mult, plus);
+ }
+
+ /**
+ * Test a String
+ *
+ * @throws Exception for any error
+ */
+ public void testString() throws Exception
+ {
+ ValueExp one = Query.value("Hello");
+ ValueExp two = Query.value("Goodbye");
+ ValueExp cat = Query.value("HelloGoodbye");
+ ValueExp three = Query.value("ZZZZZZ");
+ ValueExp four = Query.value("Hi");
+ ValueExp five = Query.value("See ya");
+ ValueExp six = Query.value("Laytaz");
+ equalsTEST(one, two);
+ catTEST(one, two, cat);
+ comparisonTEST(two, one);
+ betweenTEST(two, one, three);
+ attrTEST(new StringTest("Hello"), Query.attr("String"), one, two);
+ attrTEST(new StringTest("Hello"), Query.attr(StringTest.class.getName(), "String"), one, two);
+ inTEST(one, two, three, four, five, six);
+ }
+
+ /**
+ * Test and is true both
+ *
+ * @throws Exception for any error
+ */
+ public void testAndTrueBoth() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.and
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(10)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Hello")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test and is false first parameter
+ *
+ * @throws Exception for any error
+ */
+ public void testAndFalseFirst() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.and
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(20)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Hello")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test and is false second parameter
+ *
+ * @throws Exception for any error
+ */
+ public void testAndFalseSecond() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.and
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(10)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Goodbye")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test and is false both parameters
+ *
+ * @throws Exception for any error
+ */
+ public void testAndFalseBoth() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.and
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(20)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Goodbye")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test or is true both
+ *
+ * @throws Exception for any error
+ */
+ public void testOrTrueBoth() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.or
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(10)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Hello")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test or is false first parameter
+ *
+ * @throws Exception for any error
+ */
+ public void testOrFalseFirst() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.or
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(20)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Hello")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test or is false second parameter
+ *
+ * @throws Exception for any error
+ */
+ public void testOrFalseSecond() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.and
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(10)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Goodbye")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test or is false both parameters
+ *
+ * @throws Exception for any error
+ */
+ public void testOrFalseBoth() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.or
+ (
+ Query.eq
+ (
+ Query.value(10), Query.value(20)
+ ),
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Goodbye")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test not
+ *
+ * @throws Exception for any error
+ */
+ public void testNot() throws Exception
+ {
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.not
+ (
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Hello")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test not not
+ *
+ * @throws Exception for any error
+ */
+ public void testNotNot() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.not
+ (
+ Query.eq
+ (
+ Query.value("Hello"), Query.value("Goodbye")
+ )
+ )
+ ).test();
+ }
+
+ /**
+ * Test class attribute
+ *
+ * @throws Exception for any error
+ */
+ public void testClassAttribute() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ Query.eq
+ (
+ Query.classattr(), Query.value(NumberTest.class.getName())
+ )
+ ).test();
+ }
+
+ /**
+ * Test simple object name
+ *
+ * @throws Exception for any error
+ */
+ public void testSimpleObjectName() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ new ObjectName("Domain1:type=instance1")
+ ).test();
+ }
+
+ /**
+ * Test domain pattern object name
+ *
+ * @throws Exception for any error
+ */
+ public void testDomainPatternObjectName() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ new ObjectName("*:type=instance1")
+ ).test();
+ }
+
+ /**
+ * Test property pattern object name
+ *
+ * @throws Exception for any error
+ */
+ public void testPropertyPatternObjectName() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1"),
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain2:type=instance1")
+ },
+ new ObjectName("Domain1:*")
+ ).test();
+ }
+
+ /**
+ * Test multiple property pattern object name
+ *
+ * @throws Exception for any error
+ */
+ public void testMultiplePropertyPatternObjectName() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1,extra=true")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ new ObjectName("Domain1:extra=true,*")
+ ).test();
+ }
+
+ /**
+ * Test invalid name passed to ObjectName
+ *
+ * @throws Exception for any error
+ */
+ public void testInvalidNamePassedToObjectName() throws Exception
+ {
+ if (new ObjectName("*:*").apply(new ObjectName("*:type=patternNotAllowedHere")))
+ fail("Patterns should not be matched");
+ }
+
+ /**
+ * Test any substring
+ *
+ * @throws Exception for any error
+ */
+ public void testAnySubstring() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ellbeginning"), "Domain1:type=instance2"),
+ new MBean(new StringTest("endell"), "Domain1:type=instance3"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance4")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance1"),
+ new MBean(new StringTest("el"), "Domain2:type=instance2"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance3"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance5"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance6")
+ },
+ Query.anySubString(Query.attr("String"), Query.value("ell"))
+ ).test();
+ }
+
+ /**
+ * Test final substring
+ *
+ * @throws Exception for any error
+ */
+ public void testFinalSubstring() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("endell"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance2")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain2:type=instance1"),
+ new MBean(new StringTest("ellbeginning"), "Domain2:type=instance2"),
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance3"),
+ new MBean(new StringTest("el"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance5"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance6"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance7"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance8")
+ },
+ Query.finalSubString(Query.attr("String"), Query.value("ell"))
+ ).test();
+ }
+
+ /**
+ * Test initial substring
+ *
+ * @throws Exception for any error
+ */
+ public void testInitialSubstring() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("ellbeginning"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance2")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain2:type=instance1"),
+ new MBean(new StringTest("endell"), "Domain2:type=instance2"),
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance3"),
+ new MBean(new StringTest("el"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance5"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance6"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance7"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance8")
+ },
+ Query.initialSubString(Query.attr("String"), Query.value("ell"))
+ ).test();
+ }
+
+ /**
+ * Test match asterisk beginning
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchAsteriskBeginning() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("endell"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance2")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain2:type=instance1"),
+ new MBean(new StringTest("ellbeginning"), "Domain2:type=instance2"),
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance3"),
+ new MBean(new StringTest("el"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance5"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance6"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance7"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance8")
+ },
+ Query.match(Query.attr("String"), Query.value("*ell"))
+ ).test();
+ }
+
+ /**
+ * Test match asterisk end
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchAsteriskEnd() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("ellbeginning"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance2")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain2:type=instance1"),
+ new MBean(new StringTest("beginningell"), "Domain2:type=instance2"),
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance3"),
+ new MBean(new StringTest("el"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance5"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance6"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance7"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance8")
+ },
+ Query.match(Query.attr("String"), Query.value("ell*"))
+ ).test();
+ }
+
+ /**
+ * Test any match asterisk beginning and end
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchAsteriskBeginningAndEnd() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("ell"), "Domain1:type=instance2"),
+ new MBean(new StringTest("endell"), "Domain1:type=instance3"),
+ new MBean(new StringTest("beginningell"), "Domain1:type=instance4")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance1"),
+ new MBean(new StringTest("el"), "Domain2:type=instance2"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance3"),
+ new MBean(new StringTest("e ll"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance5"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance6")
+ },
+ Query.match(Query.attr("String"), Query.value("*ell*"))
+ ).test();
+ }
+
+ /**
+ * Test match asterisk embedded
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchAsteriskEmbedded() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("ell"), "Domain2:type=instance1"),
+ new MBean(new StringTest("endell"), "Domain2:type=instance2"),
+ new MBean(new StringTest("beginningell"), "Domain2:type=instance3"),
+ new MBean(new StringTest("Goodbye"), "Domain2:type=instance4"),
+ new MBean(new StringTest("el"), "Domain2:type=instance5"),
+ new MBean(new StringTest("ll"), "Domain2:type=instance6"),
+ new MBean(new StringTest("e ll"), "Domain4:type=instance7"),
+ new MBean(new StringTest("ELL"), "Domain2:type=instance8"),
+ new MBean(new StringTest("Ell"), "Domain2:type=instance9")
+ },
+ Query.match(Query.attr("String"), Query.value("H*o"))
+ ).test();
+ }
+
+ /**
+ * Test match question beginning
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchQuestionBeginning() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("hello"), "Domain1:type=instance2"),
+ new MBean(new StringTest(" ello"), "Domain1:type=instance3")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("ello"), "Domain2:type=instance1"),
+ new MBean(new StringTest("Ello"), "Domain2:type=instance2"),
+ new MBean(new StringTest("hhello"), "Domain2:type=instance3"),
+ },
+ Query.match(Query.attr("String"), Query.value("?ello"))
+ ).test();
+ }
+
+ /**
+ * Test match question end
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchQuestionEnd() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("HellO"), "Domain1:type=instance2"),
+ new MBean(new StringTest("Hell "), "Domain1:type=instance3")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("hell"), "Domain2:type=instance1"),
+ new MBean(new StringTest("helL"), "Domain2:type=instance2"),
+ new MBean(new StringTest("Helloo"), "Domain2:type=instance3"),
+ },
+ Query.match(Query.attr("String"), Query.value("Hell?"))
+ ).test();
+ }
+
+ /**
+ * Test match question beginning and end
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchQuestionBeginningEnd() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("HellO"), "Domain1:type=instance2"),
+ new MBean(new StringTest("hello"), "Domain1:type=instance3"),
+ new MBean(new StringTest("hellO"), "Domain1:type=instance4"),
+ new MBean(new StringTest(" ell "), "Domain1:type=instance5")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("hell"), "Domain2:type=instance1"),
+ new MBean(new StringTest("helL"), "Domain2:type=instance2"),
+ new MBean(new StringTest("ello"), "Domain2:type=instance3"),
+ new MBean(new StringTest("Ello"), "Domain2:type=instance4"),
+ new MBean(new StringTest("ell"), "Domain2:type=instance5"),
+ new MBean(new StringTest("Helloo"), "Domain2:type=instance6"),
+ new MBean(new StringTest("HHello"), "Domain2:type=instance7"),
+ new MBean(new StringTest("HHelloo"), "Domain2:type=instance8"),
+ },
+ Query.match(Query.attr("String"), Query.value("?ell?"))
+ ).test();
+ }
+
+ /**
+ * Test match question embedded
+ *
+ * @throws Exception for any error
+ */
+ public void testMatchQuestionEmbedded() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello"), "Domain1:type=instance1"),
+ new MBean(new StringTest("HeLlo"), "Domain1:type=instance2"),
+ new MBean(new StringTest("He lo"), "Domain1:type=instance3")
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("hell"), "Domain2:type=instance1"),
+ new MBean(new StringTest("ello"), "Domain2:type=instance2"),
+ new MBean(new StringTest("ell"), "Domain2:type=instance3"),
+ new MBean(new StringTest("Helloo"), "Domain2:type=instance4"),
+ new MBean(new StringTest("HHello"), "Domain2:type=instance5"),
+ new MBean(new StringTest("HHelloo"), "Domain2:type=instance6"),
+ },
+ Query.match(Query.attr("String"), Query.value("He?lo"))
+ ).test();
+ }
+
+ /**
+ * Test match escaping question mark
+ *
+ * @throws Exception for any error
+ */
+ public void testEscapingQuestion() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello?"), "Domain1:type=instance1"),
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Helloz"), "Domain2:type=instance1"),
+ },
+ Query.match(Query.attr("String"), Query.value("Hello\\?"))
+ ).test();
+ }
+
+ /**
+ * Test match escaping asterisk
+ *
+ * @throws Exception for any error
+ */
+ public void testEscapingAsterisk() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello*"), "Domain1:type=instance1"),
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Helloz"), "Domain2:type=instance1"),
+ },
+ Query.match(Query.attr("String"), Query.value("Hello\\*"))
+ ).test();
+ }
+
+ /**
+ * Test match escaping open bracket
+ *
+ * @throws Exception for any error
+ */
+ public void testEscapingOpenBracket() throws Exception
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello[ab]"), "Domain1:type=instance1"),
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Helloa"), "Domain2:type=instance1"),
+ new MBean(new StringTest("Hello\\a"), "Domain2:type=instance2"),
+ },
+ Query.match(Query.attr("String"), Query.value("Hello\\[ab]"))
+ ).test();
+ }
+
+ /**
+ * Test threading, tests that running the same query in multiple threads
+ * works. This test might not catch a threading problem on every run.
+ *
+ * @throws Exception for any error
+ */
+ public void testThreading() throws Exception
+ {
+ MBeanServer server1 = MBeanServerFactory.createMBeanServer("server1");
+ MBeanServer server2 = MBeanServerFactory.createMBeanServer("server2");
+ try
+ {
+ ObjectName name = new ObjectName("Domain1:type=instance1");
+ NumberTest bean1 = new NumberTest(1);
+ NumberTest bean2 = new NumberTest(2);
+ server1.registerMBean(bean1, name);
+ server2.registerMBean(bean2, name);
+ QueryExp query = Query.eq(Query.attr("Number"), Query.value(2));
+ QueryThread thread1 = new QueryThread(server1, query, 0);
+ QueryThread thread2 = new QueryThread(server2, query, 1);
+ thread1.start();
+ thread2.start();
+ thread1.join(10000);
+ thread1.check();
+ thread2.join(10000);
+ thread2.check();
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(server1);
+ MBeanServerFactory.releaseMBeanServer(server2);
+ }
+ }
+
+ /**
+ * Test pathological
+ *
+ * @throws Exception for any error
+ */
+ public void testPathological() throws Exception
+ {
+ try
+ {
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new StringTest("Hello(?:.)"), "Domain1:type=instance1"),
+ },
+ new MBean[]
+ {
+ new MBean(new StringTest("Hellox"), "Domain2:type=instance1"),
+ },
+ Query.match(Query.attr("String"), Query.value("Hello(?:.)"))
+ ).test();
+ }
+ catch (AssertionFailedError e)
+ {
+ fail("FAILS IN JBossMX: expected Hello(?:.) to match Hello(?:.)");
+ }
+ }
+
+ // Support ----------------------------------------------------------------
+
+ private void equalsTEST(ValueExp value1, ValueExp value2)
+ throws Exception
+ {
+ // Test equals
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ value1, value1
+ )
+ ).test();
+ // Test not equals
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.eq
+ (
+ value1, value2
+ )
+ ).test();
+ }
+
+ private void operationTEST(ValueExp value1, ValueExp value2, ValueExp div,
+ ValueExp minus, ValueExp mult, ValueExp plus)
+ throws Exception
+ {
+ // Test div
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ Query.div(value2, value1),
+ div
+ )
+ ).test();
+ // Test minus
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ Query.minus(value1, value2),
+ minus
+ )
+ ).test();
+ // Test mult
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ Query.times(value1, value2),
+ mult
+ )
+ ).test();
+ // Test plus
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ Query.plus(value1, value2),
+ plus
+ )
+ ).test();
+ }
+
+ private void catTEST(ValueExp value1, ValueExp value2, ValueExp cat)
+ throws Exception
+ {
+ // Test cat
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.eq
+ (
+ Query.plus(value1, value2),
+ cat
+ )
+ ).test();
+ }
+
+ private void comparisonTEST(ValueExp value1, ValueExp value2)
+ throws Exception
+ {
+ // Test greater than or equals (really greater than)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.geq
+ (
+ value2, value1
+ )
+ ).test();
+ // Test greater than or equals (really greater equals)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.geq
+ (
+ value1, value1
+ )
+ ).test();
+ // Test not greater than or equals
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.geq
+ (
+ value1, value2
+ )
+ ).test();
+ // Test greater than
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.gt
+ (
+ value2, value1
+ )
+ ).test();
+ // Test not greater than
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.gt
+ (
+ value1, value2
+ )
+ ).test();
+ // Test greater than or equals (really greater than)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.leq
+ (
+ value1, value2
+ )
+ ).test();
+ // Test greater than or equals (really greater equals)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.leq
+ (
+ value1, value1
+ )
+ ).test();
+ // Test not greater than or equals
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.leq
+ (
+ value2, value1
+ )
+ ).test();
+ // Test greater than
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.lt
+ (
+ value1, value2
+ )
+ ).test();
+ // Test not greater than
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.lt
+ (
+ value2, value1
+ )
+ ).test();
+ }
+
+ private void betweenTEST(ValueExp value1, ValueExp value2, ValueExp value3)
+ throws Exception
+ {
+ // Test between (really between)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.between
+ (
+ value2, value1, value3
+ )
+ ).test();
+ // Test between (equals first)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.between
+ (
+ value2, value2, value3
+ )
+ ).test();
+ // Test between (equals second)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.between
+ (
+ value2, value1, value2
+ )
+ ).test();
+ // Test between (equals both)
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.between
+ (
+ value2, value2, value2
+ )
+ ).test();
+ // Test not between (first)
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.between
+ (
+ value1, value2, value3
+ )
+ ).test();
+ // Test not between (second)
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new NumberTest(0), "Domain1:type=instance1")
+ },
+ Query.between
+ (
+ value3, value1, value2
+ )
+ ).test();
+ }
+
+ private void attrTEST(Object mbean, AttributeValueExp attr, ValueExp value1, ValueExp value2)
+ throws Exception
+ {
+ // Test true
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(mbean, "Domain1:type=instance1")
+ },
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance2")
+ },
+ Query.eq
+ (
+ attr, value1
+ )
+ ).test();
+ // Test false
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(mbean, "Domain1:type=instance1")
+ },
+ Query.eq
+ (
+ attr, value2
+ )
+ ).test();
+ }
+
+ private void inTEST(ValueExp value1, ValueExp value2, ValueExp value3,
+ ValueExp value4, ValueExp value5, ValueExp value6)
+ throws Exception
+ {
+ // Test in first
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.in
+ (
+ value1,
+ new ValueExp[]
+ {
+ value1, value2, value3, value4, value5, value6
+ }
+ )
+ ).test();
+ // Test in last
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.in
+ (
+ value6,
+ new ValueExp[]
+ {
+ value1, value2, value3, value4, value5, value6
+ }
+ )
+ ).test();
+ // Test in not the first or last
+ new TestQuery(
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ new MBean[0],
+ Query.in
+ (
+ value3,
+ new ValueExp[]
+ {
+ value1, value2, value3, value4, value5, value6
+ }
+ )
+ ).test();
+ // Test not in
+ new TestQuery(
+ new MBean[0],
+ new MBean[]
+ {
+ new MBean(new Trivial(), "Domain1:type=instance1")
+ },
+ Query.in
+ (
+ value1,
+ new ValueExp[]
+ {
+ value2, value3, value4, value5, value6
+ }
+ )
+ ).test();
+ }
+
+ private class MBean
+ {
+ public Object mbean;
+ public ObjectName objectName;
+ public MBean(Object object, String name)
+ throws Exception
+ {
+ this.mbean = object;
+ this.objectName = new ObjectName(name);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private class TestQuery
+ {
+ HashSet expectedInstances = new HashSet();
+ HashSet expectedNames = new HashSet();
+ QueryExp queryExp;
+ MBeanServer server;
+
+ public TestQuery(MBean[] expected, MBean[] others, QueryExp queryExp)
+ throws Exception
+ {
+ this.queryExp = queryExp;
+
+ server = MBeanServerFactory.createMBeanServer();
+
+ for (int i = 0; i < expected.length; i++)
+ {
+ ObjectInstance instance = server.registerMBean(expected[i].mbean,
+ expected[i].objectName);
+ expectedInstances.add(instance);
+ expectedNames.add(instance.getObjectName());
+ }
+ for (int i = 0; i < others.length; i++)
+ server.registerMBean(others[i].mbean, others[i].objectName);
+ }
+
+ public void test()
+ throws Exception
+ {
+ try
+ {
+ testQueryMBeans();
+ testQueryNames();
+ }
+ finally
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+
+ public void testQueryMBeans()
+ throws Exception
+ {
+ Set result = server.queryMBeans(null, queryExp);
+
+ Iterator iterator = result.iterator();
+ while (iterator.hasNext())
+ {
+ ObjectInstance instance = (ObjectInstance) iterator.next();
+ Iterator iterator2 = expectedInstances.iterator();
+ boolean found = false;
+ while (iterator2.hasNext())
+ {
+ if (iterator2.next().equals(instance))
+ {
+ iterator2.remove();
+ found = true;
+ break;
+ }
+ }
+ if (found == false &&
+ instance.getObjectName().getDomain().equals("JMImplementation") == false &&
+ instance.getObjectName().getDomain().equals("org.jboss.jmx") == false)
+ fail("Unexpected instance " + instance.getObjectName()
+ + "\nfor query " + queryExp);
+ }
+
+ iterator = expectedInstances.iterator();
+ if (iterator.hasNext())
+ {
+ ObjectInstance instance = (ObjectInstance) iterator.next();
+ fail("Expected instance " + instance.getObjectName()
+ + "\nfor query " + queryExp);
+ }
+ }
+
+ public void testQueryNames()
+ throws Exception
+ {
+ Set result = server.queryNames(null, queryExp);
+
+ Iterator iterator = result.iterator();
+ while (iterator.hasNext())
+ {
+ ObjectName name = (ObjectName) iterator.next();
+ Iterator iterator2 = expectedNames.iterator();
+ boolean found = false;
+ while (iterator2.hasNext())
+ {
+ if (iterator2.next().equals(name))
+ {
+ iterator2.remove();
+ found = true;
+ break;
+ }
+ }
+ if (found == false &&
+ name.getDomain().equals("JMImplementation") == false &&
+ name.getDomain().equals("org.jboss.jmx") == false)
+ fail("Unexpected name " + name
+ + "\nfor query " + queryExp);
+ }
+
+ iterator = expectedNames.iterator();
+ if (iterator.hasNext())
+ {
+ fail("Expected instance " + iterator.next()
+ + "\nfor query " + queryExp);
+ }
+ }
+ }
+
+ public class QueryThread
+ extends Thread
+ {
+ MBeanServer server;
+ QueryExp query;
+ int expected;
+ int result;
+ public QueryThread(MBeanServer server, QueryExp query, int expected)
+ {
+ this.server = server;
+ this.query = query;
+ this.expected = expected;
+ }
+ public int getExpected()
+ {
+ return expected;
+ }
+ public void check()
+ {
+ assertEquals(expected, result);
+ }
+ public void run()
+ {
+ for (int i = 0; i < 1000; i++)
+ {
+ result = server.queryNames(null, query).size();
+ if (result != expected)
+ return;
+ }
+ }
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public class BooleanTest implements BooleanTestMBean
+{
+ private Boolean bool;
+
+ public BooleanTest()
+ {
+ }
+
+ public BooleanTest(boolean bool)
+ {
+ this.bool = new Boolean(bool);
+ }
+
+ public BooleanTest(Boolean bool)
+ {
+ this.bool = bool;
+ }
+
+ public Boolean getBoolean()
+ {
+ return bool;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/BooleanTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public interface BooleanTestMBean
+{
+ Boolean getBoolean();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public class NumberTest implements NumberTestMBean
+{
+ private Number number;
+
+ public NumberTest()
+ {
+ }
+
+ public NumberTest(double number)
+ {
+ this.number = new Double(number);
+ }
+
+ public NumberTest(Double number)
+ {
+ this.number = number;
+ }
+
+ public NumberTest(float number)
+ {
+ this.number = new Float(number);
+ }
+
+ public NumberTest(Float number)
+ {
+ this.number = number;
+ }
+
+ public NumberTest(int number)
+ {
+ this.number = new Integer(number);
+ }
+
+ public NumberTest(Integer number)
+ {
+ this.number = number;
+ }
+
+ public NumberTest(long number)
+ {
+ this.number = new Long(number);
+ }
+
+ public NumberTest(Long number)
+ {
+ this.number = number;
+ }
+
+ public Number getNumber()
+ {
+ return number;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/NumberTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public interface NumberTestMBean
+{
+ Number getNumber();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public class StringTest implements StringTestMBean
+{
+ private String string = "";
+
+ public StringTest()
+ {
+ }
+
+ public StringTest(String string)
+ {
+ this.string = string;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/StringTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public interface StringTestMBean
+{
+ String getString();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/Trivial.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/Trivial.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/Trivial.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public class Trivial implements TrivialMBean
+{
+ private String string = "trivial";
+ private int number = 0;
+
+ public Trivial()
+ {
+ }
+
+ public Trivial(int number)
+ {
+ this.number = number;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+
+ public Integer getNumber()
+ {
+ return new Integer(number);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/TrivialMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/TrivialMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/query/support/TrivialMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.query.support;
+
+public interface TrivialMBean
+{
+ String getString();
+ Integer getNumber();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.registration;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class RegistrationSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All MBeanRegistration Related Tests");
+
+ suite.addTest(RegistrationTEST.suite());
+
+ return suite;
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/RegistrationTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.registration;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.registration.support.RegistrationAware;
+
+
+public class RegistrationTEST extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(RegistrationTEST.class);
+ }
+
+ public RegistrationTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testSimpleRegistration()
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ RegistrationAware ra = new RegistrationAware();
+ ObjectName name = new ObjectName("test:key=value");
+
+ server.registerMBean(ra, name);
+
+ assertTrue("preRegister", ra.isPreRegisterCalled());
+ assertTrue("postRegister", ra.isPostRegisterCalled());
+ assertTrue("postRegisterRegistrationDone", ra.isPostRegisterRegistrationDone());
+ assertEquals(name, ra.getRegisteredObjectName());
+
+ server.unregisterMBean(name);
+
+ assertTrue("preDeRegister", ra.isPreDeRegisterCalled());
+ assertTrue("postDeRegister", ra.isPostDeRegisterCalled());
+ }
+ catch (MalformedObjectNameException e)
+ {
+ fail("spurious MalformedObjectNameException");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ fail("strange MBeanRegistrationException linked to: " + e.getTargetException().getMessage());
+ }
+ catch (Exception e)
+ {
+ fail("something else went wrong: " + e.getMessage());
+ }
+ }
+
+ public void testDuplicateRegistration()
+ {
+
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:key=value");
+
+ RegistrationAware original = new RegistrationAware();
+ RegistrationAware ra = new RegistrationAware();
+
+ server.registerMBean(original, name);
+
+ try
+ {
+ server.registerMBean(ra, name);
+ fail("expected a InstanceAlreadyExistsException");
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ }
+
+ assertTrue("preRegister", ra.isPreRegisterCalled());
+ assertTrue("postRegister", ra.isPostRegisterCalled());
+ assertTrue("postRegisterRegistrationDone", !ra.isPostRegisterRegistrationDone());
+ assertTrue("preDeRegister", !ra.isPreDeRegisterCalled());
+ assertTrue("postDeRegister", !ra.isPostDeRegisterCalled());
+ assertEquals(name, ra.getRegisteredObjectName());
+
+ server.unregisterMBean(name);
+ }
+ catch (Exception e)
+ {
+ fail("got an unexpected exception: " + e.getMessage());
+ }
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAware.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAware.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAware.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.registration.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.ObjectName;
+import javax.management.MBeanServer;
+
+public class RegistrationAware implements RegistrationAwareMBean, MBeanRegistration
+{
+ private String something;
+
+ private boolean preRegisterCalled = false;
+ private boolean preDeRegisterCalled = false;
+ private boolean postRegisterCalled = false;
+ private boolean postDeRegisterCalled = false;
+ private boolean postRegisterRegistrationDone = false;
+
+ private MBeanServer registeredServer = null;
+ private ObjectName registeredObjectName = null;
+
+ private Exception exceptionOnPreRegister = null;
+ private Exception exceptionOnPreDeRegister = null;
+
+ private ObjectName alternateObjectName = null;
+ private boolean returnAlternateObjectName = false;
+
+ public RegistrationAware()
+ {
+ }
+
+ public void setSomething(String something)
+ {
+ this.something = something;
+ }
+
+ public String getSomething()
+ {
+ return something;
+ }
+
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ throws Exception
+ {
+ preRegisterCalled = true;
+ registeredServer = server;
+ registeredObjectName = name;
+
+ if (null != exceptionOnPreRegister)
+ {
+ exceptionOnPreRegister.fillInStackTrace();
+ throw exceptionOnPreRegister;
+ }
+
+ if (returnAlternateObjectName)
+ {
+ return alternateObjectName;
+ }
+
+ return name;
+ }
+
+ // MBeanRegistration impl -------------------------------------
+ public void postRegister(Boolean registrationDone)
+ {
+ postRegisterCalled = true;
+ postRegisterRegistrationDone = registrationDone.booleanValue();
+ }
+
+ public void preDeregister()
+ throws Exception
+ {
+ preDeRegisterCalled = true;
+
+ if (null != exceptionOnPreDeRegister)
+ {
+ exceptionOnPreDeRegister.fillInStackTrace();
+ throw exceptionOnPreDeRegister;
+ }
+ }
+
+ public void postDeregister()
+ {
+ postDeRegisterCalled = true;
+ }
+
+ // Settings setters -------------------------------------------
+ public void setExceptionOnPreRegister(Exception exceptionOnPreRegister)
+ {
+ this.exceptionOnPreRegister = exceptionOnPreRegister;
+ }
+
+ public void setExceptionOnPreDeRegister(Exception exceptionOnPreDeRegister)
+ {
+ this.exceptionOnPreDeRegister = exceptionOnPreDeRegister;
+ }
+
+ public void setAlternateObjectName(ObjectName alternateObjectName)
+ {
+ this.returnAlternateObjectName = true;
+ this.alternateObjectName = alternateObjectName;
+ }
+
+ // Status getters ---------------------------------------------
+ public boolean isPreRegisterCalled()
+ {
+ return preRegisterCalled;
+ }
+
+ public boolean isPreDeRegisterCalled()
+ {
+ return preDeRegisterCalled;
+ }
+
+ public boolean isPostRegisterCalled()
+ {
+ return postRegisterCalled;
+ }
+
+ public boolean isPostDeRegisterCalled()
+ {
+ return postDeRegisterCalled;
+ }
+
+ public boolean isPostRegisterRegistrationDone()
+ {
+ return postRegisterRegistrationDone;
+ }
+
+ public MBeanServer getRegisteredServer()
+ {
+ return registeredServer;
+ }
+
+ public ObjectName getRegisteredObjectName()
+ {
+ return registeredObjectName;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAwareMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAwareMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/registration/support/RegistrationAwareMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.registration.support;
+
+public interface RegistrationAwareMBean
+{
+ void setSomething(String something);
+ String getSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/DefaultDomainTestCase.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/DefaultDomainTestCase.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/DefaultDomainTestCase.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,569 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.relation.RelationService;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.server.support.Broadcaster;
+import org.jboss.test.jmx.compliance.server.support.Test;
+
+
+/**
+ * Tests default domain handling in the Server.<p>
+ *
+ * TODO createMBean x4.
+ * TODO deserialize x2
+ * TODO getAttribute x2
+ * TODO getMBeanInfo
+ * TODO instantiate x2
+ * TODO isInstanceOf
+ * TODO isRegistered
+ * TODO removeNotificationListener x2
+ * TODO setAttribute x2
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+public class DefaultDomainTestCase
+ extends JBossJMXTest
+{
+ public static junit.framework.Test suite()
+ {
+ return suite(DefaultDomainTestCase.class);
+ }
+
+ public DefaultDomainTestCase(String s)
+ {
+ super(s);
+ }
+
+ // Tests ---------------------------------------------------------------------
+
+ /**
+ * Test Register in the "anonymous" default domain.
+ */
+ public void testDefaultDomainRegisterUnqualified()
+ {
+ MBeanServer server =null;
+ ObjectName unqualifiedName = null;
+ ObjectName qualifiedName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ unqualifiedName = new ObjectName(":property=1");
+ qualifiedName = new ObjectName("DefaultDomain:property=1");
+ server.registerMBean(new Test(), unqualifiedName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ assertEquals("DefaultDomain", server.getDefaultDomain());
+
+ try
+ {
+ server.getObjectInstance(unqualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Unqualified lookup failed");
+ }
+
+ try
+ {
+ server.getObjectInstance(qualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Qualified lookup failed");
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Register in the "anonymous" default domain.
+ */
+ public void testDefaultDomainRegisterQualified()
+ {
+ MBeanServer server =null;
+ ObjectName unqualifiedName = null;
+ ObjectName qualifiedName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ unqualifiedName = new ObjectName(":property=1");
+ qualifiedName = new ObjectName("DefaultDomain:property=1");
+ server.registerMBean(new Test(), qualifiedName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ assertEquals("DefaultDomain", server.getDefaultDomain());
+
+ try
+ {
+ server.getObjectInstance(unqualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Unqualified lookup failed");
+ }
+
+ try
+ {
+ server.getObjectInstance(qualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Qualified lookup failed");
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Register in a named default domain.
+ */
+ public void testMyDefaultDomainRegisterUnqualified()
+ {
+ MBeanServer server =null;
+ ObjectName unqualifiedName = null;
+ ObjectName qualifiedName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ unqualifiedName = new ObjectName(":property=1");
+ qualifiedName = new ObjectName("MyDomain:property=1");
+ server.registerMBean(new Test(), unqualifiedName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ assertEquals("MyDomain", server.getDefaultDomain());
+
+ try
+ {
+ server.getObjectInstance(unqualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Unqualified lookup failed");
+ }
+
+ try
+ {
+ server.getObjectInstance(qualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Qualified lookup failed");
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Register in a named default domain.
+ */
+ public void testMyDefaultDomainRegisterQualified()
+ {
+ MBeanServer server =null;
+ ObjectName unqualifiedName = null;
+ ObjectName qualifiedName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ unqualifiedName = new ObjectName(":property=1");
+ qualifiedName = new ObjectName("MyDomain:property=1");
+ server.registerMBean(new Test(), qualifiedName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ assertEquals("MyDomain", server.getDefaultDomain());
+
+ try
+ {
+ server.getObjectInstance(unqualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Unqualified lookup failed");
+ }
+
+ try
+ {
+ server.getObjectInstance(qualifiedName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("Qualified lookup failed");
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test register qualified/unqualifed.
+ */
+ public void testRegisterQualifiedUnqualified()
+ {
+ duplicateRegister(":property=1", "MyDomain:property=1");
+ }
+
+ /**
+ * Test register unqualified/qualifed.
+ */
+ public void testRegisterUnqualifiedQualified()
+ {
+ duplicateRegister("MyDomain:property=1", ":property=1");
+ }
+
+ /**
+ * Test register unqualified/unqualified.
+ */
+ public void testRegisterUnqualifiedUnqualified()
+ {
+ duplicateRegister(":property=1", ":property=1");
+ }
+
+ /**
+ * Test invoke qualified/unqualifed.
+ */
+ public void testInvokeQualifiedUnqualified()
+ {
+ invoke(":property=1", "MyDomain:property=1");
+ }
+
+ /**
+ * Test invoke unqualified/qualifed.
+ */
+ public void testInvokeUnqualifiedQualified()
+ {
+ invoke("MyDomain:property=1", ":property=1");
+ }
+
+ /**
+ * Test invoke unqualified/unqualified.
+ */
+ public void testInvokeUnqualifiedUnqualified()
+ {
+ invoke(":property=1", ":property=1");
+ }
+
+ /**
+ * Test register qualified unregister unqualified.
+ */
+ public void testRegisterQualifiedUnregisterUnqualified()
+ {
+ unregister("MyDomain:property=1", ":property=1");
+ }
+
+ /**
+ * Test register unqualified unregister qualifed.
+ */
+ public void testRegisterUnQualifiedUnregisterQualified()
+ {
+ unregister(":property=1", "MyDomain:property=1");
+ }
+
+ /**
+ * Test register unqualified unregister unqualified.
+ */
+ public void testRegisterUnqualifiedUnregisterUnqualified()
+ {
+ unregister(":property=1", ":property=1");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, Listener
+ */
+ public void testAddNLUnqualifiedNameListenerRegisterQualified()
+ {
+ addNLNameListener("MyDomain:property=1", ":property=1");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, Listener
+ */
+ public void testAddNLQualifiedNameListenerRegisterUnqualified()
+ {
+ addNLNameListener(":property=1", "MyDomain:property=1");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, Listener
+ */
+ public void testAddNLUnqualifiedNameListenerRegisterUnqualified()
+ {
+ addNLNameListener(":property=1", ":property=1");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLUnqualifiedQualifiedRegisterUnqualifiedQualified()
+ {
+ addNLNameName(":property=1", "MyDomain:property=2",":property=1", "MyDomain:property=2");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLUnqualifiedQualifiedRegisterQualifiedQualified()
+ {
+ addNLNameName(":property=1", "MyDomain:property=2","MyDomain:property=1", "MyDomain:property=2");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLQualifiedQualifiedRegisterUnqualifiedQualified()
+ {
+ addNLNameName("MyDomain:property=1", "MyDomain:property=2",":property=1", "MyDomain:property=2");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLQualifiedUnqualifiedRegisterQualifiedUnqualified()
+ {
+ addNLNameName("MyDomain:property=1", ":property=2","MyDomain:property=1", ":property=2");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLQualifiedUnqualifiedRegisterQualifiedQualified()
+ {
+ addNLNameName("MyDomain:property=1", ":property=2","MyDomain:property=1", "MyDomain:property=2");
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ public void testAddNLQualifiedQualifiedRegisterQualifiedUnqualified()
+ {
+ addNLNameName("MyDomain:property=1", "MyDomain:property=2","MyDomain:property=1", ":property=2");
+ }
+
+ // Support -----------------------------------------------------------------
+
+ /**
+ * Test Duplicate Register.
+ */
+ private void duplicateRegister(String register, String test)
+ {
+ MBeanServer server =null;
+ ObjectName registerName = null;
+ ObjectName testName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ registerName = new ObjectName(register);
+ testName = new ObjectName(test);
+ server.registerMBean(new Test(), registerName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ boolean caught = false;
+ try
+ {
+ server.registerMBean(new Test(), testName);
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ caught = true;
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ if (caught == false)
+ fail("Allows duplicate registration");
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test unregister
+ */
+ private void unregister(String register, String test)
+ {
+ MBeanServer server =null;
+ ObjectName registerName = null;
+ ObjectName testName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ registerName = new ObjectName(register);
+ testName = new ObjectName(test);
+ server.registerMBean(new Test(), registerName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ try
+ {
+ server.unregisterMBean(testName);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("FAILS IN RI: unregisterMBean doesn't add the default domain");
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Add notification listenter. ObjectName, Listener
+ */
+ private void addNLNameListener(String register, String test)
+ {
+ MBeanServer server =null;
+ ObjectName registerName = null;
+ ObjectName testName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ registerName = new ObjectName(register);
+ testName = new ObjectName(test);
+ server.registerMBean(new Broadcaster(), registerName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ try
+ {
+ server.addNotificationListener(testName, new RelationService(true), null, null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Add notification listenter. ObjectName, ObjectName
+ */
+ private void addNLNameName(String register1, String register2, String test1, String test2)
+ {
+ MBeanServer server =null;
+ ObjectName register1Name = null;
+ ObjectName register2Name = null;
+ ObjectName test1Name = null;
+ ObjectName test2Name = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ register1Name = new ObjectName(register1);
+ register2Name = new ObjectName(register2);
+ test1Name = new ObjectName(test1);
+ test2Name = new ObjectName(test2);
+ server.registerMBean(new Broadcaster(), register1Name);
+ server.registerMBean(new RelationService(true), register2Name);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ try
+ {
+ server.addNotificationListener(test1Name, test2Name, null, null);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ /**
+ * Test Invoke.
+ */
+ private void invoke(String register, String test)
+ {
+ MBeanServer server =null;
+ ObjectName registerName = null;
+ ObjectName testName = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer("MyDomain");
+ registerName = new ObjectName(register);
+ testName = new ObjectName(test);
+ server.registerMBean(new Broadcaster(), registerName);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ try
+ {
+ server.invoke(testName, "doSomething", new Object[0], new String[0]);
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+
+ if (server != null)
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanDelegateTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanDelegateTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanDelegateTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.server.support.Test;
+
+
+/**
+ * Tests for the MBean server delegate.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ *
+ * @version $Revision: 86129 $
+ */
+public class MBeanDelegateTEST extends JBossJMXTest
+{
+ public static junit.framework.Test suite()
+ {
+ return suite(MBeanDelegateTEST.class);
+ }
+
+ public MBeanDelegateTEST(String s)
+ {
+ super(s);
+ }
+
+ class MyNotificationListener implements NotificationListener {
+
+ int notificationCount = 0;
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ try
+ {
+ notificationCount++;
+ }
+ catch (Exception e)
+ {
+ fail("Unexpected error: " + e.toString());
+ }
+ }
+ }
+
+ public synchronized void testRegistrationAndUnregistrationNotification() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ MyNotificationListener listener = new MyNotificationListener();
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, null, null
+ );
+
+ // force registration notification
+ server.registerMBean(new Test(), new ObjectName("test:foo=bar"));
+
+ // force unregistration notification
+ server.unregisterMBean(new ObjectName("test:foo=bar"));
+
+ // wait for notif to arrive max 5 secs
+ for (int i = 0; i < 10; ++i)
+ {
+ wait(500);
+
+ if (listener.notificationCount > 1)
+ break;
+ }
+
+ assertTrue(listener.notificationCount == 2);
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerBuilderTestCase.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerBuilderTestCase.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerBuilderTestCase.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerBuilder;
+import javax.management.MBeanServerDelegate;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.server.support.BuilderTest;
+import org.jboss.test.jmx.compliance.server.support.DelegateListener;
+import org.jboss.test.jmx.compliance.server.support.MBeanServerReplaced;
+import org.jboss.test.jmx.compliance.server.support.MBeanServerWrapper;
+import org.jboss.test.jmx.compliance.server.support.TestMBeanServerBuilder;
+import org.jboss.test.jmx.compliance.server.support.TestMBeanServerDelegate;
+
+
+
+/**
+ * Tests the MBeanServerBuilder
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+public class MBeanServerBuilderTestCase
+ extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(MBeanServerBuilderTestCase.class);
+ }
+
+ private ObjectName name;
+ private ObjectName delegateName;
+ private String defaultBuilder;
+
+ private static final String DEFAULT_DOMAIN = "default";
+ private static final String BUILDER_PROPERTY = "javax.management.builder.initial";
+
+ // Constructor ---------------------------------------------------------------
+
+ public MBeanServerBuilderTestCase(String s)
+ {
+ super(s);
+ try
+ {
+ name = new ObjectName("server:test=MBeanServerBuilder");
+ delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new RuntimeException(e.toString());
+ }
+
+ defaultBuilder = System.getProperty(BUILDER_PROPERTY, "javax.management.MBeanServerBuilder");
+ }
+
+ // Tests ---------------------------------------------------------------------
+
+ public void testNewMBeanServerDelegate()
+ throws Exception
+ {
+ MBeanServerBuilder builder = new MBeanServerBuilder();
+ MBeanServerDelegate delegate = builder.newMBeanServerDelegate();
+ assertNotNull(delegate);
+ }
+
+ public void testNewMBeanServer()
+ throws Exception
+ {
+ MBeanServerBuilder builder = new MBeanServerBuilder();
+ MBeanServerDelegate delegate = builder.newMBeanServerDelegate();
+ MBeanServer server = builder.newMBeanServer(DEFAULT_DOMAIN, null, delegate);
+ assertTrue(server.getDefaultDomain().equals(DEFAULT_DOMAIN));
+ }
+
+ public void testNewMBeanServerViaMBeanServerFactory()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer(DEFAULT_DOMAIN);
+ assertTrue(server.getDefaultDomain().equals(DEFAULT_DOMAIN));
+ }
+
+ public void testPreRegisterGetsTheOriginalMBeanServer()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer(DEFAULT_DOMAIN);
+
+ BuilderTest test = new BuilderTest();
+ server.registerMBean(test, name);
+
+ assertTrue("Registered", server.isRegistered(name));
+ assertEquals("Got the correct MBeanServer", server, test.server);
+ }
+
+ public void testPreRegisterGetsTheOuterMBeanServer()
+ throws Exception
+ {
+ MBeanServerBuilder builder = new MBeanServerBuilder();
+ MBeanServerDelegate delegate = builder.newMBeanServerDelegate();
+ MBeanServer wrapper = MBeanServerWrapper.getWrapper();
+ MBeanServer server = builder.newMBeanServer(DEFAULT_DOMAIN, wrapper, delegate);
+
+ MBeanServerWrapper.getHandler(wrapper).server = server;
+
+ BuilderTest test = new BuilderTest();
+ wrapper.registerMBean(test, name);
+
+ assertTrue("Registered", server.isRegistered(name));
+ assertTrue("Got the correct MBeanServer", test.server.equals(wrapper));
+ assertTrue("Wrapper invoked", MBeanServerWrapper.getHandler(wrapper).invoked);
+ }
+
+ public void testMBeanServerDelegateReplaced()
+ throws Exception
+ {
+ MBeanServerBuilder builder = new MBeanServerBuilder();
+ TestMBeanServerDelegate delegate = new TestMBeanServerDelegate();
+ MBeanServer server = builder.newMBeanServer(DEFAULT_DOMAIN, null, delegate);
+
+ server.getAttribute(delegateName, "MBeanServerId");
+
+ assertTrue("Delegate replaced", delegate.invoked);
+ }
+
+ public void testReplaceMBeanServerBuilderMBeanServerDelegate()
+ throws Exception
+ {
+ System.setProperty(BUILDER_PROPERTY, TestMBeanServerBuilder.class.getName());
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ DelegateListener listener = new DelegateListener();
+ server.addNotificationListener(delegateName, listener, null, null);
+
+ BuilderTest test = new BuilderTest();
+ server.registerMBean(test, name);
+
+ assertTrue("Delegate replaced", listener.userData.equals("replaced"));
+ }
+ finally
+ {
+ System.setProperty(BUILDER_PROPERTY, defaultBuilder);
+ }
+ }
+
+ public void testReplaceMBeanServerBuilderMBeanServer()
+ throws Exception
+ {
+ System.setProperty(BUILDER_PROPERTY, TestMBeanServerBuilder.class.getName());
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ boolean caught = false;
+ try
+ {
+ server.queryMBeans(null, null);
+ }
+ catch (MBeanServerReplaced e)
+ {
+ caught = true;
+ }
+
+ assertTrue("MBeanServer replaced", caught);
+ }
+ finally
+ {
+ System.setProperty(BUILDER_PROPERTY, defaultBuilder);
+ }
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerFactoryTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerFactoryTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerFactoryTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.jboss.test.jmx.JBossJMXTest;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+
+ at SuppressWarnings("unchecked")
+public class MBeanServerFactoryTEST extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(MBeanServerFactoryTEST.class);
+ }
+
+ public MBeanServerFactoryTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testFindNonCreated()
+ {
+ MBeanServerFactory.newMBeanServer();
+ List mbsList = MBeanServerFactory.findMBeanServer(null);
+ assertEquals(0, mbsList.size());
+ }
+
+ public void testCreateFindAndRelease()
+ {
+ MBeanServer server = null;
+ List mbsList = null;
+
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer();
+ mbsList = MBeanServerFactory.findMBeanServer(null);
+ assertEquals(1, mbsList.size());
+ }
+ finally
+ {
+ if (null != server)
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+
+ mbsList = MBeanServerFactory.findMBeanServer(null);
+ assertEquals(0, mbsList.size());
+ }
+
+ public void testRemoveNonCreated()
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ MBeanServerFactory.releaseMBeanServer(server);
+ fail("expected an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ catch (Exception e)
+ {
+ fail("expected an IllegalArgumentException but got: " + e.getMessage());
+ }
+ }
+
+ public void testDomainCreated()
+ {
+ String domain = "dOmAiN";
+ MBeanServer server = null;
+ try
+ {
+ server = MBeanServerFactory.createMBeanServer(domain);
+ assertEquals(domain, server.getDefaultDomain());
+ List mbsList = MBeanServerFactory.findMBeanServer(null);
+ assertEquals(server, mbsList.get(0));
+ assertTrue("expected server reference equality", mbsList.get(0) == server);
+ }
+ finally
+ {
+ if (null != server)
+ {
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+ }
+ }
+
+ public void testDomainNonCreated()
+ {
+ String domain = "dOmAiN";
+ MBeanServer server = MBeanServerFactory.newMBeanServer(domain);
+ assertEquals(domain, server.getDefaultDomain());
+ }
+
+ public void testFindByAgentID() throws Exception
+ {
+ try
+ {
+ MBeanServer server1 = MBeanServerFactory.createMBeanServer();
+ MBeanServer server2 = MBeanServerFactory.createMBeanServer();
+ MBeanServer server3 = MBeanServerFactory.newMBeanServer();
+ ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate");
+
+ String agentID1 = (String)server1.getAttribute(delegateName, "MBeanServerId");
+ String agentID2 = (String)server2.getAttribute(delegateName, "MBeanServerId");
+ String agentID3 = (String)server3.getAttribute(delegateName, "MBeanServerId");
+
+ assertTrue((MBeanServer)MBeanServerFactory.findMBeanServer(agentID1).get(0) == server1);
+ assertTrue((MBeanServer)MBeanServerFactory.findMBeanServer(agentID2).get(0) == server2);
+ assertTrue(MBeanServerFactory.findMBeanServer(agentID3).size() == 0);
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerInvocationHandlerTestCase.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerInvocationHandlerTestCase.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerInvocationHandlerTestCase.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,399 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import java.util.ArrayList;
+
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.Notification;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.server.support.EmitterInvocationHandlerTest;
+import org.jboss.test.jmx.compliance.server.support.InvocationHandlerTest;
+import org.jboss.test.jmx.compliance.server.support.InvocationHandlerTestMBean;
+import org.jboss.test.jmx.compliance.server.support.ObjectInvocationHandlerTest;
+
+
+/**
+ * Tests the MBeanServerInvocationHandler
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+public class MBeanServerInvocationHandlerTestCase
+ extends JBossJMXTest
+ implements NotificationListener
+{
+ public static Test suite()
+ {
+ return suite(MBeanServerInvocationHandlerTestCase.class);
+ }
+
+ private ObjectName invocationHandlerTestName;
+
+ private ArrayList<Notification> messages = new ArrayList<Notification>();
+
+ // Constructor ---------------------------------------------------------------
+
+ public MBeanServerInvocationHandlerTestCase(String s)
+ {
+ super(s);
+
+ try
+ {
+ invocationHandlerTestName = new ObjectName("MBeanServerInvocationHandlerTestCase:type=InvocationHandlerTest");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ // Tests ---------------------------------------------------------------------
+
+ public void testConstructor()
+ throws Exception
+ {
+ MBeanServerFactory.newMBeanServer();
+ }
+
+ public void testGetter()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+ assertEquals("Attribute", proxy.getAttribute());
+ }
+
+ public void testSetter()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ proxy.setAttribute("Changed");
+ assertEquals("Changed", test.getAttribute());
+ }
+
+ public void testGetterPrimitiveBoolean()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals(false, test.isIsPrimitive());
+ test.setIsPrimitive(true);
+
+ assertEquals(true, proxy.isIsPrimitive());
+ }
+
+ public void testSetterPrimitiveBoolean()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals(false, test.isIsPrimitive());
+ proxy.setIsPrimitive(true);
+
+ assertEquals(true, test.isIsPrimitive());
+ }
+
+ public void testGetterTypeBoolean()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals(null, test.getType());
+ test.setType(new Boolean(true));
+
+ assertEquals(true, proxy.getType().booleanValue());
+ }
+
+ public void testSetterTypeBoolean()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals(null, test.getType());
+ proxy.setType(new Boolean(true));
+
+ assertEquals(true, test.getType().booleanValue());
+ }
+
+ public void testInvokeNoArgsNoReturn()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ proxy.invokeNoArgsNoReturn();
+ assertTrue(test.invokeNoArgsNoReturnInvoked);
+ }
+
+ public void testInvokeNoArgs()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals("invokeNoArgs", proxy.invokeNoArgs());
+ }
+
+ public void testInvoke()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ assertEquals("parameter", proxy.invoke("parameter"));
+ }
+
+ public void testInvokeMixedParameters()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, false);
+
+ Integer parameter = new Integer(20);
+ assertEquals(parameter, proxy.invokeMixedParameters("parameter", 10, parameter));
+ }
+
+ public void testNotificationEmitterAdd()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ proxy.addNotificationListener(this, null, null);
+
+ messages.clear();
+ test.sendNotification();
+ assertTrue(messages.size() == 1);
+ }
+
+ public void testNotificationEmitterRemove()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ proxy.addNotificationListener(this, null, null);
+
+ messages.clear();
+ test.sendNotification();
+ assertTrue(messages.size() == 1);
+
+ proxy.removeNotificationListener(this);
+
+ messages.clear();
+ test.sendNotification();
+ assertTrue(messages.size() == 0);
+ }
+
+ public void testNotificationEmitterRemoveTriplet()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ NotificationFilterSupport filter = new NotificationFilterSupport();
+ filter.enableType("test");
+ Object handback = new Object();
+ proxy.addNotificationListener(this, filter, handback);
+
+ messages.clear();
+ test.sendNotification();
+ assertTrue(messages.size() == 1);
+
+ proxy.removeNotificationListener(this, filter, handback);
+
+ messages.clear();
+ test.sendNotification();
+ assertTrue(messages.size() == 0);
+ }
+
+ public void testGetNotificationInfo()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ EmitterInvocationHandlerTest test = new EmitterInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ NotificationEmitter proxy = (NotificationEmitter) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ MBeanNotificationInfo[] info = proxy.getNotificationInfo();
+ assertEquals("test", info[0].getNotifTypes()[0]);
+ }
+
+ public void testToString()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectInvocationHandlerTest test = new ObjectInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ assertEquals("TOSTRING", proxy.toString());
+ }
+
+ public void testToStringFailsWhenNotExposed()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ try
+ {
+ proxy.toString();
+ fail("toString() should not work when it is not exposed for management");
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ public void testEquals()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectInvocationHandlerTest test = new ObjectInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ assertTrue(proxy.equals(new Object()));
+ }
+
+ public void testEqualsFailsWhenNotExposed()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ try
+ {
+ proxy.equals(new Object());
+ fail("equals(Object) should not work when it is not exposed for management");
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ public void testHashCode()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectInvocationHandlerTest test = new ObjectInvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ assertEquals(1234, proxy.hashCode());
+ }
+
+ public void testHashCodeFailsWhenNotExposed()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ InvocationHandlerTest test = new InvocationHandlerTest();
+ server.registerMBean(test, invocationHandlerTestName);
+ InvocationHandlerTestMBean proxy = (InvocationHandlerTestMBean) MBeanServerInvocationHandler.newProxyInstance(
+ server, invocationHandlerTestName, InvocationHandlerTestMBean.class, true);
+
+ try
+ {
+ proxy.hashCode();
+ fail("hashCode() should not work when it is not exposed for management");
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ // Notification Listener -----------------------------------------------------
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ messages.add(notification);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/MBeanServerTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,2000 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MBeanServerNotification;
+import javax.management.Notification;
+import javax.management.NotificationFilterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.RuntimeErrorException;
+import javax.management.RuntimeMBeanException;
+import javax.management.RuntimeOperationsException;
+import javax.management.loading.MLet;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.server.support.BabarError;
+import org.jboss.test.jmx.compliance.server.support.Base;
+import org.jboss.test.jmx.compliance.server.support.BaseMBean;
+import org.jboss.test.jmx.compliance.server.support.Broadcaster;
+import org.jboss.test.jmx.compliance.server.support.Derived;
+import org.jboss.test.jmx.compliance.server.support.Dynamic;
+import org.jboss.test.jmx.compliance.server.support.ExceptionOnTheRun;
+import org.jboss.test.jmx.compliance.server.support.LockedTest2;
+import org.jboss.test.jmx.compliance.server.support.LockedTest3;
+import org.jboss.test.jmx.compliance.server.support.MBeanListener;
+import org.jboss.test.jmx.compliance.server.support.MyScreamingException;
+import org.jboss.test.jmx.compliance.server.support.Test;
+import org.jboss.test.jmx.compliance.server.support.Test3;
+import org.jboss.test.jmx.compliance.server.support.Test4;
+import org.jboss.test.jmx.compliance.server.support.Unrelated;
+import org.jboss.test.jmx.compliance.server.support.UnrelatedMBean;
+
+
+/**
+ * Tests the MBean server impl. through the <tt>MBeanServer</tt> interface.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 86129 $
+ *
+ */
+public class MBeanServerTEST
+ extends JBossJMXTest
+{
+ public static junit.framework.Test suite()
+ {
+ return suite(MBeanServerTEST.class);
+ }
+
+ URL location;
+
+ public MBeanServerTEST(String s) throws Exception
+ {
+ super(s);
+
+ // Workout the output location for the dynamically loaded files
+ location = getClass().getResource("/org/jboss/test/jmx/compliance/server/MBeanServerTEST.class");
+ String jarPath = location.getPath();
+ int i = jarPath.indexOf('!');
+ if (i != -1)
+ {
+ jarPath = jarPath.substring(0, i);
+ location = new URL(jarPath);
+ location = new URL(location, "file:../");
+ }
+ }
+
+ // MBeanServer invoke --------------------------------------------
+
+ /**
+ * Tests invoke with primitive boolean return type. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithPrimitiveBooleanReturn() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ Boolean bool = (Boolean)server.invoke(name, "opWithPrimBooleanReturn", null, null);
+
+ assertTrue(bool.booleanValue() == true);
+ }
+
+ /**
+ * Tests invoke with primitive long array return type. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithPrimitiveLongArrayReturn() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ long[] array = (long[])server.invoke(name, "opWithPrimLongArrayReturn", null, null);
+
+ assertTrue(array [0] == 1);
+ assertTrue(array [1] == 2);
+ assertTrue(array [2] == 3);
+ }
+
+ /**
+ * Tests invoke with Long array return type. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithLongArrayReturn() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ Long[] array = (Long[])server.invoke(name, "opWithLongArrayReturn", null, null);
+
+ assertTrue(array [0].longValue() == 1);
+ assertTrue(array [1].longValue() == 2);
+ assertTrue(array [2].longValue() == 3);
+ }
+
+ /**
+ * Tests invoke with primitive long return type. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithPrimitiveLongReturn() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ Long l = (Long)server.invoke(name, "opWithPrimLongReturn", null, null);
+
+ assertTrue(l.longValue() == 1234567890123l);
+ }
+
+ /**
+ * Tests invoke with primitive double return type. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithPrimitiveDoubleReturn() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ Double d = (Double)server.invoke(name, "opWithPrimDoubleReturn", null, null);
+
+ assertTrue(d.doubleValue() == 0.1234567890123d);
+ }
+
+ /**
+ * Tests invoke with long signature. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithLongSignature() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ server.invoke(name, "opWithLongSignature",
+ new Object[] { new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5),
+ new Integer(6), new Integer(7), new Integer(8), new Integer(9), new Integer(10),
+ new Integer(11), new Integer(12), new Integer(13), new Integer(14), new Integer(15),
+ new Integer(16), new Integer(17), new Integer(18), new Integer(19), new Integer(20) },
+ new String[] { "int", "int", "int", "int", "int", "int", "int", "int", "int", "int",
+ "int", "int", "int", "int", "int", "int", "int", "int", "int", "int" }
+ );
+ }
+
+ /**
+ * Tests invoke with mixed types in signature, especially types with double
+ * byte code length and arrays. <p>
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithMixedSignature() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":test=test");
+ server.registerMBean(new Test(), name);
+
+ server.invoke(name, "opWithMixedSignature",
+ new Object[] { new Integer(1), new Double(2.2D), new Long(333L), new Boolean(true), new Byte((byte)0x02),
+ new Short((short)6), new long[]{7L, 8L}, new Long[]{new Long(1L), new Long(2L)}, new Short((short)9), new Byte((byte)10),
+ new Long(11L), new Double(1.2D), new Integer(13), new Integer(14), new Integer(15),
+ new Integer(16), new Integer(17), new Integer(18), new Integer(19), new Integer(20) },
+ new String[] { "int", "double", "long", "boolean", "byte", "short", "[J", "[Ljava.lang.Long;", "java.lang.Short", "java.lang.Byte",
+ "java.lang.Long", "java.lang.Double", "int", "int", "int", "int", "int", "int", "int", "int" }
+ );
+ }
+
+
+ /**
+ * Attempts to invoke a method on an unregistered MBean; <tt>InstanceNotFoundException</tt> should occur.
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithNonExistantMBean() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.invoke(new ObjectName(":mbean=doesnotexist"), "noMethod", null, null);
+
+ // should not reach here
+ fail("InstanceNotFoundException was not thrown from an invoke operation on a non-existant MBean.");
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // should get here
+ }
+
+ }
+
+ /**
+ * Attempts to invoke a MBean operation that throws a business exception; <tt>MBeanException</tt> should be thrown.
+ *
+ * @throws Exception for any error
+ */
+ public void testInvokeWithBusinessException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.invoke(name, "operationWithException", null, null);
+
+ // should not get here
+ fail("MBeanException was not thrown.");
+ }
+ catch (MBeanException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+
+ // MBeanServer getAttribute --------------------------------------
+
+ public void testGetAttributeWithNonExistingAttribute() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "Foo");
+
+ // should not reach here
+ fail("AttributeNotFoundexception was not thrown when invoking getAttribute() call on a non-existant attribute.");
+ }
+ catch (AttributeNotFoundException e)
+ {
+ // Expecting this.
+ }
+ }
+
+ public void testGetAttributeWithBusinessException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.getAttribute(name, "ThisWillScream");
+
+ // should not reach here
+ fail("Did not throw the screaming exception");
+ }
+ catch (MBeanException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ public void testGetAttributeWithNonExistingMBean() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:name=DoesNotExist");
+
+ server.getAttribute(name, "Whatever");
+
+ // should not reach here
+ fail("InstanceNotFoundException was not thrown on a nonexistant MBean.");
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // this is expected
+ }
+ }
+
+ public void testGetAttributeWithUncheckedException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.getAttribute(name, "ThrowUncheckedException");
+
+ // should not reach here
+ fail("RuntimeMBeanException was not thrown");
+ }
+ catch (RuntimeMBeanException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof ExceptionOnTheRun);
+ }
+ }
+
+ public void testGetAttributeWithError() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.getAttribute(name, "Error");
+
+ // should not reach here
+ fail("Error was not thrown");
+ }
+ catch (RuntimeErrorException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetError() instanceof BabarError);
+ }
+ }
+
+
+ // MBeanServer setAttribute --------------------------------------
+
+ public void testSetAttributeWithNonExistingAttribute() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.setAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), new Attribute("Foo", "value"));
+
+ // should not reach here
+ fail("AttributeNotFoundexception was not thrown when invoking getAttribute() call on a non-existant attribute.");
+ }
+ catch (AttributeNotFoundException e)
+ {
+ // Expecting this.
+ }
+ }
+
+ public void testSetAttributeWithBusinessException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.setAttribute(name, new Attribute("ThisWillScream", "value"));
+
+ // should not reach here
+ fail("Did not throw the screaming exception");
+ }
+ catch (MBeanException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ public void testSetAttributeWithNonExistingMBean() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:name=DoesNotExist");
+
+ server.setAttribute(name, new Attribute("Whatever", "nothing"));
+
+ // should not reach here
+ fail("InstanceNotFoundException was not thrown on a nonexistant MBean.");
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // this is expected
+ }
+ }
+
+ public void testSetAttributeWithUncheckedException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.setAttribute(name, new Attribute("ThrowUncheckedException", "value"));
+
+ // should not reach here
+ fail("RuntimeMBeanException was not thrown");
+ }
+ catch (RuntimeMBeanException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof ExceptionOnTheRun);
+ }
+ }
+
+ public void testSetAttributeWithError() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new Test(), name);
+
+ server.setAttribute(name, new Attribute("Error", "value"));
+
+ // should not reach here
+ fail("Error was not thrown");
+ }
+ catch (RuntimeErrorException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetError() instanceof BabarError);
+ }
+ }
+
+
+ // MBeanServer instantiate ---------------------------------------
+
+ /**
+ * Tests instantiate(String className). Class defined by system classloader.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultConstructor() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ Object o = server.instantiate("org.jboss.test.jmx.compliance.server.support.Test");
+
+ assertTrue(o instanceof org.jboss.test.jmx.compliance.server.support.Test);
+ }
+
+ /**
+ * Tests instantiate(String className) with constructor that throws a checked application exception.
+ * Class defined by system classloader.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultConstructorAndApplicationException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.ConstructorTest");
+
+ // shouldn't get here
+ fail("Instantiate should have thrown an MBeanException.");
+ }
+ catch (MBeanException e)
+ {
+ // this is expected
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with constructor that throws an unchecked application exception.
+ * Class defined by the system classloader.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultConstructorAndRuntimeException() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.ConstructorTest2");
+
+ // shouldn't get here
+ fail("Instantiate should have thrown a RuntimeMBeanException.");
+ }
+ catch (RuntimeMBeanException e)
+ {
+ // this is expected
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with constructor that throws an error.
+ * Class defined by the system classloader.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultConstructorAndError() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.ConstructorTest3");
+
+ // shouldn't get here
+ fail("Instantiate should have thrown a RuntimeErrorException.");
+ }
+ catch (RuntimeErrorException e)
+ {
+ // this is expected
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with unfound class.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultConstructorAndUnknownClass() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("foo.Bar");
+
+ // should not get here
+ fail("Instantiate should have thrown a ReflectionException.");
+ }
+ catch (ReflectionException e)
+ {
+ // this is expected
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with class that doesn't have a default constructor.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithMissingDefaultConstructor() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.ConstructorTest6");
+
+ // should not get here
+ fail("Instantiate should have thrown a ReflectionException.");
+ }
+ catch (ReflectionException e)
+ {
+ // this is expected
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with protected (no access) no args constructor.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithInaccessibleNoArgsConstructor() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.ConstructorTest7");
+
+ // should not get here
+ fail("Instantiate should have thrown a ReflectionException.");
+ }
+ catch (ReflectionException e)
+ {
+ // this is expected
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with null class name. According to
+ * javadoc, should throw RuntimeOperationsException wrapping IllegalArgException.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithNullClassName() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate(null);
+
+ // should not reach here
+ fail("incorrect exception behavior");
+ }
+ catch (RuntimeOperationsException e)
+ {
+ // expected
+
+ // check that it wraps IAE
+ assertTrue(e.getTargetException() instanceof IllegalArgumentException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) with empty class name string. should
+ * throw ReflectionException wrapping CNFE.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithEmptyClassName() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("");
+
+ // should not reach here
+ fail("incorrect exception/classloading behavior");
+ }
+ catch (ReflectionException e)
+ {
+ // expected
+
+ // check that it wraps CNFE
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, ObjectName loader) with null class name. According to
+ * javadoc, should throw RuntimeOperationsException wrapping IllegalArgException.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithNullClassName2() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate(null, null);
+
+ // should not reach here
+ fail("incorrect exception behavior");
+ }
+ catch (RuntimeOperationsException e)
+ {
+ // expected
+
+ // check that it wraps IAE
+ assertTrue(e.getTargetException() instanceof IllegalArgumentException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, ObjectName loader) with empty class name string. should
+ * throw ReflectionException wrapping CNFE.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithEmptyClassName2() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("", null);
+
+ // should not reach here
+ fail("incorrect exception/classloading behavior");
+ }
+ catch (ReflectionException e)
+ {
+ // expected
+
+ // check that it wraps CNFE
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, Object[] args, String[] sign) with null
+ * class name. According to javadoc, should throw RuntimeOperationsException
+ * wrapping IllegalArgException.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithNullClassName3() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate(null, null, null);
+
+ // should not reach here
+ fail("incorrect exception behavior");
+ }
+ catch (RuntimeOperationsException e)
+ {
+ // expected
+
+ // check that it wraps IAE
+ assertTrue(e.getTargetException() instanceof IllegalArgumentException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, Object[] args, String[] sign) with
+ * empty class name string. should throw ReflectionException wrapping CNFE.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithEmptyClassName3() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("", null, null);
+
+ // should not reach here
+ fail("incorrect exception/classloading behavior");
+ }
+ catch (ReflectionException e)
+ {
+ // expected
+
+ // check that it wraps CNFE
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, ObjectName loader, Object[] args, String[] sign)
+ * with null class name. According to javadoc, should throw RuntimeOperationsException
+ * wrapping IllegalArgException.
+ *
+ * @throws Exception for any error
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithNullClassName4() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate(null, null, null, null);
+
+ // should not reach here
+ fail("incorrect exception behavior");
+ }
+ catch (RuntimeOperationsException e)
+ {
+ // expected
+
+ // check that it wraps IAE
+ assertTrue(e.getTargetException() instanceof IllegalArgumentException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className, ObjectName loader, Object[] args, String[] sign)
+ * with empty class name string. should throw ReflectionException wrapping CNFE.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithEmptyClassName4() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.instantiate("", null, null, null);
+
+ // should not reach here
+ fail("incorrect exception/classloading behavior");
+ }
+ catch (ReflectionException e)
+ {
+ // expected
+
+ // check that it wraps CNFE
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ /**
+ * Tests instantiate(String className) classloading behaviour. According to
+ * javadoc, DLR should be used to instantiate the class
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultLoaderRepository() throws Exception
+ {
+ // NOTE:
+ // the urls used here are relative to the location of the build.xml
+
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ MLet mlet = new MLet();
+ ObjectName name = new ObjectName(":test=test");
+
+ // mlet cl to DLR
+ try
+ {
+ mlet.addURL(new URL(location, "lib/jmxcompliance-Test.jar"));
+ server.registerMBean(mlet, name);
+
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.AClass");
+ }
+ finally
+ {
+ try
+ {
+ server.unregisterMBean(name);
+ }
+ catch (Exception ignored) {}
+ }
+
+ //assertTrue(o.getClass().getClassLoader().equals(mlet));
+ }
+
+
+ /**
+ * Tests instantiate(String className, ObjectName loader) classloading behaviour. According to
+ * javadoc, DLR should be used to instantiate the class. This should fail as
+ * the MLet MBean is never added to the agent and therefore not in the DLR.
+ *
+ * @throws Exception for any error
+ */
+ public void testInstantiateWithDefaultLoaderRepository2() throws Exception
+ {
+ try
+ {
+ // NOTE:
+ // the urls used here are relative to the location of the build.xml
+
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ MLet mlet = new MLet();
+
+ // mlet cl to DLR
+ mlet.addURL("file:./output/etc/test/compliance/server/Test.jar");
+ //server.registerMBean(mlet, new ObjectName(":test=test"));
+
+ server.instantiate("org.jboss.test.jmx.compliance.server.support.AClass");
+
+//
+// FIXME: this test won't work until we have means to reset the JVM wide
+// loader repository
+//
+
+ // should not reach here
+ //fail("incorrect classloading behavior");
+ //assertTrue(o.getClass().getClassLoader().equals(mlet));
+ }
+ catch (ReflectionException e)
+ {
+ // expected
+
+ // check that it wraps CNFE
+ assertTrue(e.getTargetException() instanceof ClassNotFoundException);
+ }
+ }
+
+ // MBeanServer registerMBean ------------------------------------
+
+ /**
+ * Tests registering with null object name.
+ *
+ * @throws Exception for any error
+ */
+ public void testRegisterNullObjectName() throws Exception
+ {
+ boolean caught = false;
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.registerMBean(new Test(), null);
+ }
+ catch (RuntimeOperationsException e)
+ {
+ if (e.getTargetException() instanceof IllegalArgumentException)
+ caught = true;
+ else
+ fail("Wrong wrapped exception " + e.getTargetException());
+ }
+ if (caught == false)
+ fail("Allowed to register with a null object name");
+ }
+
+ /**
+ * Tests registering with a pattern object name.
+ *
+ * @throws Exception for any error
+ */
+ public void testRegisterPatternObjectName() throws Exception
+ {
+ boolean caught = false;
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.registerMBean(new Test(), new ObjectName("Domai?:type=test"));
+ }
+ catch (RuntimeOperationsException e)
+ {
+ if (e.getTargetException() instanceof IllegalArgumentException)
+ caught = true;
+ else
+ fail("Wrong wrapped exception " + e.getTargetException());
+ }
+ if (caught == false)
+ fail("Allowed to register with a pattern object name");
+ }
+
+ /**
+ * Tests registering into JMImplementation
+ *
+ * @throws Exception for any error
+ */
+ public void testRegisterJMImplementationObjectName() throws Exception
+ {
+ boolean caught = false;
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ server.registerMBean(new Test(), new ObjectName("JMImplementation:type=test"));
+ }
+ catch (RuntimeOperationsException e)
+ {
+ if (e.getTargetException() instanceof IllegalArgumentException)
+ caught = true;
+ else
+ fail("Wrong wrapped exception " + e.getTargetException());
+ }
+ if (caught == false)
+ fail("Allowed to register into JMImplementation");
+ }
+
+ /**
+ * Tests register for an MBean that throws checked exception from preRegister()
+ *
+ * @throws Exception for any error
+ */
+ public void testRegisterMBeanOnExceptionFromPreRegister2() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ try
+ {
+ server.registerMBean(new Test3(), name);
+
+ // should not reach here
+ fail("Test3 registered despite of throwin an exception from the preRegister() method");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(!server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ /**
+ * Tests register for an MBean that throws an MBeanRegistrationException from
+ * preRegister() method.
+ *
+ * @throws Exception for any error
+ */
+ public void testRegisterMBeanOnExceptionFromPreRegister3() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ try
+ {
+ server.registerMBean(new Test4(), name);
+
+ // should not reach here
+ fail("Test4 registered despite of throwing an exception from the preRegister() method.");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(!server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+
+ // MBeanServer unregisterMBean ----------------------------------
+
+ /**
+ * Tests basic register/unregister
+ *
+ * @throws Exception for any error
+ */
+ public void testBasicUnregister() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ server.registerMBean(new Test(), name);
+ server.unregisterMBean(name);
+ }
+
+ /**
+ * Tests unregister with default domain name
+ *
+ * @throws Exception for any error
+ */
+ public void testUnregisterWithDefaultDomainName() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":foo=bar");
+
+ server.registerMBean(new Test(), name);
+ server.unregisterMBean(name);
+
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // FAILS IN RI: RI throws InstanceNotFoundException if you try to
+ // unregister with implicit default domain name
+ fail("FAILS IN RI: RI throws InstanceNotFoundException when an existing MBean is unregistered with an implicit default domain name.");
+ }
+ }
+
+ /**
+ * Tests unregister with default domain name gotten from ObjectInstance at registration time.
+ *
+ * @throws Exception for any error
+ */
+ public void testUnregisterWithObjectNameFromRegistration() throws Exception
+ {
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName(":foo=bar");
+
+ ObjectInstance oi = server.registerMBean(new Test(), name);
+ name = oi.getObjectName();
+
+ server.unregisterMBean(name);
+
+ }
+ catch (InstanceNotFoundException e)
+ {
+ // FAILS IN RI: RI throws InstanceNotFoundExceptin if you try yo
+ // unregister with implicit default domain name
+ fail("FAILS IN RI: RI throws InstanceNotFoundException when an existing MBean is unregistered with an implicit default domain name retrieved from the ObjectInstance returned at registration time.");
+ }
+ }
+
+ /**
+ * Tests unregister for an MBean that prevents unregistration by throwing a
+ * checked exception from its preDeregister() method.
+ *
+ * @throws Exception for any error
+ */
+ public void testUnregisterMBeanOnExceptionFromPreDeregister2() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ server.registerMBean(new LockedTest2(), name);
+
+ try
+ {
+
+ server.unregisterMBean(name);
+
+ // should not reach here
+ fail("LockedTest2 unregistered despite of throwin an exception from the preDeregister() method");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ /**
+ * Tests unregister for an MBean that prevents unregistration by throwing a
+ * MBeanRegistrationException from its preDeregister() method. This should
+ * be rethrown by the agent as-is, and not wrapped into another MBeanRegistrationException.
+ *
+ * @throws Exception for any error
+ */
+ public void testUnregisterMBeanOnExceptionFromPreDeregister3() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:foo=bar");
+
+ server.registerMBean(new LockedTest3(), name);
+
+ try
+ {
+ server.unregisterMBean(name);
+
+ // should not reach here
+ fail("LockedTest3 unregistered despite of throwing an exception from the preDeregister() method.");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ // expected
+ assertTrue(server.isRegistered(name));
+ assertTrue(e.getTargetException() instanceof MyScreamingException);
+ }
+ }
+
+ // MBeanServer NotificationListener Plain -----------------------
+
+ /**
+ * Tests basic listener registration to server delegate
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddNotificationListenerToDelegate() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener {
+
+ int notificationCount = 0;
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ try
+ {
+ notificationCount++;
+
+ assertTrue(handback instanceof String);
+ assertTrue(handback.equals("MyHandback"));
+ assertTrue(notification.getSource().equals(new ObjectName("JMImplementation:type=MBeanServerDelegate")));
+ }
+ catch (Exception e)
+ {
+ fail("Unexpected error: " + e.toString());
+ }
+ }
+ }
+
+ MyNotificationListener listener = new MyNotificationListener();
+
+ NotificationFilterSupport filter = new NotificationFilterSupport();
+ filter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, filter, "MyHandback"
+ );
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener.notificationCount == 1);
+ }
+
+ /**
+ * Tests multiple listeners with different handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddMultipleListeners()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ Object handback;
+ int result = 0;
+ public MyNotificationListener(Object handback)
+ {
+ this.handback = handback;
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result++;
+ assertEquals(this.handback, handback);
+ result++;
+ }
+ }
+
+ MyNotificationListener listener1 = new MyNotificationListener("handback1");
+ MyNotificationListener listener2 = new MyNotificationListener("handback2");
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener1, null, "handback1"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback2"
+ );
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener1.result == 2);
+ assertTrue(listener2.result == 2);
+ }
+
+ /**
+ * Tests one listener multiple handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddListenerMultipleHandbacks()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ boolean result1 = false;
+ boolean result2 = false;
+ public void handleNotification(Notification notification, Object handback)
+ {
+ if (handback.equals("handback1"))
+ result1 = true;
+ else if (handback.equals("handback2"))
+ result2 = true;
+ else
+ fail("Unexpected handback: " + handback);
+ }
+ }
+
+ MyNotificationListener listener = new MyNotificationListener();
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, null, "handback1"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, null, "handback2"
+ );
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener.result1);
+ assertTrue(listener.result2);
+ }
+
+ /**
+ * Tests removing a notification listener including multiple handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testRemoveListener()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ Object handback;
+ int result = 0;
+ public MyNotificationListener(Object handback)
+ {
+ this.handback = handback;
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result++;
+ assertEquals(this.handback, handback);
+ result++;
+ }
+ }
+
+ class MyOtherNotificationListener implements NotificationListener
+ {
+ boolean result1 = false;
+ boolean result2 = false;
+ public void handleNotification(Notification notification, Object handback)
+ {
+ if (handback.equals("handback1"))
+ result1 = true;
+ else if (handback.equals("handback2"))
+ result2 = true;
+ else
+ fail("Unexpected handback: " + handback);
+ }
+ }
+
+ MyNotificationListener listener1 = new MyNotificationListener("handback1");
+ MyOtherNotificationListener listener2 = new MyOtherNotificationListener();
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener1, null, "handback1"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback2"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback3"
+ );
+ server.removeNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2
+ );
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener1.result == 2);
+ assertTrue(listener2.result1 == false);
+ assertTrue(listener2.result2 == false);
+ }
+
+ /**
+ * Tests removing a notification listener triplet
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testRemoveTriplet()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ Object handback;
+ int result = 0;
+ public MyNotificationListener(Object handback)
+ {
+ this.handback = handback;
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result++;
+ assertEquals(this.handback, handback);
+ result++;
+ }
+ }
+
+ MyNotificationListener listener1 = new MyNotificationListener("handback1");
+ MyNotificationListener listener2 = new MyNotificationListener("handback2");
+
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener1, null, "handback1"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback2"
+ );
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback3"
+ );
+ server.removeNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener2, null, "handback3"
+ );
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener1.result == 2);
+ assertTrue(listener1.result == 2);
+ }
+
+ /**
+ * Tests removing a broadcaster
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testRemoveBroadcaster()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ long result = 0;
+ public MyNotificationListener()
+ {
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result = notification.getSequenceNumber();
+ }
+ }
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener
+ MyNotificationListener listener = new MyNotificationListener();
+ server.addNotificationListener(broadcasterName, listener, null, null);
+
+ // Test we get a notification
+ broadcaster.doSomething();
+ assertEquals(1, listener.result);
+
+ // Remove the broadcaster
+ server.unregisterMBean(broadcasterName);
+ }
+
+ /**
+ * Tests adding the listener to different broadcasters
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddListenerToTwoBroadcasters()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ long result = 0;
+ public MyNotificationListener()
+ {
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result++;
+ }
+ }
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener to the broadcaster
+ MyNotificationListener listener = new MyNotificationListener();
+ server.addNotificationListener(broadcasterName, listener, null, null);
+
+ // Add the listener to the delegate
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, null, null
+ );
+
+ // Test we get a notification from the broadcaster
+ broadcaster.doSomething();
+ assertEquals(1, listener.result);
+
+ // Test we get a notification from the delegate
+ server.registerMBean(new Test(), new ObjectName("Test:foo=bar"));
+ assertEquals(2, listener.result);
+
+ // Remove the broadcaster
+ server.unregisterMBean(broadcasterName);
+ assertEquals(3, listener.result);
+
+ // Make sure we are still listening to the delegate
+ server.unregisterMBean(new ObjectName("Test:foo=bar"));
+ assertEquals(4, listener.result);
+ }
+
+ /**
+ * Tests adding the listener to different broadcasters but remove one
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddListenerToTwoBroadcastersRemoveOne()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ class MyNotificationListener implements NotificationListener
+ {
+ long result = 0;
+ public MyNotificationListener()
+ {
+ }
+ public void handleNotification(Notification notification, Object handback)
+ {
+ result++;
+ }
+ }
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener to the broadcaster
+ MyNotificationListener listener = new MyNotificationListener();
+ server.addNotificationListener(broadcasterName, listener, null, null);
+
+ // Add the listener to the delegate
+ server.addNotificationListener(
+ new ObjectName("JMImplementation:type=MBeanServerDelegate"),
+ listener, null, null
+ );
+
+ // Remove ourselves from the broadcaster
+ server.removeNotificationListener(broadcasterName, listener);
+
+ // Test we get a notification from the broadcaster
+ broadcaster.doSomething();
+ assertEquals(0, listener.result);
+
+ // Test we get a notification from the delegate
+ server.registerMBean(new Test(), new ObjectName("Test:foo=bar"));
+ assertEquals(1, listener.result);
+ }
+
+ // MBeanServer NotificationListener Object Name -----------------
+
+ /**
+ * Tests basic listener registration to server delegate
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testaddMBeanToDelegate() throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener = new MBeanListener();
+ ObjectName listenerName = new ObjectName("test:type=listener");
+ server.registerMBean(listener, listenerName);
+
+ NotificationFilterSupport filter = new NotificationFilterSupport();
+ filter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
+
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName, listenerName, filter, "MyHandback");
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener.count == 1);
+ assertTrue(listener.source.equals(delegateName));
+ assertTrue(listener.handback.equals("MyHandback"));
+ }
+
+ /**
+ * Tests multiple listeners with different handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddMBeanMultipleListeners()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+ MBeanListener listener2 = new MBeanListener();
+ ObjectName listenerName2 = new ObjectName("test:type=listener2");
+ server.registerMBean(listener2, listenerName2);
+
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName, listenerName1, null, "handback1");
+ server.addNotificationListener(delegateName, listenerName2, null, "handback2");
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertEquals(1, listener1.count);
+ assertEquals(listener1.source,delegateName);
+ assertEquals(listener1.handback,"handback1");
+ assertEquals(1, listener2.count);
+ assertEquals(listener2.source,delegateName);
+ assertEquals(listener2.handback,"handback2");
+ }
+
+ /**
+ * Tests one listener multiple handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddMBeanListenerMultipleHandbacks()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener = new MBeanListener("handback1", "handback2");
+ ObjectName listenerName = new ObjectName("test:type=listener");
+ server.registerMBean(listener, listenerName);
+
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName, listenerName, null, "handback1");
+ server.addNotificationListener(delegateName, listenerName, null, "handback2");
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+
+ assertTrue(listener.count1 == 1);
+ assertEquals(listener.source1,delegateName);
+ assertEquals(listener.handback1,"handback1");
+ assertTrue(listener.count2 == 1);
+ assertEquals(listener.source2,delegateName);
+ assertEquals(listener.handback2,"handback2");
+ }
+
+ /**
+ * Tests removing a notification listener including multiple handbacks
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testMBeanRemoveListener()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+ MBeanListener listener2 = new MBeanListener("handback2", "handback3");
+ ObjectName listenerName2 = new ObjectName("test:type=listener2");
+ server.registerMBean(listener2, listenerName2);
+
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName, listenerName1, null, "handback1");
+ server.addNotificationListener(delegateName, listenerName2, null, "handback2");
+ server.addNotificationListener(delegateName, listenerName2, null, "handback3");
+ server.removeNotificationListener(delegateName, listenerName2);
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+ assertTrue("Listener1 should get a notification", listener1.count == 1);
+ assertTrue("Source should be the delegate", listener1.source.equals(delegateName));
+ assertTrue("Listener1 should get handback1", listener1.handback.equals("handback1"));
+ assertTrue("Listener2 should have no notiifcation", listener2.count == 0);
+ assertTrue("Listener2 should have no notiifcation for handback2", listener2.count1 == 0);
+ assertTrue("Listener2 should have no notiifcation for handback3", listener2.count2 == 0);
+ }
+
+ /**
+ * Tests removing a notification listener triple
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testMBeanRemoveTriplet()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+ MBeanListener listener2 = new MBeanListener("handback2", "handback3");
+ ObjectName listenerName2 = new ObjectName("test:type=listener2");
+ server.registerMBean(listener2, listenerName2);
+
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName, listenerName1, null, "handback1");
+ server.addNotificationListener(delegateName, listenerName2, null, "handback2");
+ server.addNotificationListener(delegateName, listenerName2, null, "handback3");
+ server.removeNotificationListener(delegateName, listenerName2, null, "handback3");
+
+ // force notification
+ server.registerMBean(new Test(), new ObjectName(":foo=bar"));
+ assertTrue("Listener1 should get a notification", listener1.count == 1);
+ assertTrue("Source should be the delegate", listener1.source.equals(delegateName));
+ assertTrue("Listener1 should get handback1", listener1.handback.equals("handback1"));
+ assertTrue("Listener2 should get a notification", listener2.count1 == 1);
+ assertTrue("Source should be the delegate", listener2.source1.equals(delegateName));
+ assertTrue("Listener2 should get handback2", listener2.handback1.equals("handback2"));
+ assertTrue("Listener2 should have no notiifcation for handback3", listener2.count2 == 0);
+ }
+
+ /**
+ * Tests MBeanRedeploy notification
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testMBeanRedeployNotification()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener = new MBeanListener();
+ ObjectName listenerName = new ObjectName("test:type=listener");
+ server.registerMBean(listener, listenerName);
+
+ ObjectName broadcasterName = new ObjectName("test:type=Broadcaster");
+ server.registerMBean(new Broadcaster(), broadcasterName);
+
+ server.addNotificationListener(broadcasterName, listenerName, null, "handback1");
+ server.removeNotificationListener(broadcasterName, listenerName, null, "handback1");
+ server.unregisterMBean(broadcasterName);
+
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+ server.addNotificationListener(broadcasterName, listenerName, null, "handback2");
+
+ // force notification
+ broadcaster.doSomething();
+ assertTrue("Listener should get a notification", listener.count == 1);
+ assertTrue("Source should be the broadcaster", listener.source.equals(broadcasterName));
+ assertTrue("Listener should get handback2", listener.handback.equals("handback2"));
+ }
+
+ /**
+ * Tests removing a broadcaster
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testMBeanRemoveBroadcaster()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener
+ server.addNotificationListener(broadcasterName, listenerName1, null, null);
+
+ // Test we get a notification
+ broadcaster.doSomething();
+ assertEquals(1, listener1.count);
+ assertEquals(broadcasterName, listener1.source);
+
+ // Remove the broadcaster
+ server.unregisterMBean(broadcasterName);
+ }
+
+ /**
+ * Tests adding the listener to different broadcasters
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddMBeanListenerToTwoBroadcasters()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener to the broadcaster
+ server.addNotificationListener(broadcasterName, listenerName1, null, null);
+
+ // Add the listener to the delegate
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName,listenerName1, null, null);
+
+ // Test we get a notification from the broadcaster
+ broadcaster.doSomething();
+ assertEquals(1, listener1.count);
+ assertEquals(broadcasterName, listener1.source);
+
+ try
+ {
+ // Test we get a notification from the delegate
+ server.registerMBean(new Test(), new ObjectName("Test:foo=bar"));
+ assertEquals(2, listener1.count);
+ assertEquals(delegateName, listener1.source);
+
+ // Remove the broadcaster
+ server.unregisterMBean(broadcasterName);
+ assertEquals(3, listener1.count);
+ assertEquals(delegateName, listener1.source);
+
+ // Make sure we are still listening to the delegate
+ server.unregisterMBean(new ObjectName("Test:foo=bar"));
+ assertEquals(4, listener1.count);
+ assertEquals(delegateName, listener1.source);
+ }
+ catch (AssertionFailedError e)
+ {
+ fail("FAILS IN RI: Listener registered with ObjectName in MBeanServer " +
+ "reports the wrong source for multiple broadcaster.");
+ }
+ }
+
+ /**
+ * Tests adding the listener to different broadcasters but remove one
+ *
+ * @throws Exception for any error
+ */
+ public synchronized void testAddMBeanListenerToTwoBroadcastersRemoveOne()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ MBeanListener listener1 = new MBeanListener();
+ ObjectName listenerName1 = new ObjectName("test:type=listener1");
+ server.registerMBean(listener1, listenerName1);
+
+ // Register the broadcaster
+ ObjectName broadcasterName = new ObjectName("test:type=broadcaster");
+ Broadcaster broadcaster = new Broadcaster();
+ server.registerMBean(broadcaster, broadcasterName);
+
+ // Add the listener to the broadcaster
+ server.addNotificationListener(broadcasterName, listenerName1, null, null);
+
+ // Add the listener to the delegate
+ ObjectName delegateName =
+ new ObjectName("JMImplementation:type=MBeanServerDelegate");
+ server.addNotificationListener(delegateName,listenerName1, null, null);
+
+ // Remove ourselves from the broadcaster
+ server.removeNotificationListener(broadcasterName, listener1);
+
+ // Test we get a notification from the broadcaster
+ broadcaster.doSomething();
+ assertEquals(0, listener1.count);
+
+ // Test we get a notification from the delegate
+ server.registerMBean(new Test(), new ObjectName("Test:foo=bar"));
+ assertEquals(1, listener1.count);
+ try
+ {
+ assertEquals(delegateName, listener1.source);
+ }
+ catch (AssertionFailedError e)
+ {
+ fail("FAILS IN RI: Listener registered with ObjectName in MBeanServer " +
+ "reports the wrong source for multiple broadcaster, " +
+ "even when the broadcaster it reports has been removed.");
+ }
+ }
+
+ public void testGetDomains()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ Set<String> expected = new HashSet<String>();
+ expected.add("JMImplementation");
+ expected.add("org.jboss.jmx");
+ Set<String> actual = new HashSet<String>(Arrays.asList(server.getDomains()));
+ assertTrue("Only two domain at the start", server.getDomains().length == 2);
+ assertEquals(expected, actual);
+
+ server.registerMBean(new Test(), new ObjectName("Domain1:test=test1"));
+ server.registerMBean(new Test(), new ObjectName("Domain1:test=test2"));
+ server.registerMBean(new Test(), new ObjectName("Domain2:test=test1"));
+ server.registerMBean(new Test(), new ObjectName("Domain3:test=test1"));
+
+ assertTrue("Now five domains", server.getDomains().length == 5);
+ List<String> domains = Arrays.asList(server.getDomains());
+ assertTrue("server has JMImplementation", domains.contains("JMImplementation"));
+ assertTrue("server has Domain1", domains.contains("Domain1"));
+ assertTrue("server has Domain2", domains.contains("Domain2"));
+ assertTrue("server has Domain3", domains.contains("Domain3"));
+
+ server.unregisterMBean(new ObjectName("Domain3:test=test1"));
+
+ assertTrue("Now four domains", server.getDomains().length == 4);
+ domains = Arrays.asList(server.getDomains());
+ assertTrue("server has JMImplementation", domains.contains("JMImplementation"));
+ assertTrue("server has Domain1", domains.contains("Domain1"));
+ assertTrue("server has Domain2", domains.contains("Domain2"));
+ assertTrue("server no longer has Domain3", domains.contains("Domain3") == false);
+
+ server.unregisterMBean(new ObjectName("Domain1:test=test1"));
+
+ assertTrue("Still four domains", server.getDomains().length == 4);
+ domains = Arrays.asList(server.getDomains());
+ assertTrue("server has JMImplementation", domains.contains("JMImplementation"));
+ assertTrue("server still has Domain1", domains.contains("Domain1"));
+ assertTrue("server has Domain2", domains.contains("Domain2"));
+ assertTrue("server no longer has Domain3", domains.contains("Domain3") == false);
+ }
+
+ public void testIsInstanceOf()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName baseName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=Base");
+ ObjectName derivedName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=Derived");
+ ObjectName unrelatedName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=Unrelated");
+
+ server.registerMBean(new Base(), baseName);
+ server.registerMBean(new Derived(), derivedName);
+ server.registerMBean(new Unrelated(), unrelatedName);
+
+ assertTrue("Base is an instance Object",
+ server.isInstanceOf(baseName, Object.class.getName()));
+ assertTrue("Base is an instance BaseMBean",
+ server.isInstanceOf(baseName, BaseMBean.class.getName()));
+ assertTrue("Base is an instance Base",
+ server.isInstanceOf(baseName, Base.class.getName()));
+ assertTrue("Derived is an instance Object",
+ server.isInstanceOf(derivedName, Object.class.getName()));
+ assertTrue("Derived is an instance BaseMBean",
+ server.isInstanceOf(derivedName, BaseMBean.class.getName()));
+ assertTrue("Derived is an instance Base",
+ server.isInstanceOf(derivedName, Base.class.getName()));
+ assertTrue("Derived is an instance Derived",
+ server.isInstanceOf(derivedName, Derived.class.getName()));
+ assertTrue("Unrelated is an instance Object",
+ server.isInstanceOf(unrelatedName, Object.class.getName()));
+ assertTrue("Unrelated is an instance UnrelatedMBean",
+ server.isInstanceOf(unrelatedName, UnrelatedMBean.class.getName()));
+ assertTrue("Unrelated is an instance Unrelated",
+ server.isInstanceOf(unrelatedName, Unrelated.class.getName()));
+
+ assertTrue("Base is an not instance Derived",
+ server.isInstanceOf(baseName, Derived.class.getName()) == false);
+ assertTrue("Base is an not instance UnrelatedMBean",
+ server.isInstanceOf(baseName, UnrelatedMBean.class.getName()) == false);
+ assertTrue("Base is an not instance Unrelated",
+ server.isInstanceOf(baseName, Unrelated.class.getName()) == false);
+ assertTrue("Derived is an not instance UnrelatedMBean",
+ server.isInstanceOf(derivedName, UnrelatedMBean.class.getName()) == false);
+ assertTrue("Dervied is an not instance Unrelated",
+ server.isInstanceOf(derivedName, Unrelated.class.getName()) == false);
+ assertTrue("Unrelated is an not instance BaseMBean",
+ server.isInstanceOf(unrelatedName, BaseMBean.class.getName()) == false);
+ assertTrue("Unrelated is an not instance Base",
+ server.isInstanceOf(unrelatedName, Base.class.getName()) == false);
+ assertTrue("Unrelated is an not instance Derived",
+ server.isInstanceOf(unrelatedName, Derived.class.getName()) == false);
+ }
+
+ public void testIsInstanceOfErrors()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName baseName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=Base");
+ ObjectName dynamicName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=Dynamic");
+ ObjectName doesNotExistName = new ObjectName("MBeanServerTEST:type=testIsInstanceOf,name=DoesNotExist");
+
+ server.registerMBean(new Base(), baseName);
+ server.registerMBean(new Dynamic(), dynamicName);
+
+ assertTrue("Base is not an instance of a class that does not exist",
+ server.isInstanceOf(baseName, "does.not.exist") == false);
+
+ boolean caught = false;
+ try
+ {
+ server.isInstanceOf(doesNotExistName, Object.class.getName());
+ }
+ catch (InstanceNotFoundException e)
+ {
+ caught = true;
+ }
+ assertTrue("Should get an instance not found for a non-existent mbean", caught);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/ServerSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/ServerSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/ServerSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class ServerSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("General MBeanServer Tests");
+
+ suite.addTest(MBeanServerFactoryTEST.suite());
+ suite.addTest(MBeanServerTEST.suite());
+ suite.addTest(MBeanDelegateTEST.suite());
+ suite.addTest(DefaultDomainTestCase.suite());
+ suite.addTest(MBeanServerBuilderTestCase.suite());
+ suite.addTest(MBeanServerInvocationHandlerTestCase.suite());
+
+ return suite;
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/AClass.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/AClass.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/AClass.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Goes into Test.jar
+ */
+public class AClass
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BabarError.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BabarError.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BabarError.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * <description>
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 86129 $
+ *
+ */
+public class BabarError
+ extends Error
+{
+ private static final long serialVersionUID = -1;
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Base.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Base.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Base.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class Base
+ implements BaseMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BaseMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BaseMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BaseMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public interface BaseMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Broadcaster.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Broadcaster.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Broadcaster.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+
+/**
+ * Simple Broadcaster
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class Broadcaster
+ extends NotificationBroadcasterSupport
+ implements BroadcasterMBean
+{
+ long sequence = 0;
+ public void doSomething()
+ {
+ sendNotification(new Notification("test", this, ++sequence));
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterInvocationHandlerTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterInvocationHandlerTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterInvocationHandlerTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcaster;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class BroadcasterInvocationHandlerTest
+ extends InvocationHandlerTest
+ implements NotificationBroadcaster
+{
+ NotificationBroadcasterSupport emitter = new NotificationBroadcasterSupport();
+
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object handback)
+ {
+ emitter.addNotificationListener(listener, filter, handback);
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ String[] types = { "test" };
+ return new MBeanNotificationInfo[]
+ {
+ new MBeanNotificationInfo(types, "name", "description")
+ };
+ }
+
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ emitter.removeNotificationListener(listener);
+ }
+
+ public void sendNotification()
+ {
+ Notification notification = new Notification("test", this, 1l);
+ emitter.sendNotification(notification);
+ }
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BroadcasterMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Simple Broadcaster Management Interface
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface BroadcasterMBean
+{
+ public void doSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Simple MBean for builder tests
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class BuilderTest
+ implements MBeanRegistration, BuilderTestMBean
+{
+ public MBeanServer server = null;
+
+ public BuilderTest()
+ {
+ }
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name)
+ {
+ this.server = server;
+ return name;
+ }
+
+ public void postRegister(Boolean registered)
+ {
+ }
+
+ public void preDeregister()
+ {
+ }
+
+ public void postDeregister()
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/BuilderTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Management Interface
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface BuilderTestMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Support class which throws a checked exception from its constructor.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest
+{
+ // Constructors --------------------------------------------------
+ public ConstructorTest() throws MyScreamingException
+ {
+ throw new MyScreamingException();
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest2.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest2.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest2.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Support class which throws an unchecked exception from its constructor.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest2
+{
+ // Constructors --------------------------------------------------
+ public ConstructorTest2()
+ {
+ throw new ExceptionOnTheRun();
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest3.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest3.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest3.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Support class which throws an error from its constructor.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest3
+{
+ // Constructors --------------------------------------------------
+ public ConstructorTest3()
+ {
+ throw new BabarError();
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest4.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest4.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest4.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Support class which fails with an unchecked exception in static initializer.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest4
+{
+
+ static
+ {
+ Object o = null;
+ o.toString(); // causes NPE!
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest5.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest5.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest5.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * Support class which fails with an error in static initializer.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest5
+{
+
+ static
+ {
+ try
+ {
+ new ObjectName(":");
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new BabarError();
+ }
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest6.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest6.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest6.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+
+/**
+ * Support class that doesn't have a default constructor.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest6
+{
+
+ public ConstructorTest6(String foo) {}
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest7.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest7.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ConstructorTest7.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Support class with protected noargs constructor.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ConstructorTest7
+{
+
+ protected ConstructorTest7() {}
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/DelegateListener.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/DelegateListener.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/DelegateListener.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.Notification;
+import javax.management.NotificationListener;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class DelegateListener
+ implements NotificationListener
+{
+ public Object userData;
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ this.userData = notification.getUserData();
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Derived.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Derived.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Derived.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class Derived
+ extends Base
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Dynamic.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Dynamic.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Dynamic.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.DynamicMBean;
+import javax.management.MBeanInfo;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class Dynamic
+ implements DynamicMBean
+{
+ public MBeanInfo getMBeanInfo()
+ {
+ return new MBeanInfo("does.not.exist", "description", null, null, null, null);
+ }
+
+ public Object invoke(String action, Object[] params, String[] signature)
+ {
+ return null;
+ }
+
+ public Object getAttribute(String attribute)
+ {
+ return null;
+ }
+
+ public AttributeList getAttributes(String[] attributes)
+ {
+ return null;
+ }
+
+ public void setAttribute(Attribute attribute)
+ {
+ }
+
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/EmitterInvocationHandlerTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/EmitterInvocationHandlerTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/EmitterInvocationHandlerTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class EmitterInvocationHandlerTest
+ extends InvocationHandlerTest
+ implements NotificationEmitter
+{
+ NotificationBroadcasterSupport emitter = new NotificationBroadcasterSupport();
+
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object handback)
+ {
+ emitter.addNotificationListener(listener, filter, handback);
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ String[] types = { "test" };
+ return new MBeanNotificationInfo[]
+ {
+ new MBeanNotificationInfo(types, "name", "description")
+ };
+ }
+
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ emitter.removeNotificationListener(listener);
+ }
+
+ public void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object handback)
+ throws ListenerNotFoundException
+ {
+ emitter.removeNotificationListener(listener, filter, handback);
+ }
+
+ public void sendNotification()
+ {
+ Notification notification = new Notification("test", this, 1l);
+ emitter.sendNotification(notification);
+ }
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ExceptionOnTheRun.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ExceptionOnTheRun.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ExceptionOnTheRun.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * An arbitrary runtime exception for server tests.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class ExceptionOnTheRun
+ extends RuntimeException
+{
+ private static final long serialVersionUID = -1;
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class InvocationHandlerTest
+ implements InvocationHandlerTestMBean
+{
+ String attribute = "Attribute";
+
+ public boolean invokeNoArgsNoReturnInvoked = false;
+ public boolean invokeNoReturnInvoked = false;
+
+ public boolean primitive;
+ public Boolean type;
+
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+ public void setAttribute(String attribute)
+ {
+ this.attribute = attribute;
+ }
+
+ public boolean isIsPrimitive()
+ {
+ return primitive;
+ }
+
+ public void setIsPrimitive(boolean bool)
+ {
+ this.primitive = bool;
+ }
+
+ public Boolean getType()
+ {
+ return type;
+ }
+
+ public void setType(Boolean bool)
+ {
+ this.type = bool;
+ }
+
+ public void invokeNoArgsNoReturn()
+ {
+ invokeNoArgsNoReturnInvoked = true;
+ }
+
+ public String invokeNoArgs()
+ {
+ return("invokeNoArgs");
+ }
+
+ public void invokeNoReturn(String parameter)
+ {
+ invokeNoReturnInvoked = true;
+ }
+
+ public String invoke(String parameter)
+ {
+ return parameter;
+ }
+
+ public Object invokeMixedParameters(String parameter1, int parameter2, Object parameter3)
+ {
+ return parameter3;
+ }
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/InvocationHandlerTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public interface InvocationHandlerTestMBean
+{
+ String getAttribute();
+
+ void setAttribute(String attribute);
+
+ boolean isIsPrimitive();
+
+ void setIsPrimitive(boolean bool);
+
+ Boolean getType();
+
+ void setType(Boolean bool);
+
+ void invokeNoArgsNoReturn();
+
+ String invokeNoArgs();
+
+ void invokeNoReturn(String parameter);
+
+ String invoke(String parameter);
+
+ Object invokeMixedParameters(String parameter1, int parameter2, Object parameter3);
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Listener.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Listener.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Listener.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class Listener
+ implements ListenerMBean, NotificationListener
+{
+ public int notificationCount = 0;
+
+ public boolean error = false;
+
+ public void doSomething()
+ {
+ }
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ if (!(handback instanceof String))
+ error = true;
+ if (!(handback.equals("MyHandback")))
+ error = true;
+ if (!(notification.getSource() instanceof ObjectName))
+ error = true;
+ if (!(notification.getSource().toString().equals("JMImplementation:type=MBeanServerDelegate")))
+ error = true;
+
+ notificationCount++;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ListenerMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ListenerMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ListenerMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Simple Listener Management Interface
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface ListenerMBean
+{
+ public void doSomething();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * MBean that disallows unregistration by throwing an exception from its
+ * <tt>preDeregister()</tt> method.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class LockedTest
+ implements LockedTestMBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ return name;
+ }
+
+ public void postRegister(Boolean b)
+ {
+
+ }
+
+ public void preDeregister() throws Exception
+ {
+ throw new RuntimeException("You cannot unregister me!");
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * MBean that disallows unregistration by throwing a checked exception from its
+ * <tt>preDeregister()</tt> method.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class LockedTest2
+ implements LockedTest2MBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ return name;
+ }
+
+ public void postRegister(Boolean b)
+ {
+
+ }
+
+ public void preDeregister() throws Exception
+ {
+ throw new MyScreamingException();
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest2MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface LockedTest2MBean
+{
+
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * MBean that disallows unregistration by throwing a checked exception from its
+ * <tt>preDeregister()</tt> method.
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class LockedTest3
+ implements LockedTest3MBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ return name;
+ }
+
+ public void postRegister(Boolean b)
+ {
+
+ }
+
+ public void preDeregister() throws Exception
+ {
+ throw new MBeanRegistrationException(new MyScreamingException(), "you can't unregister me!");
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTest3MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface LockedTest3MBean
+{
+
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/LockedTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface LockedTestMBean
+{
+
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListener.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListener.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListener.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.Notification;
+import javax.management.NotificationListener;
+
+/**
+ * Simple Listener
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class MBeanListener
+ implements NotificationListener, MBeanListenerMBean
+{
+ public long count = 0;
+ public Object source = null;
+ public Object handback = null;
+ public long count1 = 0;
+ public Object source1 = new Object();
+ public Object handback1 = new Object();
+ public long count2 = 0;
+ public Object source2 = new Object();
+ public Object handback2 = new Object();
+
+ Object hb1 = null;
+ Object hb2 = null;
+
+ public MBeanListener()
+ {
+ }
+
+ public MBeanListener(String hb1, String hb2)
+ {
+ this.hb1 = hb1;
+ this.hb2 = hb2;
+ }
+
+ public void handleNotification(Notification n, Object nhb)
+ {
+ if (nhb != null && nhb.equals(hb1))
+ {
+ count1++;
+ source1 = n.getSource();
+ handback1 = nhb;
+ }
+ else if (nhb != null && nhb.equals(hb2))
+ {
+ count2++;
+ source2 = n.getSource();
+ handback2 = nhb;
+ }
+ else
+ {
+ count++;
+ source = n.getSource();
+ handback = nhb;
+ }
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListenerMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListenerMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanListenerMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * Simple Listener Management Interface
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface MBeanListenerMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerReplaced.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerReplaced.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerReplaced.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class MBeanServerReplaced
+ extends Error
+{
+ private static final long serialVersionUID = -1;
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerWrapper.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerWrapper.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MBeanServerWrapper.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import javax.management.MBeanServer;
+
+/**
+ * A wrapper for an MBeanServer
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class MBeanServerWrapper
+ implements InvocationHandler
+{
+ public MBeanServer server;
+
+ public boolean invoked = false;
+
+ private static Method EQUALS;
+
+ static
+ {
+ try
+ {
+ EQUALS = Object.class.getClass().getMethod("equals", new Class[] { Object.class });
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ public static MBeanServer getWrapper()
+ {
+ return (MBeanServer) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] { MBeanServer.class },
+ new MBeanServerWrapper());
+ }
+
+ public static MBeanServerWrapper getHandler(MBeanServer proxy)
+ {
+ return (MBeanServerWrapper) Proxy.getInvocationHandler(proxy);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ invoked = true;
+ if (method.equals(EQUALS))
+ return new Boolean(proxy == args[0]);
+ if (method.getName().equals("queryMBeans"))
+ throw new MBeanServerReplaced();
+ return method.invoke(server, args);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MyScreamingException.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MyScreamingException.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/MyScreamingException.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * <description>
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 86129 $
+ *
+ */
+public class MyScreamingException
+ extends Exception
+{
+ private static final long serialVersionUID = -1;
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTest.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTest.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTest.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class ObjectInvocationHandlerTest
+ extends InvocationHandlerTest
+ implements ObjectInvocationHandlerTestMBean
+{
+ public String toString()
+ {
+ return "TOSTRING";
+ }
+
+ public boolean equals(Object other)
+ {
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return 1234;
+ }
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/ObjectInvocationHandlerTestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public interface ObjectInvocationHandlerTestMBean
+ extends InvocationHandlerTestMBean
+{
+ String toString();
+
+ boolean equals(Object other);
+
+ int hashCode();
+}
\ No newline at end of file
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * <description>
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 86129 $
+ *
+ */
+public class Test
+ implements TestMBean
+{
+
+ public String getThisWillScream() throws MyScreamingException
+ {
+ throw new MyScreamingException();
+ }
+
+ public void setThisWillScream(String str) throws MyScreamingException
+ {
+ throw new MyScreamingException();
+ }
+
+ public String getThrowUncheckedException()
+ {
+ throw new ExceptionOnTheRun();
+ }
+
+ public void setThrowUncheckedException(String str)
+ {
+ throw new ExceptionOnTheRun();
+ }
+
+ public String getError()
+ {
+ throw new BabarError();
+ }
+
+ public void setError(String str)
+ {
+ throw new BabarError();
+ }
+
+ public void setAStringAttribute(String str)
+ {
+
+ }
+
+ public void operationWithException() throws MyScreamingException
+ {
+ throw new MyScreamingException();
+ }
+
+ /**
+ * returns true
+ */
+ public boolean opWithPrimBooleanReturn()
+ {
+ return true;
+ }
+
+ /**
+ * Returns value 1234567890123
+ */
+ public long opWithPrimLongReturn()
+ {
+ return 1234567890123l;
+ }
+
+ /**
+ * Returns array [1,2,3]
+ */
+ public long[] opWithPrimLongArrayReturn()
+ {
+ return new long[] { 1L, 2L, 3L};
+ }
+
+ /**
+ * Returns array [1, 2, 3]
+ */
+ public Long[] opWithLongArrayReturn()
+ {
+ return new Long[] { new Long(1L), new Long(2L), new Long(3L) };
+ }
+
+ /**
+ * Returns 0.1234567890123
+ */
+ public double opWithPrimDoubleReturn()
+ {
+ return 0.1234567890123d;
+ }
+
+ public void opWithLongSignature(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
+ int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20)
+ {
+
+ }
+
+ public void opWithMixedSignature(int i1, double i2, long i3, boolean i4, byte i5,
+ short i6, long[] i7, Long[] i8, Short i9, Byte i10,
+ Long i11, Double i12, int i13, int i14, int i15,
+ int i16, int i17, int i18, int i19, int i20)
+ {
+
+ }
+
+ private int counter = 0;
+
+ public void counterWithException()
+ {
+ counter++;
+ throw new IllegalArgumentException();
+ }
+
+ public int getCounter()
+ {
+ return counter;
+ }
+
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class Test2 implements Test2MBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ throw new RuntimeException();
+ }
+
+ public void postRegister(Boolean b)
+ {
+ }
+
+ public void preDeregister() throws Exception
+ {
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test2MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface Test2MBean
+{
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class Test3 implements Test3MBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ throw new MyScreamingException();
+ }
+
+ public void postRegister(Boolean b)
+ {
+ }
+
+ public void preDeregister() throws Exception
+ {
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test3MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface Test3MBean
+{
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public class Test4 implements Test4MBean, MBeanRegistration
+{
+
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
+ {
+ throw new MBeanRegistrationException(new MyScreamingException());
+ }
+
+ public void postRegister(Boolean b)
+ {
+ }
+
+ public void preDeregister() throws Exception
+ {
+ }
+
+ public void postDeregister()
+ {
+
+ }
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Test4MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 81019 $
+ *
+ */
+public interface Test4MBean
+{
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * <description>
+ *
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>.
+ * @version $Revision: 86129 $
+ *
+ */
+public interface TestMBean
+{
+ public String getThisWillScream() throws MyScreamingException;
+ public void setThisWillScream(String str) throws MyScreamingException;
+
+ public String getThrowUncheckedException();
+ public void setThrowUncheckedException(String str);
+
+ public String getError();
+ public void setError(String str);
+
+ public void setAStringAttribute(String str);
+
+ public void operationWithException() throws MyScreamingException;
+
+ public boolean opWithPrimBooleanReturn();
+
+ public long opWithPrimLongReturn();
+
+ public long[] opWithPrimLongArrayReturn();
+
+ public Long[] opWithLongArrayReturn();
+
+ public double opWithPrimDoubleReturn();
+
+ public void opWithLongSignature(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10,
+ int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20);
+
+ public void opWithMixedSignature(int i1, double i2, long i3, boolean i4, byte i5,
+ short i6, long[] i7, Long[] i8, Short i9, Byte i10,
+ Long i11, Double i12, int i13, int i14, int i15,
+ int i16, int i17, int i18, int i19, int i20);
+
+ public void counterWithException();
+
+ public int getCounter();
+}
+
+
+
+
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerBuilder.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerBuilder.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerBuilder.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerBuilder;
+import javax.management.MBeanServerDelegate;
+
+/**
+ * An alternate builder
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class TestMBeanServerBuilder
+ extends MBeanServerBuilder
+{
+ public TestMBeanServerBuilder()
+ {
+ }
+
+ public MBeanServer newMBeanServer(String domain, MBeanServer outer, MBeanServerDelegate delegate)
+ {
+ MBeanServer original = super.newMBeanServer(domain, outer, delegate);
+ MBeanServer wrapper = MBeanServerWrapper.getWrapper();
+ MBeanServerWrapper.getHandler(wrapper).server = original;
+ return wrapper;
+ }
+
+ public MBeanServerDelegate newMBeanServerDelegate()
+ {
+ return new TestMBeanServerDelegate();
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerDelegate.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerDelegate.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/TestMBeanServerDelegate.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+import javax.management.MBeanServerDelegate;
+import javax.management.Notification;
+
+/**
+ * An alternate MBeanServerDelegate
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class TestMBeanServerDelegate
+ extends MBeanServerDelegate
+{
+ public boolean invoked = false;
+
+ public String getMBeanServerId()
+ {
+ invoked = true;
+ return super.getMBeanServerId();
+ }
+
+ public void sendNotification(Notification notification)
+ {
+ notification.setUserData("replaced");
+ super.sendNotification(notification);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Unrelated.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Unrelated.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/Unrelated.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public class Unrelated
+ implements UnrelatedMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/UnrelatedMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/UnrelatedMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/server/support/UnrelatedMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.server.support;
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ * @version $Revision: 81019 $
+ */
+public interface UnrelatedMBean
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/AttributeInfoTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/AttributeInfoTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/AttributeInfoTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class AttributeInfoTEST extends TestCase
+{
+ private String failureHint;
+ private MBeanInfo info;
+ private String attributeName;
+ private String type;
+ private boolean read;
+ private boolean write;
+ private boolean is;
+
+ public AttributeInfoTEST(String failureHint, MBeanInfo info, String attributeName, String type, boolean read, boolean write, boolean is)
+ {
+ super("testValidAttribute");
+ this.failureHint = failureHint;
+ this.info = info;
+ this.attributeName = attributeName;
+ this.type = type;
+ this.read= read;
+ this.write= write;
+ this.is= is;
+ }
+
+ public void testValidAttribute()
+ {
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ MBeanAttributeInfo attribute = InfoUtil.findAttribute(attributes, attributeName);
+
+ assertNotNull(failureHint + ": " + info.getClassName() + ": " + attributeName + " was not found", attribute);
+ assertEquals(failureHint + ": " + info.getClassName() + ": " + attributeName + " type", type, attribute.getType());
+ assertEquals(failureHint + ": " + info.getClassName() + ": " + attributeName + " readable", read, attribute.isReadable());
+ assertEquals(failureHint + ": " + info.getClassName() + ": " + attributeName + " writable", write, attribute.isWritable());
+ assertEquals(failureHint + ": " + info.getClassName() + ": " + attributeName + " isIS", is, attribute.isIs());
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/ConstructorInfoTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/ConstructorInfoTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/ConstructorInfoTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class ConstructorInfoTEST extends TestCase
+{
+ private String failureHint;
+ private MBeanInfo info;
+ private String constructorName;
+ private String signatureString;
+
+ public ConstructorInfoTEST(String failureHint, MBeanInfo info, String constructorName, String[] signature)
+ {
+ super("testValidConstructor");
+ this.failureHint = failureHint;
+ this.info = info;
+ this.constructorName = constructorName;
+ this.signatureString = InfoUtil.makeSignatureString(signature);
+ }
+
+ public void testValidConstructor()
+ {
+ MBeanConstructorInfo[] constructors = info.getConstructors();
+
+ MBeanConstructorInfo foundConstructor= null;
+
+ for (int i = 0; i < constructors.length; i++)
+ {
+ if (signatureString.equals(InfoUtil.makeSignatureString(constructors[i].getSignature())))
+ {
+ foundConstructor = constructors[i];
+ break;
+ }
+ }
+
+ assertNotNull(failureHint + ": " + info.getClassName() + "." + constructorName + signatureString + " was not found", foundConstructor);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoTortureSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoTortureSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoTortureSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.test.jmx.compliance.standard.support.Torture;
+
+/**
+ * Beat the heck out of the server's standard MBeanInfo
+ *
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+public class InfoTortureSUITE extends TestSuite
+{
+ private static int attributeTestCount = 0;
+ private static int operationTestCount = 0;
+ private static int constructorTestCount = 0;
+
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite("All MBeanInfo Torture Tests for Standard MBeans");
+
+ Object mbean = new Torture();
+ MBeanInfo info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo");
+
+ // Tests for valid constructors
+ addConstructorTest(testSuite, info, Torture.class.getName(), new String[0]);
+ addConstructorTest(testSuite, info, Torture.class.getName(), new String[] { String[][].class.getName() });
+
+ // make sure we are testing all exposed constructors (each ValidConstructorTest increments a counter
+ // which is used to figure out whether we have adequate test coverage)
+ testSuite.addTest(new TestCoverage("Torture constructor list length", constructorTestCount, info.getConstructors().length));
+
+ // Tests for attributes that should not be there
+ addSpuriousAttributeTest(testSuite, info, "peachy");
+ addSpuriousAttributeTest(testSuite, info, "Peachy");
+ addSpuriousAttributeTest(testSuite, info, "suer");
+ addSpuriousAttributeTest(testSuite, info, "settlement");
+ addSpuriousAttributeTest(testSuite, info, "Result");
+ addSpuriousAttributeTest(testSuite, info, "Multi");
+
+ // make sure remaining attributes are correct
+ // Args are: Name, Type, Readable, Writable, IsIS
+ addAttributeTest(testSuite, info, "NiceString", String.class.getName(), true, true, false);
+ addAttributeTest(testSuite, info, "NiceBoolean", boolean.class.getName(), true, true, true);
+ addAttributeTest(testSuite, info, "Something", String.class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "Int", int.class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "IntArray", int[].class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "NestedIntArray", int[][][].class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "Integer", Integer.class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "IntegerArray", Integer[].class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "NestedIntegerArray", Integer[][][].class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "Myinteger", int.class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "MyintegerArray", int[].class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "MyNestedintegerArray", int[][][].class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "MyInteger", Integer.class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "MyIntegerArray", Integer[].class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "MyNestedIntegerArray", Integer[][][].class.getName(), true, false, false);
+ addAttributeTest(testSuite, info, "ready", boolean.class.getName(), true, false, true);
+ addAttributeTest(testSuite, info, "Ready", Boolean.class.getName(), true, false, false);
+
+ // make sure we are testing all exposed attributes (each ValidAttributeTest increments a counter
+ // which is used to figure out whether we have adequate test coverage)
+ testSuite.addTest(new TestCoverage("Torture attribute list length", attributeTestCount, info.getAttributes().length));
+
+ // validate the operations
+ // Args are: Name, impact, returnTypeString, SignatureAsStringArray
+ addOperationTest(testSuite, info, "settlement", MBeanOperationInfo.UNKNOWN, int.class.getName(), new String[] { String.class.getName() });
+ addOperationTest(testSuite, info, "getSomething", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String[0]);
+ addOperationTest(testSuite, info, "ispeachy", MBeanOperationInfo.UNKNOWN, boolean.class.getName(), new String[] { int.class.getName() });
+ addOperationTest(testSuite, info, "isPeachy", MBeanOperationInfo.UNKNOWN, Boolean.class.getName(), new String[] { int.class.getName() });
+ addOperationTest(testSuite, info, "setMulti", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String[] { String.class.getName(), Integer.class.getName() });
+ addOperationTest(testSuite, info, "getResult", MBeanOperationInfo.UNKNOWN, String.class.getName(), new String[] { String.class.getName() });
+ addOperationTest(testSuite, info, "setNothing", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String[0]);
+ addOperationTest(testSuite, info, "getNothing", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String[0]);
+ addOperationTest(testSuite, info, "doSomethingCrazy", MBeanOperationInfo.UNKNOWN, String[][].class.getName(), new String[] { Object[].class.getName(), String[].class.getName(), int[][][].class.getName() });
+ // Hmmm... This fails in the RI (which causes the operation coverage test to fail too.
+ // it's odd because in the RI issuer() isn't treated as an attribute and it doesn't
+ // appear as an operation - it just disappears!
+ addOperationTest(testSuite, info, "issuer", MBeanOperationInfo.UNKNOWN, String.class.getName(), new String[0]);
+
+ // make sure we are testing all exposed operations (each ValidOperationTest increments a counter
+ // which is used to figure out whether we have adequate test coverage)
+ testSuite.addTest(new TestCoverage("Torture operation list length", operationTestCount, info.getOperations().length));
+
+ return testSuite;
+ }
+
+ public static void addConstructorTest(TestSuite testSuite, MBeanInfo info, String name, String[] signature)
+ {
+ testSuite.addTest(new ConstructorInfoTEST("InfoTortureSUITE constructor", info, name, signature));
+ constructorTestCount++;
+ }
+
+ public static void addSpuriousAttributeTest(TestSuite testSuite, MBeanInfo info, String name)
+ {
+ testSuite.addTest(new SpuriousAttributeTEST("InfoTortureSUITE spuriousAttribute", info, name));
+ }
+
+ public static void addAttributeTest(TestSuite testSuite, MBeanInfo info, String name, String type, boolean read, boolean write, boolean is)
+ {
+ testSuite.addTest(new AttributeInfoTEST("InfoTortureSUITE attribute", info, name, type, read, write, is));
+ attributeTestCount++;
+ }
+
+ public static void addOperationTest(TestSuite testSuite, MBeanInfo info, String name, int impact, String returnType, String[] signature)
+ {
+ testSuite.addTest(new OperationInfoTEST("InfoTortureSUITE operation", info, name, impact, returnType, signature));
+ operationTestCount++;
+ }
+
+ public static class TestCoverage extends TestCase
+ {
+ private String msg;
+ private int expected;
+ private int got;
+
+ public TestCoverage(String msg, int expected, int got)
+ {
+ super("testAdequateCoverage");
+ this.msg = msg;
+ this.expected = expected;
+ this.got = got;
+ }
+
+ public void testAdequateCoverage()
+ {
+ assertEquals(msg, expected, got);
+ }
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoUtil.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoUtil.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InfoUtil.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.jmx.mbeanserver.JBossMBeanServerBuilder;
+
+import junit.framework.Assert;
+
+public class InfoUtil
+{
+ public static MBeanInfo getMBeanInfo(Object mbean, String name)
+ {
+ MBeanInfo info = null;
+
+ try
+ {
+ System.setProperty(JBossMBeanServerBuilder.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, JBossMBeanServerBuilder.class.getName());
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+
+ ObjectName objectName = new ObjectName(name);
+ server.registerMBean(mbean, objectName);
+ info = server.getMBeanInfo(objectName);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ Assert.fail("got spurious MalformedObjectNameException");
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ Assert.fail("got spurious InstanceAlreadyExistsException");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ Assert.fail("got spurious MBeanRegistrationException");
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ Assert.fail("got spurious NotCompliantMBeanException");
+ }
+ catch (InstanceNotFoundException e)
+ {
+ Assert.fail("got spurious InstanceNotFoundException");
+ }
+ catch (IntrospectionException e)
+ {
+ Assert.fail("got spurious IntrospectionException");
+ }
+ catch (ReflectionException e)
+ {
+ Assert.fail("got spurious ReflectionException");
+ }
+
+ return info;
+ }
+
+ public static MBeanAttributeInfo findAttribute(MBeanAttributeInfo[] attributes, String name)
+ {
+ for (int i = 0; i < attributes.length; i++)
+ {
+ if (attributes[i].getName().equals(name))
+ {
+ return attributes[i];
+ }
+ }
+ return null;
+ }
+
+ public static void dumpConstructors(MBeanConstructorInfo[] constructors)
+ {
+ System.out.println("");
+ System.out.println("Constructors:");
+ for (int i = 0; i < constructors.length; i++)
+ {
+ StringBuffer dump = new StringBuffer();
+ MBeanConstructorInfo constructor = constructors[i];
+ dump.append("name=").append(constructor.getName());
+ dump.append(",signature=").append(makeSignatureString(constructor.getSignature()));
+
+ System.out.println(dump);
+ }
+ }
+
+ public static void dumpAttributes(MBeanAttributeInfo[] attributes)
+ {
+ System.out.println("");
+ System.out.println("Attributes:");
+ for (int i = 0; i < attributes.length; i++)
+ {
+ StringBuffer dump = new StringBuffer();
+ MBeanAttributeInfo attribute = attributes[i];
+ dump.append("name=").append(attribute.getName());
+ dump.append(",type=").append(attribute.getType());
+ dump.append(",readable=").append(attribute.isReadable());
+ dump.append(",writable=").append(attribute.isWritable());
+ dump.append(",isIS=").append(attribute.isIs());
+ System.out.println(dump);
+ }
+ }
+
+ public static void dumpOperations(MBeanOperationInfo[] operations)
+ {
+ System.out.println("");
+ System.out.println("Operations:");
+ for (int i = 0; i < operations.length; i++)
+ {
+ StringBuffer dump = new StringBuffer();
+ MBeanOperationInfo operation = operations[i];
+ dump.append("name=").append(operation.getName());
+ dump.append(",impact=").append(decodeImpact(operation.getImpact()));
+ dump.append(",returnType=").append(operation.getReturnType());
+ dump.append(",signature=").append(makeSignatureString(operation.getSignature()));
+
+ System.out.println(dump);
+ }
+ }
+
+ public static String makeSignatureString(MBeanParameterInfo[] info)
+ {
+ String[] sig = new String[info.length];
+ for (int i = 0; i < info.length; i++)
+ {
+ sig[i] = info[i].getType();
+ }
+ return makeSignatureString(sig);
+ }
+
+ public static String makeSignatureString(String[] sig)
+ {
+ StringBuffer buf = new StringBuffer("(");
+ for (int i = 0; i < sig.length; i++)
+ {
+ buf.append(sig[i]);
+ if (i != sig.length - 1)
+ {
+ buf.append(",");
+ }
+ }
+ buf.append(")");
+ return buf.toString();
+ }
+
+ public static String decodeImpact(int impact)
+ {
+ switch (impact)
+ {
+ case MBeanOperationInfo.ACTION:
+ return "ACTION";
+ case MBeanOperationInfo.ACTION_INFO:
+ return "ACTION_INFO";
+ case MBeanOperationInfo.INFO:
+ return "INFO";
+ case MBeanOperationInfo.UNKNOWN:
+ return "UNKNOWN";
+ }
+ throw new IllegalArgumentException("unknown impact value:" + impact);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InheritanceSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InheritanceSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/InheritanceSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanInfo;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.test.jmx.compliance.standard.support.DynamicDerived1;
+import org.jboss.test.jmx.compliance.standard.support.StandardDerived1;
+import org.jboss.test.jmx.compliance.standard.support.StandardDerived2;
+import org.jboss.test.jmx.compliance.standard.support.StandardDerived3;
+
+/**
+ * Beat the heck out of the server's standard MBeanInfo inheritance handling
+ *
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+public class InheritanceSUITE extends TestSuite
+{
+ private static int attributeTestCount = 0;
+ private static int operationTestCount = 0;
+ private static int constructorTestCount = 0;
+
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite testSuite = new TestSuite("All MBeanInfo Torture Tests for Standard MBeans");
+
+ Object mbean = new StandardDerived1();
+ MBeanInfo info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo");
+
+ addConstructorTest(testSuite, info, StandardDerived1.class.getName(), new String[0]);
+ testSuite.addTest(new TestCoverage("StandardDerived1 constructor list length", constructorTestCount, info.getConstructors().length));
+ addAttributeTest(testSuite, info, "ParentValue", String.class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "Available", boolean.class.getName(), false, true, false);
+ testSuite.addTest(new TestCoverage("StandardDerived1 attribute list length", attributeTestCount, info.getAttributes().length));
+ testSuite.addTest(new TestCoverage("StandardDerived1 operation list length", operationTestCount, info.getOperations().length));
+
+ resetCounters();
+
+ mbean = new StandardDerived2();
+ info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo");
+
+ addConstructorTest(testSuite, info, StandardDerived2.class.getName(), new String[0]);
+ testSuite.addTest(new TestCoverage("StandardDerived2 constructor list length", constructorTestCount, info.getConstructors().length));
+ addAttributeTest(testSuite, info, "DerivedValue", String.class.getName(), false, true, false);
+ addAttributeTest(testSuite, info, "ParentValue", String.class.getName(), true, false, false);
+ addSpuriousAttributeTest(testSuite, info, "Available");
+ testSuite.addTest(new TestCoverage("StandardDerived2 attribute list length", attributeTestCount, info.getAttributes().length));
+ testSuite.addTest(new TestCoverage("StandardDerived2 operation list length", operationTestCount, info.getOperations().length));
+
+ resetCounters();
+
+ mbean = new StandardDerived3();
+ info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo");
+
+ addConstructorTest(testSuite, info, StandardDerived3.class.getName(), new String[0]);
+ testSuite.addTest(new TestCoverage("StandardDerived3 constructor list length", constructorTestCount, info.getConstructors().length));
+ addAttributeTest(testSuite, info, "ArbitraryValue", String.class.getName(), false, true, false);
+ testSuite.addTest(new TestCoverage("StandardDerived3 attribute list length", attributeTestCount, info.getAttributes().length));
+ testSuite.addTest(new TestCoverage("StandardDerived3 operation list length", operationTestCount, info.getOperations().length));
+
+ resetCounters();
+
+ mbean = new DynamicDerived1();
+ info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo");
+
+ testSuite.addTest(new TestCoverage("DynamicDerived1 constructor list length", constructorTestCount, info.getConstructors().length));
+ testSuite.addTest(new TestCoverage("DynamicDerived1 attribute list length", attributeTestCount, info.getAttributes().length));
+ testSuite.addTest(new TestCoverage("DynamicDerived1 operation list length", operationTestCount, info.getOperations().length));
+
+ return testSuite;
+ }
+
+ public static void resetCounters()
+ {
+ constructorTestCount = 0;
+ attributeTestCount = 0;
+ operationTestCount = 0;
+ }
+
+ public static void addConstructorTest(TestSuite testSuite, MBeanInfo info, String name, String[] signature)
+ {
+ testSuite.addTest(new ConstructorInfoTEST("InheritanceSUITE constructor", info, name, signature));
+ constructorTestCount++;
+ }
+
+ public static void addSpuriousAttributeTest(TestSuite testSuite, MBeanInfo info, String name)
+ {
+ testSuite.addTest(new SpuriousAttributeTEST("InheritanceSUITE spuriousAttribute", info, name));
+ }
+
+ public static void addAttributeTest(TestSuite testSuite, MBeanInfo info, String name, String type, boolean read, boolean write, boolean is)
+ {
+ testSuite.addTest(new AttributeInfoTEST("InheritanceSUITE attribute", info, name, type, read, write, is));
+ attributeTestCount++;
+ }
+
+ public static void addOperationTest(TestSuite testSuite, MBeanInfo info, String name, int impact, String returnType, String[] signature)
+ {
+ testSuite.addTest(new OperationInfoTEST("InheritanceSUITE operation", info, name, impact, returnType, signature));
+ operationTestCount++;
+ }
+
+ public static class TestCoverage extends TestCase
+ {
+ private String msg;
+ private int expected;
+ private int got;
+
+ public TestCoverage(String msg, int expected, int got)
+ {
+ super("testAdequateCoverage");
+ this.msg = msg;
+ this.expected = expected;
+ this.got = got;
+ }
+
+ public void testAdequateCoverage()
+ {
+ assertEquals(msg, expected, got);
+ }
+ }
+
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/OperationInfoTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/OperationInfoTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/OperationInfoTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class OperationInfoTEST extends TestCase
+{
+ private String failureHint;
+ private MBeanInfo info;
+ private String operationName;
+ private int impact;
+ private String returnType;
+ private String signatureString;
+
+ public OperationInfoTEST(String failureHint, MBeanInfo info, String operationName, int impact, String returnType, String[] signature)
+ {
+ super("testValidOperation");
+ this.failureHint = failureHint;
+ this.info = info;
+ this.operationName = operationName;
+ this.impact = impact;
+ this.returnType = returnType;
+ this.signatureString = InfoUtil.makeSignatureString(signature);
+ }
+
+ public void testValidOperation()
+ {
+ MBeanOperationInfo[] operations = info.getOperations();
+
+ MBeanOperationInfo foundOperation = null;
+
+ for (int i = 0; i < operations.length; i++)
+ {
+ if (operations[i].getName().equals(operationName))
+ {
+ if (signatureString.equals(InfoUtil.makeSignatureString(operations[i].getSignature())))
+ {
+ foundOperation = operations[i];
+ break;
+ }
+ }
+ }
+
+ assertNotNull(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " was not found", foundOperation);
+ assertEquals(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " impact", impact, foundOperation.getImpact());
+ assertEquals(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " returnType", returnType, foundOperation.getReturnType());
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/SpuriousAttributeTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/SpuriousAttributeTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/SpuriousAttributeTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class SpuriousAttributeTEST extends TestCase
+{
+ private String failureHint;
+ private MBeanInfo info;
+ private String attributeName;
+
+ public SpuriousAttributeTEST(String failureHint, MBeanInfo info, String attributeName)
+ {
+ super("testForSpuriousAttribute");
+ this.failureHint = failureHint;
+ this.info = info;
+ this.attributeName = attributeName;
+ }
+
+ public void testForSpuriousAttribute()
+ {
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ assertNull(failureHint + ": attribute " + info.getClassName() + ": " + attributeName + " should not be present",
+ InfoUtil.findAttribute(attributes, attributeName));
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardMBeanTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardMBeanTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardMBeanTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,242 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.standard.support.MBeanRunnable;
+import org.jboss.test.jmx.compliance.standard.support.MyRunnable;
+import org.jboss.test.jmx.compliance.standard.support.MyStandardMBean;
+import org.jboss.test.jmx.compliance.standard.support.NoConstructorsStandardMBean;
+import org.jboss.test.jmx.compliance.standard.support.Trivial;
+import org.jboss.test.jmx.compliance.standard.support.TrivialMBean;
+
+
+
+/**
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>.
+ */
+
+public class StandardMBeanTEST
+ extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(StandardMBeanTEST.class);
+ }
+
+ public StandardMBeanTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testOverrideManagementInterface()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new MBeanRunnable(), name);
+ server.invoke(name, "run", new Object[0], new String[0]);
+ }
+
+ public void testSpecifyManagementInterface()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new StandardMBean(new MyRunnable(), Runnable.class), name);
+ server.invoke(name, "run", new Object[0], new String[0]);
+ }
+
+ public void testDontSpecifyManagementInterface()
+ throws Exception
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new StandardMBean(new Trivial(), null), name);
+ server.invoke(name, "doOperation", new Object[] { "arg" }, new String[] { String.class.getName() });
+ }
+
+ public void testGetImplementationImplied()
+ throws Exception
+ {
+ StandardMBean std = new MBeanRunnable();
+ assertTrue("MBeanRunnable is its own implementation", std == std.getImplementation());
+ assertTrue("MBeanRunnable is its own implementation class", std.getClass() == std.getImplementationClass());
+ }
+
+ public void testGetImplementationSpecified()
+ throws Exception
+ {
+ Runnable obj = new MyRunnable();
+ StandardMBean std = new StandardMBean(obj, Runnable.class);
+ assertTrue("MyRunnable is the implementation", obj == std.getImplementation());
+ assertTrue("MyRunnable is the implementation class", obj.getClass() == std.getImplementationClass());
+ }
+
+ public void testMBeanInterfaceImplied()
+ throws Exception
+ {
+ StandardMBean std = new MBeanRunnable();
+ assertTrue("MBeanRunnable has Runnable as a management interface", Runnable.class == std.getMBeanInterface());
+ }
+
+ public void testMBeanInterfaceSpecified()
+ throws Exception
+ {
+ Runnable obj = new MyRunnable();
+ StandardMBean std = new StandardMBean(obj, Runnable.class);
+ assertTrue("MyRunnable has Runnable as a management interface", Runnable.class == std.getMBeanInterface());
+ }
+
+ public void testMBeanInterfaceOldStyle()
+ throws Exception
+ {
+ Object obj = new Trivial();
+ StandardMBean std = new StandardMBean(obj, null);
+ assertTrue("Trivial has TrivialMBean as a management interface", TrivialMBean.class == std.getMBeanInterface());
+ }
+
+ public void testMetaData()
+ throws Exception
+ {
+ StandardMBean std = new MyStandardMBean();
+ MBeanInfo info = std.getMBeanInfo();
+ assertEquals(MyStandardMBean.MBEAN_CLASSNAME, info.getClassName());
+ assertEquals(MyStandardMBean.MBEAN_DESCRIPTION, info.getDescription());
+
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ assertEquals(attributes.length, 1);
+ assertEquals(MyStandardMBean.MBEAN_ATTRIBUTE_DESCRIPTION + "AnAttribute", attributes[0].getDescription());
+
+ MBeanConstructorInfo[] constructors = info.getConstructors();
+ assertEquals(constructors.length, 2);
+ for (int i = 0; i < 2; i++)
+ {
+ if (constructors[i].getSignature().length == 0)
+ assertEquals(MyStandardMBean.MBEAN_CONSTRUCTOR_DESCRIPTION + "0", constructors[i].getDescription());
+ else
+ {
+ assertEquals(MyStandardMBean.MBEAN_CONSTRUCTOR_DESCRIPTION + "2", constructors[i].getDescription());
+ MBeanParameterInfo[] params = constructors[i].getSignature();
+ assertEquals(params.length, 2);
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER + "0", params[0].getName());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER + "1", params[1].getName());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER_DESCRIPTION + "0", params[0].getDescription());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER_DESCRIPTION + "1", params[1].getDescription());
+ }
+ }
+
+ MBeanOperationInfo[] operations = info.getOperations();
+ assertEquals(operations.length, 1);
+ assertEquals(MyStandardMBean.MBEAN_OPERATION_DESCRIPTION + "anOperation", operations[0].getDescription());
+ MBeanParameterInfo[] params = operations[0].getSignature();
+ assertEquals(params.length, 2);
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER + "anOperation0", params[0].getName());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER + "anOperation1", params[1].getName());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER_DESCRIPTION + "anOperation0", params[0].getDescription());
+ assertEquals(MyStandardMBean.MBEAN_PARAMETER_DESCRIPTION + "anOperation1", params[1].getDescription());
+ assertEquals(MBeanOperationInfo.ACTION, operations[0].getImpact());
+ }
+
+ public void testNoConstructorsMetaData()
+ throws Exception
+ {
+ StandardMBean std = new NoConstructorsStandardMBean();
+ MBeanInfo info = std.getMBeanInfo();
+
+ MBeanConstructorInfo[] constructors = info.getConstructors();
+ assertEquals(constructors.length, 0);
+ }
+
+ public void testCaching()
+ throws Exception
+ {
+ StandardMBean std = new MyStandardMBean();
+ MBeanInfo info = std.getMBeanInfo();
+ assertTrue("MBeanInfo should be cached", info == std.getMBeanInfo());
+ }
+
+ public void testErrors()
+ throws Exception
+ {
+ boolean caught = false;
+ try
+ {
+ new StandardMBean(null, Runnable.class);
+ }
+ catch (IllegalArgumentException e)
+ {
+ caught = true;
+ }
+ assertTrue("Expected IllegalArgumentException for null implementation", caught);
+
+ caught = false;
+ try
+ {
+ new StandardMBean(new MyRunnable(), null);
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ caught = true;
+ }
+ assertTrue("Expected NotCompliantMBeanException for null management interface", caught);
+
+ caught = false;
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new MBeanRunnable(true), name);
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ caught = true;
+ }
+ assertTrue("Expected NotCompliantMBeanException for wrong management interface", caught);
+
+ caught = false;
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ ObjectName name = new ObjectName("test:test=test");
+ server.registerMBean(new MBeanRunnable(0), name);
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ caught = true;
+ }
+ assertTrue("Expected NotCompliantMBeanException for null management interface", caught);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardSUITE.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardSUITE.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/StandardSUITE.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class StandardSUITE extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("StandardMBean Tests");
+
+ suite.addTest(TrivialTEST.suite());
+ suite.addTest(InfoTortureSUITE.suite());
+ suite.addTest(InheritanceSUITE.suite());
+ suite.addTest(new TestSuite(StandardMBeanTEST.class));
+
+ return suite;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/TrivialTEST.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/TrivialTEST.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/TrivialTEST.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import junit.framework.Test;
+
+import org.jboss.test.jmx.JBossJMXTest;
+import org.jboss.test.jmx.compliance.standard.support.Trivial;
+
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class TrivialTEST extends JBossJMXTest
+{
+ public static Test suite()
+ {
+ return suite(TrivialTEST.class);
+ }
+
+ public TrivialTEST(String s)
+ {
+ super(s);
+ }
+
+ public void testRegistration()
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ Trivial trivial = new Trivial();
+
+ ObjectName name = null;
+ try
+ {
+ name = new ObjectName("trivial:key=val");
+ server.registerMBean(trivial, name);
+ }
+ catch (Exception e)
+ {
+ fail("registration failed: " + e.getMessage());
+ }
+ assertTrue("expected server to report it as registered", server.isRegistered(name));
+ }
+
+ public void testConstructorInfo()
+ {
+ MBeanInfo info = getTrivialInfo();
+
+ MBeanConstructorInfo[] constructors = info.getConstructors();
+ assertEquals("constructor list length", 1, constructors.length);
+
+ // I really don't feel like reflecting to get the name of the constructor,
+ // it should just be the name of the class right?
+ assertEquals("constructor name", Trivial.class.getName(), constructors[0].getName());
+
+ MBeanParameterInfo[] params = constructors[0].getSignature();
+ assertEquals("constructor signature length", 0, params.length);
+ }
+
+ public void testAttributeInfo()
+ {
+ MBeanInfo info = getTrivialInfo();
+
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+ assertEquals("attribute list length", 1, attributes.length);
+ assertEquals("attribute name", "Something", attributes[0].getName());
+ assertEquals("attribute type", String.class.getName(), attributes[0].getType());
+ assertEquals("attribute readable", true, attributes[0].isReadable());
+ assertEquals("attribute writable", true, attributes[0].isWritable());
+ assertEquals("attribute isIs", false, attributes[0].isIs());
+ }
+
+ public void testOperationInfo()
+ {
+ MBeanInfo info = getTrivialInfo();
+
+ MBeanOperationInfo[] operations = info.getOperations();
+ assertEquals("operations list length", 1, operations.length);
+ assertEquals("operation name", "doOperation", operations[0].getName());
+ assertEquals("operation return type", Void.TYPE.getName(), operations[0].getReturnType());
+ assertEquals("operation impact", MBeanOperationInfo.UNKNOWN, operations[0].getImpact());
+
+ MBeanParameterInfo[] params = operations[0].getSignature();
+ assertEquals("signature length", 1, params.length);
+ assertEquals("parameter type", String.class.getName(), params[0].getType());
+ }
+
+ public void testNotificationInfo()
+ {
+ MBeanInfo info = getTrivialInfo();
+
+ MBeanNotificationInfo[] notifications = info.getNotifications();
+ assertEquals("notification list length", 0, notifications.length);
+ }
+
+
+ private MBeanInfo getTrivialInfo()
+ {
+ MBeanInfo info = null;
+
+ try
+ {
+ MBeanServer server = MBeanServerFactory.newMBeanServer();
+ Trivial trivial = new Trivial();
+
+ ObjectName name = new ObjectName("trivial:key=val");
+ server.registerMBean(trivial, name);
+ info = server.getMBeanInfo(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ fail("got spurious MalformedObjectNameException");
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ fail("got spurious InstanceAlreadyExistsException");
+ }
+ catch (MBeanRegistrationException e)
+ {
+ fail("got spurious MBeanRegistrationException");
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ fail("got spurious NotCompliantMBeanException");
+ }
+ catch (InstanceNotFoundException e)
+ {
+ fail("got spurious InstanceNotFoundException");
+ }
+ catch (IntrospectionException e)
+ {
+ fail("got spurious IntrospectionException");
+ }
+ catch (ReflectionException e)
+ {
+ fail("got spurious ReflectionException");
+ }
+
+ return info;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/ArbitraryInterface.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/ArbitraryInterface.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/ArbitraryInterface.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface ArbitraryInterface
+{
+ void setArbitraryValue(String value);
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/DynamicDerived1.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/DynamicDerived1.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/DynamicDerived1.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ReflectionException;
+
+/**
+ * implementing DynamicMBean means that we don't inherit the mbean info from
+ * StandardParentMBean
+ */
+public class DynamicDerived1 extends StandardParent implements DynamicMBean
+{
+ public Object getAttribute(String attribute)
+ throws AttributeNotFoundException, MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, InvalidAttributeValueException,
+ MBeanException, ReflectionException
+ {
+ }
+
+ public AttributeList getAttributes(String[] attributes)
+ {
+ return new AttributeList();
+ }
+
+ public AttributeList setAttributes(AttributeList attributes)
+ {
+ return new AttributeList();
+ }
+
+ public Object invoke(String actionName,
+ Object[] params,
+ String[] signature)
+ throws MBeanException, ReflectionException
+ {
+ return null;
+ }
+
+ public MBeanInfo getMBeanInfo()
+ {
+ return new MBeanInfo(this.getClass().getName(), "tester", new MBeanAttributeInfo[0],
+ new MBeanConstructorInfo[0], new MBeanOperationInfo[0], new MBeanNotificationInfo[0]);
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MBeanRunnable.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MBeanRunnable.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MBeanRunnable.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+import javax.management.StandardMBean;
+
+public class MBeanRunnable
+ extends StandardMBean
+ implements Runnable
+{
+ public MBeanRunnable()
+ throws Exception
+ {
+ super(Runnable.class);
+ }
+
+ public MBeanRunnable(boolean wrongInterface)
+ throws Exception
+ {
+ super(ArbitraryInterface.class);
+ }
+
+ public MBeanRunnable(int nullInterface)
+ throws Exception
+ {
+ super(null);
+ }
+
+ public void run()
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyManagementInterface.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyManagementInterface.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyManagementInterface.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface MyManagementInterface
+{
+ String getAnAttribute();
+
+ void setAnAttribute(String value);
+
+ void anOperation(String param1, String param2);
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyRunnable.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyRunnable.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyRunnable.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public class MyRunnable
+ implements Runnable
+{
+ public void run()
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyStandardMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyStandardMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/MyStandardMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.StandardMBean;
+
+public class MyStandardMBean
+ extends StandardMBean
+ implements MyManagementInterface
+{
+ public static final String MBEAN_CLASSNAME = "MBEAN_CLASSNAME";
+ public static final String MBEAN_DESCRIPTION = "MBEAN_DESCRIPTION";
+ public static final String MBEAN_ATTRIBUTE_DESCRIPTION = "MBEAN_ATTRIBUTE_DESCRIPTION";
+ public static final String MBEAN_CONSTRUCTOR_DESCRIPTION = "MBEAN_CONSTRUCTOR_DESCRIPTION";
+ public static final String MBEAN_OPERATION_DESCRIPTION = "MBEAN_OPERATION_DESCRIPTION";
+ public static final String MBEAN_PARAMETER = "MBEAN_PARAMETER";
+ public static final String MBEAN_PARAMETER_DESCRIPTION = "MBEAN_PARAMETER_DESCRIPTION";
+
+ public MyStandardMBean()
+ throws Exception
+ {
+ super(MyManagementInterface.class);
+ }
+
+ public MyStandardMBean(String param1, String param2)
+ throws Exception
+ {
+ super(MyManagementInterface.class);
+ }
+
+ public String getAnAttribute()
+ {
+ return null;
+ }
+
+ public void setAnAttribute(String value)
+ {
+ }
+
+ public void anOperation(String param1, String param2)
+ {
+ }
+
+ protected String getClassName(MBeanInfo info)
+ {
+ return MBEAN_CLASSNAME;
+ }
+
+ protected String getDescription(MBeanInfo info)
+ {
+ return MBEAN_DESCRIPTION;
+ }
+
+ protected String getDescription(MBeanAttributeInfo info)
+ {
+ return MBEAN_ATTRIBUTE_DESCRIPTION + info.getName();
+ }
+
+ protected String getDescription(MBeanConstructorInfo info)
+ {
+ return MBEAN_CONSTRUCTOR_DESCRIPTION + info.getSignature().length;
+ }
+
+ protected String getDescription(MBeanOperationInfo info)
+ {
+ return MBEAN_OPERATION_DESCRIPTION + info.getName();
+ }
+
+ protected String getDescription(MBeanConstructorInfo info, MBeanParameterInfo param, int sequence)
+ {
+ return MBEAN_PARAMETER_DESCRIPTION + sequence;
+ }
+
+ protected String getDescription(MBeanOperationInfo info, MBeanParameterInfo param, int sequence)
+ {
+ return MBEAN_PARAMETER_DESCRIPTION + info.getName() + sequence;
+ }
+
+ protected String getParameterName(MBeanConstructorInfo info, MBeanParameterInfo param, int sequence)
+ {
+ return MBEAN_PARAMETER + sequence;
+ }
+
+ protected String getParameterName(MBeanOperationInfo info, MBeanParameterInfo param, int sequence)
+ {
+ return MBEAN_PARAMETER + info.getName() + sequence;
+ }
+
+ protected int getImpact(MBeanOperationInfo info)
+ {
+ return MBeanOperationInfo.ACTION;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/NoConstructorsStandardMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/NoConstructorsStandardMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/NoConstructorsStandardMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+import javax.management.MBeanConstructorInfo;
+
+public class NoConstructorsStandardMBean
+ extends MyStandardMBean
+{
+
+ public NoConstructorsStandardMBean()
+ throws Exception
+ {
+ super();
+ }
+
+ protected MBeanConstructorInfo[] getConstructors(MBeanConstructorInfo[] info, Object implementation)
+ {
+ return new MBeanConstructorInfo[0];
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived1.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived1.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived1.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public class StandardDerived1 extends StandardParent
+{
+ /**
+ * we have no MBean interface so we inherit from our superclass MBean interface
+ */
+ public StandardDerived1()
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public class StandardDerived2 extends StandardParent implements StandardDerived2MBean
+{
+ /**
+ * our own MBean interface overrides the StandardParentMBean one we inherited.
+ */
+
+ public void setDerivedValue(String derived)
+ {
+ }
+
+ public String getParentValue()
+ {
+ return null;
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived2MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface StandardDerived2MBean
+{
+ void setDerivedValue(String derived);
+ String getParentValue();
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public class StandardDerived3 implements StandardDerived3MBean
+{
+ public void setArbitraryValue(String value)
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3MBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3MBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardDerived3MBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface StandardDerived3MBean extends ArbitraryInterface
+{
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParent.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParent.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParent.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public abstract class StandardParent implements StandardParentMBean
+{
+ public void setParentValue(String value)
+ {
+ }
+
+ public void setAvailable(boolean available)
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParentMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParentMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/StandardParentMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface StandardParentMBean
+{
+ void setParentValue(String value);
+ void setAvailable(boolean available);
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Torture.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Torture.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Torture.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public class Torture implements TortureMBean
+{
+ public Torture()
+ {
+ }
+
+ public Torture(String[][] something)
+ {
+ }
+
+ Torture(int foo)
+ {
+ }
+
+ protected Torture(String wibble)
+ {
+ this(0d);
+ }
+
+ private Torture(double trouble)
+ {
+ }
+
+ public String getNiceString()
+ {
+ return null;
+ }
+
+ public void setNiceString(String nice)
+ {
+ }
+
+ public boolean isNiceBoolean()
+ {
+ return false;
+ }
+
+ public void setNiceBoolean(boolean nice)
+ {
+ }
+
+ public void setInt(int foo)
+ {
+ }
+
+ public void setIntArray(int[] foo)
+ {
+ }
+
+ public void setNestedIntArray(int[][][] foo)
+ {
+ }
+
+ public void setInteger(Integer foo)
+ {
+ }
+
+ public void setIntegerArray(Integer[] foo)
+ {
+ }
+
+ public void setNestedIntegerArray(Integer[][][] foo)
+ {
+ }
+
+ public int getMyinteger()
+ {
+ return 0;
+ }
+
+ public int[] getMyintegerArray()
+ {
+ return new int[0];
+ }
+
+ public int[][][] getMyNestedintegerArray()
+ {
+ return new int[0][][];
+ }
+
+ public Integer getMyInteger()
+ {
+ return null;
+ }
+
+ public Integer[] getMyIntegerArray()
+ {
+ return new Integer[0];
+ }
+
+ public Integer[][][] getMyNestedIntegerArray()
+ {
+ return new Integer[0][][];
+ }
+
+ // these should give an isIs right?
+ public boolean isready()
+ {
+ return false;
+ }
+
+ public Boolean getReady()
+ {
+ return null;
+ }
+
+ // these should be operations
+ public boolean ispeachy(int peachy)
+ {
+ return false;
+ }
+
+ public Boolean isPeachy(int peachy)
+ {
+ return null;
+ }
+
+ public String issuer()
+ {
+ return null;
+ }
+
+ public int settlement(String thing)
+ {
+ return 0;
+ }
+
+ public void setMulti(String foo, Integer bar)
+ {
+ }
+
+ public String getResult(String source)
+ {
+ return null;
+ }
+
+ public void setNothing()
+ {
+ }
+
+ public void getNothing()
+ {
+ }
+
+ // ok, we have an attribute called Something
+ // and an operation called getSomething...
+ public void setSomething(String something)
+ {
+ }
+
+ public void getSomething()
+ {
+ }
+
+ // ooh yesssss
+ public String[][] doSomethingCrazy(Object[] args, String[] foo, int[][][] goMental)
+ {
+ return new String[0][];
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TortureMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TortureMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TortureMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+/**
+ * @author <a href="mailto:trevor at protocool.com">Trevor Squires</a>.
+ */
+
+public interface TortureMBean
+{
+ String getNiceString();
+ void setNiceString(String nice);
+
+ boolean isNiceBoolean();
+ void setNiceBoolean(boolean nice);
+
+ void setInt(int foo);
+ void setIntArray(int[] foo);
+ void setNestedIntArray(int[][][] foo);
+
+ void setInteger(Integer foo);
+ void setIntegerArray(Integer[] foo);
+ void setNestedIntegerArray(Integer[][][] foo);
+
+ int getMyinteger();
+ int[] getMyintegerArray();
+ int[][][] getMyNestedintegerArray();
+
+ Integer getMyInteger();
+ Integer[] getMyIntegerArray();
+ Integer[][][] getMyNestedIntegerArray();
+
+ // these should give an isIs right?
+ boolean isready();
+ Boolean getReady();
+
+ // these should be operations
+ boolean ispeachy(int peachy);
+ Boolean isPeachy(int peachy);
+ String issuer();
+ int settlement(String thing);
+ void setMulti(String foo, Integer bar);
+ String getResult(String source);
+ void setNothing();
+ void getNothing();
+
+ // ok, we have an attribute called Something
+ // and an operation called getSomething...
+ void setSomething(String something);
+ void getSomething();
+
+ // ooh yesssss
+ String[][] doSomethingCrazy(Object[] args, String[] foo, int[][][] goMental);
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Trivial.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Trivial.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/Trivial.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public class Trivial implements TrivialMBean
+{
+ private String something = null;
+
+ public void setSomething(String thing)
+ {
+ this.something = thing;
+ }
+
+ public String getSomething()
+ {
+ return something;
+ }
+
+ public void doOperation(String arg)
+ {
+ }
+}
Added: projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TrivialMBean.java
===================================================================
--- projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TrivialMBean.java (rev 0)
+++ projects/jbossmx/trunk/mbeanserver/src/test/org/jboss/test/jmx/compliance/standard/support/TrivialMBean.java 2009-05-14 12:23:58 UTC (rev 88864)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jmx.compliance.standard.support;
+
+public interface TrivialMBean
+{
+ void setSomething(String thing);
+
+ String getSomething();
+
+ void doOperation(String arg);
+}
More information about the jboss-cvs-commits
mailing list