You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/04/26 16:06:28 UTC

svn commit: r532749 - in /incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21: ./ framework/ framework/junit3_8/ tests/ tests/scenarios/

Author: kelvingoodson
Date: Thu Apr 26 07:06:27 2007
New Revision: 532749

URL: http://svn.apache.org/viewvc?view=rev&rev=532749
Log:
I inserted an intermediate junit 3.8 style specific testcase class above DataObjectListTest (and propose to do this for others).  The intermediate class delgates much function off to a non junit 3.8 specific class.  So now any 4.1 style test classes can inherit from the non-junit superclass,  and the junit 3.8 style ones can use the junit specific ones.  This allows us to 1) promote setUp/tearDown to public to promote test harness agnosticism, 2) ensure that the testHelper has been initialized once per setUp() call, thereby permitting runs of individual tests, 3) do standard setup stuff such as create a HelperContext per test execution. 

I also moved the DataObjectListTest to the Approved set (will point this out on the list to ensure no one objects)
 

Added:
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java   (with props)
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java   (with props)
Modified:
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java
    incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java

Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java?view=diff&rev=532749&r1=532748&r2=532749
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/UnderReviewSuite.java Thu Apr 26 07:06:27 2007
@@ -41,7 +41,6 @@
 @Suite.SuiteClasses( {test.sdo21.paramatizedTests.CTSParamatizedSuite.class,
                       test.sdo21.paramatizedTests.conversion.TypeConversionTest.class,
                       test.sdo21.tests.general.XMLHelperTest.class,
-                      test.sdo21.tests.scenarios.DataObjectListTest.class,
                       test.sdo21.tests.xsd.XSDComplexTypeTest.class})
 public class UnderReviewSuite {
 

Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java?view=auto&rev=532749
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java Thu Apr 26 07:06:27 2007
@@ -0,0 +1,71 @@
+/*
+ *  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 test.sdo21.framework;
+
+import commonj.sdo.helper.HelperContext;
+
+public class CTSTestCase {
+
+  private static TestHelper testHelper = null; 
+  private HelperContext scope = null;
+  public static final String SDO_CTS_TESTHELPER_CLASS = "CTS_TEST_HELPER";
+  
+  private void initTestHelper() throws Exception {
+    String helperClassName = System.getenv(SDO_CTS_TESTHELPER_CLASS);
+    
+    if ((helperClassName == null) || (helperClassName.equals(""))) {
+        System.out.println(SDO_CTS_TESTHELPER_CLASS + " was not set - attempting Tuscany implementation : "
+            + helperClassName);
+        helperClassName = "test.sdo21.vendor.tuscany.testHelper.TuscanyTestHelper";
+    }
+
+    testHelper = (TestHelper)Class.forName(helperClassName).newInstance();
+    System.out.println("Loaded " + helperClassName);
+    // initialize SDO implementation
+    testHelper.init();
+  }
+  
+
+  public void setUp() throws Exception {
+    scope = getTestHelper().createHelperContext();
+  }
+
+
+  public void tearDown() throws Exception {
+    scope = null;
+  }
+
+  public HelperContext getScope() {
+    return scope;
+  }
+
+  public TestHelper getTestHelper() {
+    if(testHelper == null) {
+      try {
+        initTestHelper();
+      } catch (Exception e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+    }
+    return testHelper;
+  }
+
+}

Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java?view=auto&rev=532749
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java Thu Apr 26 07:06:27 2007
@@ -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 test.sdo21.framework.junit3_8;
+
+import test.sdo21.framework.TestHelper;
+import commonj.sdo.helper.HelperContext;
+
+import junit.framework.TestCase;
+
+public class CTSTestCase extends TestCase {
+  
+  test.sdo21.framework.CTSTestCase delegate;
+  
+  public CTSTestCase(String title) {
+    super(title);
+    delegate = new test.sdo21.framework.CTSTestCase();
+  }
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    delegate.setUp();
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    delegate.tearDown();
+    super.tearDown();
+  }
+
+  public HelperContext getScope() {
+    return delegate.getScope();
+  }
+  
+  public TestHelper getTestHelper() {
+    return delegate.getTestHelper();
+  }
+
+}

Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/framework/junit3_8/CTSTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java?view=diff&rev=532749&r1=532748&r2=532749
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/CTSGeneralSuite.java Thu Apr 26 07:06:27 2007
@@ -26,6 +26,7 @@
 import test.sdo21.tests.api.DataObjectTest;
 import test.sdo21.tests.conversion.DateConversionTest;
 import test.sdo21.tests.general.XSDHelperTest;
+import test.sdo21.tests.scenarios.DataObjectListTest;
 import test.sdo21.tests.xsd.XSDChoiceTest;
 import test.sdo21.tests.xsd.XSDComplexTypeTest;
 import test.sdo21.tests.api.DynamicTypesFromSchemaTestCase;
@@ -43,8 +44,13 @@
  * should be placed in the {@link test.sdo21.UnderReviewSuite} suite.
  */
 @RunWith(Suite.class)
-@Suite.SuiteClasses( {DateConversionTest.class, XSDHelperTest.class, DataObjectTest.class,
-                      DynamicTypesFromSchemaTestCase.class, XSDChoiceTest.class, XSDComplexTypeTest.class})
+@Suite.SuiteClasses( {DateConversionTest.class,
+                      XSDHelperTest.class,
+                      DataObjectTest.class,
+                      DynamicTypesFromSchemaTestCase.class,
+                      XSDChoiceTest.class,
+                      XSDComplexTypeTest.class,
+                      DataObjectListTest.class})
 public class CTSGeneralSuite {
 
 }

Modified: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java?view=diff&rev=532749&r1=532748&r2=532749
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java (original)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/scenarios/DataObjectListTest.java Thu Apr 26 07:06:27 2007
@@ -21,27 +21,30 @@
 
 package test.sdo21.tests.scenarios;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import test.sdo21.framework.junit3_8.CTSTestCase;
+
 import commonj.sdo.DataObject;
-import commonj.sdo.Property;
 import commonj.sdo.Type;
 import commonj.sdo.helper.DataFactory;
 import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLHelper;
 import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-import java.util.*;
+import commonj.sdo.helper.XMLHelper;
 
 /**
  * Test cases for the DataObject SDO implementation.
  */
-public class DataObjectListTest extends TestCase {
+public class DataObjectListTest extends CTSTestCase {
 
     /**
      * Number of iterations for data type tests (sets and retrieves random
      * values for each data type)
      */
+    
     public static final int DATA_TYPE_ITERATIONS = 10;
     private static int unique = 0;
 
@@ -49,7 +52,7 @@
         super(title);
     }
 
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         super.setUp();
     }
 
@@ -157,24 +160,6 @@
         return doc.getRootObject().getList("product2");
     }
 
-    // // DataGraphImpl dataGraph = new DataGraphImpl(doc);
-    // // XMLElement catalog = doc.getRootElement();
-    //
-    // // DataObjectImpl doRoot =(DataObjectImpl) dataGraph.getRootObject();
-    // Property prop=doRoot.getDataObject("catalog2").getProperty("product2");
-    // if (prop == null) {
-    // throw new IllegalStateException();
-    // }
-    //
-    // assertEquals("catalog2", catalog.getLocalPart());
-    //
-    // // List listTest=new
-    // List(dataGraph,doRoot,(XMLDocumentImpl)doc,(XMLElementImpl)catalog,prop);
-    // List listTest = new
-    // List(dataGraph,doRoot,(XMLDocumentImpl)doc,(XMLElementImpl)catalog,prop);
-    // assertNotNull(listTest);
-    // return listTest;
-    // }
 
     public void testClear() {
         XMLDocument doc = loadDocFromString("<catalog2><product2/><product2/></catalog2>");



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org