sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1401247 - in /sis/branches/JDK6: ./ ide-project/NetBeans/nbproject/ sis-utility/src/main/java/org/apache/sis/io/ sis-utility/src/main/java/org/apache/sis/math/ sis-utility/src/main/java/org/apache/sis/measure/ sis-utility/src/main/java/org...
Date Tue, 23 Oct 2012 11:20:28 GMT
Author: desruisseaux
Date: Tue Oct 23 11:20:27 2012
New Revision: 1401247

URL: http://svn.apache.org/viewvc?rev=1401247&view=rev
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/AppendableWriter.java
      - copied unchanged from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/AppendableWriter.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/IO.java
      - copied unchanged from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/IO.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/
      - copied from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Localized.java
      - copied unchanged from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Localized.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java
      - copied unchanged from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LocalizedParseException.java
      - copied unchanged from r1401244, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/LocalizedParseException.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/
      - copied from r1401244, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/
Removed:
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/AppendableAdapter.java
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/package-info.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/EndOfLineFormatterTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/ExpandedTabFormatterTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/FormatterTestCase.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/IndentedLineFormatterTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1400648-1401244

Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties Tue Oct 23 11:20:27 2012
@@ -19,6 +19,7 @@ javac.source         = 1.6
 javac.target         = 1.6
 platform.active      = default_platform
 run.jvmargs          = -ea
+junit.forkmode       = once
 
 #
 # Source directories.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java Tue Oct 23 11:20:27 2012
@@ -16,9 +16,6 @@
  */
 package org.apache.sis.io;
 
-import java.io.Writer;
-import java.io.Flushable;
-import java.io.Closeable;
 import java.io.IOException;
 import java.io.CharConversionException;
 import org.apache.sis.util.Decorator;
@@ -43,8 +40,15 @@ import org.apache.sis.internal.util.JDK7
  *   <li>No synchronization is performed.</li>
  * </ul>
  *
- * If needed, this {@code FilteredAppendable} can be viewed as a synchronized {@link Writer}
- * by invoking the {@link #asWriter()} method.
+ * If needed, this {@code FilteredAppendable} can be viewed as a synchronized
+ * {@link java.io.Writer} by invoking the {@link IO#asWriter(Appendable)} method.
+ *
+ * {@section Flushing and closing the stream}
+ * Subclasses implement the {@link java.io.Flushable} interface only if they
+ * hold data in an internal buffer before to send them to the wrapped {@code Appendable}.
+ * This is the case of {@link TableFormatter} and {@link LineWrapFormatter} for instance.
+ * For unconditionally flushing or closing an {@code Appendable} and its underlying stream,
+ * see {@link IO#flush(Appendable)} and {@link IO#close(Appendable)}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
@@ -207,47 +211,15 @@ public abstract class FilteredAppendable
     }
 
     /**
-     * If the given {@code out} argument implements {@link Flushable}, or is a
-     * {@code FilteredAppendable} wrapper around a flushable object, delegates
-     * to that object. Otherwise do nothing.
-     */
-    static void flush(Appendable out) throws IOException {
-        while (!(out instanceof Flushable)) {
-            if (!(out instanceof FilteredAppendable)) {
-                return;
-            }
-            out = ((FilteredAppendable) out).out;
-        }
-        ((Flushable) out).flush();
-    }
-
-    /**
-     * If the given {@code out} argument implements {@link Closeable}, or is a
-     * {@code FilteredAppendable} wrapper around a closeable object, delegates
-     * to that object. Otherwise do nothing.
-     */
-    static void close(Appendable out) throws IOException {
-        while (!(out instanceof Closeable)) {
-            if (out instanceof Flushable) {
-                ((Flushable) out).flush();
-            }
-            if (!(out instanceof FilteredAppendable)) {
-                return;
-            }
-            out = ((FilteredAppendable) out).out;
-        }
-        ((Closeable) out).close();
-    }
-
-    /**
-     * Returns a view of this {@code Appendable} as a writer. Any write operations performed
-     * on the writer will be forwarded to this {@code Appendable} in a synchronized block.
+     * Returns the content of this {@code Appendable} as a string if possible,
+     * or the localized "<cite>Unavailable content</cite>" string otherwise.
+     *
+     * @return The content of this {@code Appendable}, or a localized message for unavailable content.
      *
-     * @return A view of this {@code Appendable} as a writer.
+     * @see IO#content(Appendable)
      */
-    public Writer asWriter() {
-        // No need to cache this instance, since creating AppendableAdapter
-        // is cheap and AppendableAdapter does not hold any internal state.
-        return new AppendableAdapter(this);
+    @Override
+    public String toString() {
+        return IO.toString(this);
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java Tue Oct 23 11:20:27 2012
@@ -289,6 +289,6 @@ searchHyp:  for (int i=buffer.length(); 
     public void flush() throws IOException {
         out.append(buffer);
         buffer.setLength(0);
-        flush(out);
+        IO.flush(out);
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java Tue Oct 23 11:20:27 2012
@@ -619,7 +619,7 @@ public class TableFormatter extends Filt
              * Flush only if this table is not included in an outer (bigger) table.
              * This is because flushing the outer table would break its formatting.
              */
-            flush(out);
+            IO.flush(out);
         }
     }
 

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/package-info.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/package-info.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/package-info.java Tue Oct 23 11:20:27 2012
@@ -16,10 +16,11 @@
  */
 
 /**
- * Extensions to standard Java {@link java.io.Reader} and {@link java.io.Writer} for I/O operations.
- * Many classes defined in this package are actually filters applying on-the-fly formatting while
- * writing text to the output device. For example {@link org.apache.sis.io.IndentedLineFormatter}
- * adds indentation at the beginning of every new line, and {@link org.apache.sis.io.TableFormatter}
+ * Extensions to standard Java I/O ({@link java.io.Reader}, {@link java.io.Writer},
+ * {@link java.lang.Appendable}).
+ * Many classes defined in this package are filters applying on-the-fly formatting while writing
+ * text to the output device. For example {@link org.apache.sis.io.IndentedLineFormatter} adds
+ * indentation at the beginning of every new line, and {@link org.apache.sis.io.TableFormatter}
  * replaces all occurrence of {@code '\t'} by the amount of spaces needed for producing a tabular
  * output.
  *

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java Tue Oct 23 11:20:27 2012
@@ -154,6 +154,19 @@ public final class MathFunctions extends
     }
 
     /**
+     * Truncates the given value toward zero. Invoking this method is equivalent to invoking
+     * {@link Math#floor(double)} if the value is positive, or {@link Math#ceil(double)} if
+     * the value is negative.
+     *
+     * @param  value The value to truncate.
+     * @return The largest in magnitude (further from zero) integer value which is equals
+     *         or less in magnitude than the given value.
+     */
+    public static double truncate(final double value) {
+        return (value < 0) ? Math.ceil(value) : Math.floor(value);
+    }
+
+    /**
      * Returns the magnitude of the given vector. This is defined by:
      *
      * {@preformat math

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1401247&r1=1401244&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java Tue Oct 23 11:20:27 2012
@@ -41,7 +41,7 @@ import static org.apache.sis.math.MathFu
 import static org.apache.sis.math.MathFunctions.isNegative;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**
@@ -291,7 +291,7 @@ public class AngleFormat extends Format 
      * Constructs a new {@code AngleFormat} for the default pattern and the current default locale.
      */
     public AngleFormat() {
-        this(Locale.getDefault(Locale.Category.FORMAT), new DecimalFormat("#0"));
+        this(Locale.getDefault(), new DecimalFormat("#0"));
     }
 
     /**
@@ -311,7 +311,7 @@ public class AngleFormat extends Format 
      * @throws IllegalArgumentException If the specified pattern is illegal.
      */
     public AngleFormat(final String pattern) throws IllegalArgumentException {
-        this(pattern, Locale.getDefault(Locale.Category.FORMAT), new DecimalFormat("#0"));
+        this(pattern, Locale.getDefault(), new DecimalFormat("#0"));
     }
 
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java Tue Oct 23 11:20:27 2012
@@ -128,7 +128,6 @@ public final class ArgumentChecks extend
      * If this method does not thrown an exception, then the value can be casted to the class
      * represented by {@code expectedType} without throwing a {@link ClassCastException}.
      *
-     * @param  <T> The compile-time type of the value.
      * @param  name The name of the argument to be checked, used only if an exception is thrown.
      *         Can be {@code null} if the name is unknown.
      * @param  expectedType the expected type (class or interface).
@@ -136,7 +135,7 @@ public final class ArgumentChecks extend
      * @throws IllegalArgumentException if {@code value} is non-null and is not assignable
      *         to the given type.
      */
-    public static <T> void ensureCanCast(final String name, final Class<? extends T> expectedType, final T value)
+    public static void ensureCanCast(final String name, final Class<?> expectedType, final Object value)
             throws IllegalArgumentException
     {
         if (value != null) {

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java Tue Oct 23 11:20:27 2012
@@ -16,9 +16,12 @@
  */
 package org.apache.sis.util;
 
-import java.sql.SQLException;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.Locale;
+import java.sql.SQLException;
+import java.text.ParsePosition;
+import java.text.ParseException;
 
 // Related to JDK7
 import org.apache.sis.internal.util.JDK7;
@@ -40,6 +43,56 @@ public final class Exceptions extends St
     }
 
     /**
+     * Creates a {@link ParseException} with a localized message built from the given parsing
+     * information. The exception returned by this method contains the error message in two
+     * languages:
+     *
+     * <ul>
+     *   <li>{@link ParseException#getMessage()} returns the message in the default locale.</li>
+     *   <li>{@link ParseException#getLocalizedMessage() getLocalizedMessage()} returns the
+     *       message in the locale given in argument to this method. This is usually the
+     *       {@link java.text.Format} locale, which is presumed to be the end-user locale.</li>
+     * </ul>
+     *
+     * @param  locale The locale for {@link ParseException#getLocalizedMessage()}.
+     * @param  type   The type of objects parsed by the {@link java.text.Format}.
+     * @param  text   The text that {@code Format} failed to parse.
+     * @param  pos    Index of the {@linkplain ParsePosition#getIndex() first parsed character},
+     *                together with the {@linkplain ParsePosition#getErrorIndex() error index}.
+     * @return The localized exception.
+     */
+    public static ParseException createParseException(final Locale locale, final Class<?> type,
+            final String text, final ParsePosition pos)
+    {
+        final int offset = pos.getIndex();
+        final int errorOffset = Math.max(offset, pos.getErrorIndex());
+        return new LocalizedParseException(locale,
+                LocalizedParseException.arguments(type, text, offset, errorOffset), errorOffset);
+    }
+
+    /**
+     * Returns the message of the given exception, localized in the given locale if possible.
+     * Some exceptions created by SIS can format a message in different locales. This method
+     * will return such localized message if possible, or fallback on the standard
+     * {@link Throwable#getLocalizedMessage()} method otherwise. Note that by default,
+     * {@code getLocalizedMessage()} itself fallback on {@link Throwable#getMessage()}.
+     *
+     * @param  exception The exception from which to get the localize message, or {@code null}.
+     * @param  locale    The locale for the message, or {@code null} for the default locale.
+     * @return The message in the given locale if possible, or {@code null} if the {@code exception}
+     *         argument was {@code null} or the exception does not contain a message.
+     */
+    public static String getMessage(final Throwable exception, final Locale locale) {
+        if (exception == null) {
+            return null;
+        }
+        if (locale != null && exception instanceof LocalizedException) {
+            return ((LocalizedException) exception).getMessage(locale);
+        }
+        return exception.getLocalizedMessage();
+    }
+
+    /**
      * Returns an exception of the same kind and with the same stack trace than the given
      * exception, but with a different message. This method simulates the functionality
      * that we would have if {@link Throwable} defined a {@code setMessage(String)} method.
@@ -94,17 +147,18 @@ public final class Exceptions extends St
      *
      * <p>This method does not format the stack trace.</p>
      *
+     * @param  locale The preferred locale for the exception message, or {@code null}.
      * @param  header The message to insert on the first line, or {@code null} if none.
      * @param  cause  The exception, or {@code null} if none.
      * @return The formatted message, or {@code null} if both the header was {@code null}
      *         and no exception provide a message.
      */
-    public static String formatChainedMessages(String header, Throwable cause) {
+    public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
         Set<String> done = null;
         String lineSeparator = null;
         StringBuilder buffer = null;
         while (cause != null) {
-            String message = cause.getLocalizedMessage();
+            String message = getMessage(cause, locale);
             if (message != null && !(message = message.trim()).isEmpty()) {
                 if (buffer == null) {
                     done = new HashSet<String>();

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java Tue Oct 23 11:20:27 2012
@@ -543,14 +543,18 @@ public final class Logging extends Stati
          * Now prepare the log message. If we have been unable to figure out a source class and
          * method name, we will fallback on JDK logging default mechanism, which may returns a
          * less relevant name than our attempt to use the logger name as the package name.
+         *
+         * The message is fetched using Exception.getMessage() instead than getLocalizedMessage()
+         * because in a client-server architecture, we want the locale on the server-side instead
+         * than the locale on the client side.
          */
         final StringBuilder buffer = new StringBuilder(Classes.getShortClassName(error));
-        String message = error.getLocalizedMessage();
+        String message = error.getMessage(); // Targeted to system administrators.
         if (message != null) {
             buffer.append(": ").append(message);
         }
         message = buffer.toString();
-        message = Exceptions.formatChainedMessages(message, error);
+        message = Exceptions.formatChainedMessages(null, message, error);
         final LogRecord record = new LogRecord(level, message);
         if (classe != null) {
             record.setSourceClassName(classe);

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java Tue Oct 23 11:20:27 2012
@@ -87,6 +87,11 @@ public final class Errors extends Indexe
         public static final int IllegalClass_2 = 3;
 
         /**
+         * The “{0}” pattern can not be applied to formating of objects of type ‘{1}’.
+         */
+        public static final int IllegalFormatPatternForClass_2 = 29;
+
+        /**
          * The “{0}” language is not recognized.
          */
         public static final int IllegalLanguageCode_1 = 12;
@@ -147,6 +152,11 @@ public final class Errors extends Indexe
         public static final int UnexpectedArgumentDimension_3 = 5;
 
         /**
+         * More characters were expected at the end of “{0}”.
+         */
+        public static final int UnexpectedEndOfString_1 = 30;
+
+        /**
          * This affine transform is unmodifiable.
          */
         public static final int UnmodifiableAffineTransform = 23;
@@ -167,6 +177,16 @@ public final class Errors extends Indexe
         public static final int UnmodifiableObject_1 = 26;
 
         /**
+         * Text “{1}” can not be parsed as an object of type ‘{0}’.
+         */
+        public static final int UnparsableStringForClass_2 = 31;
+
+        /**
+         * Text “{1}” can not be parsed as an object of type ‘{0}’, because of the “{2}” characters.
+         */
+        public static final int UnparsableStringForClass_3 = 32;
+
+        /**
          * Can not handle instances of ‘{0}’ because arbitrary implementations are not yet supported.
          */
         public static final int UnsupportedImplementation_1 = 28;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties Tue Oct 23 11:20:27 2012
@@ -22,6 +22,7 @@ IllegalArgumentClass_3          = Argume
 IllegalArgumentValue_2          = Argument \u2018{0}\u2019 can not take the \u201c{1}\u201d value.
 IllegalBitsPattern_1            = Illegal bits pattern: {0}.
 IllegalClass_2                  = Class \u2018{0}\u2019 is illegal. It must be \u2018{1}\u2019 or a derived class.
+IllegalFormatPatternForClass_2  = The \u201c{0}\u201d pattern can not be applied to formating of objects of type \u2018{1}\u2019.
 IllegalLanguageCode_1           = The \u201c{0}\u201d language is not recognized.
 IllegalRange_2                  = Range [{0} \u2026 {1}] is not valid.
 InconsistentAttribute_2         = Value \u201c{1}\u201d of attribute \u2018{0}\u2019 is inconsistent with other attributes.
@@ -34,10 +35,13 @@ NotAPrimitiveWrapper_1          = Class 
 NullArgument_1                  = Argument \u2018{0}\u2019 shall not be null.
 RecursiveCreateCallForKey_1     = Recursive call while creating an object for the \u201c{0}\u201d key.
 UnexpectedArgumentDimension_3   = Argument \u2018{0}\u2019 has {1} dimensions, while {2} was expected.
+UnexpectedEndOfString_1         = More characters were expected at the end of \u201c{0}\u201d.
 UnmodifiableAffineTransform     = This affine transform is unmodifiable.
 UnmodifiableGeometry            = This geometry is unmodifiable.
 UnmodifiableMetadata            = This metadata is unmodifiable.
 UnmodifiableObject_1            = Object \u2018{0}\u2019 is unmodifiable.
+UnparsableStringForClass_2      = Text \u201c{1}\u201d can not be parsed as an object of type \u2018{0}\u2019.
+UnparsableStringForClass_3      = Text \u201c{1}\u201d can not be parsed as an object of type \u2018{0}\u2019, because of the \u201c{2}\u201d characters.
 UnsupportedImplementation_1     = Can not handle instances of \u2018{0}\u2019 because arbitrary implementations are not yet supported.
 UnsupportedOperation_1          = The \u2018{0}\u2019 operation is unsupported.
 ValueAlreadyDefined_1           = A value is already defined for \u201c{0}\u201d.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties Tue Oct 23 11:20:27 2012
@@ -22,6 +22,7 @@ IllegalArgumentClass_3          = L\u201
 IllegalArgumentValue_2          = L\u2019argument \u2018{0}\u2019 n\u2019accepte pas la valeur \u201c{1}\u201d.
 IllegalBitsPattern_1            = Pattern de bits invalide: {0}.
 IllegalClass_2                  = La classe \u2018{0}\u2019 est ill\u00e9gale. Il doit s\u2019agir d\u2019une classe \u2018{1}\u2019 ou d\u00e9riv\u00e9e.
+IllegalFormatPatternForClass_2  = Le mod\u00e8le \u201c{0}\u201d ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{1}\u2019.
 IllegalLanguageCode_1           = Le code de langue \u201c{0}\u201d n\u2019est pas reconnu.
 IllegalRange_2                  = La plage [{0} \u2026 {1}] n\u2019est pas valide.
 InconsistentAttribute_2         = La valeur \u201c{1}\u201d de l\u2019attribut \u2018{0}\u2019 n\u2019est pas coh\u00e9rente avec celles des autres attributs.
@@ -34,10 +35,13 @@ NotAPrimitiveWrapper_1          = La cla
 NullArgument_1                  = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre nul.
 RecursiveCreateCallForKey_1     = Appel r\u00e9cursif lors de la cr\u00e9ation d\u2019un objet pour la cl\u00e9 \u201c{0}\u201d.
 UnexpectedArgumentDimension_3   = L\u2019argument \u2018{0}\u2019 a {1} dimensions, alors qu\u2019on en attendait {2}.
+UnexpectedEndOfString_1         = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0 la fin du texte \u201c{0}\u201d.
 UnmodifiableAffineTransform     = Cette transformation affine n\u2019est pas modifiable.
 UnmodifiableGeometry            = Cette g\u00e9om\u00e9trie n\u2019est pas modifiable.
 UnmodifiableMetadata            = Cette m\u00e9ta-donn\u00e9e n\u2019est pas modifiable.
 UnmodifiableObject_1            = L\u2019objet \u2018{0}\u2019 n\u2019est pas modifiable.
+UnparsableStringForClass_2      = Le texte \u201c{1}\u201d n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019.
+UnparsableStringForClass_3      = Le texte \u201c{1}\u201d n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019, \u00e0 cause des caract\u00e8res \u201c{2}\u201d.
 UnsupportedImplementation_1     = Les instances de \u2018{0}\u2019 ne peuvent pas \u00eatre g\u00e9r\u00e9es parce que les impl\u00e9mentations arbitraires ne sont pas encore support\u00e9es.
 UnsupportedOperation_1          = L\u2019op\u00e9ration \u2018{0}\u2019 n\u2019est pas support\u00e9e.
 ValueAlreadyDefined_1           = Une valeur est d\u00e9j\u00e0 d\u00e9finie pour \u201c{0}\u201d.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java Tue Oct 23 11:20:27 2012
@@ -38,6 +38,7 @@ import org.opengis.util.InternationalStr
 
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.Classes;
+import org.apache.sis.util.Exceptions;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.logging.Logging;
 
@@ -395,11 +396,12 @@ public class IndexedResourceBundle exten
             return values;
         } catch (IOException exception) {
             record.setLevel  (Level.WARNING);
-            record.setMessage(exception.getLocalizedMessage());
+            record.setMessage(exception.getMessage()); // For administrator, use system locale.
             record.setThrown (exception);
             Logging.log(IndexedResourceBundle.class, methodName, record);
             final MissingResourceException error = new MissingResourceException(
-                    exception.getLocalizedMessage(), getClass().getCanonicalName(), key);
+                    Exceptions.getMessage(exception, getLocale()), // For users, use requested locale.
+                    getClass().getCanonicalName(), key);
             error.initCause(exception);
             throw error;
         }
@@ -468,7 +470,7 @@ public class IndexedResourceBundle exten
                 }
                 replacement = CharSequences.shortSentence(text, MAX_STRING_LENGTH);
             } else if (element instanceof Throwable) {
-                String message = ((Throwable) element).getLocalizedMessage();
+                String message = Exceptions.getMessage((Throwable) element, getFormatLocale());
                 if (message == null) {
                     message = Classes.getShortClassName(element);
                 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Loader.java Tue Oct 23 11:20:27 2012
@@ -23,6 +23,7 @@ import java.util.ResourceBundle;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.io.IOException;
+import org.apache.sis.util.Exceptions;
 
 
 /**
@@ -119,29 +120,16 @@ final class Loader extends ResourceBundl
         /*
          * If the file exists, instantiate now the resource bundle. Note that the constructor
          * will not loads the data immediately, which is why we don't pass it the above URL.
+         *
+         * Note: Do not call Constructor.setAccessible(true) - this is not allowed in Applet.
          */
         final Constructor<?> c;
         try {
-            c = classe.getDeclaredConstructor(String.class);
-        } catch (NoSuchMethodException e) {
-            throw instantiationFailure(e);
+            return (ResourceBundle) classe.getDeclaredConstructor(String.class).newInstance(filename);
+        } catch (Exception e) { // The JDK7 branch uses multi-catches here.
+            InstantiationException exception = new InstantiationException(Exceptions.getMessage(e, locale));
+            exception.initCause(e);
+            throw exception;
         }
-        final ResourceBundle bundle;
-        // Do not call c.setAccessible(true) - this is not allowed in Applet.
-        try {
-            bundle = (ResourceBundle) c.newInstance(filename);
-        } catch (InvocationTargetException e) {
-            throw instantiationFailure(e);
-        }
-        return bundle;
-    }
-
-    /**
-     * Creates an exception for a resource bundle that can not be created.
-     */
-    private static InstantiationException instantiationFailure(final Exception cause) {
-        InstantiationException exception = new InstantiationException(cause.getLocalizedMessage());
-        exception.initCause(cause);
-        return exception;
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java Tue Oct 23 11:20:27 2012
@@ -49,6 +49,11 @@ public final class Messages extends Inde
          * Changed the container capacity from {0} to {1} elements.
          */
         public static final int ChangedContainerCapacity_2 = 0;
+
+        /**
+         * Unavailable content.
+         */
+        public static final int UnavailableContent = 1;
     }
 
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties Tue Oct 23 11:20:27 2012
@@ -14,4 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-ChangedContainerCapacity_2=Changed the container capacity from {0} to {1} elements.
+ChangedContainerCapacity_2      = Changed the container capacity from {0} to {1} elements.
+UnavailableContent              = Unavailable content.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties Tue Oct 23 11:20:27 2012
@@ -14,4 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-ChangedContainerCapacity_2=Changement de la capacit\u00e9 du conteneur de {0} vers {1} \u00e9l\u00e9ments.
+ChangedContainerCapacity_2      = Changement de la capacit\u00e9 du conteneur de {0} vers {1} \u00e9l\u00e9ments.
+UnavailableContent              = Contenu non-disponible.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/EndOfLineFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/EndOfLineFormatterTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/EndOfLineFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/EndOfLineFormatterTest.java Tue Oct 23 11:20:27 2012
@@ -17,6 +17,8 @@
 package org.apache.sis.io;
 
 import java.io.IOException;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.CharSequencesTest;
 
 import static org.junit.Assert.*;
 
@@ -29,6 +31,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
+@DependsOn(CharSequencesTest.class)
 public final strictfp class EndOfLineFormatterTest extends FormatterTestCase {
     /**
      * Creates a new test case.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/ExpandedTabFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/ExpandedTabFormatterTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/ExpandedTabFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/ExpandedTabFormatterTest.java Tue Oct 23 11:20:27 2012
@@ -17,6 +17,8 @@
 package org.apache.sis.io;
 
 import java.io.IOException;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.CharSequencesTest;
 
 import static org.junit.Assert.*;
 
@@ -29,6 +31,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
+@DependsOn(CharSequencesTest.class)
 public final strictfp class ExpandedTabFormatterTest extends FormatterTestCase {
     /**
      * Creates a new test case.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/FormatterTestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/FormatterTestCase.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/FormatterTestCase.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/FormatterTestCase.java Tue Oct 23 11:20:27 2012
@@ -18,9 +18,7 @@ package org.apache.sis.io;
 
 import java.io.IOException;
 import org.apache.sis.test.TestCase;
-import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.util.CharSequencesTest;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -34,7 +32,6 @@ import static org.apache.sis.test.Assert
  * @version 0.3
  * @module
  */
-@DependsOn({CharSequencesTest.class, X364Test.class})
 public abstract class FormatterTestCase extends TestCase {
     /**
      * The buffer where to write test data.
@@ -180,7 +177,7 @@ public abstract class FormatterTestCase 
      * @throws IOException Should never happen.
      */
     final void assertOutputEquals(final String expected) throws IOException {
-        FilteredAppendable.flush(formatter);
+        IO.flush(formatter);
         final String actual = buffer.toString();
         assertMultilinesEquals("Ignoring line separators.", expected, actual);
         assertEquals          ("Checking line separators.", expected, actual);

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/IndentedLineFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/IndentedLineFormatterTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/IndentedLineFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/IndentedLineFormatterTest.java Tue Oct 23 11:20:27 2012
@@ -17,6 +17,8 @@
 package org.apache.sis.io;
 
 import java.io.IOException;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.CharSequencesTest;
 
 import static org.junit.Assert.*;
 
@@ -29,6 +31,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
+@DependsOn(CharSequencesTest.class)
 public final strictfp class IndentedLineFormatterTest extends FormatterTestCase {
     /**
      * Creates a new test case.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java Tue Oct 23 11:20:27 2012
@@ -17,6 +17,8 @@
 package org.apache.sis.io;
 
 import java.io.IOException;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.CharSequencesTest;
 
 import static org.junit.Assert.*;
 import static org.apache.sis.util.Characters.SOFT_HYPHEN;
@@ -33,6 +35,7 @@ import org.apache.sis.internal.util.JDK7
  * @version 0.3
  * @module
  */
+@DependsOn({CharSequencesTest.class, X364Test.class})
 public final strictfp class LineWrapFormatterTest extends FormatterTestCase {
     /**
      * Creates a new test case.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java Tue Oct 23 11:20:27 2012
@@ -17,6 +17,8 @@
 package org.apache.sis.io;
 
 import java.io.IOException;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.util.CharSequencesTest;
 
 import static org.junit.Assert.*;
 
@@ -32,6 +34,7 @@ import org.apache.sis.internal.util.JDK7
  * @version 0.3
  * @module
  */
+@DependsOn({CharSequencesTest.class, X364Test.class, ExpandedTabFormatterTest.class})
 public final strictfp class TableFormatterTest extends FormatterTestCase {
     /**
      * The table formatter to test. May not be same instance than {@link #formatter},

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java Tue Oct 23 11:20:27 2012
@@ -18,6 +18,7 @@ package org.apache.sis.math;
 
 import org.junit.Test;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 
 import static org.junit.Assert.*;
@@ -33,6 +34,7 @@ import static org.apache.sis.util.Arrays
  * @version 0.3
  * @module
  */
+@DependsOn(org.apache.sis.util.ArraysTest.class)
 public final strictfp class MathFunctionsTest extends TestCase {
     /**
      * Small number for floating point comparisons.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java Tue Oct 23 11:20:27 2012
@@ -22,6 +22,7 @@ import java.util.TimeZone;
 import java.util.Iterator;
 import java.util.concurrent.Callable;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.text.Format;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -97,6 +98,26 @@ public final strictfp class TestUtilitie
     }
 
     /**
+     * Formats the given value using the given formatter, and parses the text back to its value.
+     * If the parsed value is not equal to the original one, an {@link AssertionError} is thrown.
+     *
+     * @param  formatter The formatter to use for formatting and parsing.
+     * @param  value The value to format.
+     * @return The formatted value.
+     */
+    public static String formatAndParse(final Format formatter, final Object value) {
+        final String text = formatter.format(value);
+        final Object parsed;
+        try {
+            parsed = formatter.parseObject(text);
+        } catch (ParseException e) {
+            throw new AssertionError(e);
+        }
+        assertEquals("Parsed text not equal to the original value", value, parsed);
+        return text;
+    }
+
+    /**
      * Returns the single element from the given collection. If the given collection is null
      * or does not contains exactly one element, then an {@link AssertionError} is thrown.
      *

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Tue Oct 23 11:20:27 2012
@@ -33,29 +33,38 @@ import org.junit.runners.Suite;
   org.apache.sis.internal.test.AssertTest.class,
   org.apache.sis.internal.test.XMLComparatorTest.class,
 
-  // Following are testing the actual SIS library.
-  org.apache.sis.util.UtilitiesTest.class,
+  // Most basic functions of SIS library.
   org.apache.sis.util.ArraysTest.class,
   org.apache.sis.util.CharactersTest.class,
   org.apache.sis.util.CharSequencesTest.class,
   org.apache.sis.util.StringBuildersTest.class,
+  org.apache.sis.util.UtilitiesTest.class,
   org.apache.sis.util.LocalesTest.class,
   org.apache.sis.util.resources.IndexedResourceBundleTest.class,
   org.apache.sis.util.logging.PerformanceLevelTest.class,
-  org.apache.sis.util.type.TypesTest.class,
-  org.apache.sis.util.type.SimpleInternationalStringTest.class,
-  org.apache.sis.util.type.DefaultInternationalStringTest.class,
   org.apache.sis.math.MathFunctionsTest.class,
+
+  // Collections.
   org.apache.sis.internal.util.ReferenceQueueConsumerTest.class,
   org.apache.sis.util.collection.WeakHashSetTest.class,
   org.apache.sis.util.collection.WeakValueHashMapTest.class,
   org.apache.sis.util.collection.CacheTest.class,
+
+  // GeoAPI most basic types.
+  org.apache.sis.util.type.TypesTest.class,
+  org.apache.sis.util.type.SimpleInternationalStringTest.class,
+  org.apache.sis.util.type.DefaultInternationalStringTest.class,
+
+  // Formatting
+  org.apache.sis.measure.AngleFormatTest.class,
   org.apache.sis.io.X364Test.class,
   org.apache.sis.io.EndOfLineFormatterTest.class,
   org.apache.sis.io.IndentedLineFormatterTest.class,
   org.apache.sis.io.ExpandedTabFormatterTest.class,
   org.apache.sis.io.LineWrapFormatterTest.class,
   org.apache.sis.io.TableFormatterTest.class,
+
+  // XML most basic types.
   org.apache.sis.xml.XLinkTest.class,
   org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class,
   org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Tue Oct 23 11:20:27 2012
@@ -19,6 +19,7 @@ package org.apache.sis.util;
 import java.util.Arrays;
 import java.nio.CharBuffer;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.util.type.SimpleInternationalString;
 import org.junit.Test;
@@ -36,6 +37,7 @@ import static org.apache.sis.util.CharSe
  * @version 0.3
  * @module
  */
+@DependsOn(ArraysTest.class)
 public final strictfp class CharSequencesTest extends TestCase {
     /**
      * Tests {@link CharSequences#spaces(int)}.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java Tue Oct 23 11:20:27 2012
@@ -18,6 +18,7 @@ package org.apache.sis.util;
 
 import java.util.Locale;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -31,6 +32,7 @@ import static org.junit.Assert.*;
  * @version 0.3
  * @module
  */
+@DependsOn(Arrays.class)
 public final strictfp class LocalesTest extends TestCase {
     /**
      * Tests the {@link Locales#getAvailableLanguages()} method.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java Tue Oct 23 11:20:27 2012
@@ -20,6 +20,7 @@ import java.util.HashSet;
 import java.util.Random;
 import java.util.concurrent.Callable;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestConfiguration;
 import org.junit.Test;
@@ -37,6 +38,7 @@ import static org.apache.sis.test.TestUt
  * @version 0.3
  * @module
  */
+@DependsOn(org.apache.sis.util.ArraysTest.class)
 public final strictfp class WeakHashSetTest extends TestCase {
     /**
      * The size of the test sets to be created.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java Tue Oct 23 11:20:27 2012
@@ -21,8 +21,9 @@ import java.util.HashMap;
 import java.util.Random;
 import java.util.concurrent.Callable;
 import org.apache.sis.test.TestCase;
-import org.apache.sis.test.TestConfiguration;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.TestConfiguration;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
@@ -38,6 +39,7 @@ import static org.apache.sis.test.TestUt
  * @version 0.3
  * @module
  */
+@DependsOn(org.apache.sis.util.ArraysTest.class)
 public final strictfp class WeakValueHashMapTest extends TestCase {
     /**
      * The size of the test sets to be created.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java?rev=1401247&r1=1401246&r2=1401247&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java Tue Oct 23 11:20:27 2012
@@ -24,6 +24,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.SimpleFormatter;
 import org.opengis.util.InternationalString;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -37,6 +38,7 @@ import static org.junit.Assert.*;
  * @since   0.3 (derived from geotk-2.2)
  * @version 0.3
  */
+@DependsOn(org.apache.sis.util.ArraysTest.class)
 public final strictfp class IndexedResourceBundleTest extends TestCase {
     /**
      * Tests the {@link Errors#getResources(Locale)} method on different locales.



Mime
View raw message