This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 25a4935bf5fbfbc024b2f1c0a46bdb1a3e879197 Author: Martin Desruisseaux <[email protected]> AuthorDate: Mon Aug 26 16:51:55 2019 +0200 Minor reformating and test refactoring. Some module of CQL reviews will be done later (hopefully), among other for avoiding dependency to AntLR, delegate geometry parsing to JTS/ESRI library and for trying to avoid direct dependency to JTS. In the meantime, the module is available on geoapi=4.0 branch for experiment but will be excluded from Apache SIS 1.0 release. --- core/sis-cql/nb-configuration.xml | 18 ---- core/sis-cql/pom.xml | 40 +-------- .../src/main/java/org/apache/sis/cql/CQL.java | 28 ++----- .../main/java/org/apache/sis/cql/CQLException.java | 20 ++++- .../org/apache/sis/cql/FilterToCQLVisitor.java | 13 ++- .../java/org/apache/sis/internal/cql/AntlrCQL.java | 22 +++-- .../{TemporalUtilities.java => CQLTestCase.java} | 32 ++++++- .../test/java/org/apache/sis/cql/CQLTestSuite.java | 11 ++- .../org/apache/sis/cql/ExpressionReadingTest.java | 97 ++++++++++------------ .../org/apache/sis/cql/ExpressionWritingTest.java | 65 +++++++-------- .../java/org/apache/sis/cql/FilterReadingTest.java | 45 +++++----- .../java/org/apache/sis/cql/FilterWritingTest.java | 45 +++++----- 12 files changed, 199 insertions(+), 237 deletions(-) diff --git a/core/sis-cql/nb-configuration.xml b/core/sis-cql/nb-configuration.xml deleted file mode 100644 index 8b36389..0000000 --- a/core/sis-cql/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project-shared-configuration> - <!-- -This file contains additional configuration written by modules in the NetBeans IDE. -The configuration is intended to be shared among all the users of project and -therefore it is assumed to be part of version control checkout. -Without this configuration present, some functionality in the IDE may be limited or fail altogether. ---> - <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> - <!-- -Properties that influence various parts of the IDE, especially code formatting and the like. -You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. -That way multiple projects can share the same settings (useful for formatting rules for example). -Any value defined here will override the pom.xml file value but is only applicable to the current project. ---> - <netbeans.hint.jdkPlatform>JDK_10</netbeans.hint.jdkPlatform> - </properties> -</project-shared-configuration> diff --git a/core/sis-cql/pom.xml b/core/sis-cql/pom.xml index feec340..5aa10c4 100644 --- a/core/sis-cql/pom.xml +++ b/core/sis-cql/pom.xml @@ -48,17 +48,8 @@ =========================================================== --> <developers> <developer> - <name>Travis L. Pinney</name> - <id>tlpinney</id> - <email>[email protected]</email> - <roles> - <role>developer</role> - </roles> - </developer> - <developer> - <name>Martin Desruisseaux</name> - <id>desruisseaux</id> - <email>[email protected]</email> + <name>Johann Sorel</name> + <id>jsorel</id> <organization>Geomatys</organization> <organizationUrl>http://www.geomatys.com</organizationUrl> <timezone>+1</timezone> @@ -67,14 +58,6 @@ </roles> </developer> </developers> - <contributors> - <contributor> - <name>Marc le Bihan</name> - <roles> - <role>developer</role> - </roles> - </contributor> - </contributors> <!-- =========================================================== @@ -138,11 +121,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>com.esri.geometry</groupId> - <artifactId>esri-geometry-api</artifactId> - <optional>true</optional> - </dependency> - <dependency> <groupId>org.locationtech.jts</groupId> <artifactId>jts-core</artifactId> <optional>true</optional> @@ -162,20 +140,6 @@ <type>test-jar</type> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.sis.core</groupId> - <artifactId>sis-metadata</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.sis.core</groupId> - <artifactId>sis-referencing</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/core/sis-cql/src/main/java/org/apache/sis/cql/CQL.java b/core/sis-cql/src/main/java/org/apache/sis/cql/CQL.java index 8adfe41..2c543db 100644 --- a/core/sis-cql/src/main/java/org/apache/sis/cql/CQL.java +++ b/core/sis-cql/src/main/java/org/apache/sis/cql/CQL.java @@ -23,7 +23,6 @@ import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.TerminalNode; import org.apache.sis.filter.DefaultFilterFactory; import org.apache.sis.internal.cql.AntlrCQL; -import static org.apache.sis.internal.cql.CQLParser.*; import org.apache.sis.internal.cql.CQLParser.CoordinateContext; import org.apache.sis.internal.cql.CQLParser.CoordinateSerieContext; import org.apache.sis.internal.cql.CQLParser.CoordinateSeriesContext; @@ -51,11 +50,14 @@ import org.opengis.filter.Or; import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.PropertyName; +import static org.apache.sis.internal.cql.CQLParser.*; + + /** * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 - * @since 1.0 + * @since 1.0 * @module */ public final class CQL { @@ -71,7 +73,6 @@ public final class CQL { public static Expression parseExpression(String cql, FilterFactory2 factory) throws CQLException { final Object obj = AntlrCQL.compileExpression(cql); - ParseTree tree = null; Expression result = null; if (obj instanceof ExpressionContext) { @@ -81,7 +82,6 @@ public final class CQL { } result = convertExpression(tree, factory); } - return result; } @@ -92,7 +92,7 @@ public final class CQL { public static Filter parseFilter(String cql, FilterFactory2 factory) throws CQLException { cql = cql.trim(); - //bypass parsing for inclusive filter + // Bypass parsing for inclusive filter. if (cql.isEmpty() || "*".equals(cql)) { return Filter.INCLUDE; } @@ -108,7 +108,6 @@ public final class CQL { } result = convertFilter(tree, factory); } - return result; } @@ -116,7 +115,6 @@ public final class CQL { if (filter == null) { return ""; } - final StringBuilder sb = new StringBuilder(); filter.accept(FilterToCQLVisitor.INSTANCE, sb); return sb.toString(); @@ -126,7 +124,6 @@ public final class CQL { if (exp == null) { return ""; } - final StringBuilder sb = new StringBuilder(); exp.accept(FilterToCQLVisitor.INSTANCE, sb); return sb.toString(); @@ -136,7 +133,6 @@ public final class CQL { * Convert the given tree in an Expression. */ private static Expression convertExpression(ParseTree tree, FilterFactory2 ff) throws CQLException { - if (tree instanceof ExpressionContext) { //: expression MULT expression //| expression UNARY expression @@ -199,7 +195,7 @@ public final class CQL { return ff.property(name); } - //handle as a function + // Handle as a function. final List<ExpressionContext> params = prm.expression(); final List<Expression> exps = new ArrayList<Expression>(); for (int i = 0, n = params.size(); i < n; i++) { @@ -207,7 +203,6 @@ public final class CQL { } return ff.function(name, exps.toArray(new Expression[exps.size()])); } - } else if (tree instanceof ExpressionUnaryContext) { //: UNARY? expressionNum ; final ExpressionUnaryContext exp = (ExpressionUnaryContext) tree; @@ -379,10 +374,8 @@ public final class CQL { } return ff.literal(geom); } - return convertExpression(tree.getChild(0), ff); } - throw new CQLException("Unreconized expression : type=" + tree.getText()); } @@ -422,7 +415,6 @@ public final class CQL { * Convert the given tree in a Filter. */ private static Filter convertFilter(ParseTree tree, FilterFactory2 ff) throws CQLException { - if (tree instanceof FilterContext) { //: filter (AND filter)+ //| filter (OR filter)+ @@ -672,7 +664,7 @@ public final class CQL { return ff.toverlaps(left, right); } else if (exp.filterGeometry() != null) { - //expression filterGeometry + // expression filterGeometry return convertFilter(exp.filterGeometry(), ff); } @@ -754,11 +746,7 @@ public final class CQL { final Expression exp2 = convertExpression(exps.get(1), ff); return ff.within(exp1, exp2); } - } - throw new CQLException("Unreconized filter : type=" + tree.getText()); - } - } diff --git a/core/sis-cql/src/main/java/org/apache/sis/cql/CQLException.java b/core/sis-cql/src/main/java/org/apache/sis/cql/CQLException.java index ab49755..88fc422 100644 --- a/core/sis-cql/src/main/java/org/apache/sis/cql/CQLException.java +++ b/core/sis-cql/src/main/java/org/apache/sis/cql/CQLException.java @@ -18,21 +18,35 @@ package org.apache.sis.cql; /** - * CQL exception. + * Thrown when a CQL statement can not be parsed. * * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -public final class CQLException extends Exception{ +public final class CQLException extends Exception { + /** + * Serial number for inter-operability with different versions. + */ + private static final long serialVersionUID = -1494977914551289727L; + /** + * Constructs an exception with the specified detail message. + * + * @param message the detail message. + */ public CQLException(String message) { super(message); } + /** + * Constructs an exception with the specified detail message and cause. + * + * @param message the detail message. + * @param cause the cause for this exception. + */ public CQLException(String message, Throwable cause) { super(message, cause); } - } diff --git a/core/sis-cql/src/main/java/org/apache/sis/cql/FilterToCQLVisitor.java b/core/sis-cql/src/main/java/org/apache/sis/cql/FilterToCQLVisitor.java index f1ca38b..dd72df6 100644 --- a/core/sis-cql/src/main/java/org/apache/sis/cql/FilterToCQLVisitor.java +++ b/core/sis-cql/src/main/java/org/apache/sis/cql/FilterToCQLVisitor.java @@ -18,8 +18,6 @@ package org.apache.sis.cql; import java.util.Date; import java.util.List; -import java.util.SimpleTimeZone; -import java.util.TimeZone; import java.util.regex.Pattern; import org.apache.sis.internal.util.StandardDateFormat; import org.locationtech.jts.geom.Geometry; @@ -78,19 +76,19 @@ import org.opengis.filter.temporal.TContains; import org.opengis.filter.temporal.TEquals; import org.opengis.filter.temporal.TOverlaps; + /** - * Visitor to convert a Filter in CQL.<br> + * Visitor to convert a Filter in CQL. * Returned object is a StringBuilder containing the CQL text. * - * @author Johann Sorel (Geomatys) + * @author Johann Sorel (Geomatys) * @version 1.0 - * @since 1.0 + * @since 1.0 * @module */ final class FilterToCQLVisitor implements FilterVisitor, ExpressionVisitor { - public static final FilterToCQLVisitor INSTANCE = new FilterToCQLVisitor(); - private static final TimeZone TZ = new SimpleTimeZone(0, "Out Timezone"); + static final FilterToCQLVisitor INSTANCE = new FilterToCQLVisitor(); /** * Pattern to check for property name to escape against regExp @@ -655,5 +653,4 @@ final class FilterToCQLVisitor implements FilterVisitor, ExpressionVisitor { public Object visit(final NilExpression exp, final Object o) { throw new UnsupportedOperationException("NilExpression not supported in CQL."); } - } diff --git a/core/sis-cql/src/main/java/org/apache/sis/internal/cql/AntlrCQL.java b/core/sis-cql/src/main/java/org/apache/sis/internal/cql/AntlrCQL.java index f63ddc8..1f3649a 100644 --- a/core/sis-cql/src/main/java/org/apache/sis/internal/cql/AntlrCQL.java +++ b/core/sis-cql/src/main/java/org/apache/sis/internal/cql/AntlrCQL.java @@ -23,12 +23,13 @@ import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.TokenStream; import org.antlr.v4.runtime.tree.ParseTree; + /** * ANTLR CQL parser methods. - * - * @author Johann Sorel (Geomatys) + * + * @author Johann Sorel (Geomatys) * @version 1.0 - * @since 1.0 + * @since 1.0 * @module */ public final class AntlrCQL { @@ -38,22 +39,20 @@ public final class AntlrCQL { public static ParseTree compile(String cql) { final Object obj = compileFilterOrExpression(cql); - ParseTree tree = null; if (obj instanceof ParseTree) { tree = (ParseTree) obj; } - return tree; } public static Object compileExpression(String cql) { try { - //lexer splits input into tokens + // Lexer splits input into tokens. final CodePointCharStream input = CharStreams.fromString(cql); final TokenStream tokens = new CommonTokenStream(new CQLLexer(input)); - //parser generates abstract syntax tree + // Parser generates abstract syntax tree. final CQLParser parser = new CQLParser(tokens); final CQLParser.ExpressionContext ctx = parser.expression(); return ctx; @@ -65,11 +64,11 @@ public final class AntlrCQL { public static Object compileFilter(String cql) { try { - //lexer splits input into tokens + // Lexer splits input into tokens. final CodePointCharStream input = CharStreams.fromString(cql); final TokenStream tokens = new CommonTokenStream(new CQLLexer(input)); - //parser generates abstract syntax tree + // Parser generates abstract syntax tree. final CQLParser parser = new CQLParser(tokens); final CQLParser.FilterContext retfilter = parser.filter(); @@ -82,11 +81,11 @@ public final class AntlrCQL { public static Object compileFilterOrExpression(String cql) { try { - //lexer splits input into tokens + // Lexer splits input into tokens. final CodePointCharStream input = CharStreams.fromString(cql); final TokenStream tokens = new CommonTokenStream(new CQLLexer(input)); - //parser generates abstract syntax tree + // Parser generates abstract syntax tree. final CQLParser parser = new CQLParser(tokens); final CQLParser.FilterOrExpressionContext retfilter = parser.filterOrExpression(); @@ -96,5 +95,4 @@ public final class AntlrCQL { throw new IllegalStateException("Recognition exception is never thrown, only declared."); } } - } diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/TemporalUtilities.java b/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestCase.java similarity index 53% rename from core/sis-cql/src/test/java/org/apache/sis/cql/TemporalUtilities.java rename to core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestCase.java index 158ed14..a6c9c26 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/TemporalUtilities.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestCase.java @@ -16,19 +16,45 @@ */ package org.apache.sis.cql; +import java.time.Instant; import java.util.Date; +import org.opengis.filter.FilterFactory2; +import org.locationtech.jts.geom.GeometryFactory; +import org.apache.sis.filter.DefaultFilterFactory; +import org.apache.sis.test.TestCase; + /** + * Base class of all CQL tests. * * @author Johann Sorel (Geomatys) * @version 1.0 * @since 1.0 * @module */ -class TemporalUtilities { +strictfp class CQLTestCase extends TestCase { + /** + * The factory to use for creating filter and expressions. + */ + final FilterFactory2 FF; + + /** + * The factory to use for creating Java Topology Suite (JTS) objects. + */ + final GeometryFactory GF; - static Date parseDate(String date) { - throw new UnsupportedOperationException("todo"); + /** + * Creates a new test case. + */ + CQLTestCase() { + FF = new DefaultFilterFactory(); + GF = new GeometryFactory(); } + /** + * Returns a date from the given string. + */ + static Date parseDate(final String date) { + return Date.from(Instant.parse(date)); + } } diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestSuite.java b/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestSuite.java index 6bf9783..aa8762b 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestSuite.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/CQLTestSuite.java @@ -17,6 +17,7 @@ package org.apache.sis.cql; import org.apache.sis.test.TestSuite; +import org.junit.BeforeClass; import org.junit.runners.Suite; @@ -35,5 +36,13 @@ import org.junit.runners.Suite; org.apache.sis.cql.FilterWritingTest.class, }) public final strictfp class CQLTestSuite extends TestSuite { - + /** + * Verifies the list of tests before to run the suite. + * See {@link #verifyTestList(Class, Class[])} for more information. + */ + @BeforeClass + public static void verifyTestList() { + assertNoMissingTest(CQLTestSuite.class); + verifyTestList(CQLTestSuite.class); + } } diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionReadingTest.java b/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionReadingTest.java index 68b7cc2..795b34e 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionReadingTest.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionReadingTest.java @@ -17,14 +17,9 @@ package org.apache.sis.cql; import java.text.ParseException; -import org.apache.sis.filter.DefaultFilterFactory; -import static org.junit.Assert.*; -import org.junit.Ignore; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryCollection; -import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; import org.locationtech.jts.geom.LinearRing; import org.locationtech.jts.geom.MultiLineString; @@ -32,7 +27,6 @@ import org.locationtech.jts.geom.MultiPoint; import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Polygon; -import org.opengis.filter.FilterFactory2; import org.opengis.filter.expression.Add; import org.opengis.filter.expression.Divide; import org.opengis.filter.expression.Function; @@ -40,6 +34,11 @@ import org.opengis.filter.expression.Literal; import org.opengis.filter.expression.Multiply; import org.opengis.filter.expression.PropertyName; import org.opengis.filter.expression.Subtract; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Test reading CQL expressions. @@ -49,13 +48,9 @@ import org.opengis.filter.expression.Subtract; * @since 1.0 * @module */ -public class ExpressionReadingTest { - - private final FilterFactory2 FF = new DefaultFilterFactory(); - private final GeometryFactory GF = new GeometryFactory(); - +public final strictfp class ExpressionReadingTest extends CQLTestCase { @Test - public void testPropertyName1() throws CQLException{ + public void testPropertyName1() throws CQLException { final String cql = "geom"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof PropertyName); @@ -64,7 +59,7 @@ public class ExpressionReadingTest { } @Test - public void testPropertyName2() throws CQLException{ + public void testPropertyName2() throws CQLException { final String cql = "\"geom\""; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof PropertyName); @@ -73,7 +68,7 @@ public class ExpressionReadingTest { } @Test - public void testPropertyName3() throws CQLException{ + public void testPropertyName3() throws CQLException { final String cql = "ùth{e_$uglY^_pr@perté"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof PropertyName); @@ -82,7 +77,7 @@ public class ExpressionReadingTest { } @Test - public void testInteger() throws CQLException{ + public void testInteger() throws CQLException { final String cql = "15"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -91,7 +86,7 @@ public class ExpressionReadingTest { } @Test - public void testNegativeInteger() throws CQLException{ + public void testNegativeInteger() throws CQLException { final String cql = "-15"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -100,7 +95,7 @@ public class ExpressionReadingTest { } @Test - public void testDecimal1() throws CQLException{ + public void testDecimal1() throws CQLException { final String cql = "3.14"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -109,7 +104,7 @@ public class ExpressionReadingTest { } @Test - public void testDecimal2() throws CQLException{ + public void testDecimal2() throws CQLException { final String cql = "9e-1"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -118,7 +113,7 @@ public class ExpressionReadingTest { } @Test - public void testNegativeDecimal() throws CQLException{ + public void testNegativeDecimal() throws CQLException { final String cql = "-3.14"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -127,7 +122,7 @@ public class ExpressionReadingTest { } @Test - public void testText() throws CQLException{ + public void testText() throws CQLException { final String cql = "'hello world'"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -136,7 +131,7 @@ public class ExpressionReadingTest { } @Test - public void testText2() throws CQLException{ + public void testText2() throws CQLException { final String cql = "'Valle d\\'Aosta'"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -145,7 +140,7 @@ public class ExpressionReadingTest { } @Test - public void testText3() throws CQLException{ + public void testText3() throws CQLException { final String cql = "'Valle d\\'Aosta/Vallée d\\'Aoste'"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -161,7 +156,7 @@ public class ExpressionReadingTest { final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); final Literal expression = (Literal) obj; - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), expression.getValue()); + assertEquals(parseDate("2012-03-21T05:42:36Z"), expression.getValue()); } @Ignore @@ -189,7 +184,7 @@ public class ExpressionReadingTest { } @Test - public void testAddition() throws CQLException{ + public void testAddition() throws CQLException { final String cql = "3 + 2"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Add); @@ -199,7 +194,7 @@ public class ExpressionReadingTest { @Ignore @Test - public void testAddition2() throws CQLException{ + public void testAddition2() throws CQLException { final String cql = "'test' + '23'"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Add); @@ -210,7 +205,7 @@ public class ExpressionReadingTest { } @Test - public void testSubstract() throws CQLException{ + public void testSubstract() throws CQLException { final String cql = "3 - 2"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Subtract); @@ -219,7 +214,7 @@ public class ExpressionReadingTest { } @Test - public void testMultiply() throws CQLException{ + public void testMultiply() throws CQLException { final String cql = "3 * 2"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Multiply); @@ -228,7 +223,7 @@ public class ExpressionReadingTest { } @Test - public void testDivide() throws CQLException{ + public void testDivide() throws CQLException { final String cql = "3 / 2"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Divide); @@ -238,7 +233,7 @@ public class ExpressionReadingTest { @Ignore @Test - public void testFunction1() throws CQLException{ + public void testFunction1() throws CQLException { final String cql = "max(\"att\",15)"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Function); @@ -248,7 +243,7 @@ public class ExpressionReadingTest { @Ignore @Test - public void testFunction2() throws CQLException{ + public void testFunction2() throws CQLException { final String cql = "min(\"att\",cos(3.14))"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Function); @@ -257,7 +252,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryPoint() throws CQLException{ + public void testGeometryPoint() throws CQLException { final String cql = "POINT(15 30)"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -267,7 +262,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryPointEmpty() throws CQLException{ + public void testGeometryPointEmpty() throws CQLException { final String cql = "POINT EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -278,7 +273,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMPoint() throws CQLException{ + public void testGeometryMPoint() throws CQLException { final String cql = "MULTIPOINT(15 30, 45 60)"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -292,7 +287,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMPointEmpty() throws CQLException{ + public void testGeometryMPointEmpty() throws CQLException { final String cql = "MULTIPOINT EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -303,7 +298,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryLineString() throws CQLException{ + public void testGeometryLineString() throws CQLException { final String cql = "LINESTRING(10 20, 30 40, 50 60)"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -318,7 +313,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryLineStringEmpty() throws CQLException{ + public void testGeometryLineStringEmpty() throws CQLException { final String cql = "LINESTRING EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -329,7 +324,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMLineString() throws CQLException{ + public void testGeometryMLineString() throws CQLException { final String cql = "MULTILINESTRING((10 20, 30 40, 50 60),(70 80, 90 100, 110 120))"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -354,7 +349,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMLineStringEmpty() throws CQLException{ + public void testGeometryMLineStringEmpty() throws CQLException { final String cql = "MULTILINESTRING EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -365,7 +360,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryPolygon() throws CQLException{ + public void testGeometryPolygon() throws CQLException { final String cql = "POLYGON((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80))"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -392,7 +387,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryPolygonEmpty() throws CQLException{ + public void testGeometryPolygonEmpty() throws CQLException { final String cql = "POLYGON EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -403,7 +398,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMPolygon() throws CQLException{ + public void testGeometryMPolygon() throws CQLException { final String cql = "MULTIPOLYGON(" + "((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80))," + "((11 21, 31 41, 51 61, 11 21), (71 81, 91 101, 111 121, 71 81))" @@ -452,7 +447,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryMPolygonEmpty() throws CQLException{ + public void testGeometryMPolygonEmpty() throws CQLException { final String cql = "MULTIPOLYGON EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -463,7 +458,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryCollection() throws CQLException{ + public void testGeometryCollection() throws CQLException { final String cql = "GEOMETRYCOLLECTION( POINT(15 30), LINESTRING(10 20, 30 40, 50 60) )"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -483,7 +478,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryCollectionEmpty() throws CQLException{ + public void testGeometryCollectionEmpty() throws CQLException { final String cql = "GEOMETRYCOLLECTION EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -494,7 +489,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryEnvelope() throws CQLException{ + public void testGeometryEnvelope() throws CQLException { final String cql = "ENVELOPE(10, 20, 40, 30)"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -514,7 +509,7 @@ public class ExpressionReadingTest { } @Test - public void testGeometryEnvelopeEmpty() throws CQLException{ + public void testGeometryEnvelopeEmpty() throws CQLException { final String cql = "ENVELOPE EMPTY"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Literal); @@ -525,7 +520,7 @@ public class ExpressionReadingTest { } @Test - public void testCombine1() throws CQLException{ + public void testCombine1() throws CQLException { final String cql = "((3*1)+(2-6))/4"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Divide); @@ -541,7 +536,7 @@ public class ExpressionReadingTest { } @Test - public void testCombine2() throws CQLException{ + public void testCombine2() throws CQLException { final String cql = "3*1+2/4"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Add); @@ -558,7 +553,7 @@ public class ExpressionReadingTest { @Ignore @Test - public void testCombine3() throws CQLException{ + public void testCombine3() throws CQLException { final String cql = "3*max(val,15)+2/4"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Add); @@ -578,7 +573,7 @@ public class ExpressionReadingTest { @Ignore @Test - public void testCombine4() throws CQLException{ + public void testCombine4() throws CQLException { final String cql = "3 * max ( val , 15 ) + 2 / 4"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Add); @@ -597,7 +592,7 @@ public class ExpressionReadingTest { } @Test - public void testCombine5() throws CQLException{ + public void testCombine5() throws CQLException { final String cql = "(\"NB-Curistes\"*50)/12000"; final Object obj = CQL.parseExpression(cql); assertTrue(obj instanceof Divide); diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionWritingTest.java b/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionWritingTest.java index 708064f..f48fa76 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionWritingTest.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/ExpressionWritingTest.java @@ -17,18 +17,17 @@ package org.apache.sis.cql; import java.text.ParseException; -import org.apache.sis.filter.DefaultFilterFactory; -import static org.junit.Assert.*; -import org.junit.Ignore; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LineString; import org.locationtech.jts.geom.LinearRing; import org.locationtech.jts.geom.Polygon; -import org.opengis.filter.FilterFactory2; import org.opengis.filter.expression.Expression; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Test writing in CQL expressions. @@ -38,13 +37,9 @@ import org.opengis.filter.expression.Expression; * @since 1.0 * @module */ -public class ExpressionWritingTest { - - private final FilterFactory2 FF = new DefaultFilterFactory(); - private final GeometryFactory GF = new GeometryFactory(); - +public final strictfp class ExpressionWritingTest extends CQLTestCase { @Test - public void testPropertyName1() throws CQLException{ + public void testPropertyName1() throws CQLException { final Expression exp = FF.property("geom"); final String cql = CQL.write(exp); assertNotNull(cql); @@ -52,7 +47,7 @@ public class ExpressionWritingTest { } @Test - public void testPropertyName2() throws CQLException{ + public void testPropertyName2() throws CQLException { final Expression exp = FF.property("the geom"); final String cql = CQL.write(exp); assertNotNull(cql); @@ -60,7 +55,7 @@ public class ExpressionWritingTest { } @Test - public void testInteger() throws CQLException{ + public void testInteger() throws CQLException { final Expression exp = FF.literal(15); final String cql = CQL.write(exp); assertNotNull(cql); @@ -68,7 +63,7 @@ public class ExpressionWritingTest { } @Test - public void testNegativeInteger() throws CQLException{ + public void testNegativeInteger() throws CQLException { final Expression exp = FF.literal(-15); final String cql = CQL.write(exp); assertNotNull(cql); @@ -76,7 +71,7 @@ public class ExpressionWritingTest { } @Test - public void testDecimal1() throws CQLException{ + public void testDecimal1() throws CQLException { final Expression exp = FF.literal(3.14); final String cql = CQL.write(exp); assertNotNull(cql); @@ -84,7 +79,7 @@ public class ExpressionWritingTest { } @Test - public void testDecimal2() throws CQLException{ + public void testDecimal2() throws CQLException { final Expression exp = FF.literal(9.0E-21); final String cql = CQL.write(exp); assertNotNull(cql); @@ -94,7 +89,7 @@ public class ExpressionWritingTest { @Ignore @Test public void testDate() throws CQLException, ParseException{ - final Expression exp = FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z")); + final Expression exp = FF.literal(parseDate("2012-03-21T05:42:36Z")); final String cql = CQL.write(exp); assertNotNull(cql); assertEquals("2012-03-21T05:42:36Z", cql); @@ -102,7 +97,7 @@ public class ExpressionWritingTest { @Test - public void testNegativeDecimal() throws CQLException{ + public void testNegativeDecimal() throws CQLException { final Expression exp = FF.literal(-3.14); final String cql = CQL.write(exp); assertNotNull(cql); @@ -110,7 +105,7 @@ public class ExpressionWritingTest { } @Test - public void testText() throws CQLException{ + public void testText() throws CQLException { final Expression exp = FF.literal("hello world"); final String cql = CQL.write(exp); assertNotNull(cql); @@ -118,7 +113,7 @@ public class ExpressionWritingTest { } @Test - public void testAdd() throws CQLException{ + public void testAdd() throws CQLException { final Expression exp = FF.add(FF.literal(3),FF.literal(2)); final String cql = CQL.write(exp); assertNotNull(cql); @@ -126,7 +121,7 @@ public class ExpressionWritingTest { } @Test - public void testSubtract() throws CQLException{ + public void testSubtract() throws CQLException { final Expression exp = FF.subtract(FF.literal(3),FF.literal(2)); final String cql = CQL.write(exp); assertNotNull(cql); @@ -134,7 +129,7 @@ public class ExpressionWritingTest { } @Test - public void testMultiply() throws CQLException{ + public void testMultiply() throws CQLException { final Expression exp = FF.multiply(FF.literal(3),FF.literal(2)); final String cql = CQL.write(exp); assertNotNull(cql); @@ -142,7 +137,7 @@ public class ExpressionWritingTest { } @Test - public void testDivide() throws CQLException{ + public void testDivide() throws CQLException { final Expression exp = FF.divide(FF.literal(3),FF.literal(2)); final String cql = CQL.write(exp); assertNotNull(cql); @@ -151,7 +146,7 @@ public class ExpressionWritingTest { @Ignore @Test - public void testFunction1() throws CQLException{ + public void testFunction1() throws CQLException { final Expression exp = FF.function("max",FF.property("att"), FF.literal(15)); final String cql = CQL.write(exp); assertNotNull(cql); @@ -160,7 +155,7 @@ public class ExpressionWritingTest { @Ignore @Test - public void testFunction2() throws CQLException{ + public void testFunction2() throws CQLException { final Expression exp = FF.function("min",FF.property("att"), FF.function("cos",FF.literal(3.14d))); final String cql = CQL.write(exp); assertNotNull(cql); @@ -168,7 +163,7 @@ public class ExpressionWritingTest { } @Test - public void testCombine1() throws CQLException{ + public void testCombine1() throws CQLException { final Expression exp = FF.divide( FF.add( @@ -182,7 +177,7 @@ public class ExpressionWritingTest { } @Test - public void testCombine2() throws CQLException{ + public void testCombine2() throws CQLException { final Expression exp = FF.add( FF.multiply(FF.literal(3), FF.literal(1)), @@ -196,7 +191,7 @@ public class ExpressionWritingTest { @Ignore @Test - public void testCombine3() throws CQLException{ + public void testCombine3() throws CQLException { final Expression exp = FF.add( FF.multiply( @@ -211,7 +206,7 @@ public class ExpressionWritingTest { } @Test - public void testPoint() throws CQLException{ + public void testPoint() throws CQLException { final Geometry geom = GF.createPoint(new Coordinate(15, 30)); final Expression exp = FF.literal(geom); final String cql = CQL.write(exp); @@ -220,7 +215,7 @@ public class ExpressionWritingTest { } @Test - public void testMPoint() throws CQLException{ + public void testMPoint() throws CQLException { final Geometry geom = GF.createMultiPoint( new Coordinate[]{ new Coordinate(15, 30), @@ -233,7 +228,7 @@ public class ExpressionWritingTest { } @Test - public void testLineString() throws CQLException{ + public void testLineString() throws CQLException { final Geometry geom = GF.createLineString( new Coordinate[]{ new Coordinate(10, 20), @@ -247,7 +242,7 @@ public class ExpressionWritingTest { } @Test - public void testMLineString() throws CQLException{ + public void testMLineString() throws CQLException { final Geometry geom = GF.createMultiLineString( new LineString[]{ GF.createLineString( @@ -271,7 +266,7 @@ public class ExpressionWritingTest { } @Test - public void testPolygon() throws CQLException{ + public void testPolygon() throws CQLException { final Geometry geom = GF.createPolygon( GF.createLinearRing( new Coordinate[]{ @@ -297,7 +292,7 @@ public class ExpressionWritingTest { } @Test - public void testMPolygon() throws CQLException{ + public void testMPolygon() throws CQLException { final Polygon geom1 = GF.createPolygon( GF.createLinearRing( new Coordinate[]{ diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/FilterReadingTest.java b/core/sis-cql/src/test/java/org/apache/sis/cql/FilterReadingTest.java index e2946a8..ab2f673 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/FilterReadingTest.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/FilterReadingTest.java @@ -18,18 +18,11 @@ package org.apache.sis.cql; import java.text.ParseException; import java.util.Date; -import org.apache.sis.filter.DefaultFilterFactory; -import org.apache.sis.internal.util.UnmodifiableArrayList; -import static org.junit.Assert.*; -import org.junit.Ignore; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LinearRing; import org.opengis.filter.And; import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; import org.opengis.filter.Not; import org.opengis.filter.Or; import org.opengis.filter.PropertyIsBetween; @@ -68,6 +61,12 @@ import org.opengis.filter.temporal.OverlappedBy; import org.opengis.filter.temporal.TContains; import org.opengis.filter.temporal.TEquals; import org.opengis.filter.temporal.TOverlaps; +import org.apache.sis.internal.util.UnmodifiableArrayList; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Test reading CQL filters. @@ -77,11 +76,9 @@ import org.opengis.filter.temporal.TOverlaps; * @since 1.0 * @module */ -public class FilterReadingTest { +public final strictfp class FilterReadingTest extends CQLTestCase { private static final double DELTA = 0.00000001; - private final FilterFactory2 FF = new DefaultFilterFactory(); - private final GeometryFactory GF = new GeometryFactory(); private final Geometry baseGeometry = GF.createPolygon( GF.createLinearRing( new Coordinate[]{ @@ -648,7 +645,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -663,7 +660,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -678,7 +675,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -693,7 +690,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -708,7 +705,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -723,7 +720,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -738,7 +735,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -753,7 +750,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -768,7 +765,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -783,7 +780,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -798,7 +795,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -813,7 +810,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -828,7 +825,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } @Ignore @@ -843,7 +840,7 @@ public class FilterReadingTest { assertTrue(filter.getExpression2() instanceof Literal); assertTrue( ((Literal)filter.getExpression2()).getValue() instanceof Date); final Date filterdate = (Date) ((Literal)filter.getExpression2()).getValue(); - assertEquals(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"), filterdate); + assertEquals(parseDate("2012-03-21T05:42:36Z"), filterdate); } } diff --git a/core/sis-cql/src/test/java/org/apache/sis/cql/FilterWritingTest.java b/core/sis-cql/src/test/java/org/apache/sis/cql/FilterWritingTest.java index 26a671a..ff908a8 100644 --- a/core/sis-cql/src/test/java/org/apache/sis/cql/FilterWritingTest.java +++ b/core/sis-cql/src/test/java/org/apache/sis/cql/FilterWritingTest.java @@ -18,17 +18,16 @@ package org.apache.sis.cql; import java.text.ParseException; import java.util.Collections; -import org.apache.sis.filter.DefaultFilterFactory; -import org.apache.sis.internal.util.UnmodifiableArrayList; -import static org.junit.Assert.*; -import org.junit.Ignore; -import org.junit.Test; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.LinearRing; import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; +import org.apache.sis.internal.util.UnmodifiableArrayList; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.*; + /** * Test writing in CQL filters. @@ -38,10 +37,8 @@ import org.opengis.filter.FilterFactory2; * @since 1.0 * @module */ -public class FilterWritingTest { +public final strictfp class FilterWritingTest extends CQLTestCase { - private final FilterFactory2 FF = new DefaultFilterFactory(); - private final GeometryFactory GF = new GeometryFactory(); private final Geometry baseGeometry = GF.createPolygon( GF.createLinearRing( new Coordinate[]{ @@ -290,7 +287,7 @@ public class FilterWritingTest { @Ignore @Test public void testAfter() throws CQLException, ParseException { - final Filter filter = FF.after(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.after(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att AFTER 2012-03-21T05:42:36Z", cql); @@ -299,7 +296,7 @@ public class FilterWritingTest { @Ignore @Test public void testAnyInteracts() throws CQLException, ParseException { - final Filter filter = FF.anyInteracts(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.anyInteracts(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att ANYINTERACTS 2012-03-21T05:42:36Z", cql); @@ -308,7 +305,7 @@ public class FilterWritingTest { @Ignore @Test public void testBefore() throws CQLException, ParseException { - final Filter filter = FF.before(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.before(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att BEFORE 2012-03-21T05:42:36Z", cql); @@ -317,7 +314,7 @@ public class FilterWritingTest { @Ignore @Test public void testBegins() throws CQLException, ParseException { - final Filter filter = FF.begins(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.begins(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att BEGINS 2012-03-21T05:42:36Z", cql); @@ -326,7 +323,7 @@ public class FilterWritingTest { @Ignore @Test public void testBegunBy() throws CQLException, ParseException { - final Filter filter = FF.begunBy(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.begunBy(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att BEGUNBY 2012-03-21T05:42:36Z", cql); @@ -335,7 +332,7 @@ public class FilterWritingTest { @Ignore @Test public void testDuring() throws CQLException, ParseException { - final Filter filter = FF.during(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.during(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att DURING 2012-03-21T05:42:36Z", cql); @@ -344,7 +341,7 @@ public class FilterWritingTest { @Ignore @Test public void testEndedBy() throws CQLException, ParseException { - final Filter filter = FF.endedBy(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.endedBy(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att ENDEDBY 2012-03-21T05:42:36Z", cql); @@ -353,7 +350,7 @@ public class FilterWritingTest { @Ignore @Test public void testEnds() throws CQLException, ParseException { - final Filter filter = FF.ends(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.ends(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att ENDS 2012-03-21T05:42:36Z", cql); @@ -362,7 +359,7 @@ public class FilterWritingTest { @Ignore @Test public void testMeets() throws CQLException, ParseException { - final Filter filter = FF.meets(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.meets(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att MEETS 2012-03-21T05:42:36Z", cql); @@ -371,7 +368,7 @@ public class FilterWritingTest { @Ignore @Test public void testMetBy() throws CQLException, ParseException { - final Filter filter = FF.metBy(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.metBy(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att METBY 2012-03-21T05:42:36Z", cql); @@ -380,7 +377,7 @@ public class FilterWritingTest { @Ignore @Test public void testOverlappedBy() throws CQLException, ParseException { - final Filter filter = FF.overlappedBy(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.overlappedBy(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att OVERLAPPEDBY 2012-03-21T05:42:36Z", cql); @@ -389,7 +386,7 @@ public class FilterWritingTest { @Ignore @Test public void testTcontains() throws CQLException, ParseException { - final Filter filter = FF.tcontains(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.tcontains(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att TCONTAINS 2012-03-21T05:42:36Z", cql); @@ -398,7 +395,7 @@ public class FilterWritingTest { @Ignore @Test public void testTequals() throws CQLException, ParseException { - final Filter filter = FF.tequals(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.tequals(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att TEQUALS 2012-03-21T05:42:36Z", cql); @@ -407,7 +404,7 @@ public class FilterWritingTest { @Ignore @Test public void testToverlaps() throws CQLException, ParseException { - final Filter filter = FF.toverlaps(FF.property("att"), FF.literal(TemporalUtilities.parseDate("2012-03-21T05:42:36Z"))); + final Filter filter = FF.toverlaps(FF.property("att"), FF.literal(parseDate("2012-03-21T05:42:36Z"))); final String cql = CQL.write(filter); assertNotNull(cql); assertEquals("att TOVERLAPS 2012-03-21T05:42:36Z", cql);
