incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r490728 - in /incubator/yoko/trunk/bindings/src: main/java/org/apache/yoko/bindings/corba/ main/java/org/apache/yoko/bindings/corba/interceptors/ test/java/org/apache/yoko/bindings/corba/
Date Thu, 28 Dec 2006 13:58:50 GMT
Author: bravi
Date: Thu Dec 28 05:58:49 2006
New Revision: 490728

URL: http://svn.apache.org/viewvc?view=rev&rev=490728
Log:
[YOKO-170] - Throwing exceptions instead of printing out stack traces.

Added:
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.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/interceptors/CorbaInInterceptor.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java

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=490728&r1=490727&r2=490728
==============================================================================
--- 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 Thu Dec 28 05:58:49 2006
@@ -93,7 +93,7 @@
                 LOG.log(Level.SEVERE, "Unable to locate a valid CORBA address");
                 throw new CorbaBindingException("Unable to locate a valid CORBA address");
             }
-            List<Object> args = message.getContent(List.class);
+            List args = message.getContent(List.class);
             org.omg.CORBA.Object targetObject = CorbaUtils.importObjectReference(orb, address.getLocation());
             message.put(CorbaConstants.ORB, orb);
             message.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, targetObject);
@@ -113,7 +113,8 @@
             buildRequest((CorbaMessage)message, opType);
             message.getContent(OutputStream.class).close();
         } catch (Exception ex) {
-            // NEED TO DO
+            LOG.log(Level.SEVERE, "Could not build the corba request");
+            throw new CorbaBindingException(ex);
         }
     }
 
@@ -151,23 +152,18 @@
     }
         
     protected void buildRequest(CorbaMessage message, OperationType opType) throws Exception {        
-        try {
-            List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
+        List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
 
-            ServiceInfo service = message.getExchange().get(ServiceInfo.class);
-            List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
-            if (corbaTypes != null) {
-                CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
-            }
+        ServiceInfo service = message.getExchange().get(ServiceInfo.class);
+        List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+        if (corbaTypes != null) {
+            CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+        }
         
-            NVList nvlist = getArguments(message);
-            NamedValue ret = getReturn(message);
-            ExceptionList exList = getExceptionList(message, opType, typeMaps);     
-            invokeRequest(message, opType.getName(), nvlist, ret, exList);
-
-        } catch (java.lang.Exception ex) {
-            ex.printStackTrace();
-        }                
+        NVList nvlist = getArguments(message);
+        NamedValue ret = getReturn(message);
+        ExceptionList exList = getExceptionList(message, opType, typeMaps);     
+        invokeRequest(message, opType.getName(), nvlist, ret, exList);
     }
        
     protected NVList getArguments(CorbaMessage message) {
@@ -229,18 +225,14 @@
                                  org.omg.CORBA.NamedValue ret, 
                                  org.omg.CORBA.ExceptionList exList) 
         throws Exception {
-        try {            
-            ContextList ctxList = orb.create_context_list();
-            Context ctx = orb.get_default_context();            
-            org.omg.CORBA.Object targetObj = 
-                (org.omg.CORBA.Object)message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
-            if (targetObj != null) {                
-                Request request = targetObj._create_request(ctx, opName, 
-                                             nvlist, ret, exList, ctxList);                
-                request.invoke();
-            }
-        } catch (java.lang.Exception ex) {
-            ex.printStackTrace();
+        ContextList ctxList = orb.create_context_list();
+        Context ctx = orb.get_default_context();            
+        org.omg.CORBA.Object targetObj = 
+            (org.omg.CORBA.Object)message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
+        if (targetObj != null) {                
+            Request request = targetObj._create_request(ctx, opName, 
+                                                        nvlist, ret, exList, ctxList);                
+            request.invoke();
         }
     }
         

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=490728&r1=490727&r2=490728
==============================================================================
--- 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 Thu Dec 28 05:58:49 2006
@@ -21,7 +21,10 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.MessageImpl;
@@ -35,6 +38,7 @@
 
 public class CorbaDSIServant extends DynamicImplementation {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(CorbaDSIServant.class);
     private ORB orb;
     private POA servantPOA;    
     private List<String> interfaces;
@@ -68,8 +72,8 @@
                 interfaces.add(iter.next());
             }
         } catch (java.lang.Exception ex) {
-            // TODO: For now, this exception is consumed. Revisit this to see if
-            // it is the best way to handle this.
+            LOG.log(Level.SEVERE, "Couldn't initialize the corba DSI servant");
+            throw new CorbaBindingException(ex);
         }
     }
 

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=490728&r1=490727&r2=490728
==============================================================================
--- 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 Thu Dec 28 05:58:49 2006
@@ -20,6 +20,7 @@
 package org.apache.yoko.bindings.corba;
 
 import java.io.IOException;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
@@ -83,7 +84,8 @@
             try {
                 orb.destroy();
             } catch (Exception ex) {
-                // TODO: For now, we just consume.  Revisit.
+                LOG.log(Level.SEVERE, "Couldn't shutdown the corba destination. Failed to destroy orb");
+                throw new CorbaBindingException(ex);
             }
         }
     }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java?view=diff&rev=490728&r1=490727&r2=490728
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptor.java Thu Dec 28 05:58:49 2006
@@ -32,11 +32,11 @@
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
 import javax.xml.ws.Holder;
 
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataReaderFactory;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.JAXBUtils;
 import org.apache.cxf.jaxb.WrapperHelper;
 import org.apache.cxf.jaxb.io.EventDataReader;
@@ -93,36 +93,42 @@
         this.orb = mOrb;
     }
 
-    public void handleMessage(Message msg) {                  
-        CorbaMessage message = (CorbaMessage) msg;                
-        CorbaDestination destination = null;
-        if (message.getDestination() != null) {
-            destination = (CorbaDestination)message.getDestination();
-        } else {
-            destination = (CorbaDestination)message.getExchange().getDestination();
-        }
-        
-        typeMaps = new ArrayList<CorbaTypeMap>();                
-        ServiceInfo service = destination.getBindingInfo().getService();        
-        List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
-        if (corbaTypes != null) {
-            CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
-            corbaStaxObject.setTypeMaps(typeMaps);
-        }
+    public void handleMessage(Message msg) {
+        try {
+            CorbaMessage message = (CorbaMessage) msg;                
+            CorbaDestination destination = null;
+            if (message.getDestination() != null) {
+                destination = (CorbaDestination)message.getDestination();
+            } else {
+                destination = (CorbaDestination)message.getExchange().getDestination();
+            }
         
-        // TODO: where does encoding constant go?
-        //String encoding = (String)message.get("Encoding");        
+            typeMaps = new ArrayList<CorbaTypeMap>();                
+            ServiceInfo service = destination.getBindingInfo().getService();        
+            List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+            if (corbaTypes != null) {
+                CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+                corbaStaxObject.setTypeMaps(typeMaps);
+            }
+            
+            // TODO: where does encoding constant go?
+            //String encoding = (String)message.get("Encoding");        
                                
-        // check to see if we have an input or output message
-        if (!ContextUtils.isRequestor(msg)) {
-            handleNotRequestMessage(message, destination, service);                
-        } else {             
-            handleRequestMessage(message, destination, service);
-        } 
+            // check to see if we have an input or output message
+            if (!ContextUtils.isRequestor(msg)) {
+                handleNotRequestMessage(message, destination, service);                
+            } else {             
+                handleRequestMessage(message, destination, service);
+            } 
+        } catch (Exception ex) {
+            throw new Fault(ex);
+        }
     }
             
-    protected void handleNotRequestMessage(CorbaMessage message, CorbaDestination destination,
-                                           ServiceInfo service) {
+    protected void handleNotRequestMessage(CorbaMessage message,
+                                           CorbaDestination destination,
+                                           ServiceInfo service)
+        throws Exception {
         QName opQName = null;
         OperationType opType = null;
         BindingInfo bInfo = destination.getBindingInfo();              
@@ -170,8 +176,10 @@
         
     }
     
-    protected void handleRequestMessage(CorbaMessage message, CorbaDestination destination,
-                                        ServiceInfo service) {
+    protected void handleRequestMessage(CorbaMessage message,
+                                        CorbaDestination destination,
+                                        ServiceInfo service)
+        throws Exception {
         OperationType opType = null;
         
         orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);  
@@ -221,7 +229,8 @@
      * 2. Since corba binding doesn't depend on wrapped doc-style, there is no need for cxf jaxws 
      * WrapperClassIn & WrapperClassOut interceptors.
      */
-    protected void addWrapperParams(Message message, BindingOperationInfo bopInfo, boolean isOutput) {
+    protected void addWrapperParams(Message message, BindingOperationInfo bopInfo, boolean isOutput)
+        throws Exception {
         if (bopInfo.isUnwrappedCapable()) {
             OperationInfo opInfo = bopInfo.getOperationInfo();
 
@@ -238,22 +247,18 @@
             } else {
                 msgInfo = opInfo.getInput();
             }
-            List<Object> objs = message.getContent(List.class);
+            List objs = message.getContent(List.class);
             if ((objs != null) && (objs.size() == 1)) {
-                try {
-                    Object wrapperType = wrapperTypeClass.newInstance();
-                    int i = 0;
-                    for (MessagePartInfo p : msgInfo.getMessageParts()) {
-                        Object part = objs.get(i);
-                        WrapperHelper.setWrappedPart(p.getName().getLocalPart(), wrapperType, part);
-                        i++;
-                    }
-                    objs = new ArrayList<Object>();
-                    objs.add(wrapperType);
-                    message.setContent(List.class, objs);
-                } catch (Exception ex) {
-                    ex.printStackTrace();
+                Object wrapperType = wrapperTypeClass.newInstance();
+                int i = 0;
+                for (MessagePartInfo p : msgInfo.getMessageParts()) {
+                    Object part = objs.get(i);
+                    WrapperHelper.setWrappedPart(p.getName().getLocalPart(), wrapperType, part);
+                    i++;
                 }
+                objs = new ArrayList<Object>();
+                objs.add(wrapperType);
+                message.setContent(List.class, objs);
             }
         }
     }
@@ -264,7 +269,8 @@
      * 2. Since corba binding doesn't depend on wrapped doc-style, there is no need for cxf jaxws 
      * WrapperClassIn & WrapperClassOut interceptors.
      */
-    protected OperationInfo processWrappedOperation(BindingOperationInfo bopInfo, boolean isOutput) {
+    protected OperationInfo processWrappedOperation(BindingOperationInfo bopInfo, boolean isOutput)
+        throws Exception {
         OperationInfo opInfo = bopInfo.getOperationInfo();
         MessageInfo msgInfo = null;
         if (bopInfo.isUnwrappedCapable()) {
@@ -282,22 +288,18 @@
             }
             
             for (MessagePartInfo part : msgInfo.getMessageParts()) {
-                try {
-                    String elementType = null;
-                    if (part.isElement()) {
-                        elementType = part.getElementQName().getLocalPart();
-                    } else if (part.getTypeQName() == null) {
-                        // handling anonymous complex type
-                        elementType = null;
-                    } else {
-                        elementType = part.getTypeQName().getLocalPart();
-                    }
-                    part.setTypeClass(getWrappedPartClass(part.getName().getLocalPart(), 
-                                                          wrapperTypeClass,
-                                                          elementType));
-                } catch (Exception ex) {
-                    ex.printStackTrace();
+                String elementType = null;
+                if (part.isElement()) {
+                    elementType = part.getElementQName().getLocalPart();
+                } else if (part.getTypeQName() == null) {
+                    // handling anonymous complex type
+                    elementType = null;
+                } else {
+                    elementType = part.getTypeQName().getLocalPart();
                 }
+                part.setTypeClass(getWrappedPartClass(part.getName().getLocalPart(), 
+                                                      wrapperTypeClass,
+                                                      elementType));
             }
         }
         return opInfo;
@@ -307,7 +309,8 @@
                                     CorbaMessage outMessage,
                                     OperationInfo opInfo,
                                     ArgType argType, 
-                                    EventDataReader reader) {
+                                    EventDataReader reader)
+        throws Exception {
         Object retValue = null;
         
         if (outMessage.getStreamableReturn() != null) {
@@ -319,24 +322,20 @@
             outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, 
                                       Boolean.TRUE);        
 
-            try {
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-                CorbaStreamable retVal = outMessage.getStreamableReturn();
-                corbaStaxObject.writeObjectToStax(retVal.getObject(), evtWriter, 
-                                                  XMLEventFactory.newInstance(),
-                                                  false);
-                evtWriter.flush();
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);            
-                MessagePartInfo part = getReturnMessagePartInfo(msgInfo);
-                retValue = reader.read(part, evtReader);
-                List<Object> args = new ArrayList<Object>();
-                args.add(retValue);
-                message.setContent(List.class, args);
-            } catch (XMLStreamException ex) {
-                // NEED TO DO
-            }
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+            CorbaStreamable retVal = outMessage.getStreamableReturn();
+            corbaStaxObject.writeObjectToStax(retVal.getObject(), evtWriter, 
+                                              XMLEventFactory.newInstance(),
+                                              false);
+            evtWriter.flush();
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);            
+            MessagePartInfo part = getReturnMessagePartInfo(msgInfo);
+            retValue = reader.read(part, evtReader);
+            List<Object> args = new ArrayList<Object>();
+            args.add(retValue);
+            message.setContent(List.class, args);
         }
     }
     
@@ -346,7 +345,8 @@
                                       OperationType opType,
                                       OperationInfo opInfo,                                  
                                       EventDataReader reader,
-                                      boolean isOutput) {
+                                      boolean isOutput)
+        throws Exception {
 
         MessageInfo msgInfo;
         if (isOutput) {
@@ -357,57 +357,54 @@
 
         List<ParamType> params = opType.getParam();
 
-        try {       
-            CorbaStreamable[] streamables = msg.getStreamableArguments();       
-            List<Object> args = message.getContent(List.class);
-            if (args == null) {
-                args = new ArrayList<Object>();
-            }
-            int index = 0;
-            for (int i = 0; i < params.size(); i++) {
-                Object obj = null;
-                ParamType param = params.get(i);                
-                boolean skipRead = false;
-                if (!ContextUtils.isRequestor(msg)) {
-                    if (param.getMode().equals(ModeType.OUT)) {
-                        skipRead = true;
-                    }
-                } else if (param.getMode().equals(ModeType.IN)) {
+        CorbaStreamable[] streamables = msg.getStreamableArguments();       
+        List args = message.getContent(List.class);
+        if (args == null) {
+            args = new ArrayList<Object>();
+        }
+        int index = 0;
+        for (int i = 0; i < params.size(); i++) {
+            Object obj = null;
+            ParamType param = params.get(i);                
+            boolean skipRead = false;
+            if (!ContextUtils.isRequestor(msg)) {
+                if (param.getMode().equals(ModeType.OUT)) {
                     skipRead = true;
                 }
-                if (!skipRead) {
-                    XMLInputFactory inputFactory = getXMLInputFactory();
-                    XMLOutputFactory outputFactory = getXMLOutputFactory();
-
-                    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                    XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-                    corbaStaxObject.writeObjectToStax(streamables[i].getObject(),
-                                                      evtWriter,
-                                                      XMLEventFactory.newInstance(),
-                                                      false);
-                    evtWriter.flush();
-                    ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                    XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-                    MessagePartInfo part = getMessagePartInfo(msgInfo,
-                                                              index,
-                                                              opType.getReturn() == null,
-                                                              isOutput);
-                    args.add(reader.read(part, evtReader));
-                    index++;
-                } else if (!isOutput) {
-                    args.add(obj);
-                }
-
+            } else if (param.getMode().equals(ModeType.IN)) {
+                skipRead = true;
             }
-            message.setContent(List.class, args);
-        } catch (Exception ex) {
-            ex.printStackTrace();
+            if (!skipRead) {
+                XMLInputFactory inputFactory = getXMLInputFactory();
+                XMLOutputFactory outputFactory = getXMLOutputFactory();
+                
+                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+                corbaStaxObject.writeObjectToStax(streamables[i].getObject(),
+                                                  evtWriter,
+                                                  XMLEventFactory.newInstance(),
+                                                  false);
+                evtWriter.flush();
+                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+                MessagePartInfo part = getMessagePartInfo(msgInfo,
+                                                          index,
+                                                          opType.getReturn() == null,
+                                                          isOutput);
+                args.add(reader.read(part, evtReader));
+                index++;
+            } else if (!isOutput) {
+                args.add(obj);
+            }
+
         }
+        message.setContent(List.class, args);
     }    
     
     protected NVList prepareArguments(CorbaMessage corbaMsg, CorbaDestination destination,
                                       InterfaceInfo info, ServiceInfo service, 
-                                      OperationType opType, QName opQName) {
+                                      OperationType opType, QName opQName)
+        throws Exception {
         
         BindingInfo bInfo = destination.getBindingInfo();                              
         EndpointInfo eptInfo = destination.getEndPointInfo();
@@ -438,7 +435,8 @@
     protected NVList prepareDIIArgsList(CorbaMessage corbaMsg, 
                                         CorbaStreamable[] streamables, 
                                         List<ParamType> paramTypes,
-                                        List<CorbaTypeMap> maps) { 
+                                        List<CorbaTypeMap> maps)
+        throws Exception { 
         
         // Build the list of DII arguments, returns, and exceptions        
         NVList list = orb.create_list(streamables.length);        
@@ -472,24 +470,19 @@
         return list;
     } 
     
-    protected void prepareArgs(CorbaMessage corbaMsg, List<ParamType> paramTypes) {
+    protected void prepareArgs(CorbaMessage corbaMsg, List<ParamType> paramTypes)
+        throws Exception {
         List<Object> args = new ArrayList<Object>();
         int idx = 0;
         
-        try {
-            for (ParamType param : paramTypes) {                
-                Class cls = param.getIdltype().getLocalPart().getClass();
-                if (cls.isAssignableFrom(Holder.class)) {
-                    args.add(cls.newInstance());
-                } 
-                idx++;
-            }
-            corbaMsg.setContent(List.class, args);
-        } catch (InstantiationException ex) {
-            ex.printStackTrace();         
-        } catch (IllegalAccessException ex2) {
-            ex2.printStackTrace();
+        for (ParamType param : paramTypes) {                
+            Class cls = param.getIdltype().getLocalPart().getClass();
+            if (cls.isAssignableFrom(Holder.class)) {
+                args.add(cls.newInstance());
+            } 
+            idx++;
         }
+        corbaMsg.setContent(List.class, args);        
     }
     
     protected XMLOutputFactory getXMLOutputFactory() {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java?view=diff&rev=490728&r1=490727&r2=490728
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptor.java Thu Dec 28 05:58:49 2006
@@ -35,6 +35,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.DataWriterFactory;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.io.EventDataWriter;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -84,35 +85,40 @@
     }
 
     public void handleMessage(Message msg) {
-        CorbaMessage message = (CorbaMessage) msg;
-        orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
-        corbaStaxObject = new CorbaStaxObject(orb);
-        Exchange exchange = message.getExchange();
-        typeMaps = new ArrayList<CorbaTypeMap>();
-
-        ServiceInfo service = exchange.get(ServiceInfo.class);
-        List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
-        if (corbaTypes != null) {
-            CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
-            corbaStaxObject.setTypeMaps(typeMaps);
-        }        
-        getXMLOutputFactory().setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
-
-        // TODO: where does encoding constant go?
-        //String encoding = (String)message.get("Encoding");                
-        BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
-        OperationType opType = boi.getExtensor(OperationType.class);
-        OperationInfo opInfo = boi.getOperationInfo();
+        try {
+            CorbaMessage message = (CorbaMessage) msg;
+            orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
+            corbaStaxObject = new CorbaStaxObject(orb);
+            Exchange exchange = message.getExchange();
+            typeMaps = new ArrayList<CorbaTypeMap>();
+
+            ServiceInfo service = exchange.get(ServiceInfo.class);
+            List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+            if (corbaTypes != null) {
+                CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+                corbaStaxObject.setTypeMaps(typeMaps);
+            }        
+            getXMLOutputFactory().setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+            // TODO: where does encoding constant go?
+            //String encoding = (String)message.get("Encoding");                
+            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+            OperationType opType = boi.getExtensor(OperationType.class);
+            OperationInfo opInfo = boi.getOperationInfo();
         
-        if (ContextUtils.isRequestor(message)) {
-            handleOutBoundMessage(message, opType, opInfo);
-        } else {
-            handleInBoundMessage(message, opType, opInfo);
+            if (ContextUtils.isRequestor(message)) {
+                handleOutBoundMessage(message, opType, opInfo);
+            } else {
+                handleInBoundMessage(message, opType, opInfo);
+            }
+        } catch (Exception ex) {
+            throw new Fault(ex);
         }
     }
     
     
-    protected void handleOutBoundMessage(CorbaMessage message, OperationType opType, OperationInfo opInfo) {
+    protected void handleOutBoundMessage(CorbaMessage message, OperationType opType, OperationInfo opInfo)
+        throws Exception {
         EventDataWriter writer = (EventDataWriter)getDataWriter(message);
         List<ParamType> paramTypes = opType.getParam();
         List<Object> args = message.getContent(List.class);
@@ -133,7 +139,8 @@
     }
     
     protected void handleInBoundMessage(CorbaMessage message, OperationType opType,
-                                        OperationInfo opInfo) {        
+                                        OperationInfo opInfo)
+        throws Exception {        
         EventDataWriter writer = (EventDataWriter)getDataWriter(message);
         ArgType returnParam = opType.getReturn();
         List<Object> args = message.getContent(List.class);
@@ -144,106 +151,100 @@
     protected void addMarshalRequestParams(CorbaMessage message, List<Object> arguments,
                                            OperationInfo opInfo,
                                            List<ParamType> params, XMLInputFactory inputFactory,
-                                           XMLOutputFactory outputFactory, EventDataWriter writer) {
-        try {
-            if (writer != null) {
-                List<Object> args = arguments;
-
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-
-                for (int i = 0; i < args.size(); i++) {
-                    MessagePartInfo part = getInputMessagePartInfo(opInfo, i);
-                    Object partValue = args.get(i);
-                    writer.write(partValue, part, evtWriter);
+                                           XMLOutputFactory outputFactory, EventDataWriter writer)
+        throws Exception {
+        if (writer != null) {
+            List<Object> args = arguments;
+
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+
+            for (int i = 0; i < args.size(); i++) {
+                MessagePartInfo part = getInputMessagePartInfo(opInfo, i);
+                Object partValue = args.get(i);
+                writer.write(partValue, part, evtWriter);
+            }
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+            
+            for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
+                ParamType param = iter.next();
+                QName elName = new QName("", param.getName());
+                QName idlType = param.getIdltype();
+                CorbaObjectHandler obj = null;
+                if (param.getMode().equals(ModeType.OUT)) {
+                    obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
+                } else {
+                    obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
                 }
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
-
-                for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
-                    ParamType param = iter.next();
-                    QName elName = new QName("", param.getName());
-                    QName idlType = param.getIdltype();
-                    CorbaObjectHandler obj = null;
-                    if (param.getMode().equals(ModeType.OUT)) {
-                        obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
-                    } else {
-                        obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
-                    }
-                    CorbaStreamable streamable = new CorbaStreamable(obj, elName);
-                    ModeType paramMode = param.getMode();
-                    if (paramMode.value().equals("in")) {
-                        streamable.setMode(org.omg.CORBA.ARG_IN.value);
-                    } else if (paramMode.value().equals("inout")) {
-                        streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
-                    } else if (paramMode.value().equals("out")) {
-                        streamable.setMode(org.omg.CORBA.ARG_OUT.value);
-                    }
-                    message.addStreamableArgument(streamable);
+                CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+                ModeType paramMode = param.getMode();
+                if (paramMode.value().equals("in")) {
+                    streamable.setMode(org.omg.CORBA.ARG_IN.value);
+                } else if (paramMode.value().equals("inout")) {
+                    streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
+                } else if (paramMode.value().equals("out")) {
+                    streamable.setMode(org.omg.CORBA.ARG_OUT.value);
                 }
+                message.addStreamableArgument(streamable);
             }
-        } catch (java.lang.Exception ex) {
-            ex.printStackTrace();
         }
     }
     
     protected void addMarshalResponseParams(CorbaMessage message, List<Object> arguments,
                                             OperationInfo opInfo,
                                             OperationType opType, XMLInputFactory inputFactory,
-                                            XMLOutputFactory outputFactory, EventDataWriter writer) {
+                                            XMLOutputFactory outputFactory, EventDataWriter writer)
+        throws Exception {
         List<ParamType> params = opType.getParam();
-        try {
-            if (writer != null) {
-                List<Object> args = arguments;
+        if (writer != null) {
+            List<Object> args = arguments;
 
-                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-                XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
-                for (int i = 0; i < args.size(); i++) {
-                    MessagePartInfo part = getOutputMessagePartInfo(opInfo, i);
-                    Object partValue = args.get(i);
-                    writer.write(partValue, part, evtWriter);
-                }
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            XMLEventWriter evtWriter = outputFactory.createXMLEventWriter(outStream);
+            for (int i = 0; i < args.size(); i++) {
+                MessagePartInfo part = getOutputMessagePartInfo(opInfo, i);
+                Object partValue = args.get(i);
+                writer.write(partValue, part, evtWriter);
+            }
 
-                ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
-                XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+            ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+            XMLEventReader evtReader = inputFactory.createXMLEventReader(inStream);
+            
+            ArgType returnParam = opType.getReturn();
+            if (returnParam != null) {
+                QName retName = new QName("", returnParam.getName());
+                QName retIdlType = returnParam.getIdltype();
+                CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader,
+                                                                            retIdlType,
+                                                                            false);
+                CorbaStreamable streamable = new CorbaStreamable(obj, retName);
+                message.setStreamableReturn(streamable);
+            }
 
-                ArgType returnParam = opType.getReturn();
-                if (returnParam != null) {
-                    QName retName = new QName("", returnParam.getName());
-                    QName retIdlType = returnParam.getIdltype();
-                    CorbaObjectHandler obj = corbaStaxObject.readObjectFromStax(evtReader,
-                                                                                retIdlType,
-                                                                                false);
-                    CorbaStreamable streamable = new CorbaStreamable(obj, retName);
-                    message.setStreamableReturn(streamable);
+            for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
+                ParamType param = iter.next();
+                QName elName = new QName("", param.getName());
+                QName idlType = param.getIdltype();
+                CorbaObjectHandler obj = null;
+
+                if (param.getMode().equals(ModeType.IN)) {
+                    obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
+                } else {
+                    obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
                 }
 
-                for (Iterator<ParamType> iter = params.iterator(); iter.hasNext();) {
-                    ParamType param = iter.next();
-                    QName elName = new QName("", param.getName());
-                    QName idlType = param.getIdltype();
-                    CorbaObjectHandler obj = null;
-
-                    if (param.getMode().equals(ModeType.IN)) {
-                        obj = CorbaHandlerUtils.initializeObjectHandler(orb, elName, idlType, typeMaps);
-                    } else {
-                        obj = corbaStaxObject.readObjectFromStax(evtReader, idlType, false);
-                    }
-
-                    CorbaStreamable streamable = new CorbaStreamable(obj, elName);
-                    ModeType paramMode = param.getMode();
-                    if (paramMode.value().equals("in")) {
-                        streamable.setMode(org.omg.CORBA.ARG_IN.value);
-                    } else if (paramMode.value().equals("inout")) {
-                        streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
-                    } else if (paramMode.value().equals("out")) {
-                        streamable.setMode(org.omg.CORBA.ARG_OUT.value);
-                    }
-                    message.addStreamableArgument(streamable);
+                CorbaStreamable streamable = new CorbaStreamable(obj, elName);
+                ModeType paramMode = param.getMode();
+                if (paramMode.value().equals("in")) {
+                    streamable.setMode(org.omg.CORBA.ARG_IN.value);
+                } else if (paramMode.value().equals("inout")) {
+                    streamable.setMode(org.omg.CORBA.ARG_INOUT.value);
+                } else if (paramMode.value().equals("out")) {
+                    streamable.setMode(org.omg.CORBA.ARG_OUT.value);
                 }
+                message.addStreamableArgument(streamable);
             }
-        } catch (java.lang.Exception ex) {
-            ex.printStackTrace();
         }
     }            
                     

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java?view=auto&rev=490728
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java Thu Dec 28 05:58:49 2006
@@ -0,0 +1,366 @@
+/**
+ * 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.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.ws.Holder;
+
+import org.apache.type_test.types1.BoundedArray;
+import org.apache.type_test.types1.CompoundArray;
+import org.apache.type_test.types1.EmptyStruct;
+import org.apache.type_test.types1.FixedArray;
+import org.apache.type_test.types1.NestedArray;
+import org.apache.type_test.types1.NestedStruct;
+import org.apache.type_test.types1.SimpleStruct;
+import org.apache.type_test.types1.StructWithNillables;
+import org.apache.type_test.types1.UnboundedArray;
+
+public abstract class AbstractTypeTestClient1 extends AbstractTypeTestClient {
+
+    public AbstractTypeTestClient1(String name) {
+        super(name);
+    }
+
+    protected <T> boolean equalsNilable(T x, T y) {
+        if (x == null) {
+            return y == null;
+        } else if (y == null) {
+            return false;
+        } else {
+            return x.equals(y);
+        }
+    }
+
+    protected <T> boolean notNull(T x, T y) {
+        return x != null && y != null;
+    }
+
+    //org.apache.type_test.types1.EmptyStruct
+    
+    public void testEmptyStruct() throws Exception {
+        EmptyStruct x = new EmptyStruct();
+        EmptyStruct yOrig = new EmptyStruct();
+        Holder<EmptyStruct> y = new Holder<EmptyStruct>(yOrig);
+        Holder<EmptyStruct> z = new Holder<EmptyStruct>();
+        EmptyStruct ret = client.testEmptyStruct(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testEmptyStruct(): Null value for inout param",
+                       notNull(x, y.value));
+            assertTrue("testEmptyStruct(): Null value for out param",
+                       notNull(yOrig, z.value));
+            assertTrue("testEmptyStruct(): Null return value", notNull(x, ret));
+        }
+    }
+    
+    //org.apache.type_test.types1.SimpleStruct
+
+    protected boolean equals(SimpleStruct x, SimpleStruct y) {
+        return (Double.compare(x.getVarFloat(), y.getVarFloat()) == 0)
+            && (x.getVarInt().compareTo(y.getVarInt()) == 0)
+            && (x.getVarString().equals(y.getVarString()))
+            && (equalsNilable(x.getVarAttrString(), y.getVarAttrString()));
+    }
+    
+    public void testSimpleStruct() throws Exception {
+        SimpleStruct x = new SimpleStruct();
+        x.setVarFloat(3.14f);
+        x.setVarInt(new BigInteger("42"));
+        x.setVarString("Hello There");
+
+        SimpleStruct yOrig = new SimpleStruct();
+        yOrig.setVarFloat(1.414f);
+        yOrig.setVarInt(new BigInteger("13"));
+        yOrig.setVarString("Cheerio");
+
+        Holder<SimpleStruct> y = new Holder<SimpleStruct>(yOrig);
+        Holder<SimpleStruct> z = new Holder<SimpleStruct>();
+        SimpleStruct ret = client.testSimpleStruct(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testSimpleStruct(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testSimpleStruct(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testSimpleStruct(): Incorrect return value", equals(x, ret));
+        }
+    }
+    
+    //org.apache.type_test.types1.StructWithNillables
+
+    protected boolean equals(StructWithNillables x, StructWithNillables y) {
+        return equalsNilable(x.getVarFloat(), y.getVarFloat())
+            && equalsNilable(x.getVarInt(), x.getVarInt())
+            && equalsNilable(x.getVarString(), y.getVarString())
+            && equalsNilable(x.getVarStruct(), y.getVarStruct());
+    }
+    
+    public void testStructWithNillables() throws Exception {
+        StructWithNillables x = new StructWithNillables();
+        StructWithNillables yOrig = new StructWithNillables();
+        yOrig.setVarFloat(new Float(1.414f));
+        yOrig.setVarInt(new Integer(13));
+        yOrig.setVarString("Cheerio");
+
+        Holder<StructWithNillables> y = new Holder<StructWithNillables>(yOrig);
+        Holder<StructWithNillables> z = new Holder<StructWithNillables>();
+        StructWithNillables ret = client.testStructWithNillables(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testStructWithNillables(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testStructWithNillables(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testStructWithNillables(): Incorrect return value", equals(x, ret));
+        }
+    }
+
+    //org.apache.type_test.types1.NestedStruct
+
+    protected boolean equals(NestedStruct x, NestedStruct y) {
+        return (x.getVarInt() == y.getVarInt())
+            && (x.getVarFloat().compareTo(y.getVarFloat()) == 0)
+            && (x.getVarString().equals(y.getVarString()))
+            && equalsNilable(x.getVarEmptyStruct(), y.getVarEmptyStruct())
+            && equalsNilableStruct(x.getVarStruct(), y.getVarStruct());
+    }
+
+    protected boolean equalsNilable(EmptyStruct x, EmptyStruct y) {
+        if (x == null) {
+            return y == null;
+        }
+        return y != null;
+    }
+
+    protected boolean equalsNilableStruct(SimpleStruct x, SimpleStruct y) {
+        if (x == null) {
+            return y == null;
+        } else if (y == null) {
+            return false;
+        } else {
+            return equals(x, y);
+        }
+    }
+    
+    public void testNestedStruct() throws Exception {
+        SimpleStruct xs = new SimpleStruct();
+        xs.setVarFloat(30.14);
+        xs.setVarInt(new BigInteger("420"));
+        xs.setVarString("NESTED Hello There"); 
+        NestedStruct x = new NestedStruct();
+        x.setVarFloat(new BigDecimal("3.14"));
+        x.setVarInt(42);
+        x.setVarString("Hello There");
+        x.setVarEmptyStruct(new EmptyStruct());
+        x.setVarStruct(xs);
+
+        SimpleStruct ys = new SimpleStruct();
+        ys.setVarFloat(10.414);
+        ys.setVarInt(new BigInteger("130"));
+        ys.setVarString("NESTED Cheerio");
+
+        NestedStruct yOrig = new NestedStruct();
+        yOrig.setVarFloat(new BigDecimal("1.414"));
+        yOrig.setVarInt(13);
+        yOrig.setVarString("Cheerio");
+        yOrig.setVarEmptyStruct(new EmptyStruct());
+        yOrig.setVarStruct(ys);
+
+        Holder<NestedStruct> y = new Holder<NestedStruct>(yOrig);
+        Holder<NestedStruct> z = new Holder<NestedStruct>();
+        NestedStruct ret = client.testNestedStruct(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testNestedStruct(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testNestedStruct(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testNestedStruct(): Incorrect return value", equals(x, ret));
+        }
+    }
+    
+    //org.apache.type_test.types1.FixedArray
+    
+    public void testFixedArray() throws Exception {
+        FixedArray x = new FixedArray();
+        x.getItem().addAll(Arrays.asList(Integer.MIN_VALUE, 0, Integer.MAX_VALUE));
+
+        FixedArray yOrig = new FixedArray();
+        yOrig.getItem().addAll(Arrays.asList(-1, 0, 1));
+
+        Holder<FixedArray> y = new Holder<FixedArray>(yOrig);
+        Holder<FixedArray> z = new Holder<FixedArray>();
+        FixedArray ret = client.testFixedArray(x, y, z);
+
+        if (!perfTestOnly) {
+            for (int i = 0; i < 3; i++) {
+                assertEquals("testFixedArray(): Incorrect value for inout param",
+                             x.getItem().get(i), y.value.getItem().get(i));
+                assertEquals("testFixedArray(): Incorrect value for out param",
+                             yOrig.getItem().get(i), z.value.getItem().get(i));
+                assertEquals("testFixedArray(): Incorrect return value",
+                             x.getItem().get(i), ret.getItem().get(i));
+            }
+        }
+    }
+    
+    //org.apache.type_test.types1.BoundedArray
+    
+    public void testBoundedArray() throws Exception {
+        BoundedArray x = new BoundedArray();
+        x.getItem().addAll(Arrays.asList(-100.00f, 0f, 100.00f));
+        BoundedArray yOrig = new BoundedArray();
+        yOrig.getItem().addAll(Arrays.asList(-1f, 0f, 1f));
+
+        Holder<BoundedArray> y = new Holder<BoundedArray>(yOrig);
+        Holder<BoundedArray> z = new Holder<BoundedArray>();
+        BoundedArray ret = client.testBoundedArray(x, y, z);
+
+        if (!perfTestOnly) {
+            float delta = 0.0f;
+
+            int xSize = x.getItem().size(); 
+            int ySize = y.value.getItem().size(); 
+            int zSize = z.value.getItem().size(); 
+            int retSize = ret.getItem().size(); 
+            assertTrue("testBoundedArray() array size incorrect",
+                       xSize == ySize && ySize == zSize && zSize == retSize && xSize == 3);
+            for (int i = 0; i < xSize; i++) {
+                assertEquals("testBoundedArray(): Incorrect value for inout param",
+                             x.getItem().get(i), y.value.getItem().get(i), delta);
+                assertEquals("testBoundedArray(): Incorrect value for out param",
+                             yOrig.getItem().get(i), z.value.getItem().get(i), delta);
+                assertEquals("testBoundedArray(): Incorrect return value",
+                             x.getItem().get(i), ret.getItem().get(i), delta);
+            }
+        }
+    }
+    
+    //org.apache.type_test.types1.UnboundedArray
+
+    protected boolean equals(UnboundedArray x, UnboundedArray y) {
+        List<String> xx = x.getItem();
+        List<String> yy = y.getItem();
+        if (xx.size() != yy.size()) {
+            return false;
+        }
+        for (int i = 0; i < xx.size(); i++) {
+            if (!xx.get(i).equals(yy.get(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    public void testUnboundedArray() throws Exception {
+        UnboundedArray x = new UnboundedArray();
+        x.getItem().addAll(Arrays.asList("AAA", "BBB", "CCC"));
+        UnboundedArray yOrig = new UnboundedArray();
+        yOrig.getItem().addAll(Arrays.asList("XXX", "YYY", "ZZZ"));
+
+        Holder<UnboundedArray> y = new Holder<UnboundedArray>(yOrig);
+        Holder<UnboundedArray> z = new Holder<UnboundedArray>();
+        UnboundedArray ret = client.testUnboundedArray(x, y, z);
+
+        if (!perfTestOnly) {
+            for (int i = 0; i < 3; i++) {
+                assertTrue("testUnboundedArray(): Incorrect value for inout param", equals(x, y.value));
+                assertTrue("testUnboundedArray(): Incorrect value for out param", equals(yOrig, z.value));
+                assertTrue("testUnboundedArray(): Incorrect return value", equals(x, ret));
+            }
+        }
+    }
+    
+    //org.apache.type_test.types1.CompoundArray
+    
+    protected boolean equals(CompoundArray x, CompoundArray y) {
+        return x.getArray1().equals(y.getArray1())
+            && x.getArray2().equals(y.getArray2());
+    }
+    
+    public void testCompoundArray() throws Exception {
+        CompoundArray x = new CompoundArray();
+        x.getArray1().addAll(Arrays.asList("AAA", "BBB", "CCC"));
+        x.getArray2().addAll(Arrays.asList("aaa", "bbb", "ccc"));
+
+        CompoundArray yOrig = new CompoundArray();
+        yOrig.getArray1().addAll(Arrays.asList("XXX", "YYY", "ZZZ"));
+        yOrig.getArray2().addAll(Arrays.asList("xxx", "yyy", "zzz"));
+
+        Holder<CompoundArray> y = new Holder<CompoundArray>(yOrig);
+        Holder<CompoundArray> z = new Holder<CompoundArray>();
+        CompoundArray ret = client.testCompoundArray(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testCompoundArray(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testCompoundArray(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testCompoundArray(): Incorrect return value", equals(x, ret));
+        }
+    }
+
+    //org.apache.type_test.types1.NestedArray
+    
+    public void testNestedArray() throws Exception {
+        String[][] xs = {{"AAA", "BBB", "CCC"}, {"aaa", "bbb", "ccc"}, {"a_a_a", "b_b_b", "c_c_c"}};
+        String[][] ys = {{"XXX", "YYY", "ZZZ"}, {"xxx", "yyy", "zzz"}, {"x_x_x", "y_y_y", "z_z_z"}};
+
+        NestedArray x = new NestedArray();
+        NestedArray yOrig = new NestedArray();
+
+        List<UnboundedArray> xList = x.getSubarray();
+        List<UnboundedArray> yList = yOrig.getSubarray();
+        
+        for (int i = 0; i < 3; i++) {
+            UnboundedArray xx = new UnboundedArray();
+            xx.getItem().addAll(Arrays.asList(xs[i]));
+            xList.add(xx);
+            UnboundedArray yy = new UnboundedArray();
+            yy.getItem().addAll(Arrays.asList(ys[i]));
+            yList.add(yy);
+        }
+
+        Holder<NestedArray> y = new Holder<NestedArray>(yOrig);
+        Holder<NestedArray> z = new Holder<NestedArray>();
+        NestedArray ret = client.testNestedArray(x, y, z);
+
+        if (!perfTestOnly) {
+            for (int i = 0; i < 3; i++) {
+                for (int j = 0; j < 3; j++) {
+                    assertEquals("testNestedArray(): Incorrect value for inout param",
+                        x.getSubarray().get(i).getItem().get(j), 
+                        y.value.getSubarray().get(i).getItem().get(j));
+                    assertEquals("testNestedArray(): Incorrect value for out param",
+                        yOrig.getSubarray().get(i).getItem().get(j),
+                        z.value.getSubarray().get(i).getItem().get(j));
+                    assertEquals("testNestedArray(): Incorrect return value",
+                        x.getSubarray().get(i).getItem().get(j), ret.getSubarray().get(i).getItem().get(j));
+                }
+            }
+        }
+    }
+    
+
+}

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

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



Mime
View raw message