incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r544203 - in /incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba: AbstractTypeTestClient1.java CorbaTypeTest.java
Date Mon, 04 Jun 2007 18:42:55 GMT
Author: bravi
Date: Mon Jun  4 11:42:50 2007
New Revision: 544203

URL: http://svn.apache.org/viewvc?view=rev&rev=544203
Log:
[YOKO-373] - Adding some test cases for corba type testing.

Modified:
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeTest.java

Modified: 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=diff&rev=544203&r1=544202&r2=544203
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractTypeTestClient1.java
Mon Jun  4 11:42:50 2007
@@ -40,6 +40,8 @@
 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.SequenceChoiceStruct;
+import org.apache.type_test.types1.SequenceStructChoice;
 import org.apache.type_test.types1.SimpleAll;
 import org.apache.type_test.types1.SimpleChoice;
 import org.apache.type_test.types1.SimpleEnum;
@@ -366,18 +368,13 @@
         NestedArray ret = client.testNestedArray(x, y, z);
 
         if (!perfTestOnly) {
-            for (int i = 0; i < xs.length; 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));
-                }
-            }
+            assertTrue("testNestedArray(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testNestedArray(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testNestedArray(): Incorrect return value",
+                        equals(x, ret));
+
         }
     }
     
@@ -751,6 +748,111 @@
             assertTrue("testArrayWithChoice(): Incorrect value for out param",
                        equals(yOrig, z.value));
             assertTrue("testArrayWithChoice(): Incorrect return value", equals(x, ret));
+        }
+    }
+
+    protected boolean equals(NestedArray x, NestedArray y) {
+        List<UnboundedArray> xx = x.getSubarray();
+        List<UnboundedArray> yy = y.getSubarray();
+        if (xx.size() != yy.size()) {
+            return false;
+        }
+        for (int i = 0; i < xx.size(); i++) {
+            if (!equals(xx.get(i), yy.get(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    protected boolean equals(SequenceChoiceStruct x, SequenceChoiceStruct y) {
+        return (x.getVarInt() == y.getVarInt())
+            && (x.getVarString().equals(y.getVarString()))
+            && equals(x.getVarSequence(), y.getVarSequence())
+            && equals(x.getVarChoice(), y.getVarChoice());
+    }
+    
+    public void testSequenceChoiceStruct() throws Exception {
+        SequenceChoiceStruct x = new SequenceChoiceStruct();
+        x.setVarInt(45);
+        x.setVarString("Cheerio");
+        NestedArray arrayx = new NestedArray();
+        UnboundedArray uarrayx = new UnboundedArray();
+        uarrayx.getItem().add("AAA");
+        arrayx.getSubarray().add(uarrayx);
+        x.setVarSequence(arrayx);
+        SimpleChoice choicex = new SimpleChoice();
+        choicex.setVarFloat(-3.14f);
+        x.setVarChoice(choicex);
+
+        SequenceChoiceStruct yOrig = new SequenceChoiceStruct();
+        yOrig.setVarInt(13);
+        yOrig.setVarString("Hello There");
+        NestedArray arrayy = new NestedArray();
+        UnboundedArray uarrayy = new UnboundedArray();
+        uarrayy.getItem().add("BBB");
+        arrayy.getSubarray().add(uarrayy);
+        yOrig.setVarSequence(arrayy);
+        SimpleChoice choicey = new SimpleChoice();
+        choicey.setVarString("Cheerio");
+        yOrig.setVarChoice(choicex);
+
+        Holder<SequenceChoiceStruct> y = new Holder<SequenceChoiceStruct>(yOrig);
+        Holder<SequenceChoiceStruct> z = new Holder<SequenceChoiceStruct>();
+        SequenceChoiceStruct ret = client.testSequenceChoiceStruct(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testSequenceChoiceStruct(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testSequenceChoiceStruct(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testSequenceChoiceStruct(): Incorrect return value", equals(x, ret));
+        }
+    }
+
+    protected boolean equals(SequenceStructChoice x, SequenceStructChoice y) {
+        if (x.getVarString() != null && y.getVarString() != null) {
+            return x.getVarString().equals(y.getVarString());
+        } else if (x.getVarStruct() != null && y.getVarStruct() != null) {
+            return equals(x.getVarStruct(), y.getVarStruct());
+        } else if (x.getVarSequence() != null && y.getVarSequence() != null) {
+            return equals(x.getVarSequence(), y.getVarSequence());
+        } else {
+            return false;
+        }
+    }
+    
+    public void testSequenceStructChoice() throws Exception {
+        SequenceStructChoice x = new SequenceStructChoice();
+        NestedArray arrayx = new NestedArray();
+        UnboundedArray uarrayx = new UnboundedArray();
+        uarrayx.getItem().add("AAA");
+        arrayx.getSubarray().add(uarrayx);
+        x.setVarSequence(arrayx);
+
+        SequenceStructChoice yOrig = new SequenceStructChoice();
+        SimpleStruct ys = new SimpleStruct();
+        ys.setVarFloat(30.14);
+        ys.setVarInt(new BigInteger("420"));
+        ys.setVarString("NESTED Hello There"); 
+        NestedStruct nestedy = new NestedStruct();
+        nestedy.setVarFloat(new BigDecimal("3.14"));
+        nestedy.setVarInt(42);
+        nestedy.setVarString("Hello There");
+        nestedy.setVarEmptyStruct(new EmptyStruct());
+        nestedy.setVarStruct(ys);
+        yOrig.setVarStruct(nestedy);
+
+        Holder<SequenceStructChoice> y = new Holder<SequenceStructChoice>(yOrig);
+        Holder<SequenceStructChoice> z = new Holder<SequenceStructChoice>();
+        SequenceStructChoice ret = client.testSequenceStructChoice(x, y, z);
+
+        if (!perfTestOnly) {
+            assertTrue("testSequenceStructChoice(): Incorrect value for inout param",
+                       equals(x, y.value));
+            assertTrue("testSequenceStructChoice(): Incorrect value for out param",
+                       equals(yOrig, z.value));
+            assertTrue("testSequenceStructChoice(): Incorrect return value", equals(x, ret));
         }
     }
 

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeTest.java?view=diff&rev=544203&r1=544202&r2=544203
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeTest.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeTest.java
Mon Jun  4 11:42:50 2007
@@ -71,10 +71,6 @@
     public void testChoiceWithEnum() throws Exception {
     }
 
-    //Still need to add test cases
-    public void testSequenceChoiceStruct() throws Exception {
-    }
-
     public void testSequenceStructChoice() throws Exception {
     }
 



Mime
View raw message