geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r356706 - in /geronimo/trunk/sandbox/freeorb/geronimo-orb/src: main/java/org/apache/geronimo/corba/ORB.java test/java/org/apache/geronimo/corba/test/ORBTest.java
Date Wed, 14 Dec 2005 02:06:31 GMT
Author: adc
Date: Tue Dec 13 18:06:28 2005
New Revision: 356706

URL: http://svn.apache.org/viewcvs?rev=356706&view=rev
Log:
PR: GERONIMO-1216
Submitted by: Lars K├╝hne

Added:
    geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/ORBTest.java
Modified:
    geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java?rev=356706&r1=356705&r2=356706&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java
(original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/ORB.java
Tue Dec 13 18:06:28 2005
@@ -18,6 +18,7 @@
 
 import java.applet.Applet;
 import java.io.IOException;
+import java.io.ByteArrayOutputStream;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;
@@ -28,10 +29,14 @@
 import org.apache.geronimo.corba.io.DefaultConnectionManager;
 import org.apache.geronimo.corba.io.EncapsulationInputStream;
 import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.io.EncapsulationOutputStream;
+import org.apache.geronimo.corba.io.GIOPVersion;
 import org.apache.geronimo.corba.ior.InternalIOR;
 import org.apache.geronimo.corba.ior.URLManager;
 import org.apache.geronimo.corba.policy.PolicyFactoryManager;
 import org.apache.geronimo.corba.server.DefaultServerManager;
+import org.apache.geronimo.corba.util.HexUtil;
+
 import org.omg.CORBA.Context;
 import org.omg.CORBA.ContextList;
 import org.omg.CORBA.NO_IMPLEMENT;
@@ -41,6 +46,7 @@
 import org.omg.CORBA.Request;
 import org.omg.CORBA.TRANSIENT;
 import org.omg.CORBA.WrongTransaction;
+import org.omg.CORBA.INTERNAL;
 import org.omg.CORBA.ORBPackage.InvalidName;
 import org.omg.CORBA.portable.OutputStream;
 import org.omg.PortableInterceptor.ORBInitInfoOperations;
@@ -63,7 +69,7 @@
 	private InitialServicesManager ism;
 
 	private PolicyFactoryManager pfm;
-	
+
 	private InterceptorManager im;
 
 	protected void set_parameters(String[] args, Properties props) {
@@ -79,7 +85,7 @@
 				throw t;
 			}
 		}
-		
+
 		ism = new InitialServicesManager(this);
 		ism.init(args, props);
 
@@ -90,8 +96,7 @@
 	}
 
 	protected void set_parameters(Applet app, Properties props) {
-		// TODO Auto-generated method stub
-		throw new NO_IMPLEMENT();
+            throw new NO_IMPLEMENT("This ORB is currently not designed to be used in an Applet
environment");
 	}
 
 	public String[] list_initial_services() {
@@ -108,8 +113,18 @@
 	}
 
 	public String object_to_string(Object obj) {
-		// TODO Auto-generated method stub
-		return null;
+            try {
+                EncapsulationOutputStream os = new EncapsulationOutputStream(this, GIOPVersion.V1_0);
+                os.write_Object(obj);
+                os.flush();
+                byte[] bytes = os.getBytes();
+                return "IOR:" + HexUtil.byteArrayToHex(bytes);
+            } catch (IOException ex) {
+                // should never happen as we are dealing with in-memory streams here
+                final INTERNAL internal = new INTERNAL();
+                internal.initCause(ex);
+                throw internal;
+            }
 	}
 
 	public Object string_to_object(String str) {

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/ORBTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/ORBTest.java?rev=356706&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/ORBTest.java
(added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/test/java/org/apache/geronimo/corba/test/ORBTest.java
Tue Dec 13 18:06:28 2005
@@ -0,0 +1,20 @@
+package org.apache.geronimo.corba.test;
+
+import org.apache.geronimo.corba.ORB;
+import org.omg.CORBA.Object;
+
+import junit.framework.TestCase;
+
+public class ORBTest extends TestCase {
+
+    public void testObjectToString() {
+        ORB orb = new ORB();
+        final String origIOR = "IOR:000000000000003149444C3A696E732E6F70656E6F72622E6F72672F63616C6C6261636B2F43616C6C6261636B4D616E616765723A312E300000000000000001000000000000005C000102000000000E3139322E3136382E362E31303000041500000014004F4F01D2AB1DFD07010000504F41FEE046654A0000000100000001000000200000000000010001000000020001000F00010020000101090000000100010100";
+        final Object obj1 = orb.string_to_object(origIOR);
+        String str = orb.object_to_string(obj1);
+        assertTrue("Not an IOR: '" + str + "'", str.startsWith("IOR:"));
+        assertEquals("Not same IOR as original", origIOR, str);
+        Object obj2 = orb.string_to_object(str);
+        assertNotSame(obj1, obj2);
+    }
+}



Mime
View raw message