incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eno...@apache.org
Subject svn commit: r483586 [2/4] - in /incubator/yoko/trunk/bindings/src/test: java/org/apache/yoko/bindings/corba/ java/org/apache/yoko/bindings/corba/interceptors/ java/org/apache/yoko/bindings/corba/types/ resources/wsdl/
Date Thu, 07 Dec 2006 18:11:28 GMT
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=483586&r1=483585&r2=483586
==============================================================================
--- 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 Thu Dec  7 10:11:27 2006
@@ -19,10 +19,7 @@
 package org.apache.yoko.bindings.corba;
 
 import java.math.BigInteger;
-import java.util.Properties;
-
 import javax.xml.namespace.QName;
-
 import junit.framework.TestCase;
 
 import org.omg.CORBA.ORB;
@@ -37,6 +34,7 @@
 import org.apache.schemas.yoko.bindings.corba.Sequence;
 import org.apache.schemas.yoko.bindings.corba.Struct;
 import org.apache.yoko.bindings.corba.types.CorbaArrayHandler;
+
 import org.apache.yoko.bindings.corba.types.CorbaExceptionHandler;
 import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
 import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
@@ -47,27 +45,26 @@
 
 public class CorbaObjectWriterTest extends TestCase {
 
-    private ORB orb;
-
+    private static ORB orb;
+    
     public CorbaObjectWriterTest(String arg0) {
         super(arg0);
     }
-
+    
     public static void main(String[] args) {
         junit.textui.TestRunner.run(CorbaObjectWriterTest.class);
     }
-
+    
     protected void setUp() throws java.lang.Exception {
         super.setUp();
 
-        java.util.Properties props = new Properties();
-        props.putAll(System.getProperties());
+        java.util.Properties props = System.getProperties();
         props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
         props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
         props.put("yoko.orb.id", "Yoko-Binding");
         orb = ORB.init(new String[0], props);
     }
-
+    
     protected void tearDown() throws java.lang.Exception {
         if (orb != null) {
             try {
@@ -81,24 +78,24 @@
     public void testWriteBoolean() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Boolean boolValue = new Boolean(true);
         writer.writeBoolean(boolValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         boolean b = iStream.read_boolean();
         assertTrue(b == boolValue.booleanValue());
     }
-
+    
     public void testWriteChar() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Character charValue = new Character('c');
         writer.writeChar(charValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         char c = iStream.read_char();
         assertTrue(c == charValue.charValue());
@@ -107,128 +104,128 @@
     public void testWriteWChar() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Character wcharValue = new Character('w');
         writer.writeChar(wcharValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         char wc = iStream.read_char();
         assertTrue(wc == wcharValue.charValue());
     }
-
+    
     public void testWriteShort() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Short shortValue = new Short((short)-123);
         writer.writeShort(shortValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         short s = iStream.read_short();
         assertTrue(s == shortValue.shortValue());
     }
-
+    
     public void testWriteUShort() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Short ushortValue = new Short((short)123);
         writer.writeUShort(ushortValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         short us = iStream.read_ushort();
         assertTrue(us == ushortValue.shortValue());
     }
-
+    
     public void testWriteLong() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Long longValue = new Long(-1234567);
         writer.writeLong(longValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         long l = iStream.read_long();
         assertTrue(l == longValue.longValue());
     }
-
+    
     public void testWriteULong() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         BigInteger ulongValue = new BigInteger("1234567");
         writer.writeULong(ulongValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         long ul = iStream.read_ulong();
         assertTrue(ul == ulongValue.longValue());
     }
-
+    
     public void testWriteLongLong() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         BigInteger longlongValue = new BigInteger("-12345678900");
         writer.writeLongLong(longlongValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         long ll = iStream.read_longlong();
         assertTrue(ll == longlongValue.longValue());
     }
-
+    
     public void testWriteULongLong() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         BigInteger ulonglongValue = new BigInteger("12345678900");
         writer.writeULongLong(ulonglongValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         long ul = iStream.read_ulonglong();
         assertTrue(ul == ulonglongValue.longValue());
     }
-
+    
     public void testWriteFloat() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Float floatValue = new Float((float)123456.78);
         writer.writeFloat(floatValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         float f = iStream.read_float();
         assertTrue(f == floatValue.floatValue());
     }
-
+    
     public void testWriteDouble() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         Double doubleValue = new Double(987654.321);
         writer.writeDouble(doubleValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         double d = iStream.read_double();
         assertTrue(d == doubleValue.doubleValue());
     }
-
+    
     public void testWriteString() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         String stringValue = new String("String");
         writer.writeString(stringValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         String s = iStream.read_string();
         assertTrue(s.equals(stringValue));
@@ -237,19 +234,19 @@
     public void testWriteWString() {
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
-
+        
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         String wstringValue = new String("String");
         writer.writeWString(wstringValue);
-
+        
         InputStream iStream = oStream.create_input_stream();
         String s = iStream.read_wstring();
         assertTrue(s.equals(wstringValue));
     }
-
+    
     public void testWriteArray() {
         int data[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
-
+        
         // create an array of longs
         QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
         QName arrayIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "array", CorbaConstants.NP_WSDL_CORBA);
@@ -263,7 +260,7 @@
         CorbaArrayHandler obj = new CorbaArrayHandler(new QName("Array"), arrayIdlType, arrayTC, arrayType);
         for (int i = 0; i < data.length; ++i) {
             CorbaPrimitiveHandler nestedObj =
-                new CorbaPrimitiveHandler(new QName("item"), longIdlType,
+                new CorbaPrimitiveHandler(new QName("item"), longIdlType, 
                                       orb.get_primitive_tc(TCKind.tk_long), null);
             nestedObj.setValueFromData(Integer.toString(data[i]));
             obj.addElement(nestedObj);
@@ -273,24 +270,24 @@
         OutputStream oStream = new OutputStream(buf);
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         writer.writeArray(obj);
-
+        
         InputStream iStream = oStream.create_input_stream();
         for (int i = 0; i < data.length; ++i) {
             int val = iStream.read_long();
             assertTrue(val == data[i]);
         }
     }
-
+    
     public void testWriteSequence() {
         String data[] = { "one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one" };
-
+        
         // create an sequence of strings
         QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
         QName seqIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "sequence", CorbaConstants.NP_WSDL_CORBA);
 
         Sequence seqType = new Sequence();
         seqType.setBound(data.length);
-        seqType.setElemtype(stringIdlType);
+        seqType.setElemtype(stringIdlType);        
         // name and respoitory ID of the sequence are not needed for this test
 
         // build the object holder for a sequence.
@@ -298,17 +295,17 @@
         CorbaSequenceHandler obj = new CorbaSequenceHandler(new QName("Seq"), seqIdlType, seqTC, seqType);
         for (int i = 0; i < data.length; ++i) {
             CorbaPrimitiveHandler nestedObj =
-                new CorbaPrimitiveHandler(new QName("item"), stringIdlType,
+                new CorbaPrimitiveHandler(new QName("item"), stringIdlType, 
                                       orb.get_primitive_tc(TCKind.tk_string), null);
             nestedObj.setValueFromData(data[i]);
             obj.addElement(nestedObj);
         }
-
+        
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
         CorbaObjectWriter writer =  new CorbaObjectWriter(oStream);
         writer.writeSequence(obj);
-
+        
         InputStream iStream = oStream.create_input_stream();
         int length = iStream.read_long();
         for (int i = 0; i < length; ++i) {
@@ -316,7 +313,7 @@
             assertTrue(val.equals(data[i]));
         }
     }
-
+    
     public void testWriteStruct() {
         // create the following struct
         // struct TestStruct {
@@ -327,12 +324,12 @@
         int member1 = 12345;
         String member2 = "54321";
         boolean member3 = true;
-
+        
         QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA);
         QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
         QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
         QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
-
+        
         Struct structType = new Struct();
         structType.setName("TestStruct");
         MemberType m1 = new MemberType();
@@ -353,30 +350,30 @@
         structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null);
         structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null);
         structMembers[2] = new StructMember("member3", orb.get_primitive_tc(TCKind.tk_boolean), null);
-        TypeCode structTC = orb.create_struct_tc("IDL:org.apache.yoko.TestStruct/1.0", "TestStruct",
+        TypeCode structTC = orb.create_struct_tc("IDL:org.apache.yoko.TestStruct/1.0", "TestStruct", 
                                                  structMembers);
-        CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType,
+        CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType, 
                                                         structTC, structType);
-        CorbaPrimitiveHandler memberObj1 =
+        CorbaPrimitiveHandler memberObj1 = 
             new CorbaPrimitiveHandler(new QName("member1"), longIdlType, structMembers[0].type, null);
-        CorbaPrimitiveHandler memberObj2 =
+        CorbaPrimitiveHandler memberObj2 = 
             new CorbaPrimitiveHandler(new QName("member2"), stringIdlType, structMembers[1].type, null);
-        CorbaPrimitiveHandler memberObj3 =
+        CorbaPrimitiveHandler memberObj3 = 
             new CorbaPrimitiveHandler(new QName("member3"), boolIdlType, structMembers[2].type, null);
-
+        
         memberObj1.setValueFromData(Integer.toString(member1));
         memberObj2.setValueFromData(member2);
         memberObj3.setValueFromData(Boolean.toString(member3));
-
+        
         obj.addMember(memberObj1);
         obj.addMember(memberObj2);
         obj.addMember(memberObj3);
-
+        
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
         CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
         writer.writeStruct(obj);
-
+        
         InputStream iStream = oStream.create_input_stream();
         int readMember1 = iStream.read_long();
         assertTrue(readMember1 == member1);
@@ -385,7 +382,7 @@
         boolean readMember3 = iStream.read_boolean();
         assertTrue(readMember3 == member3);
     }
-
+    
     public void testWriteException() {
         // create the following exception
         // exception TestExcept {
@@ -395,11 +392,11 @@
         short code = 12345;
         String message = "54321";
         String reposID = "IDL:org.apache.yoko.TestException/1.0";
-
+        
         QName exceptIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "exception", CorbaConstants.NP_WSDL_CORBA);
         QName shortIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
         QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
-
+        
         Exception exceptType = new Exception();
         exceptType.setName("TestException");
         exceptType.setRepositoryID(reposID);
@@ -417,13 +414,13 @@
         exceptMembers[0] = new StructMember("code", orb.get_primitive_tc(TCKind.tk_short), null);
         exceptMembers[1] = new StructMember("message", orb.get_primitive_tc(TCKind.tk_string), null);
         TypeCode exceptTC = orb.create_exception_tc(reposID, "TestException", exceptMembers);
-        CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType,
+        CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType, 
                                                               exceptTC, exceptType);
-
-        CorbaPrimitiveHandler member1 =
+        
+        CorbaPrimitiveHandler member1 = 
             new CorbaPrimitiveHandler(new QName("code"), shortIdlType, exceptMembers[0].type, null);
         member1.setValueFromData(Short.toString(code));
-        CorbaPrimitiveHandler member2 =
+        CorbaPrimitiveHandler member2 = 
             new CorbaPrimitiveHandler(new QName("message"), stringIdlType, exceptMembers[1].type, null);
         member2.setValueFromData(message);
         obj.addMember(member1);
@@ -435,7 +432,7 @@
         writer.writeException(obj);
 
         InputStream iStream = oStream.create_input_stream();
-
+        
         String readId = iStream.read_string();
         assertTrue(readId.equals(reposID));
         short readCode = iStream.read_short();

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java Thu Dec  7 10:11:27 2006
@@ -0,0 +1,298 @@
+/**
+ * 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.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ServerRequest;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
+import org.apache.yoko.orb.CORBA.NVList;
+import org.apache.yoko.wsdl.CorbaConstants;
+
+public class CorbaServerConduitTest extends TestCase {
+        
+    IMocksControl control;
+    ORB orb;
+    Bus bus;
+    protected EndpointInfo endpointInfo;
+    protected EndpointReferenceType target;    
+    protected MessageObserver observer;
+    Message inMessage;
+    CorbaBindingFactory factory;
+    TestUtils testUtils;
+
+    public CorbaServerConduitTest(String arg0) {
+        super(arg0);
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CorbaBindingFactoryTest.class);
+    }
+    
+    public void setUp() throws Exception {
+     control = EasyMock.createNiceControl();
+     
+     bus = BusFactoryHelper.newInstance().getDefaultBus(); 
+     
+     java.util.Properties props = System.getProperties();
+     props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+     props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+     props.put("yoko.orb.id", "Yoko-Server-Binding");
+     orb = ORB.init(new String[0], props);
+    }
+    
+    public void tearDown() {        
+        bus.shutdown(true);
+        if (orb != null) {
+            try {
+                orb.destroy();
+            } catch (Exception ex) {
+                // Do nothing.  Throw an Exception?
+            }
+        } 
+    }
+    
+    public void testCorbaServerConduit() throws Exception {
+        CorbaServerConduit conduit = setupCorbaServerConduit(false);        
+        assertTrue("conduit should not be null", conduit != null);
+    }
+    
+    public void testSend() throws Exception {       
+        setupServiceInfo("http://yoko.apache.org/simple",
+                         "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+                         "SimpleCORBAPort");
+
+        CorbaDestination destination = new CorbaDestination(endpointInfo);
+        CorbaServerConduit conduit = new CorbaServerConduit(endpointInfo, destination.getAddress());
+        Message message = new MessageImpl();
+        try {
+            conduit.send(message);
+        } catch (Exception ex) {
+            ex.printStackTrace();            
+        }
+        OutputStream os = message.getContent(OutputStream.class);
+        assertTrue("OutputStream should not be null", os != null);        
+        ORB orb = (ORB)message.get("orb");
+        assertTrue("Orb should not be null", orb != null);
+        Object obj = message.get("endpoint");
+        assertTrue("EndpointReferenceType should not be null", obj != null);
+        destination.shutdown();
+    }
+       
+    
+    public void testGetTargetReference() throws Exception {
+        setupServiceInfo("http://yoko.apache.org/simple",
+                         "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+                         "SimpleCORBAPort");
+
+        CorbaDestination destination = new CorbaDestination(endpointInfo);
+        CorbaServerConduit conduit = new CorbaServerConduit(endpointInfo, destination.getAddress());
+        
+        EndpointReferenceType t = null;
+        EndpointReferenceType ref = conduit.getTargetReference(t);
+        assertTrue("ref should not be null", ref != null);
+        destination.shutdown();
+    }
+    
+    public void testGetAddress() throws Exception  {
+        setupServiceInfo("http://yoko.apache.org/simple",
+                         "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+                         "SimpleCORBAPort");
+
+        CorbaDestination destination = new CorbaDestination(endpointInfo);
+        endpointInfo.setAddress("corbaloc::localhost:40000/Simple");
+        CorbaServerConduit conduit = new CorbaServerConduit(endpointInfo, destination.getAddress());           
+        String address = conduit.getAddress();
+        assertTrue("address should not be null", address != null);
+        assertEquals(address, "corbaloc::localhost:40000/Simple");        
+    }
+    
+    public void testClose() throws Exception {   
+        
+        Method m = CorbaServerConduit.class.getDeclaredMethod("buildRequestResult", 
+            new Class[] {CorbaMessage.class});
+        CorbaServerConduit conduit = EasyMock.createMock(CorbaServerConduit.class, new Method[] {m});       
+        
+        CorbaMessage msg = control.createMock(CorbaMessage.class);        
+        conduit.buildRequestResult(msg);
+        EasyMock.expectLastCall();
+        OutputStream stream =control.createMock(OutputStream.class);
+        EasyMock.expect(msg.getContent(OutputStream.class)).andReturn(stream);
+        stream.close();
+        EasyMock.expectLastCall();
+        
+        control.replay();
+        conduit.close(msg);
+        control.verify();
+    }        
+                
+    public void testBuildRequestResult() {
+        NVList list = (NVList)orb.create_list(0);        
+        CorbaServerConduit conduit = setupCorbaServerConduit(false);  
+        CorbaMessage msg = control.createMock(CorbaMessage.class);
+        Exchange exchange = control.createMock(Exchange.class);        
+        ServerRequest request = control.createMock(ServerRequest.class);
+        
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
+                
+        EasyMock.expect(exchange.isOneWay()).andReturn(false);
+        CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);
+                
+        EasyMock.expect(inMsg.getList()).andReturn(list);
+        EasyMock.expect(msg.getStreamableException()).andReturn(null);                        
+        EasyMock.expect(msg.getStreamableArguments()).andReturn(null);
+        EasyMock.expect(msg.getStreamableReturn()).andReturn(null);
+        
+        control.replay();
+        conduit.buildRequestResult(msg);
+        control.verify();        
+    }
+    
+    public void testBuildRequestResultException() {
+        NVList list = (NVList)orb.create_list(0);        
+        CorbaServerConduit conduit = setupCorbaServerConduit(false);  
+        CorbaMessage msg = control.createMock(CorbaMessage.class);
+        Exchange exchange = control.createMock(Exchange.class);        
+        ServerRequest request = control.createMock(ServerRequest.class);
+        
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
+                
+        EasyMock.expect(exchange.isOneWay()).andReturn(false);
+        CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);                
+
+        EasyMock.expect(inMsg.getList()).andReturn(list);        
+        QName objName = new QName("object");
+        QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
+        TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
+        CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
+        CorbaStreamable exception = new CorbaStreamable(obj, objName);       
+
+        EasyMock.expect(msg.getStreamableException()).andReturn(exception);
+        EasyMock.expect(msg.getStreamableException()).andReturn(exception);
+               
+        control.replay();
+        conduit.buildRequestResult(msg);
+        control.verify();        
+    }
+
+    public void testBuildRequestResultArgumentReturn() {
+        CorbaStreamable[] arguments = new CorbaStreamable[1];
+        QName objName = new QName("object");
+        QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
+        TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
+        CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
+        CorbaStreamable arg = new CorbaStreamable(obj, objName);        
+        arguments[0] = arg;
+        arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);        
+        
+        NVList nvlist = (NVList)orb.create_list(2);    
+        Any value = orb.create_any();
+        value.insert_Streamable(arguments[0]);
+        nvlist.add_value(arguments[0].getName(), value, arguments[0].getMode());
+        
+        CorbaServerConduit conduit = setupCorbaServerConduit(false);  
+        CorbaMessage msg = control.createMock(CorbaMessage.class);
+        Exchange exchange = control.createMock(Exchange.class);        
+        ServerRequest request = control.createMock(ServerRequest.class);
+        
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
+                
+        EasyMock.expect(exchange.isOneWay()).andReturn(false);        
+        EasyMock.expect(msg.getExchange()).andReturn(exchange);        
+        Message message = new MessageImpl();
+        CorbaMessage corbaMessage = new CorbaMessage(message);
+        corbaMessage.setList(nvlist);
+        
+        EasyMock.expect(exchange.getInMessage()).andReturn(corbaMessage);                
+        EasyMock.expect(msg.getStreamableException()).andReturn(null);
+        EasyMock.expect(msg.getStreamableArguments()).andReturn(arguments);        
+        EasyMock.expect(msg.getStreamableReturn()).andReturn(arg);
+               
+        control.replay();
+        conduit.buildRequestResult(msg);
+        control.verify();        
+    }
+    
+    public void testGetTarget()  {
+        CorbaServerConduit conduit = setupCorbaServerConduit(false);
+        EndpointReferenceType endpoint = conduit.getTarget();
+        assertTrue("EndpointReferenceType should not be null", endpoint != null);
+    }
+    
+           
+    protected CorbaServerConduit setupCorbaServerConduit(boolean send) {
+        target = EasyMock.createMock(EndpointReferenceType.class);                   
+        endpointInfo = EasyMock.createMock(EndpointInfo.class);
+        CorbaServerConduit CorbaServerConduit = 
+            new CorbaServerConduit(endpointInfo, target);
+        
+        if (send) {
+            // setMessageObserver
+            observer = new MessageObserver() {
+                public void onMessage(Message m) {                    
+                    inMessage = m;
+                }
+            };
+            CorbaServerConduit.setMessageObserver(observer);
+        }
+        
+        return CorbaServerConduit;        
+    }
+    
+    protected void setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {        
+        URL wsdlUrl = getClass().getResource(wsdl);
+        assertNotNull(wsdlUrl);
+        WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl, new QName(ns, serviceName));
+
+        Service service = factory.create();        
+        endpointInfo = service.getServiceInfo().getEndpoint(new QName(ns, portName));
+   
+    }
+
+    
+       
+           
+}

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

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

Added: 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=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java Thu Dec  7 10:11:27 2006
@@ -0,0 +1,678 @@
+/**
+ * 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.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.schemas.yoko.bindings.corba.Array;
+import org.apache.schemas.yoko.bindings.corba.Enum;
+import org.apache.schemas.yoko.bindings.corba.Enumerator;
+import org.apache.schemas.yoko.bindings.corba.Fixed;
+import org.apache.schemas.yoko.bindings.corba.MemberType;
+import org.apache.schemas.yoko.bindings.corba.Sequence;
+import org.apache.schemas.yoko.bindings.corba.Struct;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.schemas.yoko.bindings.corba.Union;
+import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.bindings.corba.types.CorbaArrayHandler;
+import org.apache.yoko.bindings.corba.types.CorbaEnumHandler;
+import org.apache.yoko.bindings.corba.types.CorbaFixedHandler;
+import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
+import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
+import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
+import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
+import org.apache.yoko.bindings.corba.types.CorbaUnionHandler;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+
+/**
+ * Holder for reading and writing stax methods.
+ */
+public class CorbaStaxObjectTest extends TestCase {
+    protected Bus bus;
+    protected static ORB orb;    
+    protected EndpointReferenceType target;        
+    protected Message inMessage;    
+    protected EndpointInfo endpointInfo;
+    CorbaBindingFactory factory;
+    CorbaStaxObject staxObject;
+    
+    private final static String staxTestNamespaceURI = "http://yoko.apache.org/StaxTest/idl_types";
+    private final static String staxTestPrefix = "corbatm";
+    
+    public CorbaStaxObjectTest() {   
+        super();
+    }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+     
+        java.util.Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+        props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+        props.put("yoko.orb.id", "Yoko-Server-Binding");
+        orb = ORB.init(new String[0], props);
+        
+        staxObject = new CorbaStaxObject(orb);
+        staxObject.setOrb(orb);
+        TestUtils testUtils = new TestUtils();
+        endpointInfo = testUtils.setupServiceInfo("http://yoko.apache.org/StaxTest",
+                         "/wsdl/StaxTest.wsdl", "StaxTestCORBAService",
+                         "StaxTestCORBAPort");
+        
+        List<CorbaTypeMap> typeMaps;       
+        typeMaps = new ArrayList<CorbaTypeMap>();        
+        
+        CorbaDestination destination = testUtils.getStaxTypesTestDestination();
+        ServiceInfo service = destination.getBindingInfo().getService();        
+        List<TypeMappingType> corbaTypes = service.getExtensors(TypeMappingType.class);
+        if (corbaTypes != null) {
+            CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+            staxObject.setTypeMaps(typeMaps);
+        }
+        
+    }
+    
+    public void tearDown() throws Exception {
+        super.setUp();
+        if (orb != null) {
+            try {
+                orb.destroy();
+            } catch (Exception ex) {
+                // Do nothing.  Throw an Exception?
+            }
+        } 
+    }
+    
+    public void testReadWriteStaxPrimitive() {               
+        CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(new QName("BooleanType"),
+                                                              CorbaConstants.NT_CORBA_BOOLEAN,
+                                                              orb.get_primitive_tc(TCKind.tk_boolean),
+                                                              null);
+        obj.setValueFromData("false");
+
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writePrimitiveToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler result = (CorbaObjectHandler)staxObject.readPrimitiveFromStax(evtReader, 
+                                                                      obj.getIdlType(), 
+                                                                      obj.getTypeCode());
+        assertNotNull(result);
+        
+        assertTrue(result instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultObj = (CorbaPrimitiveHandler)result;
+        
+        assertTrue(resultObj.getName().equals(obj.getName()));
+        assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+        assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+        assertTrue(resultObj.getValueData().equals(obj.getValueData()));
+    }
+    
+    public void testReadWriteStaxArray() {
+                
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestArray", staxTestPrefix);
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Array);
+
+        Array arrayType = (Array)type;
+        CorbaArrayHandler obj = new CorbaArrayHandler(objName, objIdlType, objTypeCode, arrayType);
+        assertNotNull(obj);
+
+        List<CorbaObjectHandler> objElements = new ArrayList<CorbaObjectHandler>();
+        int arrayData[] = { 2, 4, 6, 8, 10 };
+        for (int i = 0 ; i < arrayData.length; ++i) {
+            QName elName = new QName("item");
+            QName elIdlType = CorbaConstants.NT_CORBA_LONG;
+            TypeCode elTC = orb.get_primitive_tc(TCKind.tk_long);
+            CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
+            el.setValue(Long.valueOf(arrayData[i]));
+            obj.addElement(el);
+            objElements.add(el);
+        }
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeArrayToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler result = staxObject.readArrayFromStax(evtReader, 
+                                                                  obj.getIdlType(), 
+                                                                  obj.getTypeCode());
+        assertNotNull(result);
+        
+        assertTrue(result instanceof CorbaArrayHandler);
+        CorbaArrayHandler resultObj = (CorbaArrayHandler)result;
+        
+        assertTrue(resultObj.getName().equals(obj.getName()));
+        assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+        assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+        List<CorbaObjectHandler> resultElements = resultObj.getElements();
+        for (int i = 0; i < resultElements.size(); ++i) {
+            assertTrue(resultElements.get(i) instanceof CorbaPrimitiveHandler);
+            CorbaPrimitiveHandler resultEl = (CorbaPrimitiveHandler)resultElements.get(i);
+            CorbaPrimitiveHandler objEl = (CorbaPrimitiveHandler)objElements.get(i);
+            assertTrue(resultEl.getValueData().equals(objEl.getValueData()));
+        }
+    }
+    
+    public void testReadWriteStaxEnum() {        
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestEnum", staxTestPrefix);
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Enum);
+        Enum enumType = (Enum)type;
+        List<Enumerator> enumerators = enumType.getEnumerator();
+        String[] enums = new String[enumerators.size()];
+        for (int i = 0; i < enumerators.size(); ++i) {
+            Enumerator e = enumerators.get(i);
+            enums[i] = e.getValue();
+        }
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaEnumHandler obj = new CorbaEnumHandler(objName, objIdlType, objTypeCode, enumType);
+        assertNotNull(obj);
+        
+        obj.setValue(enums[1]);
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeEnumToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler resultObj = staxObject.readEnumFromStax(evtReader, 
+                                                                    obj.getIdlType(), 
+                                                                    obj.getTypeCode());
+        assertNotNull(resultObj);
+        
+        assertTrue(resultObj instanceof CorbaEnumHandler);
+        CorbaEnumHandler result = (CorbaEnumHandler)resultObj;
+        
+        Object resultValueObj = result.getValue();
+        assertTrue(resultValueObj instanceof String);
+        
+        String resultValue = (String)resultValueObj;
+        assertTrue(resultValue.equals(enums[1]));
+    }
+
+    public void testReadWriteStaxFixed() {        
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestFixed", staxTestPrefix);
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Fixed);
+        Fixed fixedType = (Fixed)type;
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaFixedHandler obj = new CorbaFixedHandler(objName, objIdlType, objTypeCode, fixedType);
+        assertNotNull(obj);
+
+        java.math.BigDecimal fixedValue = new java.math.BigDecimal("12345.67");
+        obj.setValue(fixedValue);
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeFixedToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler resultObj = staxObject.readFixedFromStax(evtReader, 
+                                                                     obj.getIdlType(), 
+                                                                     obj.getTypeCode());
+        assertNotNull(resultObj);
+        
+        assertTrue(resultObj instanceof CorbaFixedHandler);
+        CorbaFixedHandler result = (CorbaFixedHandler)resultObj;
+        
+        Object resultValueObj = result.getValue();
+        assertTrue(resultValueObj instanceof java.math.BigDecimal);
+        
+        java.math.BigDecimal resultValue = (java.math.BigDecimal)resultValueObj;
+        assertTrue(resultValue.toString().equals(fixedValue.toString()));
+    }
+
+    public void testReadWriteStaxSequence() {
+                
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestSequence", staxTestPrefix);
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Sequence);
+
+        Sequence seqType = (Sequence)type;
+        CorbaSequenceHandler obj = new CorbaSequenceHandler(objName, objIdlType, objTypeCode, seqType);
+        assertNotNull(obj);
+
+        List<CorbaObjectHandler> objElements = new ArrayList<CorbaObjectHandler>();
+        short seqData[] = { 1, 3, 5, 7 };
+        for (int i = 0 ; i < seqData.length; ++i) {
+            QName elName = new QName("item");
+            QName elIdlType = CorbaConstants.NT_CORBA_SHORT;
+            TypeCode elTC = orb.get_primitive_tc(TCKind.tk_short);
+            CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
+            el.setValue(Short.valueOf(seqData[i]));
+            obj.addElement(el);
+            objElements.add(el);
+        }
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeSequenceToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler result = staxObject.readSequenceFromStax(evtReader, 
+                                                                     obj.getIdlType(), 
+                                                                     obj.getTypeCode());
+        assertNotNull(result);
+        
+        assertTrue(result instanceof CorbaSequenceHandler);
+        CorbaSequenceHandler resultObj = (CorbaSequenceHandler)result;
+        
+        assertTrue(resultObj.getName().equals(obj.getName()));
+        assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+        assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+        List<CorbaObjectHandler> resultElements = resultObj.getElements();
+        for (int i = 0; i < resultElements.size(); ++i) {
+            assertTrue(resultElements.get(i) instanceof CorbaPrimitiveHandler);
+            CorbaPrimitiveHandler resultEl = (CorbaPrimitiveHandler)resultElements.get(i);
+            CorbaPrimitiveHandler objEl = (CorbaPrimitiveHandler)objElements.get(i);
+            assertTrue(resultEl.getValueData().equals(objEl.getValueData()));
+        }
+    }
+
+    public void testReadWriteStaxStruct() {        
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestStruct", staxTestPrefix);
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Struct);
+        Struct structType = (Struct)type;
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaStructHandler obj = new CorbaStructHandler(objName, objIdlType, objTypeCode, structType);
+        assertNotNull(obj);
+
+        List<MemberType> structMembers = structType.getMember();
+        // For this test, we know what each of the members are.  Create the correct handler and assign
+        // each member a value
+        MemberType m1 = structMembers.get(0);
+        TypeCode m1TypeCode = CorbaUtils.getTypeCode(orb, m1.getIdltype(), staxObject.getTypeMaps());
+        CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName(m1.getName()),
+                                                                 m1.getIdltype(),
+                                                                 m1TypeCode,
+                                                                 null);
+        Boolean member1Value = new Boolean(false);
+        member1.setValue(member1Value);
+        obj.addMember(member1);
+        
+        MemberType m2 = structMembers.get(1);
+        TypeCode m2TypeCode = CorbaUtils.getTypeCode(orb, m2.getIdltype(), staxObject.getTypeMaps());
+        CorbaPrimitiveHandler member2 = new CorbaPrimitiveHandler(new QName(m2.getName()),
+                                                                 m2.getIdltype(),
+                                                                 m2TypeCode,
+                                                                 null);
+        String member2Value = "Member 2 string";
+        member2.setValue(member2Value);
+        obj.addMember(member2);
+        
+        MemberType m3 = structMembers.get(2);
+        TypeCode m3TypeCode = CorbaUtils.getTypeCode(orb, m3.getIdltype(), staxObject.getTypeMaps());
+        CorbaPrimitiveHandler member3 = new CorbaPrimitiveHandler(new QName(m3.getName()),
+                                                                 m3.getIdltype(),
+                                                                 m3TypeCode,
+                                                                 null);
+        Float member3Value = new Float(12345.678);
+        member3.setValue(member3Value);
+        obj.addMember(member3);
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeStructToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler resultObj = staxObject.readStructFromStax(evtReader, 
+                                                                     obj.getIdlType(), 
+                                                                     obj.getTypeCode());
+        assertNotNull(resultObj);
+        
+        assertTrue(resultObj instanceof CorbaStructHandler);
+        CorbaStructHandler result = (CorbaStructHandler)resultObj;
+        
+        List<CorbaObjectHandler> resultMembers = result.getMembers();
+        assertTrue(resultMembers.size() == 3);
+        
+        CorbaObjectHandler resultMember1Obj = resultMembers.get(0);
+        assertTrue(resultMember1Obj instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultMember1 = (CorbaPrimitiveHandler)resultMember1Obj;
+        Object resultMember1ValueObj = resultMember1.getValue();
+        assertTrue(resultMember1ValueObj instanceof Boolean);
+        Boolean resultMember1Value = (Boolean)resultMember1ValueObj;
+        assertTrue(resultMember1Value.booleanValue() == member1Value.booleanValue());
+        
+        CorbaObjectHandler resultMember2Obj = resultMembers.get(1);
+        assertTrue(resultMember2Obj instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultMember2 = (CorbaPrimitiveHandler)resultMember2Obj;
+        Object resultMember2ValueObj = resultMember2.getValue();
+        assertTrue(resultMember2ValueObj instanceof String);
+        String resultMember2Value = (String)resultMember2ValueObj;
+        assertTrue(resultMember2Value.equals(member2Value));
+        
+        CorbaObjectHandler resultMember3Obj = resultMembers.get(2);
+        assertTrue(resultMember3Obj instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultMember3 = (CorbaPrimitiveHandler)resultMember3Obj;
+        Object resultMember3ValueObj = resultMember3.getValue();
+        assertTrue(resultMember3ValueObj instanceof Float);
+        Float resultMember3Value = (Float)resultMember3ValueObj;
+        assertTrue(resultMember3Value.floatValue() == member3Value.floatValue());
+    }
+    
+    public void testReadWriteUnionStruct() {        
+        QName objName = new QName("object");
+        QName objIdlType = new QName(staxTestNamespaceURI, "TestUnion", staxTestPrefix);
+        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
+        assertTrue(type instanceof Union);
+        Union unionType = (Union)type;
+        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
+        CorbaUnionHandler obj = new CorbaUnionHandler(objName, objIdlType, objTypeCode, unionType);
+        assertNotNull(obj);
+        
+        Character unionValue = new Character('u');
+        TypeCode unionValueTC = CorbaUtils.getTypeCode(orb, CorbaConstants.NT_CORBA_WCHAR, 
+                                                       staxObject.getTypeMaps());
+        CorbaPrimitiveHandler unionValueObj = new CorbaPrimitiveHandler(new QName("case12"),
+                                                                        CorbaConstants.NT_CORBA_WCHAR,
+                                                                        unionValueTC, 
+                                                                        null);
+        unionValueObj.setValue(unionValue);
+        Short discriminatorValue = new Short((short)1);
+        TypeCode discriminatorTC = CorbaUtils.getTypeCode(orb, unionType.getDiscriminator(),
+                                                          staxObject.getTypeMaps());
+        CorbaPrimitiveHandler discriminator = new CorbaPrimitiveHandler(new QName("discriminator"),
+                                                                       unionType.getDiscriminator(),
+                                                                       discriminatorTC,
+                                                                       null);
+        discriminator.setValue(discriminatorValue);
+
+        obj.setDiscriminator(discriminator);
+        obj.setValue("1", unionValueObj);
+        
+        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+      
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        XMLEventWriter evtWriter = null;
+        try {
+            evtWriter = outputFactory.createXMLEventWriter(outStream);
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtWriter);
+        
+        try {
+            XMLEventFactory factory = XMLEventFactory.newInstance();
+            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+            evtWriter.add(startEl);
+            staxObject.writeUnionToStax(obj, evtWriter, factory);
+            EndElement endEl = factory.createEndElement(obj.getName(), null);
+            evtWriter.add(endEl);
+            evtWriter.flush();
+        } catch (XMLStreamException ex) {
+            
+        }
+
+        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());        
+        XMLEventReader evtReader = null;
+        try {            
+            evtReader = inputFactory.createXMLEventReader(inStream);
+            // read the first tag which should be a start document
+            XMLEvent evt = evtReader.nextEvent();
+            assertTrue(evt.isStartDocument());
+        } catch (XMLStreamException ex) {
+        }
+        assertNotNull(evtReader);
+        
+        CorbaObjectHandler resultObj = staxObject.readUnionFromStax(evtReader, 
+                                                                     obj.getIdlType(), 
+                                                                     obj.getTypeCode());
+        assertNotNull(resultObj);
+        
+        assertTrue(resultObj instanceof CorbaUnionHandler);
+        CorbaUnionHandler result = (CorbaUnionHandler)resultObj;
+        
+        CorbaObjectHandler resultDiscriminatorObj = result.getDiscriminator();
+        assertTrue(resultDiscriminatorObj instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultDiscriminator = (CorbaPrimitiveHandler)resultDiscriminatorObj;
+        Object resultDiscValueObj = resultDiscriminator.getValue();
+        assertTrue(resultDiscValueObj instanceof Short);
+        Short resultDiscValue = (Short)resultDiscValueObj;
+        assertTrue(resultDiscValue.shortValue() == discriminatorValue.shortValue());
+        
+        CorbaObjectHandler resultValueObj = result.getValue();
+        assertTrue(resultValueObj instanceof CorbaPrimitiveHandler);
+        CorbaPrimitiveHandler resultValue = (CorbaPrimitiveHandler)resultValueObj;
+        Object unionResultValueObj = resultValue.getValue();
+        assertTrue(unionResultValueObj instanceof Character);
+        Character unionResultValue = (Character)unionResultValueObj;
+        assertTrue(unionResultValue.charValue() == unionValue.charValue());
+    }
+
+    
+}

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

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

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStreamableTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStreamableTest.java?view=diff&rev=483586&r1=483585&r2=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStreamableTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStreamableTest.java Thu Dec  7 10:11:27 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.yoko.bindings.corba;
 
-import java.util.Properties;
 import javax.xml.namespace.QName;
 
 import org.omg.CORBA.portable.InputStream;
@@ -29,33 +28,32 @@
 import junit.framework.TestCase;
 
 import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
+import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.orb.CORBA.OutputStream;
 import org.apache.yoko.orb.OCI.Buffer;
-import org.apache.yoko.wsdl.CorbaConstants;
 
 public class CorbaStreamableTest extends TestCase {
 
-    private ORB orb;
-
+    private static ORB orb;
+    
     public CorbaStreamableTest(String arg0) {
         super(arg0);
     }
-
+    
     public static void main(String[] args) {
         junit.textui.TestRunner.run(CorbaStreamableTest.class);
     }
-
+    
     protected void setUp() throws Exception {
         super.setUp();
-
-        java.util.Properties props = new Properties();
-        props.putAll(System.getProperties());
+        
+        java.util.Properties props = System.getProperties();
         props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
         props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
         props.put("yoko.orb.id", "Yoko-Binding");
         orb = ORB.init(new String[0], props);
     }
-
+    
     protected void tearDown() throws Exception {
         if (orb != null) {
             try {
@@ -65,70 +63,70 @@
             }
         }
     }
-
+    
     public void testCreateStreamable() {
         QName objName = new QName("object");
         QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
         TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
         CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
-        CorbaStreamable streamable = new CorbaStreamable(obj, objName);
+        CorbaStreamable streamable = new CorbaStreamable(obj, objName);       
 
         assertNotNull(streamable);
     }
-
+    
     public void testGetStreamableAttributes() {
         QName objName = new QName("object");
         QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "float", CorbaConstants.NP_WSDL_CORBA);
         TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_float);
         CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
-        CorbaStreamable streamable = new CorbaStreamable(obj, objName);
+        CorbaStreamable streamable = new CorbaStreamable(obj, objName);       
 
         TypeCode type = streamable._type();
         assertTrue(type.kind().value() == objTypeCode.kind().value());
-
+        
         CorbaPrimitiveHandler storedObj = (CorbaPrimitiveHandler)streamable.getObject();
         assertNotNull(storedObj);
-
+        
         int mode = streamable.getMode();
         assertTrue(mode == org.omg.CORBA.ARG_OUT.value);
-
+        
         String name = streamable.getName();
         assertTrue(name.equals(objName.getLocalPart()));
     }
-
+    
     public void testSetStreamableAttributes() {
         QName objName = new QName("object");
         QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
         TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
         CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
-        CorbaStreamable streamable = new CorbaStreamable(obj, objName);
+        CorbaStreamable streamable = new CorbaStreamable(obj, objName);       
 
         streamable.setMode(org.omg.CORBA.ARG_IN.value);
         int mode = streamable.getMode();
         assertTrue(mode == org.omg.CORBA.ARG_IN.value);
     }
-
+    
     public void testReadStreamable() {
         QName objName = new QName("object");
         QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "char", CorbaConstants.NP_WSDL_CORBA);
         TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_char);
         CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
-        CorbaStreamable streamable = new CorbaStreamable(obj, objName);
-
+        CorbaStreamable streamable = new CorbaStreamable(obj, objName); 
+        
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
         oStream.write_char('c');
-
+        
         InputStream iStream = oStream.create_input_stream();
         streamable._read(iStream);
         CorbaPrimitiveHandler streamableObj = (CorbaPrimitiveHandler)streamable.getObject();
         Object o = streamableObj.getValue();
-
+        
         assertTrue(o instanceof Character);
         Character charValue = (Character)o;
         assertTrue(charValue.charValue() == 'c');
     }
-
+    
     public void testWriteStreamable() {
         QName objName = new QName("object");
         QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "wstring", CorbaConstants.NP_WSDL_CORBA);
@@ -136,11 +134,11 @@
         CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
         obj.setValueFromData("TestWString");
         CorbaStreamable streamable = new CorbaStreamable(obj, objName);
-
+        
         Buffer buf = new Buffer();
         OutputStream oStream = new OutputStream(buf);
         streamable._write(oStream);
-
+        
         InputStream iStream = oStream.create_input_stream();
         String value = iStream.read_wstring();
         assertTrue(value.equals("TestWString"));

Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeMapTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeMapTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeMapTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeMapTest.java Thu Dec  7 10:11:27 2006
@@ -0,0 +1,56 @@
+/**
+ * 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 javax.xml.namespace.QName;
+import junit.framework.TestCase;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public class CorbaTypeMapTest extends TestCase {
+    
+    public CorbaTypeMapTest(String arg0) {
+        super(arg0);
+    }    
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(CorbaTypeMapTest.class);
+    }
+        
+    public void testCorbaTypeMap() throws Exception {
+        CorbaTypeMap typeMap = new CorbaTypeMap("http://yoko.apache.org/ComplexTypes");
+                
+        String targetNamespace = typeMap.getTargetNamespace();
+        assertEquals(targetNamespace,"http://yoko.apache.org/ComplexTypes");
+        
+        QName qname = new QName("http://yoko.apache.org/ComplexTypes","Test.MultiPart.Colour", "");
+        QName type = new QName("http://yoko.apache.org/ComplexTypes","xsd1:Test.MultiPart.Colour", "");
+                
+        CorbaTypeImpl corbaTypeImpl = new CorbaTypeImpl();
+        corbaTypeImpl.setQName(qname);
+        corbaTypeImpl.setType(type);
+        corbaTypeImpl.setName("Test.MultiPart.Colour");
+        typeMap.addType("Test.MultiPart.Colour", corbaTypeImpl);
+        
+        CorbaTypeImpl corbatype = typeMap.getType("Test.MultiPart.Colour");
+        assertEquals(corbatype.getName(), "Test.MultiPart.Colour");
+        assertEquals(corbatype.getQName().getNamespaceURI(), "http://yoko.apache.org/ComplexTypes");
+        assertEquals(corbatype.getType().getLocalPart(), "xsd1:Test.MultiPart.Colour");
+    }
+    
+}
\ No newline at end of file

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

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

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java?view=diff&rev=483586&r1=483585&r2=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java Thu Dec  7 10:11:27 2006
@@ -18,50 +18,36 @@
  */
 package org.apache.yoko.bindings.corba;
 
-import java.util.Properties;
 import javax.xml.namespace.QName;
-
 import junit.framework.TestCase;
 
-import org.objectweb.celtix.Bus;
-import org.objectweb.celtix.bindings.BindingManager;
-import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
 import org.omg.CORBA.ORB;
 import org.omg.CORBA.TCKind;
 import org.omg.CORBA.TypeCode;
-
-import org.apache.schemas.yoko.bindings.corba.AddressType;
-import org.apache.schemas.yoko.bindings.corba.BindingType;
-import org.apache.schemas.yoko.bindings.corba.OperationType;
-
 import org.apache.yoko.wsdl.CorbaConstants;
 
-
 public class CorbaUtilsTest extends TestCase {
 
-    private ORB orb;
-    private TestUtils testUtils;
-
+    private static ORB orb;
+    
     public CorbaUtilsTest(String arg0) {
         super(arg0);
     }
-
+    
     public static void main(String[] args) {
         junit.textui.TestRunner.run(CorbaUtilsTest.class);
     }
-
+    
     protected void setUp() throws Exception {
         super.setUp();
 
-        java.util.Properties props = new Properties();
-        props.putAll(System.getProperties());
+        java.util.Properties props = System.getProperties();
         props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
         props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
         props.put("yoko.orb.id", "Yoko-Server-Binding");
         orb = ORB.init(new String[0], props);
-        testUtils = new TestUtils();
     }
-
+    
     protected void tearDown() throws Exception {
         if (orb != null) {
             try {
@@ -71,7 +57,7 @@
             }
         }
     }
-
+    
     public void testBooleanTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -79,7 +65,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_boolean);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testCharTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "char", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -87,7 +73,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_char);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testWCharTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "wchar", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -95,7 +81,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_wchar);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testOctetTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "octet", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -103,7 +89,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_octet);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testShortTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "short", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -111,7 +97,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_short);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testUShortTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "ushort", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -119,7 +105,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_ushort);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testLongTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "long", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -127,7 +113,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_long);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testULongTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "ulong", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -135,7 +121,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_ulong);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testLongLongTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "longlong", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -143,7 +129,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_longlong);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testULongLongTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "ulonglong", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -151,7 +137,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_ulonglong);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testFloatTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "float", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -159,7 +145,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_float);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testDoubleTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "double", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -167,7 +153,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_double);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testStringTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "string", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -175,7 +161,7 @@
         assertTrue(tc.kind().value() == TCKind._tk_string);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
+    
     public void testWStringTypeCode() {
         QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "wstring", "corba");
         TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
@@ -183,47 +169,5 @@
         assertTrue(tc.kind().value() == TCKind._tk_wstring);
         assertTrue(CorbaUtils.isPrimitiveIdlType(type));
     }
-
-    public void testGetCorbaAddressType() throws Exception {
-        Bus bus = Bus.init();
-
-        // programmatically add the corba binding factory
-        BindingManager manager = bus.getBindingManager();
-        CorbaBindingFactory corbaBF = new CorbaBindingFactory();
-        corbaBF.init(bus);
-        manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
-
-        EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
-        AddressType address = CorbaUtils.getCorbaAddressType(bus, endpoint);
-        assertNotNull(address);
-    }
-
-    public void testGetCorbaBindingType() throws Exception {
-        Bus bus = Bus.init();
-
-        // programmatically add the corba binding factory
-        BindingManager manager = bus.getBindingManager();
-        CorbaBindingFactory corbaBF = new CorbaBindingFactory();
-        corbaBF.init(bus);
-        manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
-
-        EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
-        BindingType binding = CorbaUtils.getCorbaBindingType(bus, endpoint);
-        assertNotNull(binding);
-    }
-
-    public void testGetCorbaOperationType() throws Exception {
-        Bus bus = Bus.init();
-
-        // programmatically add the corba binding factory
-        BindingManager manager = bus.getBindingManager();
-        CorbaBindingFactory corbaBF = new CorbaBindingFactory();
-        corbaBF.init(bus);
-        manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
-
-        EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
-        String opName = "testSimpleMethod";
-        OperationType operation = CorbaUtils.getCorbaOperationType(opName, bus, endpoint);
-        assertNotNull(operation);
-    }
+        
 }



Mime
View raw message