diff options
Diffstat (limited to 'sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java')
-rw-r--r-- | sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java new file mode 100644 index 0000000000..4fd3e71541 --- /dev/null +++ b/sdo-java/trunk-cts/sdo2.1/src/main/java/test/sdo21/framework/CTSTestCase.java @@ -0,0 +1,78 @@ +/* + * 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 junit.framework.TestCase; +import commonj.sdo.helper.HelperContext; + +/** + * A superclass for tests classes. It creates a HelperContext per test case invocation + * and provides initialization/access to the implementation sepcific test helper. + * See also the {@link test.sdo21.framework.junit3_8.CTSTestCase} Junit 3.8 variant of this + * class which inherits from {@link TestCase} in the junit 3.8 style of testing, + * but delegates to this class for much of its CTS function. + */ +public class CTSTestCase { + + private static TestHelper testHelper = null; + private HelperContext scope = null; + public static final String SDO_CTS_TESTHELPER_CLASS = "CTS_TEST_HELPER"; + + private static 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 static TestHelper getTestHelper() { + if(testHelper == null) { + try { + initTestHelper(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return testHelper; + } + +} |