dain 2004/01/16 16:14:22
Modified: modules/kernel/src/test/org/apache/geronimo/kernel
ConfigTest.java MockEndpoint.java MockGBean.java
Log:
Added tests for primitive types.
Revision Changes Path
1.6 +18 -1
incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
Index: ConfigTest.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConfigTest.java 15 Jan 2004 00:45:54 -0000 1.5
+++ ConfigTest.java 17 Jan 2004 00:14:22 -0000 1.6
@@ -64,6 +64,7 @@
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.management.Attribute;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
@@ -109,10 +110,22 @@
assertEquals(new Integer(State.RUNNING_INDEX),
mbServer.getAttribute(gbeanName1, "state"));
Object state = mbServer.getAttribute(gbeanName2, "state");
assertEquals(new Integer(State.RUNNING_INDEX), state);
+ assertEquals(new Integer(1), mbServer.getAttribute(gbeanName1,
"FinalInt"));
+ assertEquals(new Integer(2), mbServer.getAttribute(gbeanName1,
"MutableInt"));
assertEquals("1234", mbServer.getAttribute(gbeanName1, "Value"));
+ assertEquals(new Integer(3), mbServer.getAttribute(gbeanName2,
"FinalInt"));
+ assertEquals(new Integer(4), mbServer.getAttribute(gbeanName2,
"MutableInt"));
+
+ mbServer.setAttribute(gbeanName2, new Attribute("MutableInt", new
Integer(44)));
+ assertEquals(new Integer(44), mbServer.getAttribute(gbeanName2,
"MutableInt"));
+
assertEquals("no endpoint", mbServer.invoke(gbeanName1,
"checkEndpoint", null, null));
assertEquals("endpointCheck", mbServer.invoke(gbeanName2,
"checkEndpoint", null, null));
+ mbServer.setAttribute(gbeanName2, new
Attribute("EndpointMutableInt", new Integer(99)));
+ assertEquals(new Integer(99), mbServer.getAttribute(gbeanName2,
"EndpointMutableInt"));
+ assertEquals(new Integer(99), mbServer.getAttribute(gbeanName1,
"MutableInt"));
+
mbServer.invoke(configName, "stop", null, null);
try {
mbServer.getAttribute(gbeanName1, "Value");
@@ -139,10 +152,14 @@
GBeanMBean mockBean1 = new GBeanMBean(MockGBean.getGBeanInfo());
mockBean1.setAttribute("Value", "1234");
mockBean1.setAttribute("Name", "child");
+ mockBean1.setAttribute("FinalInt", new Integer(1));
+ mockBean1.setAttribute("MutableInt", new Integer(2));
gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2");
GBeanMBean mockBean2 = new GBeanMBean(MockGBean.getGBeanInfo());
mockBean2.setAttribute("Value", "5678");
mockBean2.setAttribute("Name", "Parent");
+ mockBean2.setAttribute("FinalInt", new Integer(3));
+ mockBean2.setAttribute("MutableInt", new Integer(4));
mockBean2.setEndpointPatterns("MockEndpoint",
Collections.singleton(gbeanName1));
Map gbeans = new HashMap();
1.2 +5 -1
incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java
Index: MockEndpoint.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockEndpoint.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockEndpoint.java 14 Jan 2004 20:41:56 -0000 1.1
+++ MockEndpoint.java 17 Jan 2004 00:14:22 -0000 1.2
@@ -10,4 +10,8 @@
String doSomething(String name);
+ int getMutableInt();
+
+ void setMutableInt(int mutableInt);
+
}
1.5 +29 -5
incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java
Index: MockGBean.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MockGBean.java 16 Jan 2004 23:31:21 -0000 1.4
+++ MockGBean.java 17 Jan 2004 00:14:22 -0000 1.5
@@ -55,8 +55,6 @@
*/
package org.apache.geronimo.kernel;
-import java.util.Collections;
-
import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoFactory;
@@ -72,6 +70,8 @@
public class MockGBean implements MockEndpoint {
private static final GBeanInfo GBEAN_INFO;
private final String name;
+ private final int finalInt;
+ private int mutableInt;
private String value;
private MockEndpoint endpoint;
@@ -84,22 +84,38 @@
GBeanInfoFactory infoFactory = new GBeanInfoFactory("MockGBean",
MockGBean.class.getName());
infoFactory.addAttribute(new GAttributeInfo("Name", true));
infoFactory.addAttribute(new GAttributeInfo("Value", true));
+ infoFactory.addAttribute(new GAttributeInfo("FinalInt", true));
+ infoFactory.addAttribute(new GAttributeInfo("MutableInt", true));
+ infoFactory.addAttribute(new GAttributeInfo("EndpointMutableInt"));
infoFactory.addOperation(new GOperationInfo("checkResource", new
String[]{"java.lang.String"}));
infoFactory.addOperation(new GOperationInfo("checkEndpoint"));
infoFactory.addOperation(new GOperationInfo("doSomething", new
String[]{"java.lang.String"}));
infoFactory.addEndpoint(new GEndpointInfo("MockEndpoint",
MockEndpoint.class.getName()));
- infoFactory.setConstructor(new
GConstructorInfo(Collections.singletonList("Name"),
Collections.singletonList(String.class)));
+ infoFactory.setConstructor(new GConstructorInfo(new String[]{"Name",
"FinalInt"}, new Class[]{String.class, Integer.TYPE}));
GBEAN_INFO = infoFactory.getBeanInfo();
}
- public MockGBean(String name) {
+ public MockGBean(String name, int finalInt) {
this.name = name;
+ this.finalInt = finalInt;
}
public String getName() {
return name;
}
+ public int getFinalInt() {
+ return finalInt;
+ }
+
+ public int getMutableInt() {
+ return mutableInt;
+ }
+
+ public void setMutableInt(int mutableInt) {
+ this.mutableInt = mutableInt;
+ }
+
public String getValue() {
return value;
}
@@ -130,5 +146,13 @@
return "no endpoint";
}
return endpoint.doSomething("endpointCheck");
+ }
+
+ public int getEndpointMutableInt() {
+ return endpoint.getMutableInt();
+ }
+
+ public void setEndpointMutableInt(int mutableInt) {
+ endpoint.setMutableInt(mutableInt);
}
}