sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1457163 - in /sis/branches/JDK7/sis-utility/src: main/java/org/apache/sis/internal/converter/HeuristicRegistry.java test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java
Date Fri, 15 Mar 2013 23:45:10 GMT
Author: desruisseaux
Date: Fri Mar 15 23:45:09 2013
New Revision: 1457163

URL: http://svn.apache.org/r1457163
Log:
Connected the PathConverters.

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/HeuristicRegistry.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/HeuristicRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/HeuristicRegistry.java?rev=1457163&r1=1457162&r2=1457163&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/HeuristicRegistry.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/HeuristicRegistry.java
[UTF-8] Fri Mar 15 23:45:09 2013
@@ -157,6 +157,13 @@ public final class HeuristicRegistry ext
             }
         }
         /*
+         * Various kind of paths (Path, File, URL, URI).
+         */
+        final ObjectConverter<S,T> p = PathConverter.getInstance(sourceClass, targetClass);
+        if (p != null) {
+            return p;
+        }
+        /*
          * From various objects to String.
          */
         if (targetClass == String.class) {

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java?rev=1457163&r1=1457162&r2=1457163&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/HeuristicRegistryTest.java
[UTF-8] Fri Mar 15 23:45:09 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.converter;
 
 import java.io.File;
+import java.net.URI;
 import java.util.Date;
 import org.opengis.metadata.spatial.PixelOrientation;
 import org.apache.sis.util.ObjectConverter;
@@ -115,4 +116,19 @@ public final strictfp class HeuristicReg
         assertSame(c1, assertSerializedEquals(c1));
         assertSame(c2, assertSerializedEquals(c2));
     }
+
+    /**
+     * Tests the creation of {@link PathConverter}.
+     */
+    @Test
+    public void testFileURI() {
+        final ObjectConverter<File,URI> c1 = SYSTEM.findExact(File.class, URI.class);
+        final ObjectConverter<URI,File> c2 = SYSTEM.findExact(URI.class, File.class);
+        assertInstanceOf("URI ← File", PathConverter.class, c1);
+        assertInstanceOf("File ← URI", PathConverter.class, c2);
+        assertSame("inverse()", c2, c1.inverse());
+        assertSame("inverse()", c1, c2.inverse());
+        assertSame(c1, assertSerializedEquals(c1));
+        assertSame(c2, assertSerializedEquals(c2));
+    }
 }



Mime
View raw message