Author: jcarman
Date: Thu Aug 25 05:22:37 2005
New Revision: 240054
URL: http://svn.apache.org/viewcvs?rev=240054&view=rev
Log:
Introduced unit tests for RmiProvider
Added:
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestRmiProvider.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEcho.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEchoImpl.java
Modified:
jakarta/commons/sandbox/proxy/trunk/build.xml
jakarta/commons/sandbox/proxy/trunk/commons-proxy.ipr
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/RmiProvider.java
Modified: jakarta/commons/sandbox/proxy/trunk/build.xml
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/build.xml?rev=240054&r1=240053&r2=240054&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/build.xml (original)
+++ jakarta/commons/sandbox/proxy/trunk/build.xml Thu Aug 25 05:22:37 2005
@@ -98,6 +98,7 @@
<fileset refid="build-dependencies"/>
</classpath>
</javac>
+ <rmic base="${dir.build.test}" includes="**/Rmi*Impl.class" />
</target>
<target name="build" depends="compile-java">
Modified: jakarta/commons/sandbox/proxy/trunk/commons-proxy.ipr
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/commons-proxy.ipr?rev=240054&r1=240053&r2=240054&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/commons-proxy.ipr (original)
+++ jakarta/commons/sandbox/proxy/trunk/commons-proxy.ipr Thu Aug 25 05:22:37
2005
@@ -192,7 +192,7 @@
</component>
<component name="ProjectRootManager" version="2" assert-keyword="true"
jdk-15="true" project-jdk-name="1.5.0_04" />
<component name="RmicSettings">
- <option name="IS_EANABLED" value="false" />
+ <option name="IS_EANABLED" value="true" />
<option name="DEBUGGING_INFO" value="true" />
<option name="GENERATE_NO_WARNINGS" value="false" />
<option name="GENERATE_IIOP_STUBS" value="false" />
Modified:
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/RmiProvider.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/RmiProvider.java?rev=240054&r1=240053&r2=240054&view=diff
==============================================================================
---
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/RmiProvider.java
(original)
+++
jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/provider/RmiProvider.java
Thu Aug 25 05:22:37 2005
@@ -15,7 +15,6 @@
*/
package org.apache.commons.proxy.provider;
-import org.apache.commons.proxy.ObjectProvider;
import org.apache.commons.proxy.exception.ObjectProviderException;
import java.rmi.AccessException;
@@ -31,7 +30,7 @@
* @author James Carman
* @version 1.0
*/
-public class RmiProvider<T> implements ObjectProvider
+public class RmiProvider<T> extends AbstractObjectProvider<T>
{
private String host = "localhost";
private int port = Registry.REGISTRY_PORT;
@@ -98,10 +97,12 @@
{
if( clientSocketFactory != null )
{
+ log.debug( "Looking up RMI registry at " + host + ":" + port +
" using specified client socket factory..." );
return LocateRegistry.getRegistry( host, port,
clientSocketFactory );
}
else
{
+ log.debug( "Looking up RMI registry at " + host + ":" + port +
"..." );
return LocateRegistry.getRegistry( host, port );
}
}
Added:
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestRmiProvider.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestRmiProvider.java?rev=240054&view=auto
==============================================================================
---
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestRmiProvider.java
(added)
+++
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/provider/TestRmiProvider.java
Thu Aug 25 05:22:37 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.proxy.provider;
+
+import junit.framework.TestCase;
+import org.apache.commons.proxy.util.rmi.RmiEcho;
+import org.apache.commons.proxy.util.rmi.RmiEchoImpl;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+public class TestRmiProvider extends TestCase
+{
+ RmiProvider rmiProvider;
+
+ public void testGetObject() throws Exception
+ {
+ final Registry registry = LocateRegistry.createRegistry(
Registry.REGISTRY_PORT );
+ registry.bind( "echo", new RmiEchoImpl() );
+ final RmiProvider<RmiEcho> provider = new RmiProvider<RmiEcho>(
"echo", RmiEcho.class );
+ final RmiEcho echo = provider.getObject();
+ assertEquals( "Hello, World!", echo.echoBack( "Hello, World!" ) );
+ }
+}
\ No newline at end of file
Added:
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEcho.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEcho.java?rev=240054&view=auto
==============================================================================
---
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEcho.java
(added)
+++
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEcho.java
Thu Aug 25 05:22:37 2005
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.proxy.util.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * @author James Carman
+ * @version 1.0
+ */
+public interface RmiEcho extends Remote
+{
+ public String echoBack( String message ) throws RemoteException;
+}
Added:
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEchoImpl.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEchoImpl.java?rev=240054&view=auto
==============================================================================
---
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEchoImpl.java
(added)
+++
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/rmi/RmiEchoImpl.java
Thu Aug 25 05:22:37 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.proxy.util.rmi;
+
+import java.rmi.server.UnicastRemoteObject;
+import java.rmi.RemoteException;
+
+/**
+ * @author James Carman
+ * @version 1.0
+ */
+public class RmiEchoImpl extends UnicastRemoteObject implements RmiEcho
+{
+ public RmiEchoImpl() throws RemoteException
+ {
+ }
+
+ public String echoBack( String message ) throws RemoteException
+ {
+ return message;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]