sis-commits mailing list archives

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

URL: http://svn.apache.org/r1456883
Log:
Reverse the order of classes show in the toString() representation: (target, source) instead
than (source, target).
This produce much more natural tree representation, with class hierarchy as we are used to
see.

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/Column.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/InjectiveConverter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/FallbackConverterTest.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ClassPair.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -160,6 +160,6 @@ class ClassPair<S,T> implements Serializ
     @Debug
     @Override
     public String toString() {
-        return sourceClass.getSimpleName() + " ⇨ " + targetClass.getSimpleName();
+        return targetClass.getSimpleName() + " ← " + sourceClass.getSimpleName();
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/Column.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/Column.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/Column.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/Column.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -86,7 +86,7 @@ final class Column extends TableColumn<C
      * Creates a table.
      */
     static TreeTable createTable() {
-        return new DefaultTreeTable(Column.SOURCE, Column.TARGET);
+        return new DefaultTreeTable(Column.TARGET, Column.SOURCE);
     }
 
     /**
@@ -112,7 +112,7 @@ final class Column extends TableColumn<C
     @Debug
     static String format(final TreeTable table) {
         final TreeTableFormat format = new TreeTableFormat(null, null);
-        format.setColumnSeparatorPattern("?[ ] ⇨ ");
+        format.setColumnSeparatorPattern("?[ ] ← ");
         return format.format(table);
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -443,7 +443,7 @@ public class ConverterRegistry {
     public String toString() {
         final TreeTable table = Column.createTable();
         final TreeTable.Node root = table.getRoot();
-        root.setValue(Column.SOURCE, getClass());
+        root.setValue(Column.TARGET, getClass());
         synchronized (converters) {
             for (final Map.Entry<ClassPair<?,?>, ObjectConverter<?,?>>
entry : converters.entrySet()) {
                 TreeTable.Node addTo = root;

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/InjectiveConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/InjectiveConverter.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/InjectiveConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/InjectiveConverter.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -74,7 +74,7 @@ public abstract class InjectiveConverter
     @Override
     public String toString() {
         return Classes.getShortClassName(this) + '[' +
-                getSourceClass().getSimpleName() + " ⇨ " +
-                getTargetClass().getSimpleName() + ']';
+                getTargetClass().getSimpleName() + " ← " +
+                getSourceClass().getSimpleName() + ']';
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -86,7 +86,7 @@ public abstract class SurjectiveConverte
     @Override
     public String toString() {
         return Classes.getShortClassName(this) + '[' +
-                getSourceClass().getSimpleName() + " ⇨ " +
-                getTargetClass().getSimpleName() + ']';
+                getTargetClass().getSimpleName() + " ← " +
+                getSourceClass().getSimpleName() + ']';
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/FallbackConverterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/FallbackConverterTest.java?rev=1456883&r1=1456882&r2=1456883&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/FallbackConverterTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/converter/FallbackConverterTest.java
[UTF-8] Fri Mar 15 10:47:54 2013
@@ -28,14 +28,17 @@ import static org.apache.sis.test.Assert
 
 
 /**
- * Tests {@link FallbackConverter}.
+ * Tests {@link FallbackConverter}. This test creates {@code FallbackConverter} instances
directly.
+ * It shall not use {@link ConverterRegistry}, directly or indirectly, in order to keep the
tests
+ * isolated. Note that {@link SystemConverter#inverse()} and serialization indirectly use
+ * {@code ConverterRegistry}, so those tests shall be avoided.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
  * @module
  */
-@DependsOn(StringConverterTest.class)
+@DependsOn(org.apache.sis.util.collection.TreeTableFormatTest.class)
 public final strictfp class FallbackConverterTest extends TestCase {
     /**
      * Conversions that are expected to be supported.
@@ -62,7 +65,7 @@ public final strictfp class FallbackConv
         assertEquals(INVERTIBLE,   c.properties());
         tryConversions(c, SHORT);
         assertMultilinesEquals(
-                "StringConverter.Short[String ⇨ Short]", c.toString());
+                "StringConverter.Short[Short ← String]", c.toString());
 
         c = FallbackConverter.merge(c, StringConverter.Long.INSTANCE);
         assertEquals(String.class, c.getSourceClass());
@@ -70,9 +73,9 @@ public final strictfp class FallbackConv
         assertEquals(SURJECTIVE,   c.properties());
         tryConversions(c, LONG);
         assertMultilinesEquals(
-                "String     ⇨ Number\n" +
-                "  ├─String ⇨ Short\n" +
-                "  └─String ⇨ Long\n", c.toString());
+                "Number    ← String\n" +
+                "  ├─Short ← String\n" +
+                "  └─Long  ← String\n", c.toString());
 
         c = FallbackConverter.merge(c, StringConverter.Float.INSTANCE);
         assertEquals(String.class, c.getSourceClass());
@@ -80,10 +83,10 @@ public final strictfp class FallbackConv
         assertEquals(SURJECTIVE,   c.properties());
         tryConversions(c, FLOAT);
         assertMultilinesEquals(
-                "String     ⇨ Number\n" +
-                "  ├─String ⇨ Short\n" +
-                "  ├─String ⇨ Long\n" +
-                "  └─String ⇨ Float\n", c.toString());
+                "Number    ← String\n" +
+                "  ├─Short ← String\n" +
+                "  ├─Long  ← String\n" +
+                "  └─Float ← String\n", c.toString());
 
         c = FallbackConverter.merge(c, StringConverter.Integer.INSTANCE);
         assertEquals(String.class, c.getSourceClass());
@@ -91,11 +94,11 @@ public final strictfp class FallbackConv
         assertEquals(SURJECTIVE,   c.properties());
         tryConversions(c, FLOAT);
         assertMultilinesEquals(
-                "String     ⇨ Number\n" +
-                "  ├─String ⇨ Short\n" +
-                "  ├─String ⇨ Long\n" +
-                "  ├─String ⇨ Float\n" +
-                "  └─String ⇨ Integer\n", c.toString());
+                "Number      ← String\n" +
+                "  ├─Short   ← String\n" +
+                "  ├─Long    ← String\n" +
+                "  ├─Float   ← String\n" +
+                "  └─Integer ← String\n", c.toString());
 
         c = FallbackConverter.merge(c, StringConverter.Boolean.INSTANCE);
         assertEquals(String.class, c.getSourceClass());
@@ -103,13 +106,13 @@ public final strictfp class FallbackConv
         assertEquals(SURJECTIVE,   c.properties());
         tryConversions(c, BOOLEAN);
         assertMultilinesEquals(
-                "String         ⇨ Object\n" +
-                "  ├─String     ⇨ Number\n" +
-                "  │   ├─String ⇨ Short\n" +
-                "  │   ├─String ⇨ Long\n" +
-                "  │   ├─String ⇨ Float\n" +
-                "  │   └─String ⇨ Integer\n" +
-                "  └─String     ⇨ Boolean\n", c.toString());
+                "Object          ← String\n" +
+                "  ├─Number      ← String\n" +
+                "  │   ├─Short   ← String\n" +
+                "  │   ├─Long    ← String\n" +
+                "  │   ├─Float   ← String\n" +
+                "  │   └─Integer ← String\n" +
+                "  └─Boolean     ← String\n", c.toString());
 
         c = FallbackConverter.merge(c, StringConverter.Double.INSTANCE);
         assertEquals(String.class, c.getSourceClass());
@@ -117,20 +120,24 @@ public final strictfp class FallbackConv
         assertEquals(SURJECTIVE,   c.properties());
         tryConversions(c, BOOLEAN);
         assertMultilinesEquals(
-                "String         ⇨ Object\n" +
-                "  ├─String     ⇨ Number\n" +
-                "  │   ├─String ⇨ Short\n" +
-                "  │   ├─String ⇨ Long\n" +
-                "  │   ├─String ⇨ Float\n" +
-                "  │   ├─String ⇨ Integer\n" +
-                "  │   └─String ⇨ Double\n" +
-                "  └─String     ⇨ Boolean\n", c.toString());
+                "Object          ← String\n" +
+                "  ├─Number      ← String\n" +
+                "  │   ├─Short   ← String\n" +
+                "  │   ├─Long    ← String\n" +
+                "  │   ├─Float   ← String\n" +
+                "  │   ├─Integer ← String\n" +
+                "  │   └─Double  ← String\n" +
+                "  └─Boolean     ← String\n", c.toString());
     }
 
     /**
      * Tries conversions. Parsing numbers should returns a Short, Long or Float because
      * they were the first converters declared. Parsing a boolean should succeed only
      * after we registered the boolean converter.
+     *
+     * <p>Calls to {@link SystemConverter#inverse()} and serialization shall be avoided,
+     * because they indirectly use {@link ConverterRegistry} while we want to keep the
+     * tests isolated.</p>
      */
     private static void tryConversions(final ObjectConverter<String,?> c, final int
supported) {
         assertConvertedEquals(c, (supported >= SHORT)   ? Short.valueOf((short) 5) : null,
"5");



Mime
View raw message