sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1517047 - in /sis/branches/JDK7/core/sis-referencing/src: main/java/org/apache/sis/io/wkt/ test/java/org/apache/sis/io/wkt/ test/java/org/apache/sis/test/suite/
Date Fri, 23 Aug 2013 21:23:28 GMT
Author: desruisseaux
Date: Fri Aug 23 21:23:27 2013
New Revision: 1517047

URL: http://svn.apache.org/r1517047
Log:
Ported some tests.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
  (with props)
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java?rev=1517047&r1=1517046&r2=1517047&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Symbols.java
[UTF-8] Fri Aug 23 21:23:27 2013
@@ -483,11 +483,11 @@ public class Symbols implements Localize
         final int length = wkt.length();
         boolean isQuoting = false;
         while (offset < length) {
-            final int c = Character.codePointAt(wkt, offset);
+            int c = Character.codePointAt(wkt, offset);
             if (c == (isQuoting ? closeQuote : openQuote)) {
                 isQuoting = !isQuoting;
             }
-            if (!isQuoting && Character.isJavaIdentifierStart(c)) {
+            if (!isQuoting && Character.isUnicodeIdentifierStart(c)) {
                 /*
                  * Found the beginning of a Unicode identifier.
                  * Check if this is the identifier we were looking for.
@@ -497,11 +497,24 @@ public class Symbols implements Localize
                     if (offset >= length) {
                         break;
                     }
-                    if (matchingBracket(Character.codePointAt(wkt, offset)) >= 0) {
+                    c = Character.codePointAt(wkt, offset);
+                    if (matchingBracket(c) >= 0) {
                         return true;
                     }
+                } else {
+                    /*
+                     * Not the identifier we were looking for. Skip the whole identifier.
+                     */
+                    do {
+                        offset += Character.charCount(c);
+                        if (offset >= length) {
+                            return false;
+                        }
+                        c = Character.codePointAt(wkt, offset);
+                    } while (Character.isUnicodeIdentifierPart(c));
                 }
             }
+            offset += Character.charCount(c);
         }
         return false;
     }

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java?rev=1517047&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
[UTF-8] Fri Aug 23 21:23:27 2013
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sis.io.wkt;
+
+import org.opengis.metadata.citation.Citation;
+import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link Convention} enumeration.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-3.20)
+ * @version 0.4
+ * @module
+ */
+public final strictfp class ConventionTest extends TestCase {
+    /**
+     * Tests all citations associated with enum values.
+     */
+    @Test
+    public void testGetCitation() {
+        for (final Convention convention : Convention.values()) {
+            final Citation citation = convention.getAuthority();
+            if (convention != Convention.PROJ4 && convention != Convention.INTERNAL)
{
+                assertTrue(convention.name(), convention.name().equalsIgnoreCase(Citations.getIdentifier(citation)));
+            }
+        }
+    }
+
+    /**
+     * Tests {@link Convention#forCitation(Citation, Convention)}.
+     */
+    @Test
+    public void testForCitation() {
+        assertSame(Convention.OGC,     Convention.forCitation(Citations.OGC,     null));
+        assertSame(Convention.EPSG,    Convention.forCitation(Citations.EPSG,    null));
+        assertSame(Convention.ESRI,    Convention.forCitation(Citations.ESRI,    null));
+        assertSame(Convention.ORACLE,  Convention.forCitation(Citations.ORACLE,  null));
+        assertSame(Convention.NETCDF,  Convention.forCitation(Citations.NETCDF,  null));
+        assertSame(Convention.GEOTIFF, Convention.forCitation(Citations.GEOTIFF, null));
+        assertSame(Convention.PROJ4,   Convention.forCitation(Citations.PROJ4,   null));
+    }
+
+    /**
+     * Tests {@link Convention#forIdentifier(String, Convention)}.
+     */
+    @Test
+    public void testForIdentifier() {
+        assertSame(Convention.OGC,     Convention.forIdentifier("OGC",     null));
+        assertSame(Convention.EPSG,    Convention.forIdentifier("EPSG",    null));
+        assertSame(Convention.ESRI,    Convention.forIdentifier("ESRI",    null));
+        assertSame(Convention.ORACLE,  Convention.forIdentifier("ORACLE",  null));
+        assertSame(Convention.NETCDF,  Convention.forIdentifier("NETCDF",  null));
+        assertSame(Convention.GEOTIFF, Convention.forIdentifier("GEOTIFF", null));
+        assertSame(Convention.PROJ4,   Convention.forIdentifier("PROJ4",   null));
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/ConventionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1517047&r1=1517046&r2=1517047&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
[UTF-8] Fri Aug 23 21:23:27 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.io.wkt;
 
 import org.apache.sis.internal.util.X364;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -31,6 +32,7 @@ import static org.junit.Assert.*;
  * @version 0.4
  * @module
  */
+@DependsOn({ConventionTest.class, SymbolsTest.class})
 public final strictfp class FormatterTest extends TestCase {
     /**
      * Verifies the ANSI escape sequences hard-coded in {@link Formatter}.

Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java?rev=1517047&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
(added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
[UTF-8] Fri Aug 23 21:23:27 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sis.io.wkt;
+
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link Symbols} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4 (derived from geotk-2.4)
+ * @version 0.4
+ * @module
+ */
+public final strictfp class SymbolsTest extends TestCase {
+    /**
+     * Tests the {@link Symbols#containsAxis(CharSequence)} method.
+     */
+    @Test
+    public void testContainsAxis() {
+        final Symbols s = Symbols.DEFAULT;
+        assertTrue("At beginning of a line.",   s.containsAxis(                  "AXIS[\"Long\",
EAST]"));
+        assertTrue("Embeded in GEOGCS.",        s.containsAxis("GEOGCS[\"WGS84\", AXIS[\"Long\",
EAST]]"));
+        assertTrue("Using different brackets.", s.containsAxis("GEOGCS[\"WGS84\", AXIS (\"Long\",
EAST)]"));
+        assertTrue("Mixed cases.",              s.containsAxis("GEOGCS[\"WGS84\", aXis[\"Long\",
EAST]]"));
+        assertFalse("AXIS in quoted text.",     s.containsAxis("GEOGCS[\"AXIS\"]"));
+        assertFalse("Without opening bracket.", s.containsAxis("GEOGCS[\"WGS84\", AXIS]"));
+        assertFalse("No AXIS.",                 s.containsAxis("GEOGCS[\"WGS84\"]"));
+    }
+}

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/SymbolsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1517047&r1=1517046&r2=1517047&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Aug 23 21:23:27 2013
@@ -39,6 +39,8 @@ import org.junit.BeforeClass;
     org.apache.sis.geometry.SubEnvelopeTest.class,
     org.apache.sis.geometry.ImmutableEnvelopeTest.class,
     org.apache.sis.geometry.Envelope2DTest.class,
+    org.apache.sis.io.wkt.ConventionTest.class,
+    org.apache.sis.io.wkt.SymbolsTest.class,
     org.apache.sis.io.wkt.FormatterTest.class
 })
 public final strictfp class ReferencingTestSuite extends TestSuite {



Mime
View raw message