Revision 3330
Added by Jing Tao over 17 years ago
test/edu/ucsb/nceas/metacattest/QueryGroupTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Copyright: 2004 Regents of the University of California and the |
|
4 |
* National Center for Ecological Analysis and Synthesis |
|
5 |
* |
|
6 |
* '$Author$' |
|
7 |
* '$Date$' |
|
8 |
* '$Revision$' |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or modify |
|
11 |
* it under the terms of the GNU General Public License as published by |
|
12 |
* the Free Software Foundation; either version 2 of the License, or |
|
13 |
* (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
*/ |
|
24 |
package edu.ucsb.nceas.metacattest; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.io.FileNotFoundException; |
|
28 |
import java.io.FileReader; |
|
29 |
import java.io.IOException; |
|
30 |
import java.util.Hashtable; |
|
31 |
|
|
32 |
import junit.framework.Test; |
|
33 |
import junit.framework.TestCase; |
|
34 |
import junit.framework.TestSuite; |
|
35 |
|
|
36 |
import edu.ucsb.nceas.metacat.MetaCatUtil; |
|
37 |
import edu.ucsb.nceas.metacat.QueryGroup; |
|
38 |
import edu.ucsb.nceas.metacat.QueryTerm; |
|
39 |
import edu.ucsb.nceas.utilities.Options; |
|
40 |
|
|
41 |
/** |
|
42 |
* @author jones |
|
43 |
* |
|
44 |
* Test the output of the QuerySpecification class |
|
45 |
*/ |
|
46 |
public class QueryGroupTest extends TestCase |
|
47 |
{ |
|
48 |
private QueryGroup group = null; |
|
49 |
|
|
50 |
/** |
|
51 |
* Constructor to build the test |
|
52 |
* |
|
53 |
* @param name the name of the test method |
|
54 |
*/ |
|
55 |
public QueryGroupTest(String name) |
|
56 |
{ |
|
57 |
super(name); |
|
58 |
} |
|
59 |
/** |
|
60 |
* Establishes a testing framework by initializing appropriate objects. |
|
61 |
*/ |
|
62 |
protected void setUp() throws Exception |
|
63 |
{ |
|
64 |
super.setUp(); |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* Releases any objects after tests are complete. |
|
71 |
*/ |
|
72 |
protected void tearDown() throws Exception |
|
73 |
{ |
|
74 |
|
|
75 |
super.tearDown(); |
|
76 |
} |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
/** |
|
81 |
* Tests initial |
|
82 |
*/ |
|
83 |
public void initial() |
|
84 |
{ |
|
85 |
assertTrue(1 == 1); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Tests print out sql command of QueryGroup with UNION |
|
90 |
*/ |
|
91 |
public void printUnion() |
|
92 |
{ |
|
93 |
group = new QueryGroup("UNION"); |
|
94 |
QueryTerm term1 = new QueryTerm ( false, "contains", "land", "dataset/title"); |
|
95 |
QueryTerm term2 = new QueryTerm ( false, "contains", "jones", "organizationName"); |
|
96 |
QueryTerm term3 = new QueryTerm ( false, "contains", "land ", "keyword"); |
|
97 |
QueryTerm term4 = new QueryTerm ( false, "contains", "land", "geographicCoverage/boundingCoordinates/southBoundingCoordinate"); |
|
98 |
QueryTerm term5 = new QueryTerm ( false, "contains", "datos", "entityName"); |
|
99 |
QueryGroup child = new QueryGroup("UNION"); |
|
100 |
QueryTerm term6 = new QueryTerm ( false, "contains", "value1", "path1"); |
|
101 |
QueryTerm term7 = new QueryTerm ( false, "contains", "value2", "path2"); |
|
102 |
child.addChild(term6); |
|
103 |
child.addChild(term7); |
|
104 |
group.addChild(term1); |
|
105 |
group.addChild(term2); |
|
106 |
group.addChild(term3); |
|
107 |
group.addChild(term4); |
|
108 |
group.addChild(term5); |
|
109 |
group.addChild(child); |
|
110 |
System.out.println("the query is "+group.printSQL(true)); |
|
111 |
assertTrue(1 == 1); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
/** |
|
117 |
* Create a suite of tests to be run together |
|
118 |
*/ |
|
119 |
public static Test suite() |
|
120 |
{ |
|
121 |
TestSuite suite = new TestSuite(); |
|
122 |
suite.addTest(new QueryGroupTest("initial")); |
|
123 |
suite.addTest(new QueryGroupTest("printUnion")); |
|
124 |
return suite; |
|
125 |
} |
|
126 |
|
|
127 |
|
|
128 |
} |
|
0 | 129 |
Also available in: Unified diff
Test file for query group.