Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 15232 invoked from network); 16 May 2006 13:56:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 May 2006 13:56:32 -0000 Received: (qmail 8613 invoked by uid 500); 16 May 2006 13:56:26 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 8569 invoked by uid 500); 16 May 2006 13:56:26 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 8556 invoked by uid 99); 16 May 2006 13:56:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 May 2006 06:56:26 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 16 May 2006 06:56:10 -0700 Received: (qmail 14308 invoked by uid 65534); 16 May 2006 13:55:50 -0000 Message-ID: <20060516135550.14306.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r406944 [9/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/testing... Date: Tue, 16 May 2006 13:52:07 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ITCTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ITCTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ITCTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ITCTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,272 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.lang.ref.WeakReference; +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.ExportException; +import java.util.logging.Logger; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestListener; +import junit.framework.TestResult; +import ar.org.fitc.test.rmi.integration.fase2.Net; + +/** + * Generates a log. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +class Listener implements TestListener { + + + /** + * Prints a message that receive as parameter. + * + * @param msg a message + */ + private void printMSG(String msg) { + if (msg != null && !msg.startsWith("Failed with:")) { + msg = "Failed with: " +msg; + } + System.out.println("\t\t" + msg); + } + + /** + * Adds an error trace. + * + * @param arg a testing argument + * @param arg1 a throwable argument + */ + public void addError(Test arg, Throwable arg1) { + arg1.printStackTrace(); + printMSG(arg1.getMessage()); + } + + /** + * Adds a failure trace. + * + * @param arg a testing argument + * @param arg1 an assertion failure error + */ + public void addFailure(Test arg, AssertionFailedError arg1) { + arg1.printStackTrace(); + printMSG(arg1.getMessage()); + } + + /** + * Indicates the end of the test + * + * @param a testing argument + */ + public void endTest(Test arg) { + } + + /** + * Indicates the start of the test + * + * @param a testing argument + * */ + public void startTest(Test arg) { + } +} + +/** + * Testing class for WeakReference's. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + */ +public class ITCTestCase extends TestCase { + + public static String arrayToString(Object[] arg) { + if (arg.length == 0) { + return "[]"; + } else { + String result = "[" + arg[0].toString(); + int i = 1; + while(i < arg.length) { + result += ", " + arg[i].toString(); + } + result += "]"; + return result; + } + } + + /** + * For log purpose. + */ + transient final protected static Logger log = Logger.getLogger("ar.org.fitc.test.rmi.integration.fase2.test"); + + /** + * The remote interface to a simple remote object. + */ + protected static Registry registry; + + /** + * If registry is null, creates it. + * + */ + public synchronized static void initRegistry() { + if (registry == null) { + try { + try { + registry = LocateRegistry.createRegistry(Net.getRegistryPort()); + } catch (ExportException e) { + registry = LocateRegistry.getRegistry(Net.getRegistryPort()); + } + } catch (RemoteException e) { + e.printStackTrace(); + } + } + } + + /** + * Creates a log. + * + */ + public TestResult run() { + System.out.println(this.getClass() + " start"); + TestResult r = createResult(); + r.addListener(new Listener()); + for (Method m : this.getClass().getMethods()) { + String name = m.getName(); + if (name.startsWith("test") && m.getParameterTypes().length == 0) { + System.out.println("\t" + name); + setName(name); + run(r); + } + } + System.out.println(); + System.out.println(); + return r; + } + public TestResult run(String name) { + System.out.println(this.getClass() + " start"); + TestResult r = createResult(); + r.addListener(new Listener()); + System.out.println("\t" + name); + setName(name); + run(r); + System.out.println(); + System.out.println(); + return r; + } + + /** + * Default constructor. + * + */ + public ITCTestCase() { + super(); + } + + /** + * Constructs a ITCTestCase with a name. + * + * @param arg0 a name. + */ + public ITCTestCase(String arg0) { + super(arg0); + //TODO puesto por conveniencia temporal... + // permite ejecutar los test desde el plugin de eclipse. + //sacra cuendo el proyecto este en marcha + System.setProperty("java.rmi.server.codebase", + "ftp://proftp:1@10.100.2.230/"); + System.setProperty("java.rmi.server.hostname", "10.100.2.230"); + } + + /** + * Creates a new WeakReference and forces the + * garbage collector + * + */ + @SuppressWarnings("unchecked") + public static void forceGC() { + for (int i= 0; i < 100; i++) { + System.gc(); + } + WeakReference ref = new WeakReference(new Integer(234523)); + while (ref.get() != null) { + System.gc(); + } + } + + /** + * Creates a new WeakReference and forces the + * garbage collector. + * + * @param WeakReference the specified WeakReference + * @param times the number of executions + */ + public static void forceGC(WeakReference ref, int times) { + for (int i = times; ref.get() != null || i ==0; i--) { + System.gc(); + } + } + + /** + * Verifies the WeakReference. + * + * @param ref the specified WeakReference + */ + public static void assertNull(WeakReference ref) { + forceGC(); + assertNull(ref.get()); + } + + /** + * Verifies the WeakReference. + * + * @param ref the specified WeakReference + * @param message if this assert fail this message'll be tell + */ + public static void assertNull(String message, WeakReference ref) { + forceGC(); + assertNull(message, ref.get()); + } + + /** + * Verifies the WeakReference. + * + * @param ref the specified WeakReference + */ + public static void assertNotNull(WeakReference ref) { + forceGC(); + assertNotNull(ref.get()); + } + + /** + * Verifies the WeakReference. + * + * @param ref the specified WeakReference + * @param message if this assert fail this message'll be tell + */ + public static void assertNotNull(String message, WeakReference ref) { + forceGC(); + assertNotNull(message, ref.get()); + } +} + Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/OverheadComunicationPerformanceTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/OverheadComunicationPerformanceTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/OverheadComunicationPerformanceTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/OverheadComunicationPerformanceTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,29 @@ +package ar.org.fitc.test.rmi.integration.fase2.test; + +import java.rmi.RemoteException; + +import ar.org.fitc.test.rmi.integration.fase2.AbstractITCRemote; +import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast; + +public class OverheadComunicationPerformanceTestCase extends + ComunicationPerformanceTestCase { + + public OverheadComunicationPerformanceTestCase() { + super(); + } + + public OverheadComunicationPerformanceTestCase(String arg0) { + super(arg0); + } + + protected long oneTest() throws RemoteException { + long startTime = System.currentTimeMillis(); + long clientTime = (Long) executor.execute(object, 1, "This overhead", + new AbstractITCRemote(), new ITCRemoteUnicast(), + "more overhead", new ITCRemoteUnicast(), object, true, 'a', + 2.345d, object, startTime, executor); + long stopTime = System.currentTimeMillis(); + return stopTime - startTime - clientTime; + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PerformanceTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PerformanceTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PerformanceTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PerformanceTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,57 @@ +package ar.org.fitc.test.rmi.integration.fase2.test; + +import java.rmi.RemoteException; + +abstract public class PerformanceTestCase extends ExecutorTestCase { + + public PerformanceTestCase() { + super(); + } + + public PerformanceTestCase(String arg0) { + super(arg0); + } + + public static int NumberOfIteration = 10; + + protected void setUp() throws Exception { + super.setUp(); + oneTest(); + oneTest(); + } + + abstract protected long oneTest() throws RemoteException; + + public void testPerformance() throws RemoteException { + System.out.println("\t\tTime one call:" + oneTest()); + } + + public void testPerformanceAVG() throws RemoteException { + long avg = 0; + + for (int i=0; i < NumberOfIteration; i++) { + long x = oneTest(); + avg += x; + System.out.println("\t\tTime one call:" + x); + } + avg = avg / NumberOfIteration; + System.out.println("\t\tTime avenger of " + NumberOfIteration +" calls:" + avg); + } + public void testPerformanceAVGandS2() throws RemoteException { + long avg = 0; + double s2 = 0; + for (int i=0; i < NumberOfIteration; i++) { + long x = oneTest(); + avg += x; + s2 += x*x; + System.out.println("\t\tTime one call:" + x); + + } + avg = avg / NumberOfIteration; + s2 = (s2 / (NumberOfIteration-1)) - avg * avg; + s2 = Math.sqrt(s2); + System.out.println("\t\tTime avenger of " + NumberOfIteration +" calls:" + avg); + System.out.println("\t\tStandard deviation of this calls:" + s2); + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PortableTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PortableTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PortableTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PortableTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,125 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.rmi.NotBoundException; +import java.rmi.RemoteException; + +import junit.framework.AssertionFailedError; +import ar.org.fitc.test.rmi.integration.fase2.AbstractITCRemote; +import ar.org.fitc.test.rmi.integration.fase2.executor.ClientExecutor; +import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor; +import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote; +import ar.org.fitc.test.rmi.integration.fase2.remoteexport.ExecutorGetClientHost; +import ar.org.fitc.test.rmi.integration.fase2.remoteexport.PortableUnicastRemoteObject; + +/** + * Testing class for verifies references to exported objects. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +public class PortableTestCase extends ExecutorTestCase { + + /** + * Default constructor + * + */ + public PortableTestCase() { + super(); + } + + /** + * Constructs a PortableTestCase with a name. + * + * @param arg0 a name. + */ + public PortableTestCase(String arg0) { + super(arg0); + } + + /** + * Assigns an IP reported. + * + * @throws Exception if any exception occurs + */ + protected void setUp() throws Exception { + super.setUp(); + } + + /** + * Simple implementation. + * + * @throws Exception if any exception occurs + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * An object is exported to an external host and it is used + * through his reference. Then, the object is unexported and + * we can verify that cannot use the reference + * + * @throws RemoteException if the exportation fails + * @throws NotBoundException if the name is not currently bound + */ + + public void testPortar() throws RemoteException, NotBoundException { + ITCRemote r = new AbstractITCRemote(); + ITCRemote stub = PortableUnicastRemoteObject.exportObject(hosts[0], r, 0); + r = null; + PortableUnicastRemoteObject.unexportObject(stub, true); + try { + stub.getString(); + fail("object is no longer export, but i can used"); + } catch (RemoteException e) { + } + } + + /** + * The objects are exported in different hosts (one object per + * each host). In each exportation the destiny is verified. + * + * @throws RemoteException if the exportation fails + */ + + public void testExportingAndComparing() throws RemoteException { + + for (final String host : hosts) { + ServerExecutor testObject = new ExecutorGetClientHost(); + ServerExecutor stubTestObject = null; + try { + stubTestObject = (ServerExecutor) PortableUnicastRemoteObject.exportObject(host, (ITCRemote) testObject, 0); + try { + assertEquals("The host must be " + host, host, ClientExecutor.getExecutor(host).execute(stubTestObject, 1)); + System.err.println(host + " OK" ); + } catch (AssertionFailedError e) { + System.err.println(e); + } + } catch (NotBoundException e) { + log.warning("One host (" + host +") don't work anymore"); + } finally { + if(stubTestObject != null && stubTestObject.clean(true)) {//PortableUnicastRemoteObject.unexportObject(stubTestObject, true)) { + log.warning("The ExecutorGetCliengHost can't be unexported"); + } + } + } + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropagableTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropagableTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropagableTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropagableTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,140 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.rmi.RemoteException; + +import ar.org.fitc.test.rmi.integration.fase2.PropagableTestRemote; +import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor; + +/** + * Testing class for executing object on remote hosts. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +public class PropagableTestCase extends ExecutorTestCase { + + /** + * A ServerExecutor. + */ + public ServerExecutor serv; + + /** + * Default constructor. + * + */ + public PropagableTestCase() { + super(); + } + + /** + * Constructs a PropagableTestCase with a name. + * + * @param arg0 a name. + */ + public PropagableTestCase(String arg0) { + super(arg0); + } + + /** + * Creates a PropagableTestRemote. + * + */ + protected void setUp() throws Exception { + serv = new PropagableTestRemote(); + super.setUp(); + } + + /** + * Forces the garbage collector. + * + */ + protected void tearDown() throws Exception { + super.tearDown(); + forceGC(); + } + + /** + * Simply executes an object on a host. This procedure is + * repeated on all hosts. + * + */ + public void testPropagableOneHost001() { + for (final String host : hosts) { + try { + assertTrue("The execute host must be " + host, + (Boolean) executor.execute(host, (ServerExecutor) serv.myClone(), 1,1, host)); + } catch (RemoteException e) { + fail("Non work: " + e); + } + } + } + + /** + * Executes an object on a unitary list of remote hosts. + * This procedure is repeated on all reported hosts. + * + */ + public void testPropagableOneHost002() { + for (final String host : hosts) { + try { + assertTrue("The execute host must be " + host, + (Boolean) executor.execute(new String[] { host }, (ServerExecutor) serv.myClone(), + 1,1, host)); + } catch (RemoteException e) { + fail("Non work: " + e); + + } + } + } + + /** + * Simply executes an object on a list of remote hosts. + * + * @throws SecurityException if occurs a security violation + * @throws NoSuchMethodException if a particular method cannot + * be found + * @throws IllegalArgumentException if a method has been passed + * an illegal or inappropriate argument + * @throws IllegalAccessException if tries to reflectively create + * an instance + * @throws InvocationTargetException wraps an exception thrown + * by an invoked method or constructor + * @throws RemoteException + */ + public void testPropagableAtOnes001() throws SecurityException, + NoSuchMethodException, IllegalArgumentException, + IllegalAccessException, InvocationTargetException, RemoteException { + + Method m = executor.getClass().getMethod("execute", String[].class, + ServerExecutor.class, int.class, Object[].class); + Object[] hostsP = new Object[hosts.length+1]; + hostsP[0] = hosts.length; + System.arraycopy(hosts, 0, hostsP, 1, hosts.length); + Object[] param = new Object[4]; + param[0] = hosts; + param[1] = serv; + param[2] = 1; + param[3] = hostsP; + assertTrue("The execute hosts must be " + arrayToString(hosts), + (Boolean) m.invoke(executor, param)); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropertysTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropertysTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropertysTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/PropertysTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,66 @@ +package ar.org.fitc.test.rmi.integration.fase2.test; + +import java.net.MalformedURLException; +import java.rmi.AlreadyBoundException; +import java.rmi.Naming; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.server.UnicastRemoteObject; +import java.util.Properties; + +import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast; +import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote; + +public class PropertysTestCase extends ITCTestCase { + + public PropertysTestCase() { + super(); + // TODO Auto-generated constructor stub + } + + public PropertysTestCase(String arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + protected void setUp() throws Exception { + store = new Properties(System.getProperties()); + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + restoreProperty(); + } + private Properties store = new Properties(System.getProperties()); + + protected String setProperty(String key, String value) { + return System.setProperty(key, value); + } + + protected String getProperty(String key) { + return System.getProperty(key); + } + + protected void restoreProperty(String property) { + System.setProperty(property, store.getProperty(property)); + } + protected void restoreProperty() { + System.setProperties(store); + } + + public void testServerHostName() throws RemoteException, MalformedURLException, AlreadyBoundException, NotBoundException { + setProperty("java.rmi.server.hostname","200.200.200.200"); + System.out.println(UnicastRemoteObject.toStub(new ITCRemoteUnicast())); + + LocateRegistry.createRegistry(1099); + + Naming.bind("hole", new ITCRemoteUnicast()); + System.out.println(arrayToString(Naming.list(""))); + ITCRemote o = (ITCRemote) Naming.lookup("hole"); + System.out.println(o.getString()); + System.out.println(o.toString()); + + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RMISocketFactoryTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RMISocketFactoryTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RMISocketFactoryTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RMISocketFactoryTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,126 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMIServerSocketFactory; +import java.rmi.server.UnicastRemoteObject; + +import ar.org.fitc.test.rmi.integration.fase2.LogRemoteImpl; +import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor; +import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor; +import ar.org.fitc.test.rmi.integration.fase2.socketfactory.CipherRMISocketFactory; +import ar.org.fitc.test.rmi.integration.fase2.socketfactory.GZipRMISocketFactory; + + +/** + * Testing class for RMI Socket Factories. + * + * @author Osvaldo Demo + * + * @version 1.0 + */ +public class RMISocketFactoryTestCase extends ExecutorTestCase { + + /** + * A LogRemoteImpl. + */ + public LogRemoteImpl remote; + + public Registry reg; + + public ServerExecutor exportObj; + public ServerExecutor stub; + + public RMIClientSocketFactory crsk; + + public RMIServerSocketFactory srsk; + + /** + * Default constructor. + * + */ + public RMISocketFactoryTestCase() { + super(); + } + + /** + * Constructs a RMISocketFactoryTestCase with a name. + * + * @param arg0 a name. + */ + public RMISocketFactoryTestCase(String arg0) { + super(arg0); + } + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + try { + reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); + } catch (RemoteException e) { + } + reg = LocateRegistry.getRegistry(); + + exportObj = new AbstractServerExecutor() { + + private static final long serialVersionUID = 3635772699140965835L; + + @Override + public Object execute(Object... arguments) throws RemoteException { + System.out.println("\t\tRuning remote object with Custom Sockets"); + return true; + } + }; + super.setUp(); + } + + protected void tearDown() throws Exception { + exportObj = null; + } + + public void testCipherSocketFactory() throws RemoteException { + srsk = new CipherRMISocketFactory(); + crsk = new CipherRMISocketFactory(); + stub = (ServerExecutor) UnicastRemoteObject.exportObject(exportObj, 0, crsk, srsk); + assertTrue((Boolean)executor.execute(stub, 10)); + } + + public void testZIPSocketFactory() throws RemoteException { + srsk = new GZipRMISocketFactory(); + crsk = new GZipRMISocketFactory(); + stub = (ServerExecutor) UnicastRemoteObject.exportObject(exportObj, 0, crsk, srsk); + assertTrue((Boolean)executor.execute(stub, 10)); + } + + public void testZIPSocketFactoryError() throws RemoteException { + srsk = new GZipRMISocketFactory(); + crsk = new GZipRMISocketFactory(); +// crsk = new CipherRMISocketFactory(); + try { + stub = (ServerExecutor) UnicastRemoteObject.exportObject(exportObj, 0, crsk, srsk); + fail("No error reported"); + } catch (RemoteException e) { + + } + } + +} + + Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RemoteRegistryTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RemoteRegistryTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RemoteRegistryTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/RemoteRegistryTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,235 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.net.MalformedURLException; +import java.rmi.AccessException; +import java.rmi.AlreadyBoundException; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.ServerException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +import ar.org.fitc.test.rmi.integration.fase2.AutoBindITCRemoteUnicast; +import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast; +import ar.org.fitc.test.rmi.integration.fase2.Net; +import ar.org.fitc.test.rmi.integration.fase2.executor.ReportIPServer; +import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote; + +/** + * Testing class for a remote Registry. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +public class RemoteRegistryTestCase extends ITCTestCase { + + /** + * A simple Registry. + */ + public Registry reg; + + /** + * An ITCRemote for exporting. + */ + public ITCRemote exportObj; + + /** + * Default constructor. + * + */ + public RemoteRegistryTestCase() { + super(); + } + + /** + * Constructs a RemoteRegistryTestCase with a name. + * + * @param arg0 a name. + */ + public RemoteRegistryTestCase(String arg0) { + super(arg0); + } + + /** + * Assigns a Registry for each reported server and + * exports an object on them. + * + * @throws Exception if a failure occurs during exportation + */ + protected void setUp() throws Exception { + String[] hosts = ReportIPServer.getit(); + for (String host: hosts) { + if (!Net.isOwnHost(host)) { + reg = LocateRegistry.getRegistry(host, Net.getRegistryPort()); + break; + } + } + exportObj = new ITCRemoteUnicast(); + super.setUp(); + } + + /** + * Tries to bind a remote object in a Registry of a + * non-local host. + * + * @throws RemoteException if remote communication with the + * registry failed + * @throws AlreadyBoundException if the name is already bound + */ + public void testBind001() throws RemoteException, AlreadyBoundException { + + try { + reg.bind("echo", exportObj); + fail("Stub of registry can't chanch registry"); + } catch (ServerException e) { + } + } + + /** + * This test verifies that all elements in a non-local + * Registry are functional. + * + * @throws AccessException if this registry is local and it + * denies the caller access to perform this operation + * @throws RemoteException if remote communication with the + * registry failed + * @throws NotBoundException if the name is not currently bound + */ + public void testLookup001() throws AccessException, RemoteException, + NotBoundException { + try { + for (String bindName : reg.list() ) { + ITCRemote o =(ITCRemote) reg.lookup(bindName); + o.getString(); + } + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + } + + /** + * This test tries lookup a non-bounded remote object. + * + * @throws RemoteException if remote communication with the + * registry failed + * @throws MalformedURLException if the name is not an + * appropriately formatted URL + * @throws NotBoundException if the name is not currently bound + */ + public void testLookup002() throws RemoteException, MalformedURLException, + NotBoundException { + try { + reg.lookup("echo123413"); + fail("Mal formed URL"); + } catch (NotBoundException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /** + * This test tries lookup a remote object with a non-existing name. + * + * @throws RemoteException if remote communication with the + * registry failed + * @throws MalformedURLException if the name is not an + * appropriately formatted URL + * @throws NotBoundException if the name is not currently bound + */ + public void testLookup003() { + try { + reg.lookup("#$%$%echo"); + fail("Mal formed URL"); + } catch (NotBoundException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /** + * This test tries to re-bind a remote object with a same name + * in a Registry. + * + * @throws RemoteException if remote communication with the + * registry failed + * @throws AlreadyBoundException if the name is already bound + */ + public void testRebind001() throws RemoteException, MalformedURLException, + NotBoundException { + try { + reg.rebind("echo", exportObj); + fail("Stub of registry can't chanch registry"); + } catch (ServerException e) { + } + } + + /** + * This test tries to un-bind remote objects from a non-local + * Registry. The object must to be registred. + * + * @throws AccessException if this registry is local and it + * denies the caller access to perform this operation + * @throws RemoteException if remote communication with the + * registry failed + * @throws NotBoundException if the name is not currently bound + */ + @SuppressWarnings("unchecked") + public void testUnbind() throws AccessException, RemoteException, + NotBoundException { + for (String bindName : reg.list() ) { + try { + reg.unbind(bindName); + fail("Stub of registry can't chanch registry"); + } catch (ServerException e) { + ITCRemote o =(ITCRemote) reg.lookup(bindName); + o.getString(); + } + } + } + + /** + * This case makes a test on a non-exported object. If this + * object is deserialized, it is exported and bounded. This object + * is sent as parameter to a non-local Registry. The + * binding fails. However the object will be bounded because + * will be deserialized. + * + * @throws RemoteException if remote communication with the + * registry failed + */ + public void testAutoBindAndExportionUsingRemoteRegistry() throws RemoteException { + exportObj = new AutoBindITCRemoteUnicast(); + exportObj.clean(true); + + try { + reg.rebind(AutoBindITCRemoteUnicast.BIND_NAME, exportObj); + fail("can't bind remotelly"); + } catch (ServerException e) { + } + + try { + reg.lookup(AutoBindITCRemoteUnicast.BIND_NAME); + } catch (NotBoundException e) { + fail("Object not binded"); + } + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ReportIPTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ReportIPTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ReportIPTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ReportIPTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,124 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.UnknownHostException; +import java.rmi.RemoteException; + +import ar.org.fitc.test.rmi.integration.fase2.executor.ClientExecutor; +import ar.org.fitc.test.rmi.integration.fase2.executor.ReportIP; + +/** + * Testing class for ReportIP. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +public class ReportIPTestCase extends ITCTestCase { + + /** + * A ReportIP. + */ + public ReportIP reporter; + + /** + * Default constructor. + * + */ + public ReportIPTestCase() { + super(); + } + + /** + * Constructs a ReportIPTestCase with a name. + * + * @param arg0 a name. + */ + public ReportIPTestCase(String arg0) { + super(arg0); + } + + /** + * Creates a ReportIP + * + */ + protected void setUp() throws Exception { + reporter = (ReportIP) java.rmi.Naming.lookup(ReportIP.BIND_NAME); + super.setUp(); + } + + /** + * Verifies the host name of the current ReportIP. + * + * @throws RemoteException if the remote operation fails + * @throws UnknownHostException if the IP address of a host could + * not be determined + */ + public void testMyHostName001() throws RemoteException, + UnknownHostException { + String hostName = reporter.myHostName(); + for (InetAddress address : InetAddress.getAllByName(hostName)) { + if (address.isLoopbackAddress() || address.isSiteLocalAddress()) { + return; + } + } + fail("The reporter.myHostName is not my"); + } + + /** + * Verifies that the ReportIPServer returns a string + * of valid IP addresses. + * + * @throws RemoteException if the remote operation fails + * @throws UnknownHostException if the IP address of a host could + * not be determined + */ + public void testGetIt001() throws RemoteException, UnknownHostException { + String[] hosts = reporter.getIP(); + for (String host : hosts) { + assertNotNull(InetAddress.getAllByName(host)); + } + } + + /** + * Reports a new host and wait that the ReportIP adds + * the host + * + * @throws RemoteException if the remote operation fails + * @throws MalformedURLException if the name is not an appropriately + * formatted URL + */ + public void testReport001() throws RemoteException, MalformedURLException { + String hostName = reporter.myHostName(); + ClientExecutor.exportExecutor(); + String[] initialhosts = reporter.getIP(); + reporter.report(); + String[] hosts = reporter.getIP(); + for (int i = 0, j = 0; i < hosts.length; i++, j++) { + if (hosts[i].equals(hostName)) { + j--; + } else if (hosts[i].equals(initialhosts[j])) { + + } else { + fail("I report and i don't see me in the list"); + } + } + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/SocketFactoryDCGTestCase.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/SocketFactoryDCGTestCase.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/SocketFactoryDCGTestCase.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/SocketFactoryDCGTestCase.java Tue May 16 06:51:00 2006 @@ -0,0 +1,42 @@ +package ar.org.fitc.test.rmi.integration.fase2.test; + +import java.lang.ref.WeakReference; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMIServerSocketFactory; +import java.rmi.server.UnicastRemoteObject; + +import ar.org.fitc.test.rmi.integration.fase2.LogRemoteImpl; +import ar.org.fitc.test.rmi.integration.fase2.MoveRemoteObject; +import ar.org.fitc.test.rmi.integration.fase2.interfaces.LogRemote; +import ar.org.fitc.test.rmi.integration.fase2.socketfactory.CipherRMISocketFactory; + + +/** + * DGC Test case with Cipher Socket Factory + * + * @author Osvaldo Demo + * + * @version 1.0 + */ + +public class SocketFactoryDCGTestCase extends DGCTestCase { + + public RMIClientSocketFactory crsk; + + public RMIServerSocketFactory srsk; + + @SuppressWarnings("unchecked") + @Override + protected void setUp() throws Exception { + + crsk = new CipherRMISocketFactory(); + srsk = new CipherRMISocketFactory(); + remote = new LogRemoteImpl(); + stub = (LogRemote) UnicastRemoteObject.exportObject(remote, 0,crsk,srsk); + // Container and remote execution + serv = new MoveRemoteObject(remote); + wref = new WeakReference(remote); + super.setUp(); + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemote.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemote.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemote.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemote.java Tue May 16 06:51:00 2006 @@ -0,0 +1,174 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.lang.ref.WeakReference; +import java.net.MalformedURLException; +import java.rmi.Naming; +import java.rmi.NoSuchObjectException; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.server.UnicastRemoteObject; + +import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote; + +/** + * Testing class for ITCRemote. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +abstract public class TestITCRemote extends ITCTestCase { + + /** + * A simple ITCRemote object. + */ + protected ITCRemote ret; + + /** + * A simple ITCRemote object. + */ + private ITCRemote retBind; + + /** + * Binds a copy of an ITCRemote object. + * + * @throw Exception if the bind operation fails + */ + protected void setUp() throws Exception { + initRegistry(); + retBind = ret; + ret = retBind.myClone(); +// ret = null; + Naming.bind("ITCREMOTE", retBind); + super.setUp(); + } + + /** + * Unbinds an ITCRemote object. + * + * @throw Exception if the unbind operation fails + */ + protected void tearDown() throws Exception { + super.tearDown(); + ret = null; + retBind = null; + Naming.unbind("ITCREMOTE"); + forceGC(); + } + + /** + * Forces the unexport of an ITCRemote object. + * + * @throws RemoteException if the unexport operation fails + */ + @SuppressWarnings("unchecked") + public void testClean() throws RemoteException { + retBind.clean(true); + WeakReference weak = new WeakReference(retBind); + retBind = null; + assertNull(weak); + } + + @SuppressWarnings("unchecked") + public void testClean2() throws RemoteException { + ret.clean(true); + WeakReference weak = new WeakReference(ret); + ret = null; + assertNull(weak); + } + + /** + * Verifies the WeakReference. + * + */ + @SuppressWarnings("unchecked") + public void testGCBindObject() { + WeakReference weak = new WeakReference(retBind); + retBind = null; + assertNotNull(weak); + } + + /** + * Verifies a WeakReference by forcing the + * unexport of an ITCRemote object. + * + * @throws RemoteException if the operation fail + * @throws MalformedURLException if the name is not an appropriately + * formatted URL + * @throws NotBoundException if name is not currently bound + */ + @SuppressWarnings("unchecked") + public void testGCCleanBind() throws RemoteException, MalformedURLException, NotBoundException { + retBind.clean(true); + WeakReference weak = new WeakReference(retBind); + retBind = null; + assertNull(weak); + try { + ((ITCRemote)Naming.lookup("ITCREMOTE")).getString(); + } catch (NoSuchObjectException e) { + } + } + + /** + * Verifies a lookup of an ITCRemote object. + * + * @throws RemoteException if the lookup operation fails + * @throws MalformedURLException if the name is not an appropriately + * formatted URL + * @throws NotBoundException if name is not currently bound + */ + public void test001() throws RemoteException, MalformedURLException, NotBoundException { + assertNotNull(Naming.lookup("ITCREMOTE")); + } + + /** + * Verifies the WeakReference of an export object. + * + * @throws RemoteException if the exportation fails + */ + @SuppressWarnings("unchecked") + public void testDGCExport() throws RemoteException { + UnicastRemoteObject.exportObject(ret, 10000); + WeakReference weak = new WeakReference(ret); + ret = null; + assertNull(weak); + } + + /** + * Verifies the imInServer method. + * + * @throws RemoteException if the remote operation fails + */ + public void testImInServer() throws RemoteException { + assertTrue(ret.imInServer()); + } + + /** + * Verifies the imInServer method on a remote + * reference. + * + * @throws RemoteException if the remote operation fails + * @throws MalformedURLException if the name is not an appropriately + * formatted URL + * @throws NotBoundException if name is not currently bound + */ + public void testImInServerRef() throws RemoteException, MalformedURLException, NotBoundException { + assertTrue(((ITCRemote)Naming.lookup("ITCREMOTE")).imInServer()); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemoteUnicast.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemoteUnicast.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemoteUnicast.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/TestITCRemoteUnicast.java Tue May 16 06:51:00 2006 @@ -0,0 +1,41 @@ +/* + * 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.test.rmi.integration.fase2.test; + +import java.rmi.RemoteException; + +import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast; + +/** + * Testing class for ITCRemoteUnicast. + * + * @author Jorge Rafael + * @author Marcelo Arcidiacono + * + * @version 1.0 + */ +public class TestITCRemoteUnicast extends TestITCRemote { + + /** + * Creates a new ITCRemoteUnicast. + * + * @throws RemoteException if failed to export object + */ + protected void setUp() throws Exception { + ret = new ITCRemoteUnicast(); + super.setUp(); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/Calculator.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/Calculator.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/Calculator.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/Calculator.java Tue May 16 06:51:00 2006 @@ -0,0 +1,23 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.Vector; + +public interface Calculator extends Remote { + + public static final String SERVICENAME = "RemoteCalculator"; + + public void setVectorA(Vector data) throws RemoteException; + + public void setMatrixA(int[][] data) throws RemoteException; + + public void setMatrixB(int[][] data) throws RemoteException; + + public int[][] sumMatrixAB() throws RemoteException; + + public int[][] multiplyMatrixAB() throws RemoteException; + + public double[] getDevProm() throws RemoteException; + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CalculatorBI.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CalculatorBI.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CalculatorBI.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CalculatorBI.java Tue May 16 06:51:00 2006 @@ -0,0 +1,27 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.util.Vector; + +public interface CalculatorBI extends Remote { + + public static final String SERVICENAME = "RemoteCalculator"; + + public void setVectorA(Vector data) throws RemoteException; + + public void setMatrixA(BigInteger[][] data) throws RemoteException; + + public void setMatrixB(BigInteger[][] data) throws RemoteException; + + public BigInteger[][] sumMatrixAB() throws RemoteException; + + public BigInteger[][] multiplyMatrixAB() throws RemoteException; + + public BigDecimal[] getDevProm() throws RemoteException; + + + +} \ No newline at end of file Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherRMISocketFactory.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherRMISocketFactory.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherRMISocketFactory.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherRMISocketFactory.java Tue May 16 06:51:00 2006 @@ -0,0 +1,24 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import java.rmi.server.RMISocketFactory; + +public class CipherRMISocketFactory extends RMISocketFactory { + + public CipherRMISocketFactory() { + super(); + } + + @Override + public Socket createSocket(String host, int port) throws IOException { + return new CipherSocket(host, port); + } + + @Override + public ServerSocket createServerSocket(int port) throws IOException { + return new CipherServerSocket(port); + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherServerSocket.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherServerSocket.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherServerSocket.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherServerSocket.java Tue May 16 06:51:00 2006 @@ -0,0 +1,37 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; + + + +public class CipherServerSocket extends ServerSocket { + + public CipherServerSocket() throws IOException { + super(); + + } + + public CipherServerSocket(int port) throws IOException { + super(port); + + } + + public CipherServerSocket(int port, int backlog) throws IOException { + super(port, backlog); + + } + + public CipherServerSocket(int port, int backlog, InetAddress bindAddr) + throws IOException { + super(port, backlog, bindAddr); + + } + public Socket accept() throws IOException{ + Socket s = new CipherSocket(); + implAccept(s); + return s; + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherSocket.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherSocket.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherSocket.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/CipherSocket.java Tue May 16 06:51:00 2006 @@ -0,0 +1,64 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Proxy; +import java.net.Socket; +import java.net.SocketException; +import java.net.SocketImpl; +import java.net.UnknownHostException; +import javax.crypto.*; + +public class CipherSocket extends Socket { + + public CipherSocket() { + super(); + } + + public CipherSocket(Proxy proxy) { + super(proxy); + } + + public CipherSocket(SocketImpl impl) throws SocketException { + super(impl); + } + + public CipherSocket(String host, int port) throws UnknownHostException, + IOException { + super(host, port); + } + + public CipherSocket(InetAddress address, int port) throws IOException { + super(address, port); + } + + public CipherSocket(String host, int port, InetAddress localAddr, + int localPort) throws IOException { + super(host, port, localAddr, localPort); + } + + public CipherSocket(InetAddress address, int port, InetAddress localAddr, + int localPort) throws IOException { + super(address, port, localAddr, localPort); + } + + public CipherSocket(String host, int port, boolean stream) + throws IOException { + super(host, port, stream); + + } + + public CipherSocket(InetAddress host, int port, boolean stream) + throws IOException { + super(host, port, stream); + } + + public OutputStream getOutputStream() throws IOException { + return new CipherOutputStream(super.getOutputStream(), RemoteCipherImpl.getCipher(Cipher.ENCRYPT_MODE)); + } + public InputStream getInputStream() throws IOException { + return new CipherInputStream(super.getInputStream(), RemoteCipherImpl.getCipher(Cipher.DECRYPT_MODE)); + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTest.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTest.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTest.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTest.java Tue May 16 06:51:00 2006 @@ -0,0 +1,12 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface ProtocolTest extends Remote { + + public static final String SERVICENAME = "ProtocolTest"; + + public void setByte(byte data) throws RemoteException; + +} \ No newline at end of file Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestByte.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestByte.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestByte.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestByte.java Tue May 16 06:51:00 2006 @@ -0,0 +1,19 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.RemoteException; +import java.rmi.server.UnicastRemoteObject; + +public class ProtocolTestByte extends UnicastRemoteObject implements ProtocolTest { + + private byte myData; + + public ProtocolTestByte() throws RemoteException { + super(); + } + + public void setByte(byte data) throws RemoteException { + myData = data; + System.out.println(data); + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestClient.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestClient.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestClient.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestClient.java Tue May 16 06:51:00 2006 @@ -0,0 +1,35 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class ProtocolTestClient { + + public static void main(String[] args) { + + String addr = "127.0.0.1"; + + ProtocolTest pt = null; + Registry remoteRegistry = null; + + + byte b = 0x43; + + try { + remoteRegistry = LocateRegistry.getRegistry(addr); + pt = (ProtocolTest) remoteRegistry.lookup(ProtocolTest.SERVICENAME); + + pt.setByte(b); + pt.setByte((byte) 0x12); + + } catch (RemoteException e) { + e.printStackTrace(); + } catch (NotBoundException e) { + e.printStackTrace(); + } + + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestServer.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestServer.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestServer.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/ProtocolTestServer.java Tue May 16 06:51:00 2006 @@ -0,0 +1,30 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class ProtocolTestServer { + + public static void main(String[] args) { + Registry localRegistry = null; + System.setProperty("sun.rmi.transport.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000"); + + try { + localRegistry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); + } catch (RemoteException e) { + e.printStackTrace(); + } + + try { + ProtocolTestByte rc = new ProtocolTestByte(); + localRegistry.rebind(ProtocolTest.SERVICENAME,rc); + + } catch (RemoteException e) { + e.printStackTrace(); + } + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculator.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculator.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculator.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculator.java Tue May 16 06:51:00 2006 @@ -0,0 +1,160 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.RemoteException; +import java.rmi.server.ServerNotActiveException; +import java.rmi.server.UnicastRemoteObject; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; + +public class RemoteCalculator extends UnicastRemoteObject implements Calculator { + + public RemoteCalculator() throws RemoteException { + super(); + } + + private static final long serialVersionUID = 1L; + + private Vector v1; + + private int[][] m1; + private int[][] m2; + + public void setVectorA(Vector data) { + if (data.size() < 1) { + throw new RuntimeException("Vector should not be empty!"); + } + try { + System.out.println("Vector A entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + this.v1 = data; + System.out.println(data.toString()); + System.out.println(); + } + + public double[] getDevProm() { + try { + System.out.println("get Standard Deviation and Average called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + double[] result = new double[2]; + if ((v1 == null) || (v1.size() <= 1)) { + result[0] = 0; + result[1] = 0; + return result; + } + + double sumatoria = 0; + Enumeration e = v1.elements(); + while (e.hasMoreElements()) { + Double oneValue = (Double) e.nextElement(); + double dValue = oneValue.doubleValue(); + sumatoria += dValue; + } + + double promedio = sumatoria/v1.size(); + double temp = 0; + + e = v1.elements(); + + while (e.hasMoreElements()) { + Double value = (Double) e.nextElement(); + double doubleValue = value.doubleValue(); + temp += Math.pow(doubleValue - promedio,2.0); + } + + double devstandard = Math.sqrt(temp/(v1.size() - 1)); + + System.out.println("Standard Deviation: "+devstandard); + System.out.println("Average: "+promedio); + result[0] = devstandard; + result[1] = promedio; + return result; + } + + public void setMatrixA(int[][] data) { + if (data.length != data[0].length) { + throw new RuntimeException("Matrix should be square!"); + } + try { + System.out.println("Matrix A entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + System.out.println(Arrays.toString(data[0])); + System.out.println(Arrays.toString(data[1])); + System.out.println(); + this.m1 = data; + } + + public void setMatrixB(int[][] data) { + if (data.length != data[0].length) { + throw new RuntimeException("Matrix should be square!"); + } + try { + System.out.println("Matrix B entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + System.out.println(Arrays.toString(data[0])); + System.out.println(Arrays.toString(data[1])); + System.out.println(); + this.m2 = data; + } + + public int[][] sumMatrixAB() { + if ((m1 == null)|| (m2 == null)) { + throw new RuntimeException("Matrix not loaded"); + } + try { + System.out.println("add Matrix called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + int[][] result = new int[m1.length][m2.length]; + int i, j; + for (i = 0; i < m1.length; i++) { + for (j = 0; j < m2.length; j++) { + result [i][j] = m1 [i][j] + m2 [i][j]; + } + } + System.out.println("Result Matrix (add)"); + System.out.println(Arrays.toString(result[0])); + System.out.println(Arrays.toString(result[1])); + System.out.println(); + return result; + } + + public int[][] multiplyMatrixAB() { + if ((m1 == null)|| (m2 == null)) { + throw new RuntimeException("Matrix not loaded"); + } + try { + System.out.println("multiply Matrix called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + int[][] result = new int[m1.length][m2.length]; + int i, j, k; + int sum; + + for (i = 0; i < m1.length; i++) { + for (j = 0; j < m2.length; j++) { + sum = 0; + for (k = 0; k < m1.length; k++) { + sum += m1[i][k] * m2[k][j]; + } + result[i][j] = sum; + } + } + System.out.println("Result Matrix (multiply)"); + System.out.println(Arrays.toString(result[0])); + System.out.println(Arrays.toString(result[1])); + System.out.println(); + return result; + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorBI.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorBI.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorBI.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorBI.java Tue May 16 06:51:00 2006 @@ -0,0 +1,166 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.rmi.RemoteException; +import java.rmi.server.ServerNotActiveException; +import java.rmi.server.UnicastRemoteObject; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; + +public class RemoteCalculatorBI extends UnicastRemoteObject implements CalculatorBI { + + public RemoteCalculatorBI() throws RemoteException { + super(); + } + + private static final long serialVersionUID = 1L; + + private Vector v1; + + private BigInteger[][] m1; + private BigInteger[][] m2; + + public void setVectorA(Vector data) { + if (data.size() < 1) { + throw new RuntimeException("Vector should not be empty!"); + } + try { + System.out.println("Vector A entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + this.v1 = data; + System.out.println(data.toString()); + System.out.println(); + } + + public BigDecimal[] getDevProm() { + try { + System.out.println("get Standard Deviation and Average called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + BigDecimal[] result = new BigDecimal[2]; + if ((v1 == null) || (v1.size() <= 1)) { + result[0] = BigDecimal.ZERO; + result[1] = BigDecimal.ZERO; + return result; + } + + BigDecimal sumatoria = BigDecimal.ZERO; + Enumeration e = v1.elements(); + while (e.hasMoreElements()) { + BigDecimal dValue = (BigDecimal) e.nextElement(); + + sumatoria.add(dValue); + } + + BigDecimal promedio = sumatoria.divide(BigDecimal.valueOf(v1.size())); + BigDecimal temp = BigDecimal.ZERO; + + + e = v1.elements(); + + while (e.hasMoreElements()) { + BigDecimal value = (BigDecimal) e.nextElement(); + temp = temp.add(value.add(promedio.negate()).pow(2)); + } + + BigDecimal devstandard = temp.divide(BigDecimal.valueOf(v1.size()-1)); + + System.out.println("Standard Deviation: "+devstandard); + System.out.println("Average: "+promedio); + result[0] = devstandard; + result[1] = promedio; + return result; + } + + public void setMatrixA(BigInteger[][] data) { + if (data.length != data[0].length) { + throw new RuntimeException("Matrix should be square!"); + } + try { + System.out.println("Matrix A entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + System.out.println(Arrays.toString(data[0])); + System.out.println(Arrays.toString(data[1])); + System.out.println(); + this.m1 = data; + } + + public void setMatrixB(BigInteger[][] data) { + if (data.length != data[0].length) { + throw new RuntimeException("Matrix should be square!"); + } + try { + System.out.println("Matrix B entered from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + System.out.println(Arrays.toString(data[0])); + System.out.println(Arrays.toString(data[1])); + System.out.println(); + this.m2 = data; + } + + public BigInteger[][] sumMatrixAB() { + if ((m1 == null)|| (m2 == null)) { + throw new RuntimeException("Matrix not loaded"); + } + + try { + System.out.println("add Matrix called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + BigInteger[][] result = new BigInteger[m1.length][m2.length]; + + int i, j; + for (i = 0; i < m1.length; i++) { + for (j = 0; j < m2.length; j++) { + result [i][j] = m1 [i][j].add(m2 [i][j]); + } + } + System.out.println("Result Matrix (add)"); + System.out.println(Arrays.toString(result[0])); + System.out.println(Arrays.toString(result[1])); + System.out.println(); + return result; + } + + public BigInteger[][] multiplyMatrixAB() { + if ((m1 == null)|| (m2 == null)) { + throw new RuntimeException("Matrix not loaded"); + } + + try { + System.out.println("multiply Matrix called from "+getClientHost()); + } catch (ServerNotActiveException e) { + e.printStackTrace(); + } + BigInteger[][] result = new BigInteger[m1.length][m2.length]; + + int i, j, k; + BigInteger sum; + + for (i = 0; i < m1.length; i++) { + for (j = 0; j < m2.length; j++) { + sum = BigInteger.ZERO; + for (k = 0; k < m1.length; k++) { + sum = m1[i][k].multiply(m2[k][j]).add(sum); + } + result[i][j] = sum; + } + } + System.out.println("Result Matrix (multiply)"); + System.out.println(Arrays.toString(result[0])); + System.out.println(Arrays.toString(result[1])); + System.out.println(); + return result; + } + +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClient.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClient.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClient.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClient.java Tue May 16 06:51:00 2006 @@ -0,0 +1,112 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.io.IOException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.RMISocketFactory; +import java.util.Arrays; +import java.util.Vector; +import java.util.logging.Logger; + +import ar.org.fitc.test.rmi.tunneling.testrunner.Util; + +public class RemoteCalculatorClient { + + protected static Logger logger = Logger.getAnonymousLogger(); + + /* + * arg[0] ---> mode + * arg[1] ---> proxy ip number + * arg[2] ---> proxy port number + * arg[3] ---> client ip number + * arg[4] ---> rmi package supplier + * + */ + + @SuppressWarnings({"unchecked"}) + public static void main(String[] args) { + + if (args.length != 5) { + System.err.println("5 Parameters needed..."); + System.exit(1); + } + + System.setProperty("sun.rmi.transport.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000"); + + System.setProperty("http.proxyHost",args[1]); + System.setProperty("http.proxyPort",args[2]); + + if (args[4].equalsIgnoreCase("sun")) { + try { + RMISocketFactory.setSocketFactory(Util.getSunSocketFactory(args[0])); + } catch (IOException e1) { + e1.printStackTrace(); + } + } else if (args[4].equalsIgnoreCase("itc")) { + Util.setITCSocketFactoryMode(args[0]); + } + + String addr = args[3]; + if (addr == null) { + addr = "10.100.2.246"; + } + + Calculator remoteCalc = null; + Registry remoteRegistry = null; + + try { + logger.info("RemoteCalculatorClient locating RMI registry on remote host \""+ addr + "\"."); + remoteRegistry = LocateRegistry.getRegistry(addr); + + logger.info("RemoteCalculatorClient looking up service \""+ RemoteCalculator.SERVICENAME + "\"."); + remoteCalc = (Calculator) remoteRegistry.lookup(RemoteCalculator.SERVICENAME); + + int[][] a = new int[][] {{9,2},{6,4}}; + int[][] b = new int[][] {{1,4},{1,5}}; + + remoteCalc.setMatrixA(a); + remoteCalc.setMatrixB(b); + + System.out.println("Matrix A"); + System.out.println(Arrays.toString(a[0])); + System.out.println(Arrays.toString(a[1])); + System.out.println(); + + System.out.println("Matrix B"); + System.out.println(Arrays.toString(b[0])); + System.out.println(Arrays.toString(b[1])); + System.out.println(); + + System.out.println("Result Matrix (multiply)"); + System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[0])); + System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[1])); + System.out.println(); + + System.out.println("Result Matrix (add)"); + System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[0])); + System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[1])); + System.out.println(); + + + System.out.println("Vector"); + Vector v = new Vector(4); + v.add(new Double(50.21)); + v.add(new Double(2000.125)); + v.add(new Double(196.15)); + v.add(new Double(36.95)); + + remoteCalc.setVectorA(v); + + System.out.println(v.toString()); + System.out.println(); + + System.out.println("Standard Deviation: "+remoteCalc.getDevProm()[0]); + System.out.println("Average: "+remoteCalc.getDevProm()[1]); + + } catch (Exception e) { + logger.info("RemoteCalculatorClient problem with RemoteCalculator, exception:\n "+ e); + } + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClientBI.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClientBI.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClientBI.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorClientBI.java Tue May 16 06:51:00 2006 @@ -0,0 +1,133 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.io.IOException; +import java.math.BigInteger; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.RMISocketFactory; +import java.util.Arrays; +import java.util.Vector; +import java.util.logging.Logger; + +import ar.org.fitc.test.rmi.tunneling.testrunner.Util; + +public class RemoteCalculatorClientBI { + + private static Logger logger = Logger.getAnonymousLogger(); + + /* + * arg[0] ---> mode + * arg[1] ---> proxy ip number + * arg[2] ---> proxy port number + * arg[3] ---> client ip number + * arg[4] ---> rmi package supplier + * + */ + + @SuppressWarnings({"unchecked"}) + public static void main(String[] args) { + + if (args.length != 5) { + System.err.println("5 Parameters needed..."); + System.exit(1); + } + + System.setProperty("sun.rmi.transport.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000"); + + System.setProperty("http.proxyHost",args[1]); + System.setProperty("http.proxyPort",args[2]); + + try { + RMISocketFactory.setSocketFactory(new CipherRMISocketFactory()); + } catch (IOException e2) { + e2.printStackTrace(); + } + + + if (args[4].equalsIgnoreCase("sun")) { + try { + RMISocketFactory.setSocketFactory(Util.getSunSocketFactory(args[0])); + } catch (IOException e1) { + e1.printStackTrace(); + } + } else if (args[4].equalsIgnoreCase("itc")) { + Util.setITCSocketFactoryMode(args[0]); + } + + String addr = args[3]; + if (addr == null) { + addr = "10.100.2.246"; + } + + CalculatorBI remoteCalc = null; + Registry remoteRegistry = null; + + try { + logger.info("RemoteCalculatorClient locating RMI registry on remote host \""+ addr + "\"."); + remoteRegistry = LocateRegistry.getRegistry(addr); + + logger.info("RemoteCalculatorClient looking up service \""+ RemoteCalculatorBI.SERVICENAME + "\"."); + remoteCalc = (CalculatorBI) remoteRegistry.lookup(RemoteCalculatorBI.SERVICENAME); + + BigInteger[][] a = new BigInteger[2][2]; + a[0][0]=new BigInteger("9"); + a[0][1]=new BigInteger("2"); + a[1][0]=new BigInteger("6"); + a[1][1]=new BigInteger("4"); + + + + BigInteger[][] b = new BigInteger[2][2]; + b[0][0]=new BigInteger("1"); + b[0][1]=new BigInteger("4"); + b[1][0]=new BigInteger("1"); + b[1][1]=new BigInteger("5"); + + remoteCalc.setMatrixA(a); + remoteCalc.setMatrixB(b); + + System.out.println("Matrix A"); + System.out.println(Arrays.toString(a[0])); + System.out.println(Arrays.toString(a[1])); + System.out.println(); + + System.out.println("Matrix B"); + System.out.println(Arrays.toString(b[0])); + System.out.println(Arrays.toString(b[1])); + System.out.println(); + + System.out.println("Result Matrix (multiply)"); + System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[0])); + System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[1])); + System.out.println(); + + System.out.println("Result Matrix (add)"); + System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[0])); + System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[1])); + System.out.println(); + + + System.out.println("Vector"); + Vector v = new Vector(4); + v.add(new Double(50.21)); + v.add(new Double(2000.125)); + v.add(new Double(196.15)); + v.add(new Double(36.95)); + + remoteCalc.setVectorA(v); + + System.out.println(v.toString()); + System.out.println(); + + System.out.println("Standard Deviation: "+remoteCalc.getDevProm()[0]); + System.out.println("Average: "+remoteCalc.getDevProm()[1]); + + } catch (Exception e) { + logger.info("RemoteCalculatorClient problem with RemoteCalculator, exception:\n "+ e); + e.printStackTrace(); + + } + } +} Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorServer.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorServer.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorServer.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/tunneling/integration/RemoteCalculatorServer.java Tue May 16 06:51:00 2006 @@ -0,0 +1,44 @@ +package ar.org.fitc.test.rmi.tunneling.integration; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.util.logging.Logger; + +public class RemoteCalculatorServer { + + private static Logger logger = + Logger.getAnonymousLogger(); + + public static void main(String[] args) { + + System.setProperty("sun.rmi.transport.logLevel", "VERBOSE"); + System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE"); + + Registry localRegistry = null; + try { + localRegistry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); + } catch (RemoteException e) { + try { + localRegistry = LocateRegistry.getRegistry(Registry.REGISTRY_PORT); + } catch (RemoteException e1) { + e1.printStackTrace(); + } + } + + try { + RemoteCalculator rc = new RemoteCalculator(); + localRegistry.rebind(RemoteCalculator.SERVICENAME,rc); + logger.info("RemoteCalculator Server Ready."); + } catch (RemoteException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(3*60*6000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +}