You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/05/16 15:52:07 UTC

svn commit: r406944 [17/30] - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi2: ./ build/ doc/ doc/testing/ doc/testing/rmi http tunneling/ doc/testing/rmi http tunneling/Results - ITC/ doc/testing/rmi http tunneling/Results - SUN/ doc/testin...

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java Tue May 16 06:51:00 2006
@@ -0,0 +1,159 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.transport.jrmp;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.rmi.UnmarshalException;
+
+import ar.org.fitc.rmi.transport.EndpointID;
+import ar.org.fitc.rmi.transport.ProtocolException;
+
+/**
+ * Implements the Server side management of the messages of the JRMP protocol.
+ * 
+ * @author Gustavo Petri
+ */
+public final class ServerProtocolHandler {
+
+	/**
+	 * The client endpoint of the connection.
+	 */
+	private EndpointID clientEP;
+
+	/**
+	 * The local {@link java.io.InputStream} to interact with the client
+	 */
+	private DataInputStream in;
+
+	/**
+	 * The local {@link java.io.OutputStream} to interact with the client.
+	 */
+	private DataOutputStream out;
+
+	/**
+	 * The {@link ProtocolType} which identifies the type of the connection
+	 */
+	private ProtocolType protocolType;
+
+	/**
+	 * Constructs a new {@link ServerProtocolHandler}
+	 * 
+	 * @param in
+	 *            the {@link ar.org.fitc.rmi.transport.RMIObjectInputStream}
+	 * @param out
+	 *            the {@link ar.org.fitc.rmi.transport.RMIObjectInputStream}
+	 * @param clientEP
+	 *            the client {@link EndpointID}
+	 */
+	public ServerProtocolHandler(DataInputStream in, DataOutputStream out,
+			EndpointID clientEP) {
+
+		this.out = out;
+		this.in = in;
+		this.clientEP = (clientEP == null) ? new EndpointID() : clientEP;
+	}
+
+	/**
+	 * Writes the JRMP handshake answer to the client.
+	 * 
+	 * @throws ProtocolException
+	 *             if an exception occurs writing the hanshake data to the
+	 *             client.
+	 */
+	public final void answerHandshake() throws ProtocolException {
+
+		try {
+			if (protocolType == ProtocolType.STREAM) {
+				out.writeByte(HeaderResponse.PROTOCOL_ACK.getValue());
+				clientEP.write(out);
+			} else if (protocolType == ProtocolType.SINGLE_OP) {
+				out.writeByte(HeaderResponse.PROTOCOL_ACK.getValue());
+			} else {
+				out.writeByte(HeaderResponse.PROTOCOL_NOT_SUPPORTED.getValue());
+			}
+		} catch (IOException e) {
+			throw new ProtocolException("Error sending Protocol answer");
+		}
+	}
+
+	/**
+	 * Reads the default client's Endpoint used to accept calls.
+	 * 
+	 * @return an {@link ar.org.fitc.rmi.transport.EndpointID}
+	 */
+	public final EndpointID readEndpointNegotiation() {
+		EndpointID defaultEP = null;
+		try {
+			defaultEP = EndpointID.read(in);
+		} catch (IOException e) {
+			new ProtocolException("Exception reading EndpointID", e);
+		}
+		return defaultEP;
+	}
+
+	/**
+	 * Reads the initial handshake sequence sent by the client.
+	 * 
+	 * @param type
+	 *            a {@link ProtocolType} object indicating the protocol type
+	 * @throws ProtocolException
+	 *             if an exception occurs while reading the handshake data from
+	 *             the imput stream
+	 */
+	public final void readHandShake(ProtocolType type) throws ProtocolException {
+		Header header = new Header(type);
+		try {
+			header.readExternal(in);
+			protocolType = header.getProtocolType();
+		} catch (IOException e) {
+			throw new ProtocolException("I/O Error Reading Transport Header", e);
+		}
+	}
+
+	/**
+	 * Reads a {@link Message} object from the connection's input stream.
+	 * 
+	 * @return the {@link Message} object read.
+	 * @throws UnmarshalException
+	 *             if an exception occurs reading the input stream.
+	 */
+	public final Message readMessage() throws UnmarshalException {
+		Message msg = new Message();
+		try {
+			msg.readExternal(in);
+		} catch (IOException e) {
+			throw new UnmarshalException("IO error unmarshaling a message", e);
+		}
+		return msg;
+	}
+
+	/**
+	 * Writes a {@link MessageResponse#PING_ACK} into the ouput stream.
+	 * 
+	 * @throws ProtocolException
+	 *             if there is an error in the underlying protocol
+	 */
+	public final void writePingAck() throws ProtocolException {
+		try {
+			out.writeByte(MessageResponse.PING_ACK.getValue());
+		} catch (IOException e) {
+			throw new ProtocolException("I/O Error Marshaling a ProtocolAck", e);
+		}
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java Tue May 16 06:51:00 2006
@@ -0,0 +1,184 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * This class provides the methods that compute the hash for a specific method
+ * 
+ * @author Horacio de Oro
+ */
+public final class MethodHashGenerator {
+    private static MessageDigest md;
+    
+    static {
+        try {
+            md = MessageDigest.getInstance("SHA1");
+        } catch (NoSuchAlgorithmException nsae) {
+            throw new InternalError("SHA1 not implemented: " + nsae);
+        }
+    }
+    
+    /**
+     * This method computes the hash of a specific method
+     * 
+     * @param method
+     *            to compute his hash
+     * @return the hash of the method
+     */
+    public final static long getMethodHash(final Method method) {
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        DataOutput dataOutput = new DataOutputStream(baos);
+
+        try {
+            dataOutput.writeUTF(getMethodDescriptor(method));
+        } catch (IOException ioe) {
+            throw new InternalError("IOException while using DataOutput: "
+                    + ioe);
+        }
+
+        byte[] bytes = baos.toByteArray();
+
+        byte[] digest = md.digest(bytes);
+
+        //
+        // 64-bit (long) integer computed from the
+        // first two 32-bit values of the message digest
+        //
+        // The 64-bit hash value is the little-endian composition of an eight
+        // byte sequence
+        // where the first four bytes are the first 32-bit value of the message
+        // digest in
+        // big-endian byte order and the last four bytes are the second 32-bit
+        // value of the
+        // message digest in big-endian byte order. For example, if the first
+        // two 32-bit
+        // values of the message digest are 0xB0B1B2B3 and 0xB4B5B6B7, then the
+        // hash value
+        // would be 0xB7B6B5B4B3B2B1B0.
+        //
+
+        byte[] hash = new byte[8];
+
+        hash[0] = digest[7];
+        hash[1] = digest[6];
+        hash[2] = digest[5];
+        hash[3] = digest[4];
+        hash[4] = digest[3];
+        hash[5] = digest[2];
+        hash[6] = digest[1];
+        hash[7] = digest[0];
+
+        return new BigInteger(hash).longValue();
+    }
+
+    /** Create the description of a method */
+    /**
+     * This method creates the description of a method
+     * 
+     * @param method
+     *            to create the descriptor
+     * @return a descriptor for the method
+     */
+    private final static String getMethodDescriptor(final Method method) {
+
+        StringBuilder sb = new StringBuilder();
+
+        sb.append(method.getName());
+        sb.append("(");
+
+        for (Class clazz : method.getParameterTypes())
+            sb.append(MethodHashGenerator.getFieldDescriptor(clazz));
+
+        sb.append(")");
+        sb.append(MethodHashGenerator
+                .getFieldDescriptor(method.getReturnType()));
+
+        return sb.toString();
+    }
+
+    /**
+     * This method returns the descriptor for the type represented by the class
+     * clazz
+     * 
+     * @param clazz
+     *            type to compute the descriptor
+     * @return the descriptor for the type represented by the class clazz
+     */
+    private final static String getFieldDescriptor(Class clazz) {
+
+        if (clazz == null) {
+            // TODO: what kind of
+            // exception should be
+            // thrown here?
+            throw new InternalError("clazz == null!"); 
+        }
+        
+        if (clazz.isArray()) {
+            return clazz.getName().replace('.', '/');
+        }
+
+        if (clazz.isPrimitive()) {
+
+            if (clazz.equals(Boolean.TYPE))
+                return "Z";
+
+            else if (clazz.equals(Character.TYPE))
+                return "C";
+
+            else if (clazz.equals(Byte.TYPE))
+                return "B";
+
+            else if (clazz.equals(Short.TYPE))
+                return "S";
+
+            else if (clazz.equals(Integer.TYPE))
+                return "I";
+
+            else if (clazz.equals(Long.TYPE))
+                return "J";
+
+            else if (clazz.equals(Float.TYPE))
+                return "F";
+
+            else if (clazz.equals(Double.TYPE))
+                return "D";
+
+            else if (clazz.equals(Void.TYPE))
+                return "V";
+
+            else
+                throw new InternalError("Unknown primitive type: " + clazz);
+
+        }
+
+        //
+        // clazz.isPrimitive() == false
+        //
+
+        return "L" + clazz.getName().replace('.', '/') + ";";
+
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/Pair.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/Pair.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/Pair.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/Pair.java Tue May 16 06:51:00 2006
@@ -0,0 +1,85 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+/**
+ * This class implements a generic pair.
+ * 
+ * @author Gustavo Petri
+ */
+public final class Pair<E, T> {
+    private E comp1;
+
+    private T comp2;
+
+    /**
+     * @param comp1
+     *            first component
+     * @param comp2
+     *            second component
+     */
+    public Pair(E comp1, T comp2) {
+        this.comp1 = comp1;
+        this.comp2 = comp2;
+    }
+
+    /**
+     * @return the first component of pair
+     */
+    public final E getFirst() {
+        return comp1;
+    }
+
+    /**
+     * @return the second component of pair
+     */
+    public final T getSecond() {
+        return comp2;
+    }
+
+    /**
+     * @param o
+     *            the object that will be compared for equality.
+     * @return <code>true</code> if <code>obj</code> is instance of the
+     *         class <code>Pair</code>, else return <code>false</code>
+     */
+    public final boolean equals(Object o) {
+
+        if (o == null)
+            return false;
+        if (o == this)
+            return true;
+        if (!(o instanceof Pair))
+            return false;
+        Pair oPair = (Pair) o;
+        return (this.comp1.equals(oPair.comp1) && this.comp2
+                .equals(oPair.comp2));
+    }
+
+    /**
+     * @return the hash code for this object.
+     */
+    public final int hashCode() {
+        return this.comp1.hashCode() ^ this.comp2.hashCode();
+    }
+
+    /**
+     * @return a description of the contained of an object of this class
+     */
+    public final String toString() {
+        return "Pair " + this.comp1.toString() + ", " + this.comp2.toString();
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/Pair.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java Tue May 16 06:51:00 2006
@@ -0,0 +1,87 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+import java.io.PrintStream;
+import java.util.logging.LogRecord;
+import java.util.logging.StreamHandler;
+
+/**
+ * This handler publishes log records into a <code>PrintStream</code>.
+ * 
+ * @author Gonzalo Ortega
+ */
+public final class PrintStreamHandler extends StreamHandler {
+
+    private PrintStream out;
+
+    /**
+     * Creates a new <code>PrintStreamHandler</code>, with
+     * <code>System.err</code> as destiny for the log records.
+     */
+    public PrintStreamHandler() {
+        out = System.err;
+        super.setOutputStream(out);
+    }
+
+    /**
+     * Creates a new <code>PrintStreamHandler<code>, with <code>out</code> 
+     * as destiny for the log records. 
+     *
+     * @param out The <code>PrintStream</code> where the messages will be logged to
+     */
+    public PrintStreamHandler(PrintStream out) {
+        if (out != null) {
+            super.setOutputStream(out);
+        }
+        this.out = out;
+    }
+
+    /**
+     * @param record
+     *            The log record to be published
+     */
+    @Override
+    public final void publish(LogRecord record) {
+        if ((out != null) && isLoggable(record)) {
+            out.println(getFormatter().format(record));
+            out.flush();
+        }
+    }
+
+    /**
+     * @param out
+     *            The <code>PrintStream</code> where the messages will be
+     *            logged, or <code>null</code> if no logging is desired.
+     */
+    public void setOutputPrintStream(PrintStream out) {
+        this.out = out;
+    }
+
+    /**
+     * 
+     */
+    @Override
+    public final void close() {
+        if (out != null) {
+            super.close();
+            if (out != System.err) {
+                out.close();
+            }
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PropertiesReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PropertiesReader.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PropertiesReader.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PropertiesReader.java Tue May 16 06:51:00 2006
@@ -0,0 +1,71 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+public final class PropertiesReader {
+
+    /** To prevent instantiation */
+    private PropertiesReader() {}
+    
+    public final static int readInt(String name, int defaultValue) {
+        int ret;
+        try {
+            ret = Integer.parseInt(System.getProperty(name));
+            if (ret < 0) {
+                // TODO LOG HERE
+                ret = defaultValue;
+            }
+        } catch (NumberFormatException e) {
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;
+    }
+
+    public final static long readLong(String name, long defaultValue) {
+        long ret;
+        try {
+            ret = Long.parseLong(System.getProperty(name));
+            if (ret < 0) {
+                // TODO LOG HERE
+                ret = defaultValue;
+            }
+        } catch (NumberFormatException e) {
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;    
+    }
+    
+    public final static boolean readBoolean(String name, boolean defaultValue) {
+        boolean ret;
+        try {
+            ret = Boolean.valueOf(System.getProperty(name));
+        } catch (Exception e) {   // TODO: exception name
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;
+    }
+    
+    public final static String readString (String name) {
+        String ret = System.getProperty(name);
+        if (ret == null) {
+            // TODO LOG HERE
+        }
+        return ret; 
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/PropertiesReader.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/RemoteUtils.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/RemoteUtils.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/RemoteUtils.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/RemoteUtils.java Tue May 16 06:51:00 2006
@@ -0,0 +1,122 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+/**
+ * A Collection of utility methods used to get the Remote interfaces and
+ * methods from a Class.
+ * 
+ * @author Gonzalo Ortega
+ */
+public final class RemoteUtils {
+	
+	/**
+	 * Map used to cache the remote interfaces of a class, saving time when
+	 * exporting multiple instances of the same class. 
+	 */
+	static Map<Class, Set<Class>> remoteInterfacesCache;
+
+	static {
+		remoteInterfacesCache = Collections.synchronizedMap(new WeakHashMap<Class, Set<Class>>());
+	}
+	
+    /**
+     * Returns a set containing all the remote interfaces implemented by a class
+     * 
+     * @param inspect
+     *            the class that implements the remote interfaces
+     * @return A <code>Set</code> containing all the remote interfaces
+     *         implemented by a class
+     */
+    public final static Set<Class> getRemoteInterfaces(Class inspect) {
+    	if (remoteInterfacesCache.containsKey(inspect)) {
+    		return remoteInterfacesCache.get(inspect);
+    	}
+        LinkedHashSet<Class> classSet = new LinkedHashSet<Class>();
+        Class clazz = inspect;
+        do {
+            getRemoteInterfacesAux(clazz, classSet);
+        } while ((clazz = clazz.getSuperclass()) != null);
+        remoteInterfacesCache.put(inspect, classSet);
+        return classSet;
+    }
+
+    /**
+     * Auxiliary method needed for <code>getRemoteInterfaces</code>
+     * 
+     * @param inspect
+     *            The class or intarface that implements or extends the remote
+     *            interface
+     * @param classSet
+     *            A <code>Set</code> where the found remote intrefaces are
+     *            stored
+     * @return <code>true</code> if the received intarface is
+     *         <code>Remote</code>
+     */
+    private final static boolean getRemoteInterfacesAux(Class inspect,
+            Set<Class> classSet) {
+        boolean isRemote = false;
+
+        Class[] allInterfaces = inspect.getInterfaces();
+        for (int x = 0; x < allInterfaces.length; x++) {
+            isRemote = isRemote
+                    | getRemoteInterfacesAux(allInterfaces[x], classSet);
+        }
+        if (inspect.equals(java.rmi.Remote.class)) {
+            isRemote = true;
+        }
+        if (isRemote && inspect.isInterface()) {
+            classSet.add(inspect);
+        }
+        return isRemote;
+    }
+
+    /**
+     * Returns a set containing all the remote methods declared by all the
+     * remote interfaces implemented by a class.
+     * 
+     * @param inspect
+     *            the class that implements the remote interfaces
+     * @return A <code>Set</code> containing all the remote methods of the
+     *         class
+     */
+    public final static Set<Method> getRemoteMethods(Class inspect) {
+        Set<Class> classSet = getRemoteInterfaces(inspect);
+        LinkedHashSet<Method> methods = new LinkedHashSet<Method>();
+
+        for (Class interfaz : classSet) {
+            Method[] methodArray = interfaz.getDeclaredMethods();
+            for (int y = 0; y < methodArray.length; y++) {
+                Class[] exceptions = methodArray[y].getExceptionTypes();
+                for (Class clazz : exceptions) {
+                    if (clazz.equals(java.rmi.RemoteException.class)
+                            || clazz.equals(java.io.IOException.class)
+                            || clazz.equals(java.lang.Exception.class)) {
+                        methods.add(methodArray[y]);
+                    }
+                }
+            }
+        }
+        return methods;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/RemoteUtils.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java Tue May 16 06:51:00 2006
@@ -0,0 +1,121 @@
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  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 ar.org.fitc.rmi.utils;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * 
+ * This class constructs a generic structure by which is possible to relate one
+ * element "A1" with a list of elements "L11, L12, ..., L1n". This structure
+ * also maintains a list of these relationships "A1, A2, …, Am" with the
+ * corresponding series "L11, L12, ..., L1n, ...", "L21, L22, ..., L2n", ...,
+ * "Lm1, Lm2, ..., Lmn". Thus, if an element "Ai" is known, this class provides
+ * a method that returns a corresponding list of elements "Li". On the other
+ * hand, if an element "Lij" of the list is known, this class provides a method
+ * that return the element "Ai" which contains "Lij".
+ * 
+ * @author Gustavo Petri
+ */
+
+public final class ReversibleHashSet<E, T> {
+
+    private HashMap<E, Set<T>> oneToMany;
+
+    private HashMap<T, E> oneToOne;
+
+    /**
+     * Constructor of the class
+     */
+    public ReversibleHashSet() {
+        this.oneToMany = new HashMap<E, Set<T>>();
+        this.oneToOne = new HashMap<T, E>();
+    }
+
+    /**
+     * This method inserts a value
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @param value
+     *            of the an element of the series
+     */
+    public final void insert(E key, T value) {
+
+        if (oneToMany.get(key) != null) {
+            oneToMany.get(key).add(value);
+        } else {
+            HashSet<T> newHashSet = new HashSet<T>();
+            newHashSet.add(value);
+            oneToMany.put(key, newHashSet);
+        }
+        oneToOne.put(value, key);
+
+        return;
+    }
+
+    /**
+     * This method returns a list of the elements of the series
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @return a list of the elements of the series
+     */
+    public final Set<T> getValues(E key) {
+        return oneToMany.get(key);
+    }
+
+    /**
+     * This method returns the value of the series's identifier
+     * 
+     * @param value
+     *            of the an element of the series
+     * @return the key of the series, the value of the series's identifier
+     */
+    public final E getKeyFromValue(T value) {
+        return oneToOne.get(value);
+    }
+
+    /**
+     * This method validate if exists an element in the series
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @return <code>true</code> if exists an element in the list, else
+     *         <code>false</code>
+     */
+    public final  boolean hasValues(E key) {
+        return !(oneToMany.get(key) == null);
+    }
+
+    /**
+     * This method remove a value of the series
+     * 
+     * @param value
+     *            of the an element of the series
+     */
+    public final void removeValue(T value) {
+        E key = oneToOne.get(value);
+        if (key != null) {
+            oneToMany.get(key).remove(value);
+            oneToOne.remove(value);
+            if (oneToMany.get(key).isEmpty())
+                oneToMany.remove(key);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestMarshalledObject.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestMarshalledObject.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestMarshalledObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestMarshalledObject.java Tue May 16 06:51:00 2006
@@ -0,0 +1,215 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RMISecurityManager;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.util.Messages;
+
+public class TestMarshalledObject extends TestCase implements Messages {
+
+    public static void main(String[] args) {
+    }
+
+    public TestMarshalledObject(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.rmi.MarshalledObject.MarshalledObject(Object)'
+     */
+    public void testMarshalledObject001() {
+        try {
+            assertNotNull(msgNotNull, new MarshalledObject(new Double(23.4)));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testMarshalledObject002() {
+        try {
+            assertNotNull(msgNotNull, new MarshalledObject(null));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testMarshalledObject003() {
+        try {
+            new MarshalledObject(new RMISecurityManager());
+            fail(msgRaise + " IOException");
+        } catch (IOException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.MarshalledObject.get()'
+     */
+    public void testGet001() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            assertEquals("must be equals", s, m.get());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testGet002() {
+        try {
+            MarshalledObject m = new MarshalledObject(null);
+            assertNull("must be null", m.get());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testGet003() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            assertNotSame("must not be same ", m.get(), m.get());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testGet004() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            assertEquals("must not be same ", m.get(), m.get());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testGet005() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            assertNotSame("must not be same ", s, m.get());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.MarshalledObject.equals(Object)'
+     */
+    public void testEquals001() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            MarshalledObject m2 = new MarshalledObject(s);
+            assertTrue("must be equals", m2.equals(m));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testEquals002() {
+        try {
+            MarshalledObject m = new MarshalledObject(null);
+            MarshalledObject m2 = new MarshalledObject(null);
+            assertTrue("must be equals", m2.equals(m));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testEquals003() {
+        try {
+            MarshalledObject m = new MarshalledObject(new Integer(3));
+            MarshalledObject m2 = new MarshalledObject(new Integer(4));
+            assertFalse("must not be equals", m2.equals(m));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testEquals004() {
+        try {
+            MarshalledObject m = new MarshalledObject(new Integer(3));
+            assertFalse("must not be equals", m.equals(null));
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.MarshalledObject.hashCode()'
+     */
+    public void testHashCode001() {
+        try {
+            Serializable s = new Integer(3);
+            MarshalledObject m = new MarshalledObject(s);
+            MarshalledObject m2 = new MarshalledObject(s);
+            int hc = m.hashCode();
+            for (int i = 1; i < 15; i++) {
+                assertEquals("must have same hashCode", m2.hashCode(), hc);
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testHashCode002() {
+        try {
+            MarshalledObject m = new MarshalledObject(null);
+            MarshalledObject m2 = new MarshalledObject(null);
+            int hc = m.hashCode();
+            for (int i = 1; i < 15; i++) {
+                assertEquals("must have same hashCode", m2.hashCode(), hc);
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testHashCode003() {
+        try {
+            MarshalledObject m = new MarshalledObject(new Integer(3));
+            MarshalledObject m2 = new MarshalledObject(new Integer(4));
+            assertFalse("must not have same hashCode", m2.hashCode() == m
+                    .hashCode());
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestMarshalledObject.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestNaming.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestNaming.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestNaming.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestNaming.java Tue May 16 06:51:00 2006
@@ -0,0 +1,566 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi;
+
+import java.net.MalformedURLException;
+
+import java.rmi.AlreadyBoundException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.rmi.object2test.Echo;
+import ar.org.fitc.test.rmi.object2test.EchoUnicast_Imp;
+
+class ORemote extends Object implements Remote {
+}
+
+public class TestNaming extends TestCase {
+
+    private EchoUnicast_Imp e;
+
+    String ipString = null;
+
+    private static Registry reg = null;
+
+    public static void main(String[] args) {
+    }
+
+    public TestNaming(String name) throws RemoteException {
+        super(name);
+
+        if (reg == null) {
+            reg = LocateRegistry.createRegistry(1099);
+        }
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+    }
+
+    /*
+     * Test method for 'java.rmi.Naming.bind(String, Remote)'
+     */
+    @SuppressWarnings("unchecked")
+    public void testBind001() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("echo", e);
+
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+
+            while (!it.next().endsWith("echo")) {
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testBind002() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//localhost:1099/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            assertFalse("There is same thing in the list", cs.isEmpty());
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            Naming.unbind("echo");
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testBind003() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//:1099/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testBind004() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//localhost/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+    }
+
+    public void testBind005() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            EchoUnicast_Imp e = new EchoUnicast_Imp();
+            Naming.bind("echo", e);
+            Naming.bind("echo", e);
+            fail("Two bind to the same port make a exception that is missing");
+        } catch (AlreadyBoundException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            Naming.unbind("echo");
+        }
+
+    }
+
+    public void testBind006() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("???··~~$$echo", e);
+            fail("The URL is mal formed");
+        } catch (MalformedURLException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testBind008() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind(null, e);
+            fail("The URL can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testBind009() {
+        try {
+            Naming.bind("echo", null);
+            fail("The remoteObject can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testBind010() {
+        try {
+            Naming.bind(null, null);
+            fail("The remoteObject and URL can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testBind011() {
+
+        try {
+            Naming.bind("echo", new ORemote());
+            fail("The remoteObject can't be null");
+        } catch (RemoteException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.Naming.list(String)'
+     */
+    public void testList001() {
+        try {
+            assertEquals("Must be an empty array", 0, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testList002() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("echo", e);
+            assertEquals("Must be an unitary array", 1, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            Naming.unbind("echo");
+        }
+    }
+
+    public void testList003() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            for (int i = 0; i < 30; i++) {
+                Naming.bind("echo" + i, e);
+            }
+            assertEquals("Must be an unitary array", 30, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            for (int i = 0; i < 30; i++) {
+                Naming.unbind("echo" + i);
+            }
+        }
+    }
+
+    public void testList004() {
+        try {
+            Naming.list(null);
+            fail("Can't execute with null String");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testList005() {
+        try {
+            Naming.list("???··~~$$echo");
+            fail("The URL is mal formed");
+        } catch (MalformedURLException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.Naming.lookup(String)'
+     */
+    public void testLookup001() {
+        try {
+            Naming.lookup("echo");
+            fail("Non bind object");
+        } catch (NotBoundException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testLookup002() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+
+            e = new EchoUnicast_Imp();
+            Naming.bind("echo", e);
+            Echo f = (Echo) Naming.lookup("echo");
+            assertTrue("Must be an unitary array", f instanceof Echo);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            Naming.unbind("echo");
+        }
+
+    }
+
+    public void testLookup003() {
+        try {
+            Naming.lookup("#$%$%echo");
+            fail("Mal formed URL");
+        } catch (MalformedURLException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.Naming.unbind(String)'
+     */
+    public void testUnbind001() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("echo", e);
+
+            Naming.unbind("echo");
+            assertEquals("Must be a empty array", 0, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+
+    }
+
+    public void testUnbind002() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//localhost:1099/echo", e);
+            Naming.unbind("echo");
+            assertEquals("Must be an empty array", 0, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testUnbind003() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//:1099/echo", e);
+            Naming.unbind("echo");
+            assertEquals("Must be an empty array", 0, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testUnbind004() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.bind("//localhost/echo", e);
+            Naming.unbind("echo");
+            assertEquals("Must be an empty array", 0, Naming.list("").length);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+        }
+    }
+
+    public void testUnbind005() {
+        try {
+            Naming.unbind(":$#$%echo");
+        } catch (MalformedURLException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testUnbind006() {
+        try {
+            Naming.unbind(null);
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testUnbind007() {
+        try {
+            Naming.unbind("echo");
+        } catch (NotBoundException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    /*
+     * Test method for 'java.rmi.Naming.rebind(String, Remote)'
+     */
+    @SuppressWarnings("unchecked")
+    public void testRebind001() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind("echo", e);
+
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+
+            while (!it.next().endsWith("echo")) {
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testRebind002() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind("//localhost:1099/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            assertFalse("There is same thing in the list", cs.isEmpty());
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testRebind003() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind("//:1099/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testRebind004() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind("//localhost/echo", e);
+            Collection<String> cs = null;
+            cs = (Collection<String>) new CopyOnWriteArrayList(Naming.list(""));
+            Iterator<String> it = cs.iterator();
+            while (!it.next().endsWith("echo")) {
+
+                assertTrue("In Naming List is Echo_Imp", it.hasNext());
+            }
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+
+            Naming.unbind("echo");
+        }
+    }
+
+    public void testRebind005() throws RemoteException, MalformedURLException,
+            NotBoundException {
+        try {
+            EchoUnicast_Imp e = new EchoUnicast_Imp();
+            Naming.rebind("echo", e);
+            Naming.rebind("echo", e);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            Naming.unbind("echo");
+        }
+    }
+
+    public void testRebind006() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind("???··~~$$echo", e);
+            fail("The URL is mal formed");
+        } catch (MalformedURLException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testRebind008() {
+        try {
+            e = new EchoUnicast_Imp();
+            Naming.rebind(null, e);
+            fail("The URL can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testRebind009() {
+        try {
+            Naming.rebind("echo", null);
+            fail("The remoteObject can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testRebind010() {
+        try {
+            Naming.rebind(null, null);
+            fail("The remoteObject and URL can't be null");
+        } catch (RuntimeException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testRebind011() {
+        try {
+            Naming.rebind("echo", new ORemote());
+            fail("The remoteObject can't be null");
+        } catch (RemoteException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestNaming.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestRMISecurityManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestRMISecurityManager.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestRMISecurityManager.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestRMISecurityManager.java Tue May 16 06:51:00 2006
@@ -0,0 +1,78 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi;
+
+import java.rmi.RMISecurityManager;
+import java.security.Permission;
+
+import junit.framework.TestCase;
+
+public class TestRMISecurityManager extends TestCase {
+
+    public static void main(String[] args) {
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'java.rmi.RMISecurityManager.RMISecurityManager()'
+     */
+    public void testRMISecurityManager001() {
+        try {
+            assertTrue(new RMISecurityManager() instanceof RMISecurityManager);
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        }
+    }
+
+    public void testRMISecurityManager002() {
+        SecurityManager smOld = System.getSecurityManager();
+        try {
+            SecurityManager sm = new SecurityManager() {
+                boolean allow = false;
+
+                public void checkPermission(Permission perm) {
+                    if (!allow) {
+                        allow = true;
+                        throw new SecurityException(
+                                "No, No, No, you can't do that.");
+                    }
+                }
+            };
+            System.setSecurityManager(sm);
+            new RMISecurityManager();
+            fail("SecurityMAnager not allow the first use");
+        } catch (SecurityException e) {
+        } catch (Throwable e) {
+            fail("Failed with:" + e);
+        } finally {
+            System.setSecurityManager(smOld);
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestRMISecurityManager.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestSuiteRMI.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestSuiteRMI.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestSuiteRMI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestSuiteRMI.java Tue May 16 06:51:00 2006
@@ -0,0 +1,43 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class TestSuiteRMI {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(TestSuiteRMI.suite());
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for ar.org.fitc.test.rmi");
+
+        suite.addTestSuite(TestNaming.class);
+        suite.addTestSuite(TestMarshalledObject.class);
+        suite.addTestSuite(TestRMISecurityManager.class);
+
+        return suite;
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/TestSuiteRMI.java
------------------------------------------------------------------------------
    svn:executable = *