summaryrefslogtreecommitdiffstats
path: root/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools')
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/CalculatorTest.java29
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/EnvHandlerTest.java46
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/ImplClassWithNameSpaceTest.java46
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceButNotInClassAttrTest.java46
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceTest.java46
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/MissingModuleAndFragmentTest.java46
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/SimplePublicPrivateProtectedTest.java47
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestAllModulesTest.java82
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestDeployAssistTool.java94
-rw-r--r--tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TuscanyTestCase.java332
10 files changed, 0 insertions, 814 deletions
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/CalculatorTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/CalculatorTest.java
deleted file mode 100644
index 448fd6dd7d..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/CalculatorTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.junit.TuscanyTestCase;
-
-/**
- * This test case tests a simple Calculator service tools generation
- */
-public class CalculatorTest extends TuscanyTestCase {
-
- public void testCalculatorModuleAndComponent() {
- testModule("CalculatorModuleAndComponent", check_results);
- }
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/EnvHandlerTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/EnvHandlerTest.java
deleted file mode 100644
index 2f1bf78921..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/EnvHandlerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
-*
-* Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class EnvHandlerTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public EnvHandlerTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
- testModule("MyValueServiceModule", check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/ImplClassWithNameSpaceTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/ImplClassWithNameSpaceTest.java
deleted file mode 100644
index 1dfe302cf1..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/ImplClassWithNameSpaceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
-*
-* Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class ImplClassWithNameSpaceTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public ImplClassWithNameSpaceTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
- testModule("MyValueServiceModuleImplClassWithNamespace", check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceButNotInClassAttrTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceButNotInClassAttrTest.java
deleted file mode 100644
index 146c18fa1b..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceButNotInClassAttrTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
-*
-* Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class IntfClassWithNameSpaceButNotInClassAttrTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public IntfClassWithNameSpaceButNotInClassAttrTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
- testModule("MyValueServiceModuleIntfClassWithNamespaceButNotInClassAttr", check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceTest.java
deleted file mode 100644
index c78f8a5f93..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/IntfClassWithNameSpaceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
-*
-* Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class IntfClassWithNameSpaceTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public IntfClassWithNameSpaceTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
- testModule("MyValueServiceModuleIntfClassWithNamespace", check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/MissingModuleAndFragmentTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/MissingModuleAndFragmentTest.java
deleted file mode 100644
index 4a8f8449a6..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/MissingModuleAndFragmentTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
-*
-* Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class MissingModuleAndFragmentTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public MissingModuleAndFragmentTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
- testModule("MyValueServiceModuleMissingScaModule",check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/SimplePublicPrivateProtectedTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/SimplePublicPrivateProtectedTest.java
deleted file mode 100644
index 9c05599286..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/SimplePublicPrivateProtectedTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * This is a "run this first" testcase that just tests some simple operations of
- * the scagen tools it uses the
- * Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule SCA module as
- * input data.
- */
-public class SimplePublicPrivateProtectedTest extends TuscanyTestCase {
-
- /**
- * Constructor for CustomerInfoTestOLD.
- *
- * @param arg0
- */
- public SimplePublicPrivateProtectedTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test the Hydra.sca.core\test\testSCASystem\modules\MyValueServiceModule
- * proxy and wrapper generation.
- */
- public void testEnvHandler() {
-
- testModule("SimplePublicPrivateProtectedTest", check_results);
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestAllModulesTest.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestAllModulesTest.java
deleted file mode 100644
index fc5c8c5653..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestAllModulesTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * IBM Confidential
- *
- * OCO Source Materials
- *
- * <PID TBD>
- *
- * (C) Copyright IBM Corp. 2005
- *
- * The source code for this program is not published
- * or otherwise divested of its trade secrets,
- * irrespective of what has been deposited with the
- * U. S. Copyright Office.
- */
-package org.apache.tuscany.sca.cpp.tools.junit;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.tuscany.sca.cpp.tools.junit.TuscanyTestCase;
-
-/**
- * This test case will test all the modules placed in the "modules" directory
- * against the results in their repectice "expected_results" folders.
- */
-public class TestAllModulesTest extends TuscanyTestCase {
-
- String testsDir = TuscanyTestCase.junit_modules;
-
- Set excludes = new HashSet();
-
- public TestAllModulesTest(String arg0) {
- super(arg0);
- excludes.add("MyValueServiceModuleMissingScaModule");
- excludes.add("CVS");
- }
-
-
- /* main exists to allow running from the java ant task */
- public static void main(String[] args) {
- TestAllModulesTest test = new TestAllModulesTest("");
- test.testAllModulesRegression();
- }
-
- public void testAllModulesRegression() {
- File dir = new File(testsDir);
-
- if (dir.isDirectory()) {
- System.out.println("Testing all modules under "
- + dir.getAbsolutePath());
- String[] test_modules = dir.list();
-
- for (int i = 0; i < test_modules.length; i++) {
- File test_module = new File(testsDir, test_modules[i]);
-
- String module_name = null;
- if (test_module.isDirectory()) {
- module_name = test_module.getName();
- if (!excludes.contains(module_name.intern())) {
- testModule(module_name, check_results);
- System.out.println("Test of module \"" + module_name
- + "\" passed.");
- continue;
- } else {
- System.out
- .println("Ignoring excluded module subdirectory \""
- + module_name + "\"");
- }
- }
- }
-
- } else {
-
- fail("Test directory is not a directory! \r The variable org.apache.tuscany.sca.cpp.tools.junit.TuscanyTestCase.root sets the location of the junit input data,\r it is currently set as "
- + TuscanyTestCase.root + "\rand we expect to find a testinput\\modules directory under there.");
- }
-
- System.out.println("testAllModules test passed.");
- }
-
-} \ No newline at end of file
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestDeployAssistTool.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestDeployAssistTool.java
deleted file mode 100644
index fb4cd4b606..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TestDeployAssistTool.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * IBM Confidential
- *
- * OCO Source Materials
- *
- * <PID TBD>
- *
- * (C) Copyright IBM Corp. 2005
- *
- * The source code for this program is not published
- * or otherwise divested of its trade secrets,
- * irrespective of what has been deposited with the
- * U. S. Copyright Office.
- */
-package org.apache.tuscany.sca.cpp.tools.junit;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.tuscany.sca.cpp.tools.common.Utils;
-import org.apache.tuscany.sca.cpp.tools.junit.TuscanyTestCase;
-
-/**
- * This test case will test all the modules placed in the "modules" directory
- * against the results in their repectice "expected_results" folders.
- */
-public class TestDeployAssistTool extends TuscanyTestCase {
-
- String testsDir = TuscanyTestCase.junit_modules;
-
- Set excludes = new HashSet();
-
- public TestDeployAssistTool(String arg0) {
- super(arg0);
- excludes.add("MyValueServiceModuleMissingScaModule");
- excludes.add("CVS");
- }
-
- /* main exists to allow running from the test script which will
- * wrap this test case and pipe the satandard output to somewhere
- * for checking.
- */
-
- public static void main(String[] args) {
- TestDeployAssistTool test = new TestDeployAssistTool("");
- test.testDeployToolNullParms();
- }
-
- public void testDeployTool() {
- //Utils.setReportArtefacts(true);
- TestAllModulesTest t = new TestAllModulesTest("");
- File dir = new File(testsDir);
-
- if (dir.isDirectory()) {
- String[] test_modules = dir.list();
-
- for (int i = 0; i < test_modules.length; i++) {
- File test_module = new File(testsDir, test_modules[i]);
- String module_name = null;
- if (test_module.isDirectory()) {
- module_name = test_module.getName();
- if (!excludes.contains(module_name.intern())) {
- t.testModuleDeploy(module_name, create_results, "c:\\colin", "cp");
- }
- }
- System.out.println("");
- }
- }
- }
-
- public void testDeployToolNullParms() {
- //Utils.setReportArtefacts(true);
- TestAllModulesTest t = new TestAllModulesTest("");
- File dir = new File(testsDir);
-
- if (dir.isDirectory()) {
- String[] test_modules = dir.list();
-
- for (int i = 0; i < test_modules.length; i++) {
- File test_module = new File(testsDir, test_modules[i]);
- String module_name = null;
- if (test_module.isDirectory()) {
- module_name = test_module.getName();
- if (!excludes.contains(module_name.intern())) {
- t.testModuleDeploy(module_name, create_results, null, null);
- }
- }
- System.out.println("");
- }
- }
- }
-}
-
diff --git a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TuscanyTestCase.java b/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TuscanyTestCase.java
deleted file mode 100644
index 00f6868ce6..0000000000
--- a/tags/cpp-sca-20060405/tools/scagen/junit/org/apache/tuscany/sca/cpp/tools/junit/TuscanyTestCase.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed 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.tuscany.sca.cpp.tools.junit;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.cpp.tools.common.Options;
-import org.apache.tuscany.sca.cpp.tools.services.Scagen;
-
-/**
- * A superclass for testcases that can be used to store common functions.
- */
-public class TuscanyTestCase extends TestCase {
-
- public static String root = "cpp\\sca\\tools\\scagen\\junit\\";
-
- public static String junit_modules = root + "testinput\\modules\\";
-
- public static String junit_output = root + "testoutput\\";
-
- private String testcase = "TESTCASE NOT SET BY SUBCLASS";
-
- String input = null;
-
- String output = null;
-
- /**
- * Check the resulting files with the contents of the expected_results
- * folder in the testModule method
- */
- public final static boolean check_results = true;
-
- /**
- * Create test output but do not check it (useful for setting up new
- * expected test output
- */
- public final static boolean create_results = false;
-
- /**
- *
- */
- public TuscanyTestCase() {
- super();
- }
-
- /**
- * @param arg0
- */
- public TuscanyTestCase(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Tests to see if two files are the same - this is just a scratch method at
- * the moment that flags up testcase output files not matching expected
- * results rather than needing to be a fully robust implementation and needs
- * a little further work.
- *
- * @param file1
- * the first file to compare
- * @param file2
- * the second file to compare
- *
- */
- protected boolean areFilesEqual(String file1, String file2) {
-
- try {
- FileInputStream fis1 = new java.io.FileInputStream(file1);
- FileInputStream fis2 = new java.io.FileInputStream(file2);
-
- BufferedReader br1 = new BufferedReader(new InputStreamReader(fis1));
- BufferedReader br2 = new BufferedReader(new InputStreamReader(fis2));
-
- String line1 = br1.readLine();
- String line2 = br2.readLine();
- boolean moretodo = (line1 != null) && (line2 != null);
-
- for (int line = 1; moretodo; line++) {
-
- if (line1.equals(line2)) {
-
- line1 = br1.readLine();
- line2 = br2.readLine();
-
- } else {
-
- int l1i, l2i;
-
- if ((l1i = line1.lastIndexOf("$Id")) > 0) {
- //allow CVS strings
- line1 = br1.readLine();
- }
-
- if ((l2i = line2.lastIndexOf("$Id")) > 0) {
- //allow CVS strings
- line2 = br2.readLine();
- }
-
- if (l1i == -1 && l2i == -1) {
-
- // they don't match
- System.out.println("file " + file1 + " and file "
- + file2);
- System.out.println(" don't match at line " + line);
- System.out.println("1 is :" + line1);
- System.out.println("2 is :" + line2);
-
- return false;
- }
- }
-
- moretodo = (line1 != null) && (line2 != null);
- }
-
- System.out.println("MATCH FOR: file " + file1 + " and file "
- + file2);
- return true;
-
- } catch (Throwable t) {
- t.printStackTrace();
- return true;
- }
-
- }
-
- /**
- * @param outputDir
- */
- protected void clearDirButNotExpectedOutputSubDir(String outputDir) {
- File dir = new File(outputDir);
- if (dir.isDirectory()) {
- String[] files = dir.list();
- for (int i = 0; i < files.length; i++) {
- File child = new File(dir, files[i]);
- if (child.isDirectory()) {
- if (!child.getName().equals("expected_output")) {
- clearDirButNotExpectedOutputSubDir(dir
- .getAbsolutePath()
- + File.separator + files[i]);
- }
- }
- child.delete();
- }
-
- }
-
- }
-
- public void testModule(String module, boolean check) {
-
- Options.reset();
- setTestcase(module);
- clearDirButNotExpectedOutputSubDir(output);
-
- String[] commandLine = new String[] { "-dir", input, "-output", output };
- try {
- Scagen.main(commandLine);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- if (check) {
- checkDirWithExpected(output);
- }
- }
-
- public void testModuleDeploy(String module, boolean check,
- String deployDir, String command) {
-
- Options.reset();
- setTestcase(module);
- clearDirButNotExpectedOutputSubDir(output);
-
- String[] commandLine;
- if (null == deployDir) {
- commandLine = new String[] { "-dir", input, "-output",
- output, "-deploy"};
- } else {
- commandLine = new String[] { "-dir", input, "-output",
- output, "-deploy", deployDir, "-command", command };
- }
- try {
- Scagen.main(commandLine);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- if (check) {
- checkDirWithExpected(output);
- }
- }
-
- /**
- * @param outputDirName
- */
- private void checkDirWithExpected(String outputDirName) {
-
- File actualDir = new File(outputDirName);
- if (actualDir == null || !actualDir.isDirectory()) {
- fail("result directory does not exist");
- }
-
- File expectedDir = new File(outputDirName + File.separator
- + "expected_output");
- if (expectedDir == null || !actualDir.isDirectory()) {
- fail("can't check results as expected directory does not exist");
- }
-
- //Check every file in the expected output directory is present
- //in the actual directory
-
- String[] expectedFiles = expectedDir.list();
-
- if (expectedFiles == null) {
- fail("no expected results for " + expectedDir.getPath());
- }
- for (int i = 0; expectedFiles != null && i < expectedFiles.length; i++) {
- File expectedFile = new File(expectedDir, expectedFiles[i]);
- if (expectedFile.isDirectory()) {
- // we can't check subdirectories yet
- // and it conveniently skips over "CVS"
- } else {
- File actualFile = checkFileExistsFailIfNot(actualDir,
- expectedFile.getName());
- checkFileHasNoTabsAndEndsInNewline(actualDir, expectedFile
- .getName());
- if (!areFilesEqual(expectedFile.getAbsolutePath(), actualFile
- .getAbsolutePath())) {
- fail("odd output for " + expectedFile.getPath());
- }
-
- }
-
- }
-
- }
-
- /**
- * @param actualDir
- * @param name
- */
- private File checkFileExistsFailIfNot(File dir, String name) {
-
- File f = new File(dir, name);
- if (f == null || !f.exists() || !f.isFile()) {
- fail("Expected result file " + f + " does not exist");
- }
- return f;
-
- }
-
- /**
- * @param actualDir
- * @param name
- */
- private void checkFileHasNoTabsAndEndsInNewline(File dir, String name) {
-
- try {
- File f = new File(dir, name);
- FileInputStream fis = new FileInputStream(f);
- InputStreamReader isr = new InputStreamReader(fis);
- Reader br = new BufferedReader(isr);
- int ch, charBeforeMinusOne = -1;
- while ((ch = br.read()) > -1) {
- if (ch == '\t') {
- fail("found tab in output " + f.getPath());
- }
- charBeforeMinusOne = ch;
- }
- //The last char must be newline;
- if (charBeforeMinusOne != '\n') {
- fail("last char in file is not a newline in " + "(char is:"
- + ch + " " + dir.getName() + File.separator + name);
- }
-
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- fail("io exception in tab/newline checker for " + dir.getName()
- + File.separator + name);
- return;
- }
-
- }
-
- /**
- * @param testcase
- * The testcase to set.
- */
- void setTestcase(String testcase) {
- this.testcase = testcase;
- input = TuscanyTestCase.junit_modules + testcase;
- output = TuscanyTestCase.junit_output + testcase;
- }
-
- /**
- * @return Returns the testcase.
- */
- String getTestcase() {
- return testcase;
- }
-
-} \ No newline at end of file