incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmidd...@apache.org
Subject svn commit: r514833 - in /incubator/yoko/trunk/bindings/src: main/java/org/apache/yoko/bindings/corba/ test/java/org/apache/yoko/bindings/corba/
Date Mon, 05 Mar 2007 19:45:03 GMT
Author: dmiddlem
Date: Mon Mar  5 11:45:02 2007
New Revision: 514833

URL: http://svn.apache.org/viewvc?view=rev&rev=514833
Log:
Updates to WS-Addressing support for CORBA object references (YOKO-270)

Added:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
  (with props)
Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectWriterTest.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTestServer.java

Added: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java?view=auto&rev=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
(added)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
Mon Mar  5 11:45:02 2007
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.yoko.bindings.corba;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.omg.CORBA.ORB;
+
+public class CorbaBindingHelper {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaBindingHelper.class);
+    private static Map<String, ORB> orbList = new HashMap<String, ORB>();
+    private static ORB defaultORB;
+    
+    public static ORB getDefaultORB(OrbConfig config) {
+        
+        if (defaultORB == null) {
+            Properties props = System.getProperties();
+            props.put("org.omg.CORBA.ORBClass", config.getOrbClass());
+            props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
+            props.put("yoko.orb.id", "Yoko-Binding");
+            List<String> orbArgs = config.getOrbArgs();
+            defaultORB = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
+            if (defaultORB == null) {
+                LOG.severe("Could not create instance of the ORB");
+                throw new CorbaBindingException("Could not create instance of the ORB");
+            }
+        }
+        return defaultORB;
+    }
+    
+    public static ORB createAddressSpecificORB(String address, OrbConfig config) {
+        ORB orb = null;
+        
+        URI addressURI = null;
+        try {
+            addressURI = new URI(address);
+        } catch (URISyntaxException ex) {
+            throw new CorbaBindingException("Unable to create ORB with address " + address);
+        }
+
+        Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", config.getOrbClass());
+        props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
+        props.put("yoko.orb.id", "Yoko-Binding-" + address);
+        List<String> orbArgs = config.getOrbArgs();
+        
+        String scheme = addressURI.getScheme();
+        // A corbaloc address gives us host and port information to use when setting up the
+        // endpoint for the ORB.  Other types of references will just create ORBs on the

+        // host and port used when no preference has been specified.
+        if (scheme.equals("corbaloc")) {
+            String schemeSpecificPart = addressURI.getSchemeSpecificPart();
+            int keyIndex = schemeSpecificPart.indexOf('/');
+            String corbaAddr = schemeSpecificPart.substring(0, keyIndex);
+
+            int index = corbaAddr.indexOf(':');
+            String protocol = "iiop";
+            if (index != 0) {
+                protocol = corbaAddr.substring(0, index);
+            }
+            int oldIndex = index;
+            index = corbaAddr.indexOf(':', oldIndex + 1);
+            String host = corbaAddr.substring(oldIndex + 1, index);
+            String port = corbaAddr.substring(index + 1);
+            
+            props.put("yoko.orb.oa.endpoint", new String(protocol + " --host " + host + "
--port " + port));
+            
+            orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
+            
+            orbList.put(getORBNameFromAddress(address), orb);
+        } else if (scheme.equals("file") || scheme.equals("relfile") || scheme.equals("IOR"))
{
+            orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
+            
+            orbList.put(getORBNameFromAddress(address), orb);
+        } else {
+            throw new CorbaBindingException("Unsupported address scheme type " + scheme);
+        }
+
+        return orb;
+    }
+    
+    public static ORB getAddressSpecificORB(String address) {
+        return orbList.get(getORBNameFromAddress(address));
+    }
+    
+    public static String getORBNameFromAddress(String address) {
+        String name = null;
+        
+        URI addressURI = null;
+        try {
+            addressURI = new URI(address);
+        } catch (URISyntaxException ex) {
+            throw new CorbaBindingException("Unable to locate ORB with address " + address);
+        }
+        
+        String scheme = addressURI.getScheme();
+        if (scheme.equals("corbaloc")) {
+            String schemeSpecificPart = addressURI.getSchemeSpecificPart();
+            int keyIndex = schemeSpecificPart.indexOf('/');
+            name = schemeSpecificPart.substring(0, keyIndex);
+        } else if (scheme.equals("IOR")) {
+            name = addressURI.toString();
+        } else if (scheme.equals("file") || scheme.equals("relfile")) {
+            name = addressURI.getPath();
+            if (name == null) {
+                name = addressURI.getSchemeSpecificPart();
+            }
+        } else {
+            throw new CorbaBindingException("Unsupported address scheme type " + scheme);
+        }
+
+        return name;
+    }
+}

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
Mon Mar  5 11:45:02 2007
@@ -77,18 +77,7 @@
         endpointInfo = ei;
         target = getTargetReference(ref);
         orbConfig = config;
-        // TODO: Set any additional properties needed to initialize the ORB  before
-        // we initialize it.
-        java.util.Properties props = System.getProperties();
-        props.put("org.omg.CORBA.ORBClass", orbConfig.getOrbClass());
-        props.put("org.omg.CORBA.ORBSingletonClass", orbConfig.getOrbSingletonClass());
-        props.put("yoko.orb.id", "Yoko-Client-Binding");
-        List<String> orbArgs = orbConfig.getOrbArgs();
-        orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
-        if (orb == null) {
-            LOG.severe("Could not create instance of the ORB");
-            throw new CorbaBindingException("Could not create instance of the ORB");
-        }
+        orb = CorbaBindingHelper.getDefaultORB(config);
     }
 
     public void send(Message message) throws IOException {    
@@ -115,6 +104,7 @@
             message.setContent(OutputStream.class,
                                new CorbaOutputStream(message));
         } catch (java.lang.Exception ex) {
+            ex.printStackTrace();
             LOG.log(Level.SEVERE, "Could not resolve target object");
             throw new CorbaBindingException(ex);
         }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDSIServant.java
Mon Mar  5 11:45:02 2007
@@ -50,9 +50,9 @@
     }
     
     public void init(ORB theOrb,
-                           POA poa,
-                           CorbaDestination dest,
-                           MessageObserver observer) {
+                     POA poa,
+                     CorbaDestination dest,
+                     MessageObserver observer) {
         orb = theOrb;
         servantPOA = poa;
         destination = dest;

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaDestination.java
Mon Mar  5 11:45:02 2007
@@ -20,7 +20,7 @@
 package org.apache.yoko.bindings.corba;
 
 import java.io.IOException;
-import java.util.List;
+//import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -102,64 +102,57 @@
     }
 
     public synchronized void setMessageObserver(MessageObserver observer) {
-        String location = address.getLocation();
-        LOG.info("Service address retrieved: " + location);
+        String location = null;
+        if (endpointInfo != null) {
+            location = endpointInfo.getAddress();
+        } 
         
-        // TODO: Get any configuration options for the ORB and set the appropriate properties.
-        java.util.Properties props = System.getProperties();
-        props.put("org.omg.CORBA.ORBClass", orbConfig.getOrbClass());
-        props.put("org.omg.CORBA.ORBSingletonClass", orbConfig.getOrbSingletonClass());
-        props.put("yoko.orb.id", "Yoko-Server-Binding");
-
-        // If we have one of these two types of addresses, we should specify the address
-        // and port information as properties to the ORB during initialization.
-        if (location.startsWith("IOR:")) {
-            // TODO: How to handle this? Can we obtain port/host information from the IOR
-            // or do we just want to let the ORB pick the port and export the IOR to the

-            // Logs?
-        } else if (location.startsWith("corbaloc")) {
-            int corbalocIndex = location.indexOf(":");
-            int protocolIndex = location.indexOf(":", corbalocIndex + 1);
-            String protocol = location.substring(corbalocIndex + 1, protocolIndex);
-            int hostIndex = location.indexOf(":", protocolIndex + 1);
-            String host = location.substring(protocolIndex + 1, hostIndex);
-            // the port number should be followed by a '/' character
-            int portIndex = location.indexOf("/", hostIndex + 1);
-            String port = location.substring(hostIndex + 1, portIndex);
-            if (protocol.length() == 0) {
-                // This means no protocol was defined.  Default to iiop
-                protocol = "iiop";
-            }
-            props.put("yoko.orb.oa.endpoint", new String(protocol + " --host " + host + "
--port " + port));
-            LOG.info("Set server endpoint: " + protocol + " --host " + host + " --port "
+ port);
+        if (location == null) {
+            location = address.getLocation();
+        }
+        LOG.info("Service address retrieved: " + location);
+
+        orb = CorbaBindingHelper.getAddressSpecificORB(location);
+        if (orb == null) {
+            LOG.log(Level.INFO, "Creating ORB with address " + location);
+            orb = CorbaBindingHelper.createAddressSpecificORB(location, orbConfig);
         }
-        List<String> orbArgs = orbConfig.getOrbArgs();
-        orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
         activate(observer);
     }
 
     public void activate(MessageObserver observer) {
         // Get the address that the DSI servant should be publishing
         String location = address.getLocation();
-
+        
         org.omg.CORBA.Object obj = null;
         try {
             POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
             POAManager poaManager = rootPOA.the_POAManager();
 
-            Policy[] policies = new Policy[3];
-            policies[0] = rootPOA
-                    .create_lifespan_policy(
-                        org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
-            policies[1] = rootPOA
-                    .create_implicit_activation_policy(
-                        org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
-            policies[2] = rootPOA
-                    .create_id_uniqueness_policy(
-                        org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
+            POA bindingPOA = null;
+            try {
+                bindingPOA = rootPOA.find_POA("BindingPOA", true);
+            } catch (org.omg.PortableServer.POAPackage.AdapterNonExistent ex) {
+                // An AdapterNonExistent exception will be thrown if the POA does not exist.
 If
+                // this is the case, then we'll create one.
+                Policy[] policies = new Policy[3];
+                policies[0] = rootPOA
+                        .create_lifespan_policy(
+                            org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
+                policies[1] = rootPOA
+                        .create_implicit_activation_policy(
+                            org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
+                policies[2] = rootPOA
+                        .create_id_uniqueness_policy(
+                            org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
+
+                bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
+            }
+            
+            if (bindingPOA == null) {
+                throw new CorbaBindingException("Unable to create Yoko Binding POA");
+            }
 
-            POA bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
-           // CorbaDSIServant servant = new CorbaDSIServant(orb, bindingPOA, this, observer);
             CorbaDSIServant servant = new CorbaDSIServant();
             servant.init(orb, bindingPOA, this, observer);
             byte[] objectId = bindingPOA.activate_object(servant);

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaServerConduit.java
Mon Mar  5 11:45:02 2007
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -44,9 +43,8 @@
 import org.omg.CORBA.ORB;
 import org.omg.CORBA.ServerRequest;
 
-
 public class CorbaServerConduit implements Conduit {
-    private static final Logger LOG = LogUtils.getL7dLogger(CorbaConduit.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaServerConduit.class);
 
     private EndpointInfo endpointInfo;
     private EndpointReferenceType target;
@@ -56,19 +54,7 @@
     public CorbaServerConduit(EndpointInfo ei, EndpointReferenceType ref, OrbConfig config)
{
         endpointInfo = ei;
         target = getTargetReference(ref);
-        // TODO: Set any additional properties needed to initialize the ORB  before
-        // we initialize it. We will get this information from the Celtix configuration 
-        // that is used with the current application.
-        java.util.Properties props = System.getProperties();
-        props.put("org.omg.CORBA.ORBClass", config.getOrbClass());
-        props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
-        props.put("yoko.orb.id", "Yoko-Client-Binding");
-        List<String> orbArgs = config.getOrbArgs();
-        orb = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
-        if (orb == null) {
-            LOG.severe("Could not create instance of the ORB");
-            throw new CorbaBindingException("Could not create instance of the ORB");
-        }
+        orb = CorbaBindingHelper.getDefaultORB(config);
     }
 
     public void send(Message message) throws IOException {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
Mon Mar  5 11:45:02 2007
@@ -1316,6 +1316,12 @@
         CorbaObjectReferenceHandler objRefHandler = (CorbaObjectReferenceHandler)obj;
         org.omg.CORBA.Object corbaObject = objRefHandler.getReference();
         
+        // There is a situation where the ORB may not yet be initialized.  If this is the
case,
+        // a default ORB will do
+        if (orb == null) {
+            orb = CorbaBindingHelper.getDefaultORB(new OrbConfig());
+        }
+        
         // Register the servant if not already done.
         String objAddress = orb.object_to_string(corbaObject);
         org.omg.CORBA.Object servant = CorbaObjectReferenceHelper.getReferenceById(objAddress);

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
Mon Mar  5 11:45:02 2007
@@ -19,6 +19,7 @@
 package org.apache.yoko.bindings.corba;
 
 import java.math.BigInteger;
+import java.net.URL;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -44,6 +45,7 @@
 import org.apache.yoko.bindings.corba.types.CorbaExceptionHandler;
 import org.apache.yoko.bindings.corba.types.CorbaFixedHandler;
 import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
+import org.apache.yoko.bindings.corba.types.CorbaObjectReferenceHandler;
 import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
 import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
 import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
@@ -505,5 +507,40 @@
         reader.readFixed(obj);
         
         assertTrue(obj.getValue().equals(new java.math.BigDecimal("12345.67")));
+    }
+    
+    public void testReadObjectReference() {
+        Buffer buf = new Buffer();
+        OutputStream oStream = new OutputStream(buf);
+        
+        URL refUrl = getClass().getResource("/references/account.ref");
+        System.out.println("DEBUG > Path = " + refUrl.getPath());
+        org.omg.CORBA.Object objRef = orb.string_to_object("file://" + refUrl.getPath());
+        assertNotNull(objRef);
+        oStream.write_Object(objRef);
+        // we need an ORBinstance to handle reading objects so use the Yoko input stream
and
+        // ORB_impl
+        org.apache.yoko.orb.CORBA.InputStream iStream = 
+            (org.apache.yoko.orb.CORBA.InputStream)oStream.create_input_stream();
+        org.apache.yoko.orb.OBCORBA.ORB_impl o = (org.apache.yoko.orb.OBCORBA.ORB_impl)orb;
+        iStream._OB_ORBInstance(o._OB_ORBInstance());
+        
+        CorbaObjectReader reader = new CorbaObjectReader(iStream);
+        
+        // create a test object
+        org.apache.schemas.yoko.bindings.corba.Object objectType = 
+            new org.apache.schemas.yoko.bindings.corba.Object();
+        objectType.setRepositoryID("IDL:Account:1.0");
+        objectType.setBinding(new QName("AccountCORBABinding"));
+        
+        QName objectName = new QName("TestObject");
+        QName objectIdlType = new QName("corbaatm:TestObject");
+        TypeCode objectTC = orb.create_interface_tc("IDL:Account:1.0", "TestObject");
+        
+        CorbaObjectReferenceHandler obj = new CorbaObjectReferenceHandler(objectName, objectIdlType,

+                                                                          objectTC, objectType);
+        
+        reader.readObjectReference(obj);
+        assertTrue(obj.getReference()._is_equivalent(objRef));
     }
 }

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectWriterTest.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectWriterTest.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectWriterTest.java
Mon Mar  5 11:45:02 2007
@@ -19,6 +19,8 @@
 package org.apache.yoko.bindings.corba;
 
 import java.math.BigInteger;
+import java.net.URL;
+
 import javax.xml.namespace.QName;
 import junit.framework.TestCase;
 
@@ -36,6 +38,7 @@
 import org.apache.yoko.bindings.corba.types.CorbaArrayHandler;
 
 import org.apache.yoko.bindings.corba.types.CorbaExceptionHandler;
+import org.apache.yoko.bindings.corba.types.CorbaObjectReferenceHandler;
 import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
 import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
 import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
@@ -439,5 +442,43 @@
         assertTrue(readCode == code);
         String readMessage = iStream.read_string();
         assertTrue(readMessage.equals(message));
+    }
+    
+    public void testWriteObject() {
+        URL refUrl = getClass().getResource("/references/account.ref");
+        org.omg.CORBA.Object objRef = 
+            orb.string_to_object("file://" + refUrl.getPath());
+        assertNotNull(objRef);
+        
+        // create a test object
+        org.apache.schemas.yoko.bindings.corba.Object objectType = 
+            new org.apache.schemas.yoko.bindings.corba.Object();
+        objectType.setRepositoryID("IDL:Account:1.0");
+        objectType.setBinding(new QName("AccountCORBABinding"));
+        
+        QName objectName = new QName("TestObject");
+        QName objectIdlType = new QName("corbaatm:TestObject");
+        TypeCode objectTC = orb.create_interface_tc("IDL:Account:1.0", "TestObject");
+        
+        CorbaObjectReferenceHandler obj = new CorbaObjectReferenceHandler(objectName, objectIdlType,

+                                                                          objectTC, objectType);
+        obj.setReference(objRef);        
+        
+        Buffer buf = new Buffer();
+        OutputStream oStream = new OutputStream(buf);
+        CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
+        writer.writeObjectReference(obj);
+
+        // we need an ORBinstance to handle reading objects so use the Yoko input stream
and
+        // ORB_impl
+        org.apache.yoko.orb.CORBA.InputStream iStream = 
+            (org.apache.yoko.orb.CORBA.InputStream)oStream.create_input_stream();
+        org.apache.yoko.orb.OBCORBA.ORB_impl o = (org.apache.yoko.orb.OBCORBA.ORB_impl)orb;
+        iStream._OB_ORBInstance(o._OB_ORBInstance());
+
+        //InputStream iStream = oStream.create_input_stream();
+        
+        org.omg.CORBA.Object resultObj = iStream.read_Object();
+        assertTrue(resultObj._is_equivalent(obj.getReference()));
     }
 }

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java
Mon Mar  5 11:45:02 2007
@@ -116,7 +116,7 @@
     }
     
     public void tearDown() throws Exception {
-        super.setUp();
+        super.tearDown();
         if (orb != null) {
             try {
                 orb.destroy();

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTestServer.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTestServer.java?view=diff&rev=514833&r1=514832&r2=514833
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTestServer.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTestServer.java
Mon Mar  5 11:45:02 2007
@@ -36,7 +36,8 @@
 
     public void _start() {
         Object implementor = new IdlToWsdlTypeTestImpl();
-        String address = "corbaloc::localhost:40012/type_test";
+        //String address = "corbaloc::localhost:40012/type_test";
+        String address = "corbaloc::localhost:40010/idltowsdl_type_test";
         Endpoint.publish(address, implementor);
         serverReady = true;
     }



Mime
View raw message