Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 16300 invoked from network); 16 May 2006 13:56:53 -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:53 -0000 Received: (qmail 10367 invoked by uid 500); 16 May 2006 13:56:48 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 10208 invoked by uid 500); 16 May 2006 13:56:47 -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 9990 invoked by uid 99); 16 May 2006 13:56:46 -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:45 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,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:17 -0700 Received: (qmail 14421 invoked by uid 65534); 16 May 2006 13:55:57 -0000 Message-ID: <20060516135557.14417.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r406944 [26/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... 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/src/ar/org/fitc/test/rmi/server/TestRemoteObject.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObject.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObject.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObject.java Tue May 16 06:51:00 2006 @@ -0,0 +1,350 @@ +/* + * 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.server; + +import java.rmi.NoSuchObjectException; +import java.rmi.Remote; +import java.rmi.server.RemoteObject; +import java.rmi.server.RemoteRef; +import junit.framework.TestCase; +import ar.org.fitc.test.rmi.object2test.Echo; +import ar.org.fitc.test.rmi.object2test.EchoWithStubUnicast_Imp; +import ar.org.fitc.test.rmi.object2test.EchoUnicast_Imp; +import ar.org.fitc.test.rmi.object2test.MyRemoteRef; + +public class TestRemoteObject extends TestCase { + + private class MyRemoteObject extends RemoteObject { + private static final long serialVersionUID = -1684084133953032001L; + + public MyRemoteObject(RemoteRef r) { + super(r); + } + + public MyRemoteObject() { + super(); + } + } + + public RemoteObject constructor() { + return new MyRemoteObject(); + } + + public RemoteObject constructor(RemoteRef r) { + return new MyRemoteObject(r); + } + + /* + * Test method for 'java.rmi.server.RemoteObject.getRef()' + */ + public void testGetRef001() { + try { + RemoteObject ro = constructor(); + assertNull("not ref, make getRef to return null", ro.getRef()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testGetRef002() { + try { + RemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + assertSame("getRef return initial RemoteRef", rr, ro.getRef()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /* + * Test method for 'java.rmi.server.RemoteObject.equals(Object)' + */ + public void testEquals001() { + try { + RemoteObject ro = constructor(); + assertEquals("getRef return initial RemoteRef", ro.equals(ro), true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals002() { + try { + RemoteObject ro = constructor(); + assertEquals("getRef return initial RemoteRef", ro + .equals(constructor()), false); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals003() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = false; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + constructor()), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals004() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = true; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + constructor()), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals005() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = false; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + new EchoUnicast_Imp()), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals006() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = true; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + new EchoUnicast_Imp()), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals007() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = false; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + constructor(rr)), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals008() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = true; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + constructor(rr)), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals009() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = false; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + null), rr.bRemoteEquals); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testEquals010() { + try { + MyRemoteRef rr = new MyRemoteRef(); + rr.bRemoteEquals = true; + assertEquals("equals is ref.remoteEquals", constructor(rr).equals( + null), false); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /* + * Test method for 'java.rmi.server.RemoteObject.hashCode()' + */ + public void testHashCode001() { + try { + RemoteObject ro = constructor(); + assertEquals("HashCode may preserve", ro.hashCode(), ro.hashCode()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + public void testHashCode002() { + try { + MyRemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + rr.iHashCode = -5; + assertEquals("hashCode is ref.remoteHashCode", ro.hashCode(), + rr.iHashCode); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + public void testHashCode003() { + try { + MyRemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + rr.iHashCode = 100123012; + assertEquals("hashCode is ref.remoteHashCode", ro.hashCode(), + rr.iHashCode); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + /* + * Test method for 'java.rmi.server.RemoteObject.toString()' + */ + public void testToString001() { + try { + RemoteObject ro = constructor(); + assertEquals("toString must be equals RemoteObject casting", ro + .toString(), "" + ro); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + public void testToString002() { + try { + MyRemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + rr.sToString = "Hello"; + assertTrue("toString contains remoteToString", ro.toString() + .contains(rr.sToString)); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + public void testToString003() { + try { + MyRemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + rr.sToString = ""; + assertTrue("toString contains remoteToString", ro.toString() + .contains(rr.sToString)); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + public void testToString004() { + try { + MyRemoteRef rr = new MyRemoteRef(); + RemoteObject ro = constructor(rr); + rr.sToString = "This is a long phrase, very very long, sufficient like bothering a little. I Repite :" + + "This is a long phrase, very very long, sufficient like bothering a little. I Repite :" + + "This is a long phrase, very very long, sufficient like bothering a little. I Repite "; + assertTrue("toString contains remoteToString", ro.toString() + .contains(rr.sToString)); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + /* + * Test method for 'java.rmi.server.RemoteObject.toStub(Remote)' + */ + public void testToStub001() { + try { + Echo e = new EchoUnicast_Imp(); + Remote r = RemoteObject.toStub(e); + assertTrue("The remote return is an instance of Echo", + r instanceof Echo); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testToStub002() { + try { + RemoteObject.toStub(constructor()); + fail("Non export object make throw a exception"); + } catch (NoSuchObjectException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testToStub003() { + try { + RemoteObject.toStub(null); + fail("null make throw a exception"); + } catch (NoSuchObjectException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testToStub004() { + try { + Echo e = new EchoUnicast_Imp(); + Remote r = RemoteObject.toStub(e); + assertNotSame("Stub is not the object", r, e); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testToStub005() { + try { + Echo e = new EchoUnicast_Imp(); + assertEquals("Message count initial 0", 0, + ((EchoUnicast_Imp) e).msgCount); + Remote r = RemoteObject.toStub(e); + assertNotSame("Stub is not the object", r, e); + ((Echo) r).echo("hi"); + assertEquals("Message count finally 1", 1, + ((EchoUnicast_Imp) e).msgCount); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testToStub006() { + try { + Echo e = new EchoWithStubUnicast_Imp(); + Remote r = RemoteObject.toStub(e); + assertEquals("Stub is not the object", e, r); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObject.java ------------------------------------------------------------------------------ svn:executable = * Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObjectInvocationHandler.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObjectInvocationHandler.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObjectInvocationHandler.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObjectInvocationHandler.java Tue May 16 06:51:00 2006 @@ -0,0 +1,364 @@ +/* + * 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.server; + +import java.lang.reflect.Proxy; +import java.rmi.AlreadyBoundException; +import java.rmi.NotBoundException; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.UnexpectedException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.RemoteObject; +import java.rmi.server.RemoteObjectInvocationHandler; +import java.rmi.server.RemoteRef; +import java.rmi.server.RemoteStub; +import java.rmi.server.UnicastRemoteObject; +import junit.framework.TestCase; +import ar.org.fitc.test.rmi.object2test.BigEcho; +import ar.org.fitc.test.rmi.object2test.BigEcho_imp; +import ar.org.fitc.test.rmi.object2test.Echo; +import ar.org.fitc.test.rmi.object2test.EchoUnicast_Imp; +import ar.org.fitc.test.rmi.object2test.Echo_Imp; +import ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest003; +import ar.org.fitc.test.rmi.server.testclasses.LoaderRemoteClassTest; +import ar.org.fitc.test.util.Messages; + +public class TestRemoteObjectInvocationHandler extends TestCase implements + Messages { + + private RemoteObjectInvocationHandler r; + + private Registry reg; + + protected void setUp() throws Exception { + super.setUp(); + reg = LocateRegistry.createRegistry(1099); + } + + protected void tearDown() throws Exception { + super.tearDown(); + UnicastRemoteObject.unexportObject(reg, true); + } + + /* + * Test method for + * 'java.rmi.server.RemoteObjectInvocationHandler.RemoteObjectInvocationHandler(RemoteRef)' + */ + public final void testRemoteObjectInvocationHandler001() { + try { + + new RemoteObjectInvocationHandler(null); + fail("Shoud raise NullPointerException"); + } catch (NullPointerException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testRemoteObjectInvocationHandler002() { + try { + RemoteRef lightStatusRef = null; + + new RemoteObjectInvocationHandler(lightStatusRef); + fail("Shoud raise NullPointerException"); + } catch (NullPointerException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testRemoteObjectInvocationHandler003() + throws RemoteException { + Registry registry = LocateRegistry.getRegistry(); + try { + r = new RemoteObjectInvocationHandler(((RemoteStub) registry) + .getRef()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /* + * Test method for + * 'java.rmi.server.RemoteObjectInvocationHandler.invoke(Object, Method, + * Object[])' + */ + public final void testInvoke001() throws RemoteException { + Registry registry = LocateRegistry.getRegistry(); + r = new RemoteObjectInvocationHandler(((RemoteStub) registry).getRef()); + LoaderClassTest003 test = new LoaderClassTest003(); + Object o[] = null; + + try { + r.invoke(test, test.getClass().getMethod("proxy1"), o); + fail("Should raise IllegalArgumentException"); + } catch (IllegalArgumentException e) { + } catch (Throwable e) { + fail("Should raise IllegalArgumentException but raised:" + e); + } + } + + public final void testInvoke002() throws RemoteException { + Registry registry = LocateRegistry.getRegistry(); + r = new RemoteObjectInvocationHandler(((RemoteStub) registry).getRef()); + LoaderRemoteClassTest test = new LoaderRemoteClassTest(); + Object params[] = null; + try { + r.invoke(test, test.getClass().getMethod("getValue"), params); + fail("Should raise UnexpectedException"); + } catch (UnexpectedException e) { + } catch (Throwable e) { + fail("Should raise UnexpectedException but raised:" + e); + } + } + + public final void testInvoke003() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + try { + r = new RemoteObjectInvocationHandler(ref); + + r.invoke(proxy, Echo.class.getMethods()[0], new Object[] {}); + + fail("Same arguments is missing"); + } catch (RuntimeException e) { + + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke004() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + String toSend = "hola invoquer"; + try { + r = new RemoteObjectInvocationHandler(ref); + assertEquals("The result is what we expect", toSend, r.invoke( + proxy, Echo.class.getMethods()[0], new Object[] { toSend })); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke005() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + throw new RemoteException(msg); + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + String toSend = "hola invoquer"; + try { + r = new RemoteObjectInvocationHandler(ref); + r + .invoke(proxy, Echo.class.getMethods()[0], + new Object[] { toSend }); + } catch (RemoteException e) { + assertEquals("Exception must contain the msg", toSend, e.getCause() + .getMessage()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke006() throws RemoteException { + Echo_Imp eui = new Echo_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + Remote proxy = UnicastRemoteObject.exportObject(eui, 1100); + String toSend = "hola invoquer"; + r = (RemoteObjectInvocationHandler) Proxy.getInvocationHandler(proxy); + try { + assertEquals("The result is what we expect", toSend, r.invoke( + proxy, Echo.class.getMethods()[0], new Object[] { toSend })); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke007() throws RemoteException, + AlreadyBoundException, NotBoundException { + Echo_Imp eui = new Echo_Imp() { + public String echo(String msg) throws RemoteException { + throw new RemoteException(msg); + } + }; + Remote proxy = UnicastRemoteObject.exportObject(eui, 1100); + String toSend = "hola invoquer"; + r = (RemoteObjectInvocationHandler) Proxy.getInvocationHandler(proxy); + try { + + r + .invoke(proxy, Echo.class.getMethods()[0], + new Object[] { toSend }); + } catch (RemoteException e) { + assertEquals("Exception must contain the msg", toSend, e.getCause() + .getMessage()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke008() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + String toSend = "hola invoquer"; + try { + r = new RemoteObjectInvocationHandler(ref); + assertEquals("The result is what we expected", toSend, r.invoke( + proxy, Echo.class.getMethods()[0], new Object[] { toSend, + toSend })); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke009() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + try { + r = new RemoteObjectInvocationHandler(ref); + r.invoke(proxy, Echo.class.getMethods()[0], null); + fail("Same arguments are missing"); + } catch (RuntimeException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke010() throws RemoteException { + BigEcho_imp bei = new BigEcho_imp(); + RemoteRef ref = bei.getRef(); + BigEcho proxy = (BigEcho) RemoteObject.toStub(bei); + try { + r = new RemoteObjectInvocationHandler(ref); + assertNull(r.invoke(proxy, BigEcho.class.getMethod("echo"), null)); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke011() throws RemoteException { + BigEcho_imp bei = new BigEcho_imp() { + public void echo() throws RemoteException { + throw new RemoteException("Always pass throw here"); + } + + public void echo(Object... objs) throws RemoteException { + if (objs == null) { + throw new RemoteException("Objs Null"); + } + } + }; + RemoteRef ref = bei.getRef(); + BigEcho proxy = (BigEcho) RemoteObject.toStub(bei); + try { + r = new RemoteObjectInvocationHandler(ref); + assertNull(r.invoke(proxy, BigEcho.class.getMethods()[1], + new Object[] { new Object[] { 1, 2, 3, 4 } })); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke012() throws RemoteException { + BigEcho_imp bei = new BigEcho_imp() { + public void echo() throws RemoteException { + throw new RemoteException("Always pass throw here"); + } + + public void echo(Object... objs) throws RemoteException { + if (objs == null) { + throw new RemoteException("Objs Null"); + } + } + }; + RemoteRef ref = bei.getRef(); + BigEcho proxy = (BigEcho) RemoteObject.toStub(bei); + try { + r = new RemoteObjectInvocationHandler(ref); + assertNull(r.invoke(proxy, BigEcho.class.getMethods()[1], + new Object[] { new Object[] {} })); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke013() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + try { + r = new RemoteObjectInvocationHandler(ref); + r.invoke(proxy, Echo.class.getMethods()[0], new Object[] { 3 }); + } catch (IllegalArgumentException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testInvoke014() throws RemoteException { + EchoUnicast_Imp eui = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + return msg; + } + }; + RemoteRef ref = eui.getRef(); + Echo proxy = (Echo) RemoteObject.toStub(eui); + try { + r = new RemoteObjectInvocationHandler(ref); + r.invoke(proxy, Echo.class.getMethods()[0], new Object[] { null }); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteObjectInvocationHandler.java ------------------------------------------------------------------------------ svn:executable = * Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteServer.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteServer.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteServer.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteServer.java Tue May 16 06:51:00 2006 @@ -0,0 +1,160 @@ +/* + * 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.server; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.UnknownHostException; +import java.rmi.RemoteException; +import java.rmi.server.RemoteObject; +import java.rmi.server.RemoteRef; +import java.rmi.server.RemoteServer; +import java.rmi.server.ServerNotActiveException; +import java.security.Permission; +import java.util.logging.LoggingPermission; + +import ar.org.fitc.test.rmi.object2test.Echo; +import ar.org.fitc.test.rmi.object2test.EchoUnicast_Imp; +import ar.org.fitc.test.util.Net; + +public class TestRemoteServer extends TestRemoteObject { + + private class MyRemoteServer extends RemoteServer { + public MyRemoteServer(RemoteRef r) { + super(r); + } + + public MyRemoteServer() { + super(); + } + } + + public RemoteObject constructor() { + return new MyRemoteServer(); + } + + public RemoteObject constructor(RemoteRef r) { + return new MyRemoteServer(r); + } + + /* + * Test method for 'java.rmi.server.RemoteServer.getClientHost()' + */ + public void testGetClientHost001() { + try { + RemoteServer.getClientHost(); + fail("Nobody is using the server"); + } catch (ServerNotActiveException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testGetClientHost002() { + try { + EchoUnicast_Imp e = new EchoUnicast_Imp() { + public String echo(String msg) throws RemoteException { + + try { + assertEquals("The client is localhost", RemoteServer + .getClientHost(), Net.ip()); + } catch (ServerNotActiveException e) { + fail("It is working, no exception is expect"); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + return EchoUnicast_Imp.class + " - Have said: " + msg; + } + }; + Echo msg = (Echo) RemoteServer.toStub(e); + msg.echo("hi"); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /* + * Test method for 'java.rmi.server.RemoteServer.getLog()' + */ + public void testGetLog001() { + try { + RemoteServer.getLog(); + } catch (Throwable e) { + fail("Failed with:" + e); + } + + } + + /* + * Test method for 'java.rmi.server.RemoteServer.setLog(OutputStream)' + */ + public void testSetLog001() { + try { + RemoteServer.setLog(null); + assertNull("Not logger is set", RemoteServer.getLog()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testSetLog002() { + try { + RemoteServer.setLog(new ByteArrayOutputStream()); + assertNotNull("One logger is set", RemoteServer.getLog()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public void testSetLog003() { + SecurityManager smOld = System.getSecurityManager(); + try { + SecurityManager sm = new SecurityManager() { + public void checkPermission(Permission perm) { + if (perm instanceof LoggingPermission) + throw new SecurityException( + "No, No, No, you can't do that."); + } + }; + System.setSecurityManager(sm); + RemoteServer.setLog(null); + fail("SecurityMAnager not allow LoggingPermission"); + } catch (SecurityException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } finally { + System.setSecurityManager(smOld); + } + } + + public void testSetLog004() { + try { + OutputStream outS = RemoteServer.getLog(); + RemoteServer.setLog(new PrintStream(new ByteArrayOutputStream())); + RemoteServer.setLog(outS); + assertSame(outS, RemoteServer.getLog()); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRemoteServer.java ------------------------------------------------------------------------------ svn:executable = * Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestSuiteRMIServer.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestSuiteRMIServer.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestSuiteRMIServer.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestSuiteRMIServer.java Tue May 16 06:51:00 2006 @@ -0,0 +1,50 @@ +/* + * 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.server; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class TestSuiteRMIServer { + + public static void main(String[] args) { + junit.textui.TestRunner.run(TestSuiteRMIServer.suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite("Test for ar.org.fitc.test.rmi.server"); + + suite.addTestSuite(TestRMIClassLoader.class); + suite.addTestSuite(TestRMISocketFactory.class); + suite.addTestSuite(TestUID.class); + // suite.addTestSuite(TestOperation.class); + suite.addTestSuite(TestUnicastRemoteObject.class); + suite.addTestSuite(TestObjId.class); + suite.addTestSuite(TestRemoteObject.class); + suite.addTestSuite(TestRemoteObjectInvocationHandler.class); + // suite.addTestSuite(TestLogStream.class); + suite.addTestSuite(TestRemoteServer.class); + + return suite; + } + +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestSuiteRMIServer.java ------------------------------------------------------------------------------ svn:executable = * Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestUID.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestUID.java?rev=406944&view=auto ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestUID.java (added) +++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestUID.java Tue May 16 06:51:00 2006 @@ -0,0 +1,670 @@ +/* + * 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.server; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.rmi.server.UID; +import java.util.StringTokenizer; + +import junit.framework.TestCase; +import ar.org.fitc.test.util.Messages; + +public class TestUID extends TestCase implements Messages { + + UID uid = null; + + public static void main(String[] args) { + junit.textui.TestRunner.run(TestUID.class); + } + + public TestUID(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /* + * Test method for 'java.rmi.server.UID.UID()' + */ + public final void testUID001() { + assertNotNull(msgNotNull, new UID()); + } + + public final void testUID002() { + uid = new UID(); + for (int i = 0; i < 15; i++) { + assertNotSame(uid.toString(), new UID().toString()); + } + } + + /* + * Test method for 'java.rmi.server.UID.UID(short)' + */ + public final void testUIDShort001() { + short s = 0; + assertNotNull(msgNotNull, new UID(s)); + } + + public final void testUIDShort002() { + short s = Short.MIN_VALUE; + assertNotNull(msgNotNull, new UID(s)); + } + + public final void testUIDShort003() { + short s = Short.MAX_VALUE; + assertNotNull(msgNotNull, new UID(s)); + } + + public final void testUIDShort004() { + short s = 5594; + assertNotNull(msgNotNull, new UID(s)); + } + + public final void testUIDShort005() { + short s = 0; + uid = new UID(s); + for (int i = 0; i < 15; i++) { + assertNotSame(uid.toString(), new UID(s).toString()); + } + + } + + public final void testUIDShort006() { + short s = Short.MIN_VALUE; + uid = new UID(s); + for (int i = 0; i < 15; i++) { + assertNotSame(uid.toString(), new UID(s).toString()); + } + } + + public final void testUIDShort007() { + short s = Short.MAX_VALUE; + uid = new UID(s); + for (int i = 0; i < 15; i++) { + assertNotSame(uid.toString(), new UID(s).toString()); + } + } + + public final void testUIDShort008() { + short s = 5594; + uid = new UID(s); + for (int i = 0; i < 15; i++) { + assertNotSame(uid.toString(), new UID(s).toString()); + } + } + + /* + * Test method for 'java.rmi.server.UID.hashCode()' + */ + public final void testHashCode001() { + assertNotSame("must not be equals", new UID().hashCode(), new UID() + .hashCode()); + } + + public final void testHashCode002() { + uid = new UID(); + int hc = uid.hashCode(); + for (int i = 1; i < 15; i++) { + assertEquals("must be equals", uid.hashCode(), hc); + } + } + + public final void testHashCode003() { + short s = 555; + assertNotSame("must not be equals", new UID(s).hashCode(), new UID() + .hashCode()); + } + + public final void testHashCode004() { + + uid = new UID(); + int hc = uid.hashCode(); + for (int i = 1; i < 15; i++) { + assertEquals("must be equals", uid.hashCode(), hc); + } + } + + /* + * Test method for 'java.rmi.server.UID.equals(Object)' + */ + public void testEquals001() { + + uid = new UID(); + assertTrue("must be equals", uid.equals(uid)); + + } + + public void testEquals002() { + uid = new UID(); + assertFalse("mustn't be equals", uid.equals(null)); + + } + + public void testEquals003() { + uid = new UID(); + assertFalse("mustn't be equals", uid.equals(new UID())); + + } + + public void testEquals004() { + uid = new UID(); + UID uid2 = new UID(); + assertEquals("must be equals", uid2.equals(uid), uid.equals(uid2)); + + } + + public void testEquals005() { + uid = new UID(); + Object o = new Object(); + assertFalse("must not be equals", uid.equals(o)); + + } + + public void testEquals006() { + uid = new UID(); + assertFalse("must not be equals", uid.equals(null)); + + } + + public void testEquals007() { + uid = new UID(); + for (int i = 1; i < 10; i++) { + assertTrue("must be equals", uid.equals(uid)); + } + + } + + public void testEquals008() { + uid = new UID(); + for (int i = 1; i < 10; i++) { + assertFalse("mustn't be equals", uid.equals(null)); + } + + } + + public void testEquals009() { + uid = new UID(); + for (int i = 1; i < 10; i++) { + assertFalse("mustn't be equals", uid.equals(new UID())); + } + + } + + public void testEquals010() { + uid = new UID(); + UID uid2 = new UID(); + for (int i = 1; i < 10; i++) { + assertEquals("must be equals", uid2.equals(uid), uid.equals(uid2)); + } + + } + + public void testEquals011() { + uid = new UID(); + Object o = new Object(); + for (int i = 1; i < 10; i++) { + assertFalse("must not be equals", uid.equals(o)); + } + + } + + public void testEquals012() { + uid = new UID(); + for (int i = 1; i < 10; i++) { + assertFalse("must not be equals", uid.equals(null)); + } + + } + + public void testEquals013() { + short s = 555; + uid = new UID(s); + assertTrue("must be equals", uid.equals(uid)); + + } + + public void testEquals014() { + short s = 555; + uid = new UID(s); + assertFalse("mustn't be equals", uid.equals(null)); + + } + + public void testEquals015() { + short s = 555; + + uid = new UID(s); + assertTrue("mustn't be equals", uid.equals(new UID(s))); + + } + + public void testEquals016() { + short s = 555; + uid = new UID(s); + UID uid2 = new UID(s); + assertEquals("must be equals", uid2.equals(uid), uid.equals(uid2)); + + } + + public void testEquals017() { + short s = 555; + uid = new UID(s); + Object o = new Object(); + assertFalse("must not be equals", uid.equals(o)); + + } + + public void testEquals018() { + short s = 555; + uid = new UID(s); + assertFalse("must not be equals", uid.equals(null)); + + } + + public void testEquals019() { + short s = 555; + uid = new UID(s); + for (int i = 1; i < 10; i++) { + assertTrue("must be equals", uid.equals(uid)); + } + + } + + public void testEquals020() { + short s = 555; + uid = new UID(s); + for (int i = 1; i < 10; i++) { + assertFalse("mustn't be equals", uid.equals(null)); + } + + } + + public void testEquals021() { + short s = 555; + uid = new UID(s); + for (int i = 1; i < 10; i++) { + assertTrue("must be equals", uid.equals(new UID(s))); + } + + } + + public void testEquals022() { + short s = 555; + uid = new UID(s); + UID uid2 = new UID(s); + for (int i = 1; i < 10; i++) { + assertEquals("must be equals", uid2.equals(uid), uid.equals(uid2)); + } + + } + + public void testEquals023() { + short s = 555; + uid = new UID(s); + Object o = new Object(); + for (int i = 1; i < 10; i++) { + assertFalse("must not be equals", uid.equals(o)); + } + + } + + public void testEquals024() { + short s = 555; + uid = new UID(s); + for (int i = 1; i < 10; i++) { + assertFalse("must not be equals", uid.equals(null)); + } + } + + /* + * Test method for 'java.rmi.server.UID.toString()' + */ + public final void testToString001() { + short s = 0; + uid = new UID(s); + + String string = "0:0:0"; + assertEquals(uid.toString(), string); + } + + public final void testToString002() { + short s = 555; + uid = new UID(s); + + String string = "0:0:22b"; + assertEquals(uid.toString(), string); + } + + public final void testToString003() { + short s = Short.MIN_VALUE; + uid = new UID(s); + + String string = "0:0:-8000"; + assertEquals(uid.toString(), string); + } + + public final void testToString004() { + short s = Short.MAX_VALUE; + uid = new UID(s); + + String string = "0:0:7fff"; + assertEquals(uid.toString(), string); + } + + public final void testToString005() { + + uid = new UID(); + StringTokenizer st = new StringTokenizer(uid.toString(), ":"); + String s[] = new String[5]; + for (int i = 0; i < 3; i++) { + s[i] = st.nextToken(":"); + } + UID uid2 = new UID(); + StringTokenizer st2 = new StringTokenizer(uid2.toString(), ":"); + String s2[] = new String[5]; + for (int i = 0; i < 3; i++) { + s2[i] = st2.nextToken(":"); + } + for (int i = 0; i < 2; i++) { + assertEquals(s[i], s2[i]); + } + assertNotSame(s[2], s2[2]); + } + + /* + * Test method for 'java.rmi.server.UID.write(DataOutput)' + */ + public final void testWrite001() { + try { + uid = new UID(); + ByteArrayOutputStream baops = new ByteArrayOutputStream(); + DataOutputStream dops = new DataOutputStream(baops); + uid.write(dops); + + boolean zero = true; + for (int i = 0; i < baops.toByteArray().length; i++) { + if (baops.toByteArray()[i] != 0) { + zero = false; + } + } + assertFalse(zero); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite002() { + try { + uid = new UID(); + File file = new File("c:\\xx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "r"); + uid.write(raf); + fail("Should raise IOException"); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite003() { + try { + + short s = 0; + uid = new UID(s); + ByteArrayOutputStream baops = new ByteArrayOutputStream(); + DataOutputStream dops = new DataOutputStream(baops); + uid.write(dops); + + for (int i = 1; i < baops.toByteArray().length; i++) { + assertEquals(baops.toByteArray()[i], 0); + } + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite004() { + try { + short s = 0; + uid = new UID(s); + File file = new File("c:\\xx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "r"); + uid.write(raf); + fail("Should raise IOException"); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite005() { + try { + + short s = Short.MIN_VALUE; + uid = new UID(s); + ByteArrayOutputStream baops = new ByteArrayOutputStream(); + DataOutputStream dops = new DataOutputStream(baops); + uid.write(dops); + byte[] ba = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, 0, 0 }; + for (int i = 1; i < baops.toByteArray().length; i++) { + + assertEquals(baops.toByteArray()[i], ba[i]); + } + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite006() { + try { + short s = Short.MIN_VALUE; + uid = new UID(s); + File file = new File("c:\\xx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "r"); + uid.write(raf); + fail("Should raise IOException"); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite007() { + try { + + short s = Short.MAX_VALUE; + uid = new UID(s); + ByteArrayOutputStream baops = new ByteArrayOutputStream(); + DataOutputStream dops = new DataOutputStream(baops); + uid.write(dops); + byte[] ba = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, -1, 0 }; + for (int i = 1; i < baops.toByteArray().length; i++) { + assertEquals(baops.toByteArray()[i], ba[i]); + } + System.out.println(); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite008() { + try { + short s = Short.MAX_VALUE; + uid = new UID(s); + File file = new File("c:\\xx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "r"); + uid.write(raf); + fail("Should raise IOException"); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite009() { + try { + + short s = 5594; + uid = new UID(s); + ByteArrayOutputStream baops = new ByteArrayOutputStream(); + DataOutputStream dops = new DataOutputStream(baops); + uid.write(dops); + byte[] ba = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, -38 }; + for (int i = 1; i < baops.toByteArray().length; i++) { + assertEquals(baops.toByteArray()[i], ba[i]); + } + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testWrite010() { + try { + short s = 5594; + uid = new UID(s); + File file = new File("c:\\xx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "r"); + uid.write(raf); + fail("Should raise IOException"); + } catch (IOException e) { + assertTrue(true); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + /* + * Test method for 'java.rmi.server.UID.read(DataInput)' + */ + public final void testRead001() { + try { + byte[] ba = { -5, 67, 99, -111, 125, 124, 33, -11, 45, 63, 52, 14, + 21, -38 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + uid = UID.read(dis); + assertEquals(uid.toString(), "-4bc9c6f:7d7c21f52d3f340e:15da"); + + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testRead002() { + try { + byte[] ba = { 5, 67, 0, 33, 125, -124, 33, -11, 45, 63, 52, 0, 0, 0 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + uid = UID.read(dis); + + assertEquals(uid.toString(), "5430021:7d8421f52d3f3400:0"); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testRead003() { + try { + byte[] ba = { 4, -33, 57, 13, 0, 0, 0, 0, 0, 0, 0, 0, -21, -38 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + uid = UID.read(dis); + + assertEquals(uid.toString(), "4df390d:0:-1426"); + } catch (Throwable e) { + fail("Failed with:" + e); + } + } + + public final void testRead004() { + byte[] ba = { 0, 0, 0, 0, -22, 124, 33, -11, 55, 25, 1, 111, 99, -99 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + try { + uid = UID.read(dis); + } catch (Throwable e) { + fail("Failed with:" + e); + } + assertEquals(uid.toString(), "0:-1583de0ac8e6fe91:639d"); + } + + public final void testRead005() { + byte[] ba = { -5, 67, 99, -111, 125, 38, 33, -11, 45, 63, 52, 14, 21, + -38 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + try { + uid = UID.read(dis); + } catch (Throwable e) { + fail("Failed with:" + e); + } + assertEquals(uid.toString(), "-4bc9c6f:7d2621f52d3f340e:15da"); + } + + public final void testRead006() { + byte[] ba = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ByteArrayInputStream baops = new ByteArrayInputStream(ba); + DataInputStream dis = new DataInputStream(baops); + try { + uid = UID.read(dis); + } catch (Throwable e) { + fail("Failed with:" + e); + } + assertEquals(uid.toString(), "0:0:0"); + } + + public final void testRead007() throws FileNotFoundException { + File file = new File("c:\\xxxx.bin"); + RandomAccessFile raf = new RandomAccessFile(file, "rwd"); + try { + + UID.read(raf); + fail("Should raise IOException"); + } catch (IOException e) { + } catch (Throwable e) { + fail("Failed with:" + e); + } + } +} Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestUID.java ------------------------------------------------------------------------------ svn:executable = *