hammant 2003/02/02 02:00:57
Modified: altrmi/src/java/org/apache/excalibur/altrmi/client/impl
DynamicInvoker.java
altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic
DynamicInvokerTestCase.java
Log:
dynamicInvoker 100% tested
Revision Changes Path
1.8 +1 -14
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DynamicInvoker.java
Index: DynamicInvoker.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DynamicInvoker.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DynamicInvoker.java 9 Jan 2003 22:55:09 -0000 1.7
+++ DynamicInvoker.java 2 Feb 2003 10:00:57 -0000 1.8
@@ -151,15 +151,7 @@
Reply ar =
m_clientInvocationHandler.handleInvocation(
new ListMethodsRequest(publishedName));
-
- if (ar instanceof ListMethodsReply)
- {
- return ((ListMethodsReply) ar).getListOfMethods();
- }
- else//shld never occur
- {
- return new String[0];
- }
+ return ((ListMethodsReply) ar).getListOfMethods();
}
/**
@@ -189,11 +181,6 @@
if (stub == null)
{
stub = (DynamicStub) m_factory.lookup(publishedName);
- if (stub == null)
- {
- throw new ConnectionException(
- publishedName + " is NOT published on the server");
- }
m_stubs.put(publishedName, stub);
}
if (args == null)
1.4 +32 -22
jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic/DynamicInvokerTestCase.java
Index: DynamicInvokerTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/dynamic/DynamicInvokerTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DynamicInvokerTestCase.java 5 Jan 2003 23:11:40 -0000 1.3
+++ DynamicInvokerTestCase.java 2 Feb 2003 10:00:57 -0000 1.4
@@ -82,6 +82,8 @@
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.TestInterface3;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
+import org.apache.excalibur.altrmi.common.NotPublishedException;
+import org.apache.excalibur.altrmi.common.ConnectionException;
/**
* Test case for the stubless invoker of remote methods
@@ -159,13 +161,8 @@
* A very simple test
*
*/
- public void testAHelloCall() throws Exception
+ public void testInvocation() throws ConnectionException
{
- // listOfMethods returns a string array of all the methods within
- // the given published Name.
- // This can be used to dynamically select any method to invoke
- // within the given remote object.
- assertNotNull(dynamicInvoker.listOfMethods("Hello"));
// Invoking the methods returning void
dynamicInvoker.invoke(
@@ -187,30 +184,43 @@
new Object[] { new Integer(11)},
new Class[] { Integer.TYPE });
assertEquals(ret, new Integer(11));
-
-
- }
-
- /**
- * test exceptions
- */
- public void testExceptions() throws Exception
- {
// Invoke on a non-existent remote object
- boolean exceptionOccured = false;
try
{
- dynamicInvoker.invoke("Helloooo", "somemethod", null, null);
+ dynamicInvoker.invoke("Helloooo", "some method", null, null);
+ fail("Dynamic Invoker should have failed");
}
- catch (Exception e)
+ catch (NotPublishedException e)
{
- exceptionOccured = true;
+ // expected
}
- assertTrue(exceptionOccured);
-
+
+
+
}
-
+
+ public void testListMethods() {
+ String[] methods = dynamicInvoker.listOfMethods("Hello");
+ assertNotNull(methods);
+ assertTrue(methods.length > 0);
+ assertEquals("getTestObjects()", methods[0]);
+
+ methods = dynamicInvoker.listOfMethods("does not exist");
+ assertNotNull(methods);
+ assertTrue(methods.length == 0);
+
+ }
+
+
+ public void testList() {
+ String[] publications = dynamicInvoker.list();
+ assertNotNull(publications);
+ assertTrue(publications.length > 0);
+ assertEquals("Hello", publications[0]);
+ }
+
+
/**
* test methods with multiple arguments
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]