User: juhalindfors
Date: 02/02/05 08:22:59
Modified: src/main/test/compliance/loading MLetTEST.java
Log:
Revision Changes Path
1.3 +103 -5 jmx/src/main/test/compliance/loading/MLetTEST.java
Index: MLetTEST.java
===================================================================
RCS file: /cvsroot/jboss/jmx/src/main/test/compliance/loading/MLetTEST.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MLetTEST.java 2002/02/03 23:25:45 1.2
+++ MLetTEST.java 2002/02/05 16:22:58 1.3
@@ -7,6 +7,8 @@
package test.compliance.loading;
+import java.net.URL;
+
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
@@ -53,6 +55,8 @@
// NOTE:
// the urls used here are relative to the location of the build.xml
+ final String MLET_URL =
"file:./src/main/test/compliance/loading/support/mlet/BasicConfig.mlet";
+
try
{
MBeanServer server = MBeanServerFactory.createMBeanServer();
@@ -61,17 +65,29 @@
server.registerMBean(mlet, name);
server.invoke(name, "getMBeansFromURL",
- new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/BasicConfig.mlet" },
+ new Object[] { MLET_URL },
new String[] { String.class.getName() }
);
+
+ try
+ {
+ assertTrue(server.isRegistered(new ObjectName("test:name=Trivial")));
+ }
+ catch (AssertionFailedError e)
+ {
+ URL[] urls = mlet.getURLs();
+ fail("FAILS IN RI: SUN JMX RI builds a malformed URL from an MLet text
file URL '" +
+ MLET_URL + "' resulting into MLET codebase URL '" + urls[0] + "'
and therefore fails " +
+ "to load the required classes from the Java archive
(MyMBeans.jar)");
+ }
- assertTrue(server.isRegistered(new ObjectName("test:name=Trivial")));
assertTrue(server.getMBeanInfo(new ObjectName("test:name=Trivial")) !=
null);
server.invoke(new ObjectName("test:name=Trivial"), "doOperation",
new Object[] { "Test" },
new String[] { String.class.getName() }
);
+
}
catch (AssertionFailedError e)
{
@@ -201,7 +217,7 @@
server.registerMBean(mlet, name);
server.invoke(name, "getMBeansFromURL",
- new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/MissingMAndatoryCode.mlet" },
+ new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/MissingMandatoryCode.mlet" },
new String[] { String.class.getName() }
);
@@ -228,6 +244,8 @@
// NOTE:
// the urls used here are relative to the location of the build.xml
+ final String MLET_URL =
"file:./src/main/test/compliance/loading/support/mlet/ArchiveList.mlet";
+
try
{
MBeanServer server = MBeanServerFactory.createMBeanServer();
@@ -236,11 +254,24 @@
server.registerMBean(mlet, name);
server.invoke(name, "getMBeansFromURL",
- new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/ArchiveList.mlet" },
+ new Object[] { MLET_URL },
new String[] { String.class.getName() }
);
- Class c = mlet.loadClass("test.compliance.loading.support.AClass");
+ Class c = null;
+
+ try
+ {
+ c = mlet.loadClass("test.compliance.loading.support.AClass");
+ }
+ catch (ClassNotFoundException e)
+ {
+ URL[] urls = mlet.getURLs();
+ fail("FAILS IN RI: SUN JMX RI builds a malformed URL from an MLet text
file URL '" +
+ MLET_URL + "' resulting into MLET codebase URL '" + urls[0] + "'
and therefore fails " +
+ "to load the required classes from the Java archive.");
+ }
+
Object o = c.newInstance();
server.setAttribute(new ObjectName("test:name=AnotherTrivial"), new
Attribute("Something", o));
@@ -251,6 +282,73 @@
catch (AssertionFailedError e)
{
throw e;
+ }
+ catch (Throwable t)
+ {
+ fail("Unexpected error: " + t.toString());
+ }
+ }
+
+ public void testUnexpectedEndOfFile()
+ {
+ // NOTE:
+ // the urls used here are relative to the location of the build.xml
+
+ try
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ MLet mlet = new MLet();
+ ObjectName name = new ObjectName("test:name=mlet");
+ server.registerMBean(mlet, name);
+
+ server.invoke(name, "getMBeansFromURL",
+ new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/UnexpectedEnd.mlet" },
+ new String[] { String.class.getName() }
+ );
+
+ // should not reach here
+ fail("Unexpected end of file from mlet text file did not cause an
exception.");
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ catch (MBeanException e)
+ {
+ assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
+ }
+ catch (Throwable t)
+ {
+ fail("Unexpected error: " + t.toString());
+ }
+ }
+
+ public void testMissingEndMLetTag()
+ {
+ // NOTE:
+ // the urls used here are relative to the location of the build.xml
+
+ try
+ {
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+ MLet mlet = new MLet();
+ ObjectName name = new ObjectName("test:name=mlet");
+ server.registerMBean(mlet, name);
+
+ server.invoke(name, "getMBeansFromURL",
+ new Object[] {
"file:./src/main/test/compliance/loading/support/mlet/MissingEndTag.mlet" },
+ new String[] { String.class.getName() }
+ );
+
+ assertTrue(!server.isRegistered(new ObjectName("test:name=Trivial")));
+ }
+ catch (AssertionFailedError e)
+ {
+ throw e;
+ }
+ catch (MBeanException e)
+ {
+ assertTrue(e.getTargetException() instanceof ServiceNotFoundException);
}
catch (Throwable t)
{
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development