sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1457579 - in /sis/branches/JDK7/sis-utility/src: main/java/org/apache/sis/internal/converter/ main/resources/META-INF/services/ test/java/org/apache/sis/internal/converter/ test/java/org/apache/sis/test/suite/
Date Sun, 17 Mar 2013 22:56:37 GMT
Author: desruisseaux
Date: Sun Mar 17 22:56:37 2013
New Revision: 1457579

URL: http://svn.apache.org/r1457579
Log:
Added or connected the last converters.
The package is not complete (for now).

Added:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
  (with props)
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
  (with props)
Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/NumberConverter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemConverter.java
    sis/branches/JDK7/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/SystemRegistryTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java?rev=1457579&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
(added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -0,0 +1,104 @@
+/*
+ * 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.internal.converter;
+
+import java.util.Set;
+import net.jcip.annotations.Immutable;
+import org.apache.sis.measure.Angle;
+import org.apache.sis.util.ObjectConverter;
+import org.apache.sis.math.FunctionProperty;
+
+
+/**
+ * Handles conversions between {@link Angle} and {@link Double}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.00)
+ * @version 0.3
+ * @module
+ */
+@Immutable
+public final class AngleConverter extends SystemConverter<Angle,Double> {
+    /** For cross-version compatibility. */
+    private static final long serialVersionUID = -1034882100844343376L;
+
+    /** The unique instance. */
+    static final AngleConverter INSTANCE = new AngleConverter();
+
+    /** Creates a new converter. */
+    public AngleConverter() { // Instantiated by ServiceLoader.
+        super(Angle.class, Double.class);
+    }
+
+    /** Returns the unique instance. */
+    @Override public ObjectConverter<Angle,Double> unique() {
+        return INSTANCE;
+    }
+
+    /** Returns the inverse converter. */
+    @Override public ObjectConverter<Double,Angle> inverse() {
+        return Inverse.INSTANCE;
+    }
+
+    /** Declares that the converter is bijective. */
+    @Override public Set<FunctionProperty> properties() {
+        return bijective();
+    }
+
+    /** Converts the given angle. */
+    @Override public Double convert(final Angle object) {
+        return object.degrees();
+    }
+
+
+    /**
+     * The inverse of {@link AngleConverter}.
+     */
+    @Immutable
+    public static final class Inverse extends SystemConverter<Double,Angle> {
+        /** For cross-version compatibility. */
+        private static final long serialVersionUID = -8973303108935526882L;
+
+        /** The unique instance. */
+        static final Inverse INSTANCE = new Inverse();
+
+        /** Creates a new converter. */
+        public Inverse() { // Instantiated by ServiceLoader.
+            super(Double.class, Angle.class);
+        }
+
+        /** Returns the unique instance. */
+        @Override public ObjectConverter<Double,Angle> unique() {
+            return INSTANCE;
+        }
+
+        /** Returns the inverse converter. */
+        @Override public ObjectConverter<Angle,Double> inverse() {
+            return AngleConverter.INSTANCE;
+        }
+
+        /** Declares that the converter is bijective. */
+        @Override public Set<FunctionProperty> properties() {
+            return bijective();
+        }
+
+        /** Converts the given angle. */
+        @Override public Angle convert(final Double object) {
+            return new Angle(object);
+        }
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/AngleConverter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/CollectionConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -60,12 +60,11 @@ abstract class CollectionConverter<T> ex
     /**
      * Converter from {@link Collection} to {@link java.util.List}.
      */
-    @Immutable
-    static final class List extends CollectionConverter<java.util.List<?>> {
+    public static final class List extends CollectionConverter<java.util.List<?>>
{
         private static final long serialVersionUID = 5492247760609833586L;
 
         @SuppressWarnings("unchecked")
-        List() {
+        public List() { // Instantiated by ServiceLoader.
             super((Class) java.util.List.class);
         }
 
@@ -85,12 +84,11 @@ abstract class CollectionConverter<T> ex
     /**
      * Converter from {@link Collection} to {@link java.util.Set}.
      */
-    @Immutable
-    static final class Set extends CollectionConverter<java.util.Set<?>> {
+    public static final class Set extends CollectionConverter<java.util.Set<?>>
{
         private static final long serialVersionUID = -4200659837453206164L;
 
         @SuppressWarnings("unchecked")
-        Set() {
+        public Set() { // Instantiated by ServiceLoader.
             super((Class) java.util.Set.class);
         }
 

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/DateConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -123,8 +123,7 @@ abstract class DateConverter<T> extends 
         }
 
         @Override public Set<FunctionProperty> properties() {
-            return EnumSet.of(FunctionProperty.INJECTIVE, FunctionProperty.SURJECTIVE,
-                    FunctionProperty.ORDER_PRESERVING, FunctionProperty.INVERTIBLE);
+            return bijective();
         }
 
         @Override public java.lang.Long convert(final Date source) {

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/NumberConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/NumberConverter.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/NumberConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/NumberConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -144,8 +144,7 @@ final class NumberConverter<S extends Nu
         @Override
         public Set<FunctionProperty> properties() {
             if (targetClass.isAssignableFrom(sourceClass)) {
-                return EnumSet.of(FunctionProperty.INJECTIVE, FunctionProperty.SURJECTIVE,
-                            FunctionProperty.ORDER_PRESERVING);
+                return bijective();
             }
             return EnumSet.noneOf(FunctionProperty.class);
         }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -299,6 +299,15 @@ abstract class StringConverter<T> extend
         }
     }
 
+    public static final class Angle extends StringConverter<org.apache.sis.measure.Angle>
{
+        private static final long serialVersionUID = -6937967772504961327L;
+        public Angle() {super(org.apache.sis.measure.Angle.class);} // Instantiated by ServiceLoader.
+
+        @Override org.apache.sis.measure.Angle doConvert(String source) throws NumberFormatException
{
+            return new org.apache.sis.measure.Angle(source);
+        }
+    }
+
     public static final class InternationalString extends StringConverter<org.opengis.util.InternationalString>
{
         private static final long serialVersionUID = 730809620191573819L;
         public InternationalString() {super(org.opengis.util.InternationalString.class);}
// Instantiated by ServiceLoader.
@@ -307,10 +316,9 @@ abstract class StringConverter<T> extend
             return new SimpleInternationalString(source);
         }
 
-        /** Declares a bijective function. */
+        /** Declares that the converter is bijective. */
         @Override public Set<FunctionProperty> properties() {
-            return EnumSet.of(FunctionProperty.INJECTIVE, FunctionProperty.SURJECTIVE,
-                    FunctionProperty.ORDER_PRESERVING, FunctionProperty.INVERTIBLE);
+            return bijective();
         }
     }
 

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemConverter.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemConverter.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -16,7 +16,10 @@
  */
 package org.apache.sis.internal.converter;
 
+import java.util.Set;
+import java.util.EnumSet;
 import java.io.ObjectStreamException;
+import org.apache.sis.math.FunctionProperty;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.resources.Errors;
 
@@ -67,6 +70,15 @@ abstract class SystemConverter<S,T> exte
     }
 
     /**
+     * Convenience method for {@link #properties()} implementation of bijective converters
+     * between comparable objects. The converter is presumed invertible and to preserve order.
+     */
+    static Set<FunctionProperty> bijective() {
+        return EnumSet.of(FunctionProperty.INJECTIVE, FunctionProperty.SURJECTIVE,
+                    FunctionProperty.ORDER_PRESERVING, FunctionProperty.INVERTIBLE);
+    }
+
+    /**
      * Default to non-invertible conversion. Must be overridden by subclasses that support
inversions.
      */
     @Override
@@ -113,6 +125,8 @@ abstract class SystemConverter<S,T> exte
      * Returns an unique instance of this converter if one exists. If a converter already
      * exists for the same source an target classes, then this converter is returned.
      * Otherwise this converter is returned <strong>without</strong> being cached.
+     *
+     * @return The unique instance, or {@code this} if no unique instance can be found.
      */
     public ObjectConverter<S,T> unique() {
         final ObjectConverter<S,T> existing = SystemRegistry.INSTANCE.findEquals(this);

Modified: sis/branches/JDK7/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/resources/META-INF/services/org.apache.sis.util.ObjectConverter
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -16,6 +16,9 @@ org.apache.sis.internal.converter.String
 org.apache.sis.internal.converter.StringConverter$Path
 org.apache.sis.internal.converter.StringConverter$URI
 org.apache.sis.internal.converter.StringConverter$URL
+org.apache.sis.internal.converter.StringConverter$Angle
+org.apache.sis.internal.converter.AngleConverter
+org.apache.sis.internal.converter.AngleConverter$Inverse
 org.apache.sis.internal.converter.PathConverter$FileURI
 org.apache.sis.internal.converter.PathConverter$FileURL
 org.apache.sis.internal.converter.PathConverter$URLFile
@@ -25,3 +28,5 @@ org.apache.sis.internal.converter.PathCo
 org.apache.sis.internal.converter.DateConverter$Long
 org.apache.sis.internal.converter.DateConverter$SQL
 org.apache.sis.internal.converter.DateConverter$Timestamp
+org.apache.sis.internal.converter.CollectionConverter$List
+org.apache.sis.internal.converter.CollectionConverter$Set

Added: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java?rev=1457579&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
(added)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.internal.converter;
+
+import org.apache.sis.measure.Angle;
+import org.apache.sis.util.ObjectConverter;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests the various {@link AngleConverter} implementations.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-2.4)
+ * @version 0.3
+ * @module
+ */
+public final strictfp class AngleConverterTest extends TestCase {
+    /**
+     * Tests conversions to {@link Double}.
+     */
+    @Test
+    public void testDouble() {
+        final ObjectConverter<Angle,Double> c1 = AngleConverter.INSTANCE;
+        final ObjectConverter<Double,Angle> c2 = AngleConverter.Inverse.INSTANCE;
+        final Angle  v1 = new Angle (30.25);
+        final Double v2 = new Double(30.25);
+        assertEquals(v2, c1.convert(v1));
+        assertEquals(v1, c2.convert(v2));
+        assertSame(c2, c1.inverse());
+        assertSame(c1, c2.inverse());
+        assertSame(c1, assertSerializedEquals(c1));
+        assertSame(c2, assertSerializedEquals(c2));
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/AngleConverterTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -28,10 +28,12 @@ import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.spatial.PixelOrientation;
+import org.apache.sis.measure.Angle;
 import org.apache.sis.math.FunctionProperty;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.UnconvertibleObjectException;
 import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -50,6 +52,7 @@ import java.nio.file.Paths;
  * @version 0.3
  * @module
  */
+@DependsOn(org.apache.sis.measure.AngleTest.class)
 public final strictfp class StringConverterTest extends TestCase {
     /**
      * Asserts that conversion of the given {@code source} value produces
@@ -181,6 +184,17 @@ public final strictfp class StringConver
     }
 
     /**
+     * Tests conversions to {@link Angle}.
+     */
+    @Test
+    public void testAngle() {
+        final ObjectConverter<String,Angle> c = new StringConverter.Angle();
+        runInvertibleConversion(c, "42°30′00″", new Angle(42.5));
+        tryUnconvertibleValue(c);
+        assertSerializedEquals(c);
+    }
+
+    /**
      * Tests conversions to boolean values.
      */
     @Test

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/SystemRegistryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/SystemRegistryTest.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/SystemRegistryTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/SystemRegistryTest.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -19,7 +19,10 @@ package org.apache.sis.internal.converte
 import java.io.File;
 import java.net.URI;
 import java.util.Date;
+import java.util.List;
+import java.util.Collection;
 import org.opengis.metadata.spatial.PixelOrientation;
+import org.apache.sis.measure.Angle;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -48,8 +51,8 @@ public final strictfp class SystemRegist
     public void testStringFile() {
         final ObjectConverter<String,File> c1 = INSTANCE.findExact(String.class, File.class);
         final ObjectConverter<File,String> c2 = INSTANCE.findExact(File.class, String.class);
-        assertInstanceOf("File ← String", StringConverter.class, c1);
-        assertInstanceOf("String ← File", ObjectToString.class,  c2);
+        assertInstanceOf("File ← String", StringConverter.File.class, c1);
+        assertInstanceOf("String ← File", ObjectToString.class, c2);
         assertSame("inverse()", c2, c1.inverse());
         assertSame("inverse()", c1, c2.inverse());
         assertSame(c1, assertSerializedEquals(c1));
@@ -63,8 +66,8 @@ public final strictfp class SystemRegist
     public void testStringCodeList() {
         final ObjectConverter<String, PixelOrientation> c1 = INSTANCE.findExact(String.class,
PixelOrientation.class);
         final ObjectConverter<PixelOrientation, String> c2 = INSTANCE.findExact(PixelOrientation.class,
String.class);
-        assertInstanceOf("PixelOrientation ← String", StringConverter.class, c1);
-        assertInstanceOf("String ← PixelOrientation", ObjectToString.class,  c2);
+        assertInstanceOf("PixelOrientation ← String", StringConverter.CodeList.class,
c1);
+        assertInstanceOf("String ← PixelOrientation", ObjectToString.CodeList.class,
 c2);
         assertSame("inverse()", c2, c1.inverse());
         assertSame("inverse()", c1, c2.inverse());
         assertSame(c1, assertSerializedEquals(c1));
@@ -93,7 +96,7 @@ public final strictfp class SystemRegist
     public void testDateLong() {
         final ObjectConverter<Date,Long> c1 = INSTANCE.findExact(Date.class, Long.class);
         final ObjectConverter<Long,Date> c2 = INSTANCE.findExact(Long.class, Date.class);
-        assertInstanceOf("Long ← Date", DateConverter.class,   c1);
+        assertInstanceOf("Long ← Date", DateConverter.Long.class, c1);
         assertInstanceOf("Date ← Long", SystemConverter.class, c2);
         assertSame("inverse()", c2, c1.inverse());
         assertSame("inverse()", c1, c2.inverse());
@@ -109,7 +112,7 @@ public final strictfp class SystemRegist
     public void testDateSQL() {
         final ObjectConverter<Date, java.sql.Date> c1 = INSTANCE.findExact(Date.class,
java.sql.Date.class);
         final ObjectConverter<java.sql.Date, Date> c2 = INSTANCE.findExact(java.sql.Date.class,
Date.class);
-        assertInstanceOf("sql.Date ← Date", DateConverter.class,     c1);
+        assertInstanceOf("sql.Date ← Date", DateConverter.SQL.class, c1);
         assertInstanceOf("Date ← sql.Date", IdentityConverter.class, c2);
         assertSame("inverse()", c2, c1.inverse());
         assertSame("inverse()", c1, c2.inverse());
@@ -124,11 +127,37 @@ public final strictfp class SystemRegist
     public void testFileURI() {
         final ObjectConverter<File,URI> c1 = INSTANCE.findExact(File.class, URI.class);
         final ObjectConverter<URI,File> c2 = INSTANCE.findExact(URI.class, File.class);
-        assertInstanceOf("URI ← File", PathConverter.class, c1);
-        assertInstanceOf("File ← URI", PathConverter.class, c2);
+        assertInstanceOf("URI ← File", PathConverter.FileURI.class, c1);
+        assertInstanceOf("File ← URI", PathConverter.URIFile.class, c2);
         assertSame("inverse()", c2, c1.inverse());
         assertSame("inverse()", c1, c2.inverse());
         assertSame(c1, assertSerializedEquals(c1));
         assertSame(c2, assertSerializedEquals(c2));
     }
+
+    /**
+     * Tests the creation of {@link AngleConverter}.
+     */
+    @Test
+    public void testAngle() {
+        final ObjectConverter<Angle,Double> c1 = INSTANCE.findExact(Angle.class, Double.class);
+        final ObjectConverter<Double,Angle> c2 = INSTANCE.findExact(Double.class, Angle.class);
+        assertInstanceOf("Double ← Angle", AngleConverter.class, c1);
+        assertInstanceOf("Angle ← Double", AngleConverter.Inverse.class, c2);
+        assertSame("inverse()", c2, c1.inverse());
+        assertSame("inverse()", c1, c2.inverse());
+        assertSame(c1, assertSerializedEquals(c1));
+        assertSame(c2, assertSerializedEquals(c2));
+    }
+
+    /**
+     * Tests the creation of {@link CollectionConverter}.
+     */
+    @Test
+    @SuppressWarnings("rawtypes")
+    public void testCollection() {
+        final ObjectConverter<Collection,List> c1 = INSTANCE.findExact(Collection.class,
List.class);
+        assertInstanceOf("List ← Collection", CollectionConverter.class, c1);
+        assertSame(c1, assertSerializedEquals(c1));
+    }
 }

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1457579&r1=1457578&r2=1457579&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Sun Mar 17 22:56:37 2013
@@ -91,6 +91,7 @@ import org.junit.runners.Suite;
     org.apache.sis.util.collection.RangeSetTest.class,
 
     // Converters
+    org.apache.sis.internal.converter.AngleConverterTest.class,
     org.apache.sis.internal.converter.PathConverterTest.class,
     org.apache.sis.internal.converter.StringConverterTest.class,
     org.apache.sis.internal.converter.FallbackConverterTest.class,



Mime
View raw message