qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agazzar...@apache.org
Subject svn commit: r744651 - /qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java
Date Sun, 15 Feb 2009 10:43:11 GMT
Author: agazzarini
Date: Sun Feb 15 10:43:10 2009
New Revision: 744651

URL: http://svn.apache.org/viewvc?rev=744651&view=rev
Log:
QPID-1579 : Additional test case for MBean capability builder when target resource has no
properties / no methods

Modified:
    qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java

Modified: qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java?rev=744651&r1=744650&r2=744651&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java
(original)
+++ qpid/trunk/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilderTest.java
Sun Feb 15 10:43:10 2009
@@ -21,7 +21,10 @@
 package org.apache.qpid.management.wsdm.capabilities;
 
 import java.lang.management.ManagementFactory;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import javassist.CtClass;
@@ -33,6 +36,7 @@
 import javax.management.MBeanParameterInfo;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.xml.namespace.QName;
 
 import junit.framework.TestCase;
 
@@ -50,6 +54,25 @@
 public class MBeanCapabilityBuilderTest extends TestCase
 {
 	
+	/**
+	 * Management interface for an mbean that has no properties and no 
+	 * methods.
+	 * 
+	 * @author Andrea Gazzarini
+	 */
+	public interface NoPropertiesNoMethodsMBean 
+	{
+	}
+
+	/**
+	 * Implementation of the managenent interface described above.
+	 * 
+	 * @author Andrea Gazzarini
+	 */
+	public class NoPropertiesNoMethods implements NoPropertiesNoMethodsMBean 
+	{
+	}
+
 	private MBeanCapabilityBuilder _builder;
 	private ObjectName _objectName;
 	
@@ -126,6 +149,40 @@
 	}
 	
 	/**
+	 * Tests buils of a capability that has no properties and methods
+	 * 
+	 * <br>precondition : the incoming entity definition is empty (no properties and no
methods)
+	 * <br>postcondition : the capability class is built successfully and has no props
and methods.
+	 * 								The getPropertyNames returns an empty QName array.
+	 */
+	public void testOK_WithNoPropertiesNoMethods() throws Exception {
+
+		ObjectName name = new ObjectName("Test:Name=NoPropertiesNoMethods");
+		
+		MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+		server.registerMBean(new NoPropertiesNoMethods(), name);
+		
+		_builder.begin(name);
+		_builder.endAttributes();
+		_builder.endOperations();
+		Class<MBeanCapability> capabilityClass = _builder.getCapabilityClass();
+		
+		Field[] fields = capabilityClass.getDeclaredFields();
+		Method [] methods = capabilityClass.getDeclaredMethods();
+		
+		assertEquals(Arrays.toString(fields),0,fields.length);
+		assertEquals(Arrays.toString(methods),1,methods.length);
+		
+		Method getPropertyNames = methods[0];
+		assertEquals("getPropertyNames",getPropertyNames.getName());
+		
+		
+		MBeanCapability capability = capabilityClass.newInstance();
+		QName [] properties = (QName[]) getPropertyNames.invoke(capability);
+		assertEquals(0,properties.length);
+	}
+	
+	/**
 	 * Tests the whole execution of the builder.
 	 */
 	@SuppressWarnings("unchecked")



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message