You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/05/16 15:52:07 UTC
svn commit: r406944 [25/30] - in
/incubator/harmony/enhanced/classlib/trunk/modules/rmi2: ./ build/ doc/
doc/testing/ doc/testing/rmi http tunneling/ doc/testing/rmi http
tunneling/Results - ITC/ doc/testing/rmi http tunneling/Results - SUN/
doc/testin...
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestLocateRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestLocateRegistry.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestLocateRegistry.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestLocateRegistry.java Tue May 16 06:51:00 2006
@@ -0,0 +1,508 @@
+/*
+ * 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.registry;
+
+import java.net.MalformedURLException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
+
+import javax.rmi.ssl.SslRMIClientSocketFactory;
+import javax.rmi.ssl.SslRMIServerSocketFactory;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.util.Messages;
+
+public class TestLocateRegistry extends TestCase implements Messages {
+
+ private static int port = 1999;
+
+ public static void main(String[] args) {
+ }
+
+ public TestLocateRegistry(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ port += 1;
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.createRegistry(int)'
+ */
+ public void testCreateRegistryInt001() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.createRegistry(port));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryInt002() {
+ try {
+ LocateRegistry.createRegistry(port);
+ LocateRegistry.createRegistry(port);
+ fail("Two registry with same port is imposible");
+ } catch (RemoteException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryInt003() {
+ try {
+ LocateRegistry.createRegistry(-port);
+ fail("non negative number can't be port");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryInt004() {
+ try {
+ LocateRegistry.createRegistry(99999);
+ fail("The port is bounded of top");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ // REGISTRY_PORT=1099
+ public void testCreateRegistryInt005() {
+ try {
+
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.createRegistry(int,
+ * RMIClientSocketFactory, RMIServerSocketFactory)'
+ */
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory001() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.createRegistry(port,
+ RMISocketFactory.getDefaultSocketFactory(),
+ RMISocketFactory.getDefaultSocketFactory()));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory002() {
+ try {
+ LocateRegistry.createRegistry(port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ LocateRegistry.createRegistry(port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("Two registry with same port is imposible");
+ } catch (RemoteException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory003() {
+ try {
+ LocateRegistry.createRegistry(-port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("non negative number can't be port");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory004() {
+ try {
+ LocateRegistry.createRegistry(99999, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("The port is bounded of top");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory005() {
+ try {
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT,
+ RMISocketFactory.getDefaultSocketFactory(),
+ RMISocketFactory.getDefaultSocketFactory()));
+ } catch (RemoteException re) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory006() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory()));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory007() {
+ try {
+ LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("Two registry with same port is imposible");
+ } catch (RemoteException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory008() {
+ try {
+ LocateRegistry.createRegistry(-port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("non negative number can't be port");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory009() {
+ try {
+ LocateRegistry.createRegistry(99999,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("The port is bounded of top");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory010() {
+ try {
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory()));
+ } catch (RemoteException re) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory011() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.createRegistry(port,
+ RMISocketFactory.getDefaultSocketFactory(),
+ new SslRMIServerSocketFactory()));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory012() {
+ try {
+ LocateRegistry.createRegistry(port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ LocateRegistry.createRegistry(port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("Two registry with same port is imposible");
+ } catch (RemoteException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory013() {
+ try {
+ LocateRegistry.createRegistry(-port, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("non negative number can't be port");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory014() {
+ try {
+ LocateRegistry.createRegistry(99999, RMISocketFactory
+ .getDefaultSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("The port is bounded of top");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory015() {
+ try {
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT,
+ RMISocketFactory.getDefaultSocketFactory(),
+ new SslRMIServerSocketFactory()));
+ } catch (RemoteException re) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory016() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(),
+ new SslRMIServerSocketFactory()));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory017() {
+ try {
+ LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ LocateRegistry.createRegistry(port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("Two registry with same port is imposible");
+ } catch (RemoteException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory018() {
+ try {
+ LocateRegistry.createRegistry(-port,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("non negative number can't be port");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory019() {
+ try {
+ LocateRegistry.createRegistry(99999,
+ new SslRMIClientSocketFactory(), RMISocketFactory
+ .getDefaultSocketFactory());
+ fail("The port is bounded of top");
+ } catch (RuntimeException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory020() {
+ try {
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT,
+ new SslRMIClientSocketFactory(),
+ new SslRMIServerSocketFactory()));
+ fail("Should raise RemoteException");
+ } catch (RemoteException re) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testCreateRegistryIntRMIClientSocketFactoryRMIServerSocketFactory021() {
+ try {
+ assertNotNull(LocateRegistry.createRegistry(Registry.REGISTRY_PORT,
+ new SslRMIClientSocketFactory(),
+ new SslRMIServerSocketFactory()));
+ fail("Should raise RemoteException");
+ } catch (RemoteException re) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.getRegistry()'
+ */
+ public void testGetRegistry001() {
+ try {
+ assertNotNull(LocateRegistry.getRegistry());
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.getRegistry(int)'
+ */
+ public void testGetRegistryInt001() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.getRegistry(port));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryInt002() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.getRegistry(port));
+ assertNotNull(msgNotNull, LocateRegistry.getRegistry(port));
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryInt003() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.getRegistry(-port));
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryInt004() {
+ try {
+ assertNotNull(msgNotNull, LocateRegistry.getRegistry(99999));
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ // REGISTRY_PORT=1099
+ public void testGetRegistryInt005() {
+ try {
+ assertNotNull(LocateRegistry.getRegistry(Registry.REGISTRY_PORT));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.getRegistry(String)'
+ */
+ public void testGetRegistryString001() {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("localhost"));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryString002() {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("ltrsjyat"));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.getRegistry(String,
+ * int)'
+ */
+ public void testGetRegistryStringInt001() throws RemoteException,
+ MalformedURLException {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("ltrsjyat", 1));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryStringInt002() throws RemoteException,
+ MalformedURLException {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("ltrsjyat", 1000));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryStringInt003() throws RemoteException,
+ MalformedURLException {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("localhost", 1099));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryStringInt004() throws RemoteException,
+ MalformedURLException {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("localhost", -999));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public void testGetRegistryStringInt005() throws RemoteException,
+ MalformedURLException {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("localhost", 0));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.registry.LocateRegistry.getRegistry(String, int, RMIClientSocketFactory)'
+ */
+ public void testGetRegistryStringIntRMIClientSocketFactory001() {
+ try {
+ assertNotNull(LocateRegistry.getRegistry("ltrsjyat", 1,
+ new SslRMIClientSocketFactory()));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestLocateRegistry.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestSuiteRMIRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestSuiteRMIRegistry.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestSuiteRMIRegistry.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestSuiteRMIRegistry.java Tue May 16 06:51:00 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.registry;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class TestSuiteRMIRegistry {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestSuiteRMIRegistry.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for ar.org.fitc.test.rmi.registry");
+
+ suite.addTestSuite(TestLocateRegistry.class);
+
+ return suite;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/registry/TestSuiteRMIRegistry.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestLogStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestLogStream.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestLogStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestLogStream.java Tue May 16 06:51:00 2006
@@ -0,0 +1,245 @@
+/*
+ * 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.FileOutputStream;
+import java.io.PrintStream;
+import java.rmi.server.LogStream;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.util.Messages;
+
+public class TestLogStream extends TestCase implements Messages {
+ LogStream ls = null;
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestLogStream.class);
+ }
+
+ public TestLogStream(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.log(String)'
+ */
+
+ public final void testLog001() {
+ assertNotNull(msgNotNull, LogStream.log(""));
+ }
+
+ public final void testLog002() {
+ assertNotNull(msgNotNull, LogStream
+ .log("p´¿'269572´y t{+oñ_ÑL=)\"&!(0%=)"));
+ }
+
+ public final void testLog003() {
+ assertNotNull(msgNotNull, LogStream.log("no"));
+ }
+
+ public final void testLog004() {
+ assertNotNull(msgNotNull, LogStream.log("brief"));
+ }
+
+ public final void testLog005() {
+ assertNotNull(msgNotNull, LogStream.log("verbose"));
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.getDefaultStream()'
+ */
+
+ public final void testGetDefaultStream001() {
+ byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
+ 16 };
+ ByteArrayOutputStream bas = new ByteArrayOutputStream();
+ try {
+ bas.write(ba);
+ PrintStream ps1 = new PrintStream(bas);
+ ls = LogStream.log("tcp");
+ ls.setDefaultStream(ps1);
+ PrintStream ps2 = ls.getDefaultStream();
+ ps2.flush();
+ assertEquals(ps1, ps2);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testGetDefaultStream002() {
+ byte[] ba = new byte[0];
+ ByteArrayOutputStream bas = new ByteArrayOutputStream();
+ try {
+ bas.write(ba);
+ PrintStream ps1 = new PrintStream(bas);
+ ls = LogStream.log("tcp");
+ ls.setDefaultStream(ps1);
+ PrintStream ps2 = ls.getDefaultStream();
+ assertEquals(ps1, ps2);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testGetDefaultStream003() {
+ byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
+ 16 };
+ ByteArrayOutputStream bas = new ByteArrayOutputStream();
+ try {
+ PrintStream ps1 = new PrintStream(bas);
+ ls = LogStream.log("tcp");
+
+ PrintStream ps2 = ls.getDefaultStream();
+ ps2.flush();
+ int i = 1;
+ assertNotNull(ps2);
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.toString()'
+ */
+ public final void testToString001() {
+ try {
+ assertEquals(LogStream.log("no").toString(), "no");
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testToString002() {
+ assertEquals(LogStream.log("verbose").toString(), "verbose");
+ }
+
+ public final void testToString003() {
+ assertEquals(LogStream.log("VERBOSE").toString(), "VERBOSE");
+ }
+
+ public final void testToString004() {
+ try {
+ assertEquals(LogStream.log("").toString(), "");
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.write(int)'
+ */
+ public final void testWriteInt() {
+ try {
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.write(byte[], int, int)'
+ */
+ public final void testWriteByteArrayIntInt() {
+ try {
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.getOutputStream()'
+ */
+ public final void testGetOutputStream() {
+ try {
+
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.setOutputStream(OutputStream)'
+ */
+ public final void testSetOutputStream() {
+ try {
+ FileOutputStream tcpLogFile = new FileOutputStream("C:\\tcplog.txt");
+ ls = LogStream.log("tcp");
+ ls.setOutputStream(tcpLogFile);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.LogStream.parseLevel(String)'
+ */
+
+ public final void testParseLevel001() {
+ try {
+ ls = LogStream.log("tcp");
+ int i = ls.parseLevel("VERBOSE");
+ assertEquals(i, 20);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testParseLevel002() {
+ try {
+ ls = LogStream.log("tcp");
+ int i = ls.parseLevel("BRIEF");
+ assertEquals(i, 10);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testParseLevel003() {
+ try {
+ ls = LogStream.log("tcp");
+ int i = ls.parseLevel("SILENT");
+ assertEquals(i, 0);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testParseLevel004() {
+ try {
+ int i = LogStream.log("tcp").parseLevel("tcp");
+ assertEquals(i, -1);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestLogStream.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestObjId.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestObjId.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestObjId.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestObjId.java Tue May 16 06:51:00 2006
@@ -0,0 +1,599 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.rmi.server.ObjID;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.util.Messages;
+
+public class TestObjId extends TestCase implements Messages {
+ ObjID oid = null;
+
+ int i = 0;
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestObjId.class);
+ }
+
+ public TestObjId(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.ObjID()'
+ */
+ public final void testObjID001() {
+ assertNotNull(msgNotNull, new ObjID());
+ }
+
+ public final void testObjID002() {
+ oid = new ObjID();
+ for (int i = 0; i < 15; i++) {
+ assertNotSame(oid.toString(), new ObjID().toString());
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.ObjID(int)'
+ */
+ public final void testObjIDInt001() {
+ assertNotNull(msgNotNull, new ObjID(i));
+ }
+
+ public final void testObjIDInt002() {
+ i = Integer.MIN_VALUE;
+ assertNotNull(msgNotNull, new ObjID(i));
+ }
+
+ public final void testObjIDInt003() {
+ i = Integer.MAX_VALUE;
+ assertNotNull(msgNotNull, new ObjID(i));
+ }
+
+ public final void testObjIDInt004() {
+ i = 5594;
+ assertNotNull(msgNotNull, new ObjID(i));
+ }
+
+ public final void testObjIDInt005() {
+ i = 0;
+ oid = new ObjID(i);
+ for (int i = 0; i < 15; i++) {
+ assertNotSame(oid.toString(), new ObjID(i).toString());
+ }
+ }
+
+ public final void testObjIDInt006() {
+ i = Integer.MIN_VALUE;
+ oid = new ObjID(i);
+ for (int i = 0; i < 15; i++) {
+ assertNotSame(oid.toString(), new ObjID(i).toString());
+ }
+ }
+
+ public final void testObjIDInt007() {
+ i = Integer.MAX_VALUE;
+ oid = new ObjID(i);
+ for (int i = 0; i < 15; i++) {
+ assertNotSame(oid.toString(), new ObjID(i).toString());
+ }
+ }
+
+ public final void testObjIDInt008() {
+ i = 5594;
+ oid = new ObjID(i);
+ for (int i = 0; i < 15; i++) {
+ assertNotSame(oid.toString(), new ObjID(i).toString());
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.hashCode()'
+ */
+ public final void testHashCode001() {
+ assertNotSame("must not be equals", new ObjID().hashCode(), new ObjID()
+ .hashCode());
+ }
+
+ public final void testHashCode002() {
+ oid = new ObjID();
+ int hc = oid.hashCode();
+ for (int i = 1; i < 15; i++) {
+ assertEquals("must be equals", oid.hashCode(), hc);
+ }
+ }
+
+ public final void testHashCode003() {
+ i = 555;
+ assertNotSame("must not be equals", new ObjID(i).hashCode(),
+ new ObjID().hashCode());
+ }
+
+ public final void testHashCode004() {
+ i = 555;
+ oid = new ObjID();
+ int hc = oid.hashCode();
+ for (int i = 1; i < 15; i++) {
+ assertEquals("must be equals", oid.hashCode(), hc);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.equals(Object)'
+ */
+ public void testEquals001() {
+
+ oid = new ObjID();
+ assertTrue("must be equals", oid.equals(oid));
+
+ }
+
+ public void testEquals002() {
+ oid = new ObjID();
+ assertFalse("mustn't be equals", oid.equals(null));
+
+ }
+
+ public void testEquals003() {
+ oid = new ObjID();
+ assertFalse("mustn't be equals", oid.equals(new ObjID()));
+
+ }
+
+ public void testEquals004() {
+ oid = new ObjID();
+ ObjID uid2 = new ObjID();
+ assertEquals("must be equals", uid2.equals(oid), oid.equals(uid2));
+
+ }
+
+ public void testEquals005() {
+ oid = new ObjID();
+ Object o = new Object();
+ assertFalse("must not be equals", oid.equals(o));
+
+ }
+
+ public void testEquals006() {
+ oid = new ObjID();
+ assertFalse("must not be equals", oid.equals(null));
+
+ }
+
+ public void testEquals007() {
+ oid = new ObjID();
+ for (int i = 1; i < 10; i++) {
+ assertTrue("must be equals", oid.equals(oid));
+ }
+
+ }
+
+ public void testEquals008() {
+ oid = new ObjID();
+ for (int i = 1; i < 10; i++) {
+ assertFalse("mustn't be equals", oid.equals(null));
+ }
+
+ }
+
+ public void testEquals009() {
+ oid = new ObjID();
+ for (int i = 1; i < 10; i++) {
+ assertFalse("mustn't be equals", oid.equals(new ObjID()));
+ }
+
+ }
+
+ public void testEquals010() {
+ oid = new ObjID();
+ ObjID uid2 = new ObjID();
+ for (int i = 1; i < 10; i++) {
+ assertEquals("must be equals", uid2.equals(oid), oid.equals(uid2));
+ }
+
+ }
+
+ public void testEquals011() {
+ oid = new ObjID();
+ Object o = new Object();
+ for (int i = 1; i < 10; i++) {
+ assertFalse("must not be equals", oid.equals(o));
+ }
+
+ }
+
+ public void testEquals012() {
+ oid = new ObjID();
+ for (int i = 1; i < 10; i++) {
+ assertFalse("must not be equals", oid.equals(null));
+ }
+
+ }
+
+ public void testEquals013() {
+ i = 555;
+ oid = new ObjID(i);
+ assertTrue("must be equals", oid.equals(oid));
+
+ }
+
+ public void testEquals014() {
+ i = 555;
+ oid = new ObjID(i);
+ assertFalse("mustn't be equals", oid.equals(null));
+
+ }
+
+ public void testEquals015() {
+ i = 555;
+
+ oid = new ObjID(i);
+ assertTrue("mustn't be equals", oid.equals(new ObjID(i)));
+
+ }
+
+ public void testEquals016() {
+ i = 555;
+ oid = new ObjID(i);
+ ObjID uid2 = new ObjID(i);
+ assertEquals("must be equals", uid2.equals(oid), oid.equals(uid2));
+
+ }
+
+ public void testEquals017() {
+ i = 555;
+ oid = new ObjID(i);
+ Object o = new Object();
+ assertFalse("must not be equals", oid.equals(o));
+
+ }
+
+ public void testEquals018() {
+ i = 555;
+ oid = new ObjID(i);
+ assertFalse("must not be equals", oid.equals(null));
+
+ }
+
+ public void testEquals019() {
+ i = 555;
+ oid = new ObjID(i);
+ for (int i = 1; i < 10; i++) {
+ assertTrue("must be equals", oid.equals(oid));
+ }
+
+ }
+
+ public void testEquals020() {
+ i = 555;
+ oid = new ObjID(i);
+ for (int i = 1; i < 10; i++) {
+ assertFalse("mustn't be equals", oid.equals(null));
+ }
+
+ }
+
+ public void testEquals021() {
+ i = 555;
+ oid = new ObjID(i);
+ for (int i = 1; i < 10; i++) {
+ assertFalse("mustn't be equals", oid.equals(new ObjID(i)));
+ }
+
+ }
+
+ public void testEquals022() {
+ i = 555;
+ oid = new ObjID(i);
+ ObjID uid2 = new ObjID(i);
+ for (int i = 1; i < 10; i++) {
+ assertEquals("must be equals", uid2.equals(oid), oid.equals(uid2));
+ }
+
+ }
+
+ public void testEquals023() {
+ i = 555;
+ oid = new ObjID(i);
+ Object o = new Object();
+ for (int i = 1; i < 10; i++) {
+ assertFalse("must not be equals", oid.equals(o));
+ }
+
+ }
+
+ public void testEquals024() {
+ i = 555;
+ oid = new ObjID(i);
+ for (int i = 1; i < 10; i++) {
+ assertFalse("must not be equals", oid.equals(null));
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.toString()'
+ */
+ public final void testToString001() {
+ i = 0;
+ oid = new ObjID(i);
+
+ String string = "[0:0:0, 0]";
+ assertEquals(oid.toString(), string);
+ }
+
+ public final void testToString002() {
+ i = 555;
+ oid = new ObjID(i);
+
+ String string = "[0:0:0, 555]";
+ assertEquals(oid.toString(), string);
+ }
+
+ public final void testToString003() {
+ i = Short.MIN_VALUE;
+ oid = new ObjID(i);
+
+ String string = "[0:0:0, -32768]";
+
+ assertEquals(oid.toString(), string);
+
+ }
+
+ public final void testToString004() {
+ i = Short.MAX_VALUE;
+ oid = new ObjID(i);
+
+ String string = "[0:0:0, 32767]";
+
+ assertEquals(oid.toString(), string);
+
+ }
+
+ public final void testToString005() {
+ oid = new ObjID();
+
+ String string = "[46]";
+ assertEquals(string, oid.toString());
+ ObjID oid2 = new ObjID();
+ String string2 = "[47]";
+ assertEquals(string2, oid2.toString());
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.write(ObjectOutput)'
+ */
+ public final void testWrite001() {
+ try {
+ oid = new ObjID();
+ ByteArrayOutputStream baops = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baops);
+ oid.write(oos);
+ 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 testWrite003() {
+ try {
+
+ int s = 0;
+ oid = new ObjID(s);
+ ByteArrayOutputStream baops = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baops);
+ oid.write(oos);
+
+ boolean zero = true;
+ for (int i = 0; i < baops.toByteArray().length; i++) {
+ // System.out.println(baops.toByteArray()[i]);
+ if (baops.toByteArray()[i] != 0) {
+ zero = false;
+ }
+ }
+
+ assertFalse(zero);
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testWrite005() {
+ try {
+ int s = 1;
+ oid = new ObjID(s);
+ ByteArrayOutputStream baops = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baops);
+ oid.write(oos);
+ 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 testWrite007() {
+ try {
+
+ int s = Integer.MAX_VALUE;
+ oid = new ObjID(s);
+ ByteArrayOutputStream baops = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baops);
+ oid.write(oos);
+ 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 testWrite009() {
+ try {
+
+ int s = 5594;
+ oid = new ObjID(s);
+ ByteArrayOutputStream baops = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baops);
+ oid.write(oos);
+ 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);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.ObjID.read(ObjectInput)'
+ */
+
+ public final void testRead001() {
+ try {
+
+ byte[] b = { -84, -19, 0, 5, 119, 22, 0, 0, 0, 0, 127, -1, -1, -1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ ByteArrayInputStream baops = new ByteArrayInputStream(b);
+ ObjectInputStream dis = new ObjectInputStream(baops);
+ ObjID.read(dis);
+ // assertEquals(oid.toString(),"-4bc9c6f:7d7c21f52d3f340e:15da");
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testRead002() {
+ try {
+
+ byte[] b = { -84, -19, 0, 5, 119, 22, 0, 0, 0, 0, 0, 0, 21, -38, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ ByteArrayInputStream baops = new ByteArrayInputStream(b);
+ ObjectInputStream dis = new ObjectInputStream(baops);
+ oid = ObjID.read(dis);
+ assertEquals(oid.toString(), "[0:0:0, 5594]");
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testRead003() {
+ try {
+ PipedInputStream pi = new PipedInputStream();
+ PipedOutputStream po = new PipedOutputStream(pi);
+ ObjectOutputStream oo = new ObjectOutputStream(po);
+ ObjectInputStream oi = new ObjectInputStream(pi);
+ oid = new ObjID(3452432);
+ oid.write(oo);
+ oo.flush();
+ assertEquals(oid, ObjID.read(oi));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testRead004() {
+ final String myException = "algo especial que decir??";
+ try {
+
+ oid = ObjID.read(new ObjectInputStream(new InputStream() {
+ public int read() throws IOException {
+ throw new IOException(myException);
+ };
+ }));
+ fail("Must fail");
+
+ } catch (IOException e) {
+ assertEquals(myException, e.getMessage());
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testRead006() {
+ try {
+ byte[] b = { -84, -19, 0, 5, 119, 22, 0, 0, 0, 0, 0, 0, 21, -38, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ ByteArrayInputStream baops = new ByteArrayInputStream(b);
+ oid = ObjID.read(new ObjectInputStream(baops));
+ baops.reset();
+ assertEquals(oid, ObjID.read(new ObjectInputStream(baops)));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+ public final void testRead007() {
+ try {
+ byte[] b = { -84, -19, 0, 5, 119, 22, 0, 0, 0, 0, 0, 0, 21, -38, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ ByteArrayInputStream baops = new ByteArrayInputStream(b);
+ oid = ObjID.read(new ObjectInputStream(baops));
+ baops.reset();
+ assertNotSame(oid, ObjID.read(new ObjectInputStream(baops)));
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestObjId.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestOperation.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestOperation.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestOperation.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestOperation.java Tue May 16 06:51:00 2006
@@ -0,0 +1,103 @@
+/*
+ * 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.server.Operation;
+
+import ar.org.fitc.test.util.Messages;
+
+import junit.framework.TestCase;
+
+public class TestOperation extends TestCase implements Messages {
+ Operation o;
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestOperation.class);
+ }
+
+ public TestOperation(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'java.rmi.server.Operation.Operation(String)'
+ */
+ public void testOperation001() {
+ assertNotNull(msgNotNull, new Operation(
+ "greaqy5m, o8985453|´*'00/08.8,-"));
+ }
+
+ public void testOperation002() {
+ assertNotNull(msgNotNull, new Operation(""));
+ }
+
+ public void testOperation003() {
+ assertNotNull(msgNotNull, new Operation(null));
+ }
+
+ /*
+ * Test method for 'java.rmi.server.Operation.getOperation()'
+ */
+ public void testGetOperation001() {
+ o = new Operation("xfohgtrajytklourfiñourfysahtawt'37iú6-szhk'´4w798'2");
+ assertEquals("xfohgtrajytklourfiñourfysahtawt'37iú6-szhk'´4w798'2", o
+ .getOperation());
+ }
+
+ public void testGetOperation002() {
+ o = new Operation("");
+ assertEquals("", o.getOperation());
+ }
+
+ public void testGetOperation003() {
+ o = new Operation(null);
+ assertEquals(null, o.getOperation());
+ }
+
+ /*
+ * Test method for 'java.rmi.server.Operation.toString()'
+ */
+
+ public void testToString001() {
+ o = new Operation("xfohgtrajytklourfiñourfysahtawt'37iú6-szhk'´4w798'2");
+ assertEquals("xfohgtrajytklourfiñourfysahtawt'37iú6-szhk'´4w798'2", o
+ .toString());
+ }
+
+ public void testToString002() {
+ o = new Operation("");
+ assertEquals("", o.toString());
+ }
+
+ public void testToString003() {
+ o = new Operation(null);
+ assertEquals(null, o.toString());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestOperation.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMIClassLoader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMIClassLoader.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMIClassLoader.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMIClassLoader.java Tue May 16 06:51:00 2006
@@ -0,0 +1,625 @@
+/*
+ * 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.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.NotBoundException;
+import java.rmi.RMISecurityManager;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClassLoader;
+import java.security.Permission;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002;
+import ar.org.fitc.test.util.MyClassLoader;
+
+public class TestRMIClassLoader extends TestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestRMIClassLoader.class);
+ }
+
+ static final String path = System.getProperties().get("user.dir")
+ .toString();
+
+ static final String pathOwnClass = path + File.separatorChar + ".."
+ + File.separatorChar + "RMIClassToLoad" + File.separatorChar;
+
+ public TestRMIClassLoader(String name) {
+ super(name);
+
+ }
+
+ private void LoadClassStringString(String clase, boolean url) {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ try {
+ if (url) {
+ RMIClassLoader.loadClass(new URL("file://" + pathOwnClass),
+ clase);
+ } else {
+ RMIClassLoader.loadClass("file://" + pathOwnClass, clase);
+ }
+ } catch (Throwable e) {
+ fail("Failed with: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+
+ }
+
+ private void LoadClassStringStringClassLoader(String path, String clase,
+ String name) throws MalformedURLException {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ try {
+ File f = new File(pathOwnClass);
+ if (f.exists() && f.isDirectory()) {
+ URL list[] = { new URL("file://" + pathOwnClass) };
+ try {
+ RMIClassLoader.loadClass(path, clase, new URLClassLoader(
+ list));
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ } else {
+ System.err
+ .println("Directory: " + pathOwnClass + " not found.");
+ System.err.println(name + " disabled.");
+ fail("TEST DISABLED");
+ }
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ System.setProperty("java.rmi.server.codebase", "file://" + path);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.getClassAnnotation(Class<?>)'
+ */
+ public final void testGetClassAnnotation001() {
+ assertNotNull(RMIClassLoader
+ .getClassAnnotation(LoaderClassTest002.class));
+ }
+
+ public final void testGetClassAnnotation002() throws RemoteException,
+ MalformedURLException, NotBoundException {
+ assertEquals("file://" + path, RMIClassLoader
+ .getClassAnnotation(LoaderClassTest002.class));
+ }
+
+ public final void testGetClassAnnotation003() {
+ try {
+ RMIClassLoader.getClassAnnotation(null);
+ fail("Should raise NullPointerException");
+ } catch (NullPointerException e) {
+ } catch (Throwable e) {
+ fail("Should raise NullPointerException but raised: " + e);
+ }
+ }
+
+ public final void testGetClassAnnotation004() {
+ System.getProperties().remove("java.rmi.server.codebase");
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.getClassLoader(String)'
+ */
+ public final void testGetClassLoader001() {
+ try {
+ assertNotNull(RMIClassLoader.getClassLoader(null));
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+
+ public final void testGetClassLoader002() {
+ try {
+
+ RMIClassLoader.getClassLoader("any");
+ fail("Should raise MalformedURLException");
+ } catch (MalformedURLException e) {
+ } catch (Throwable e) {
+ fail("Should raise MalformedURLException but raised: " + e);
+ }
+ }
+
+ public final void testGetClassLoader003() throws RemoteException,
+ MalformedURLException {
+ SecurityManager smOld = System.getSecurityManager();
+ try {
+ SecurityManager sm = new SecurityManager() {
+ boolean allow = false;
+
+ public void checkPermission(Permission perm) {
+ if (!allow) {
+ allow = true;
+ throw new SecurityException("Is it use the Security?");
+ }
+ }
+ };
+ System.setSecurityManager(sm);
+ RMIClassLoader.getClassLoader("file://" + pathOwnClass);
+ fail("Should raise SecurityException");
+ } catch (SecurityException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ } finally {
+ try {
+ System.setSecurityManager(smOld);
+ } catch (SecurityException e) {
+ System.setSecurityManager(smOld);
+ }
+ }
+
+ }
+
+ public final void testGetClassLoader004() {
+ try {
+ assertNotNull(RMIClassLoader.getClassLoader("file://" + path
+ + " file://" + pathOwnClass));
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+
+ /*
+ * Test method for
+ * 'java.rmi.server.RMIClassLoader.getDefaultProviderInstance()'
+ */
+ public final void testGetDefaultProviderInstance001() {
+ assertNotNull(RMIClassLoader.getDefaultProviderInstance());
+ }
+
+ public final void testGetDefaultProviderInstance002() {
+
+ SecurityManager smOld = System.getSecurityManager();
+ try {
+ SecurityManager sm = new SecurityManager() {
+ boolean allow = false;
+
+ public void checkPermission(Permission perm) {
+ if (!allow) {
+ allow = true;
+ throw new SecurityException(
+ "No, No, No, you can't do that.");
+ }
+ }
+ };
+ System.setSecurityManager(sm);
+ RMIClassLoader.getDefaultProviderInstance();
+ fail("Should raise SecurityException");
+ } catch (SecurityException e) {
+ } catch (Throwable e) {
+ fail("Failed with:" + e);
+ } finally {
+ try {
+ System.setSecurityManager(smOld);
+ } catch (SecurityException e) {
+ System.setSecurityManager(smOld);
+ }
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.loadClass(String,
+ * String)'
+ */
+ public final void testLoadClassStringString001()
+ throws MalformedURLException, ClassNotFoundException {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
+ false);
+ }
+
+ public final void testLoadClassStringString002() {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002",
+ false);
+ }
+
+ public final void testLoadClassStringString003() {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest003",
+ false);
+ }
+
+ public final void testLoadClassStringString004() {
+ try {
+ RMIClassLoader
+ .loadClass("file://.",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest006");
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should raise ClassNotFoundException but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassStringString005() {
+ try {
+ RMIClassLoader
+ .loadClass("????//.??",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001");
+ fail("Should raise MalformedURLException");
+ } catch (MalformedURLException e) {
+ } catch (Throwable e) {
+ fail("Should raise MalformedURLException but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassStringString006() {
+ try {
+ RMIClassLoader
+ .loadClass("",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002");
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.loadClass(String, String,
+ * ClassLoader)'
+ */
+ public final void testLoadClassStringStringClassLoader001() {
+ try {
+ RMIClassLoader
+ .loadClass(
+ "file://.",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002",
+ null);
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassStringStringClassLoader002() {
+ try {
+ RMIClassLoader
+ .loadClass(
+ "//.",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002",
+ new MyClassLoader());
+ fail("Should raise MalformedURLException");
+ } catch (MalformedURLException e) {
+ } catch (Throwable e) {
+ fail("Should raise MalformedURLException but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassStringStringClassLoader003() {
+ try {
+ RMIClassLoader
+ .loadClass(
+ "file://.",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest016",
+ new MyClassLoader());
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should raise ClassNotFoundException");
+ }
+ }
+
+ public final void testLoadClassStringStringClassLoader004()
+ throws MalformedURLException {
+ LoadClassStringStringClassLoader("",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
+ "testLoadClassStringStringClassLoader004");
+ }
+
+ public final void testLoadClassStringStringClassLoader005()
+ throws MalformedURLException {
+ LoadClassStringStringClassLoader("",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002",
+ "testLoadClassStringStringClassLoader005");
+ }
+
+ public final void testLoadClassStringStringClassLoader006() {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ try {
+ RMIClassLoader
+ .loadClass(
+ "file://" + pathOwnClass,
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
+ null);
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.loadClass(URL, String)'
+ */
+ public final void testLoadClassURLString001() {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
+ true);
+ }
+
+ public final void testLoadClassURLString002() {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002",
+ true);
+ }
+
+ public final void testLoadClassURLString003() {
+ LoadClassStringString(
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest003",
+ true);
+ }
+
+ public final void testLoadClassURLString004() {
+ try {
+ RMIClassLoader
+ .loadClass(new URL("file://."),
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest006");
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should raise ClassNotFoundException but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassURLString005() {
+ try {
+ RMIClassLoader
+ .loadClass(new URL("//."),
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001");
+ fail("Should raise MalformedURLException");
+ } catch (MalformedURLException e) {
+ } catch (Throwable e) {
+ fail("Should raise MalformedURLException but raised: " + e);
+ }
+ }
+
+ public final void testLoadClassURLString006() {
+ try {
+ RMIClassLoader
+ .loadClass((URL) null,
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest002");
+ } catch (Throwable e) {
+ fail("Failed with: " + e);
+ }
+ }
+
+ public final void testLoadClassURLString007() {
+ try {
+ RMIClassLoader
+ .loadClass((URL) null,
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001");
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Failed with: " + e);
+ }
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMIClassLoader.loadProxyClass(String,
+ * String[], ClassLoader)'
+ */
+ public final void testLoadProxyClass001() {
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy" };
+ Class c = null;
+
+ try {
+ c = RMIClassLoader.loadProxyClass("file://" + pathOwnClass,
+ interfaces, new MyClassLoader());
+ try {
+ c.getMethod("proxy1");
+ c.getMethod("proxy2");
+ } catch (NoSuchMethodException e) {
+ fail("The class is not implementing all the interfaces");
+ }
+
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+
+ }
+
+ public final void testLoadProxyClass002() {
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxyasdf" };
+ try {
+ RMIClassLoader.loadProxyClass("file://" + pathOwnClass, interfaces,
+ new MyClassLoader());
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+
+ }
+
+ public final void testLoadProxyClass003() {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+ Class c = null;
+
+ try {
+ c = RMIClassLoader.loadProxyClass("file://" + pathOwnClass,
+ interfaces, new MyClassLoader());
+ try {
+ c.getMethod("proxy1");
+ c.getMethod("proxy2");
+ } catch (NoSuchMethodException e) {
+ fail("The class is not implementing all the interfaces");
+ }
+
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+
+ }
+
+ public final void testLoadProxyClass004() {
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+
+ try {
+ RMIClassLoader.loadProxyClass("file://" + pathOwnClass, interfaces,
+ new MyClassLoader());
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+
+ }
+
+ public final void testLoadProxyClass005() {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+ try {
+ RMIClassLoader.loadProxyClass("file://.", interfaces,
+ new MyClassLoader());
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+
+ }
+
+ public final void testLoadProxyClass006() {
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+ try {
+ RMIClassLoader.loadProxyClass(null, interfaces, new URLClassLoader(
+ new URL[] { new URL("file://" + pathOwnClass) }));
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+
+ }
+
+ public final void testLoadProxyClass007() {
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+ try {
+ RMIClassLoader.loadProxyClass("file://" + pathOwnClass, interfaces,
+ null);
+ fail("Should raise ClassNotFoundException");
+ } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+
+ }
+
+ public final void testLoadProxyClass008() {
+ SecurityManager smOld = System.getSecurityManager();
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
+ String interfaces[] = {
+ "ar.org.fitc.test.rmi.server.testclasses.SuperProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.OverProxy",
+ "ar.org.fitc.test.rmi.server.testclasses.LoaderInterface" };
+ Class c = null;
+
+ try {
+ c = RMIClassLoader.loadProxyClass("file://" + pathOwnClass,
+ interfaces, null);
+ try {
+ c.getMethod("proxy1");
+ c.getMethod("proxy2");
+ } catch (NoSuchMethodException e) {
+ fail("The class is not implementing all the interfaces");
+ }
+
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+
+ }
+
+ public final void testLoadProxyClass009() {
+
+ String interfaces[] = {};
+ Class c = null;
+
+ try {
+ c = RMIClassLoader.loadProxyClass(null, interfaces, null);
+ assertNotNull(c);
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMIClassLoader.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMISocketFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMISocketFactory.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMISocketFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMISocketFactory.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.server;
+
+import java.io.IOException;
+import java.rmi.server.RMISocketFactory;
+import java.security.Permission;
+
+import junit.framework.TestCase;
+import ar.org.fitc.test.rmi.server.testclasses.MyRMISocketFactory;
+import ar.org.fitc.test.util.Messages;
+
+public class TestRMISocketFactory extends TestCase implements Messages {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(TestRMISocketFactory.class);
+ }
+
+ public TestRMISocketFactory(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * Test method for
+ * 'java.rmi.server.RMISocketFactory.getDefaultSocketFactory()'
+ */
+ public final void testGetDefaultSocketFactory001() {
+ assertNotNull(RMISocketFactory.getDefaultSocketFactory().getClass()
+ .getCanonicalName());
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMISocketFactory.getFailureHandler()'
+ */
+ public final void testGetFailureHandler001() {
+ assertNotNull(msgNotNull, RMISocketFactory.getDefaultSocketFactory());
+ }
+
+ public final void testGetFailureHandler002() {
+ RMISocketFactory.setFailureHandler(null);
+ assertNotNull(msgNotNull, RMISocketFactory.getDefaultSocketFactory());
+ }
+
+ /*
+ * Test method for
+ * 'java.rmi.server.RMISocketFactory.setFailureHandler(RMIFailureHandler)'
+ */
+ public final void testSetFailureHandler002() {
+ RMISocketFactory.setFailureHandler(null);
+ assertNotNull(msgNotNull, RMISocketFactory.getDefaultSocketFactory());
+ }
+
+ /*
+ * Test method for 'java.rmi.server.RMISocketFactory.setSocketFactory()'
+ */
+
+ public final void testSetSocketFactory001() {
+ SecurityManager smOld = System.getSecurityManager();
+ try {
+ SecurityManager sm = new SecurityManager() {
+ public void checkPermission(Permission perm) {
+ boolean allow = !perm.implies(new RuntimePermission(
+ "setFactory"));
+ if (!allow) {
+ throw new SecurityException(
+ "No, No, No, you can't do that.");
+ }
+ }
+ };
+ System.setSecurityManager(sm);
+ RMISocketFactory.setSocketFactory(new MyRMISocketFactory());
+ fail("Should raise SecurityException");
+ } catch (SecurityException e) {
+ } catch (Throwable e) {
+ fail("Should raise SecurityException but raised: " + e);
+ } finally {
+ System.setSecurityManager(smOld);
+ }
+ }
+
+ public final void testSetSocketFactory002() {
+ try {
+ RMISocketFactory.setSocketFactory(new MyRMISocketFactory());
+ } catch (Throwable e) {
+ fail("Should not raise an exception but raised: " + e);
+ }
+ }
+
+ public final void testSetSocketFactory003() throws IOException {
+ try {
+ RMISocketFactory.setSocketFactory(null);
+ fail("Should raise IOException");
+ } catch (IOException e) {
+ } catch (Throwable e) {
+ fail("Should raise IOException but raised: " + e);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/server/TestRMISocketFactory.java
------------------------------------------------------------------------------
svn:executable = *