Skip to content

Commit 2f5820b

Browse files
committed
Fix a test in ADQLLib and an import in UWSLib
1 parent ae4a4e7 commit 2f5820b

2 files changed

Lines changed: 0 additions & 172 deletions

File tree

Lines changed: 0 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,3 @@
1-
<<<<<<< HEAD:test/adql/parser/TestUnknownTypes.java
2-
package adql.parser;
3-
4-
import static org.junit.Assert.assertEquals;
5-
import static org.junit.Assert.assertFalse;
6-
import static org.junit.Assert.assertNotNull;
7-
import static org.junit.Assert.assertNull;
8-
import static org.junit.Assert.assertTrue;
9-
import static org.junit.Assert.fail;
10-
11-
import java.util.Arrays;
12-
import java.util.Collection;
13-
14-
import org.junit.After;
15-
import org.junit.AfterClass;
16-
import org.junit.Before;
17-
import org.junit.BeforeClass;
18-
import org.junit.Test;
19-
20-
import adql.db.DBChecker;
21-
import adql.db.DBColumn;
22-
import adql.db.DBTable;
23-
import adql.db.DBType;
24-
import adql.db.DBType.DBDatatype;
25-
import adql.db.DefaultDBColumn;
26-
import adql.db.DefaultDBTable;
27-
import adql.db.FunctionDef;
28-
import adql.query.ADQLQuery;
29-
import adql.query.ADQLSet;
30-
31-
public class TestUnknownTypes {
32-
33-
@BeforeClass
34-
public static void setUpBeforeClass() throws Exception {
35-
}
36-
37-
@AfterClass
38-
public static void tearDownAfterClass() throws Exception {
39-
DBType.DBDatatype.UNKNOWN.setCustomType(null);
40-
}
41-
42-
@Before
43-
public void setUp() throws Exception {
44-
}
45-
46-
@After
47-
public void tearDown() throws Exception {
48-
}
49-
50-
public void testForFctDef() {
51-
// Test with the return type:
52-
try {
53-
FunctionDef fct = FunctionDef.parse("foo()->aType");
54-
assertTrue(fct.isUnknown());
55-
assertFalse(fct.isString());
56-
assertFalse(fct.isNumeric());
57-
assertFalse(fct.isGeometry());
58-
assertEquals("?aType?", fct.returnType.type.toString());
59-
} catch(Exception ex) {
60-
ex.printStackTrace(System.err);
61-
fail("Unknown types MUST be allowed!");
62-
}
63-
64-
// Test with a parameter type:
65-
try {
66-
FunctionDef fct = FunctionDef.parse("foo(param1 aType)");
67-
assertTrue(fct.getParam(0).type.isUnknown());
68-
assertFalse(fct.getParam(0).type.isString());
69-
assertFalse(fct.getParam(0).type.isNumeric());
70-
assertFalse(fct.getParam(0).type.isGeometry());
71-
assertEquals("?aType?", fct.getParam(0).type.toString());
72-
} catch(Exception ex) {
73-
ex.printStackTrace(System.err);
74-
fail("Unknown types MUST be allowed!");
75-
}
76-
}
77-
78-
@Test
79-
public void testForColumns() {
80-
final String QUERY_TXT = "SELECT FOO(C1), FOO(C2), FOO(C4), C1, C2, C3, C4 FROM T1";
81-
82-
try {
83-
// Create the parser:
84-
ADQLParser parser = new ADQLParser();
85-
86-
// Create table/column metadata:
87-
DefaultDBTable table1 = new DefaultDBTable("T1");
88-
table1.addColumn(new DefaultDBColumn("C1", table1));
89-
table1.addColumn(new DefaultDBColumn("C2", new DBType(DBDatatype.UNKNOWN), table1));
90-
table1.addColumn(new DefaultDBColumn("C3", new DBType(DBDatatype.VARCHAR), table1));
91-
table1.addColumn(new DefaultDBColumn("C4", new DBType(DBDatatype.UNKNOWN_NUMERIC), table1));
92-
Collection<DBTable> tList = Arrays.asList(new DBTable[]{ table1 });
93-
94-
// Check the type of the column T1.C1:
95-
DBColumn col = table1.getColumn("C1", true);
96-
assertNotNull(col);
97-
assertNull(col.getDatatype());
98-
99-
// Check the type of the column T1.C2:
100-
col = table1.getColumn("C2", true);
101-
assertNotNull(col);
102-
assertNotNull(col.getDatatype());
103-
assertTrue(col.getDatatype().isUnknown());
104-
assertFalse(col.getDatatype().isNumeric());
105-
assertFalse(col.getDatatype().isString());
106-
assertFalse(col.getDatatype().isGeometry());
107-
assertEquals("UNKNOWN", col.getDatatype().toString());
108-
109-
// Check the type of the column T1.C4:
110-
col = table1.getColumn("C4", true);
111-
assertNotNull(col);
112-
assertNotNull(col.getDatatype());
113-
assertTrue(col.getDatatype().isUnknown());
114-
assertTrue(col.getDatatype().isNumeric());
115-
assertFalse(col.getDatatype().isString());
116-
assertFalse(col.getDatatype().isGeometry());
117-
assertEquals("UNKNOWN_NUMERIC", col.getDatatype().toString());
118-
119-
// Define a UDF, and allow all geometrical functions and coordinate systems:
120-
FunctionDef udf1 = FunctionDef.parse("FOO(x INTEGER) -> INTEGER");
121-
parser.getSupportedFeatures().support(udf1.toLanguageFeature());
122-
Collection<FunctionDef> udfList = Arrays.asList(new FunctionDef[]{ udf1 });
123-
Collection<String> geoList = null;
124-
Collection<String> csList = null;
125-
126-
// Create the Query checker:
127-
QueryChecker checker = new DBChecker(tList, udfList, geoList, csList);
128-
129-
// Parse the query:
130-
ADQLSet pq = parser.parseQuery(QUERY_TXT);
131-
132-
// Check the parsed query:
133-
checker.check(pq);
134-
135-
/* Ensure the type of every ADQLColumn is as expected: */
136-
// isNumeric() = true for FOO(C1), but false for the others
137-
assertTrue(((ADQLQuery)pq).getSelect().get(0).getOperand().isNumeric());
138-
assertFalse(((ADQLQuery)pq).getSelect().get(0).getOperand().isString());
139-
assertFalse(((ADQLQuery)pq).getSelect().get(0).getOperand().isGeometry());
140-
// isNumeric() = true for FOO(C2), but false for the others
141-
assertTrue(((ADQLQuery)pq).getSelect().get(1).getOperand().isNumeric());
142-
assertFalse(((ADQLQuery)pq).getSelect().get(1).getOperand().isString());
143-
assertFalse(((ADQLQuery)pq).getSelect().get(1).getOperand().isGeometry());
144-
// isNumeric() = true for FOO(C4), but false for the others
145-
assertTrue(((ADQLQuery)pq).getSelect().get(2).getOperand().isNumeric());
146-
assertFalse(((ADQLQuery)pq).getSelect().get(2).getOperand().isString());
147-
assertFalse(((ADQLQuery)pq).getSelect().get(2).getOperand().isGeometry());
148-
// isNumeric() = isString() = isGeometry() for C1
149-
assertTrue(((ADQLQuery)pq).getSelect().get(3).getOperand().isNumeric());
150-
assertTrue(((ADQLQuery)pq).getSelect().get(3).getOperand().isString());
151-
assertTrue(((ADQLQuery)pq).getSelect().get(3).getOperand().isGeometry());
152-
// isNumeric() = isString() = isGeometry() for C2
153-
assertTrue(((ADQLQuery)pq).getSelect().get(4).getOperand().isNumeric());
154-
assertTrue(((ADQLQuery)pq).getSelect().get(4).getOperand().isString());
155-
assertTrue(((ADQLQuery)pq).getSelect().get(4).getOperand().isGeometry());
156-
// isString() = true for C3, but false for the others
157-
assertFalse(((ADQLQuery)pq).getSelect().get(5).getOperand().isNumeric());
158-
assertTrue(((ADQLQuery)pq).getSelect().get(5).getOperand().isString());
159-
assertFalse(((ADQLQuery)pq).getSelect().get(5).getOperand().isGeometry());
160-
// isString() = true for C4, but false for the others
161-
assertTrue(((ADQLQuery)pq).getSelect().get(6).getOperand().isNumeric());
162-
assertFalse(((ADQLQuery)pq).getSelect().get(6).getOperand().isString());
163-
assertFalse(((ADQLQuery)pq).getSelect().get(6).getOperand().isGeometry());
164-
} catch(Exception ex) {
165-
ex.printStackTrace(System.err);
166-
fail("The construction, configuration and usage of the parser are correct. Nothing should have failed here. (see console for more details)");
167-
}
168-
}
169-
}
170-
=======
1711
package adql.parser;
1722

1733
import static org.junit.Assert.assertEquals;
@@ -336,4 +166,3 @@ public void testForColumns() {
336166
}
337167
}
338168
}
339-
>>>>>>> 6430497 (Initial split into sub-projects):ADQLLib/test/adql/parser/TestUnknownTypes.java

UWSLib/src/uws/service/error/DefaultUWSErrorWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.json.JSONException;
3434
import org.json.JSONWriter;
3535

36-
import tap.TAPException;
3736
import uws.AcceptHeader;
3837
import uws.UWSException;
3938
import uws.UWSToolBox;

0 commit comments

Comments
 (0)