KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > lang > LangScripts


1 /*
2  *
3  * Derby - Class org.apache.derbyTesting.functionTests.tests.lang.LangScripts
4  *
5  * Licensed to the Apache Software Foundation (ASF) under one or more
6  * contributor license agreements. See the NOTICE file distributed with
7  * this work for additional information regarding copyright ownership.
8  * The ASF licenses this file to You under the Apache License, Version 2.0
9  * (the "License"); you may not use this file except in compliance with
10  * the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */

20 package org.apache.derbyTesting.functionTests.tests.lang;
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24
25 import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
26 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
27
28 /**
29  * LangScripts runs SQL scripts (.sql files) in the lang package
30  * and compares the output to a canon file in the
31  * standard master package.
32  * <BR>
33  * Its suite() method returns a set of tests where each test is an instance of
34  * this class for an individual script wrapped in a clean database decorator.
35  * <BR>
36  * It can also be used as a command line program to run one or more
37  * language based SQL scripts as tests.
38  *
39  */

40 public final class LangScripts extends ScriptTestCase {
41     
42     /**
43      * Language SQL scripts (.sql files) that run under all configurations.
44      */

45     private static final String JavaDoc[] SQL_LANGUAGE_TESTS = {
46         "case",
47         "constantExpression",
48         };
49
50     /**
51      * Language SQL scripts (.sql files) that run under Derby's client configurations.
52      */

53     private static final String JavaDoc[] DERBY_TESTS = {
54         "bit2",
55         "derived",
56         };
57     
58     /**
59      * Language SQL scripts (.sql files) that only run in embedded.
60      */

61     private static final String JavaDoc[] EMBEDDED_TESTS = {
62         "arithmetic",
63         "depend",
64         "union",
65         };
66
67     /**
68      * Run a set of language SQL scripts (.sql files) passed in on the
69      * command line. Note the .sql suffix must not be provided as
70      * part of the script name.
71      * <code>
72      * example
73      * java org.apache.derbyTesting.functionTests.tests.lang.LangScripts case union
74      * </code>
75      */

76     public static void main(String JavaDoc[] args)
77     {
78         junit.textui.TestRunner.run(getSuite(args));
79     }
80
81     /**
82      * Return the suite that runs all the langauge SQL scripts.
83      */

84     public static Test suite() {
85         TestSuite suite = new TestSuite();
86         suite.addTest(getSuite(SQL_LANGUAGE_TESTS));
87         
88         if (usingEmbedded() || usingDerbyNetClient())
89             suite.addTest(getSuite(DERBY_TESTS));
90         
91         if (usingEmbedded())
92             suite.addTest(getSuite(EMBEDDED_TESTS));
93         
94         return suite;
95     }
96     
97     /*
98      * A single JUnit test that runs a single language SQL script.
99      */

100     private LangScripts(String JavaDoc langTest){
101         super(langTest);
102     }
103     
104     /**
105      * Return a suite of language SQL tests from the list of
106      * script names. Each test is surrounded in a decorator
107      * that cleans the database.
108       */

109     private static Test getSuite(String JavaDoc[] list)
110     {
111         TestSuite suite = new TestSuite();
112         for (int i = 0; i < list.length; i++)
113             suite.addTest(
114                     new CleanDatabaseTestSetup(
115                     new LangScripts(list[i])));
116
117         return getIJConfig(suite);
118     }
119 }
120
Popular Tags