sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1731686 [5/5] - in /sis/branches/JDK6: ./ core/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ ...
Date Mon, 22 Feb 2016 16:56:42 GMT
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1731686&r1=1731685&r2=1731686&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] Mon Feb 22 16:56:41 2016
@@ -30,6 +30,7 @@ import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.lang.reflect.Modifier;
+import javax.measure.unit.Unit;
 import org.opengis.util.CodeList;
 import org.opengis.util.ControlledVocabulary;
 import org.opengis.util.InternationalString;
@@ -41,6 +42,7 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.util.PatchedUnitFormat;
 
 // Related to JDK7
 import org.apache.sis.internal.jdk7.JDK7;
@@ -73,7 +75,7 @@ import org.apache.sis.internal.jdk7.JDK7
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public class IndexedResourceBundle extends ResourceBundle implements Localized {
@@ -415,12 +417,14 @@ public class IndexedResourceBundle exten
                 replacement = Classes.getShortName(getPublicType((Class<?>) element));
             } else if (element instanceof ControlledVocabulary) {
                 replacement = Types.getCodeTitle((ControlledVocabulary) element).toString(getLocale());
+            } else if (element instanceof Unit<?>) {
+                replacement = PatchedUnitFormat.toString((Unit<?>) element);
             }
             // No need to check for Numbers or Dates instances, since they are
             // properly formatted in the ResourceBundle locale by MessageFormat.
             if (replacement != element) {
                 if (array == arguments) {
-                    array = array.clone(); // Protect the user-provided array from change.
+                    array = array.clone();                  // Protect the user-provided
array from change.
                 }
                 array[i] = replacement;
             }

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java?rev=1731686&r1=1731685&r2=1731686&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
[UTF-8] Mon Feb 22 16:56:41 2016
@@ -84,7 +84,7 @@ public final strictfp class MeasurementR
         MeasurementRange<Float> range = MeasurementRange.create(10f, true, 20f, true,
SI.KILOMETRE);
         assertEquals("[10.0 … 20.0] km", range.toString());
         range = MeasurementRange.create(10f, true, 20f, true, NonSI.DEGREE_ANGLE);
-        assertEquals("[10.0 … 20.0] deg", range.toString());
+        assertEquals("[10.0 … 20.0]°", range.toString());
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java?rev=1731686&r1=1731685&r2=1731686&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
[UTF-8] Mon Feb 22 16:56:41 2016
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.test;
 
+import java.util.Queue;
+import java.util.LinkedList;
+import java.util.ConcurrentModificationException;
 import java.util.logging.Filter;
 import java.util.logging.Logger;
 import java.util.logging.LogRecord;
@@ -27,44 +30,41 @@ import static org.junit.Assert.*;
 
 
 /**
- * Watches the logs sent to the given logger. Logs will be allowed only if the test was
- * expected to cause some logging events to occur, otherwise a test failure will occurs.
- *
- * <div class="note">Usage example</div>
- * Create a rule in the JUnit test class like below:
+ * Watches the logs sent to the given logger.
+ * For using, create a rule in the JUnit test class like below:
  *
  * {@preformat java
  *     &#64;Rule
- *     public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.XML))
{
- *         &#64;Override protected void verifyMessage(final String message) {
- *             assertTrue(message.contains("An expected word in the logging message"));
- *         }
- *     };
+ *     public final LoggingWatcher loggings = new LoggingWatcher(Logging.getLogger(Loggers.XML));
  * }
  *
- * Then, <em>only</em> in the test which are expected to emit a warning, add
the following line
- * (replace 1 by a higher value if more than one logging is expected):
+ * Recommended but not mandatory, ensure that there is no unexpected logging in any tests:
  *
  * {@preformat java
- *     listener.maximumLogCount = 1;
+ *     &#64;After
+ *     public void assertNoUnexpectedLog() {
+ *         loggings.assertNoUnexpectedLog();
+ *     }
+ * }
+ *
+ * In tests that are expected to emit warnings, add the following lines:
+ *
+ * {@preformat java
+ *     // Do the test here.
+ *     loggings.assertNextLogContains("Some keywords", "that are expected", "to be found
in the message");
+ *     loggings.assertNoUnexpectedLog();
  * }
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
-public strictfp class LoggingWatcher extends TestWatcher implements Filter {
+public final strictfp class LoggingWatcher extends TestWatcher implements Filter {
     /**
-     * The maximal number of logs expected by the test. If this value is positive, then it
is
-     * decremented when {@link #isLoggable(LogRecord)} is invoked until the value reach zero.
-     * If the value is zero and {@code isLoggable(LogRecord)} is invoked, then a test failure
-     * occurs.
-     *
-     * <p>The initial value of this field is 0. Test cases shall set this field to
a non-zero
-     * value in order to allow log events.</p>
+     * The logged messages.
      */
-    public int maximumLogCount;
+    private final Queue<String> messages = new LinkedList<String>();
 
     /**
      * The logger to watch.
@@ -87,6 +87,15 @@ public strictfp class LoggingWatcher ext
     }
 
     /**
+     * Creates a new watcher for the given logger.
+     *
+     * @param logger The name of logger to watch.
+     */
+    public LoggingWatcher(final String logger) {
+        this.logger = Logger.getLogger(logger);
+    }
+
+    /**
      * Invoked when a test is about to start. This method installs this {@link Filter}
      * for the log messages before the tests are run. This installation will cause the
      * {@link #isLoggable(LogRecord)} method to be invoked when a message is logged.
@@ -99,7 +108,6 @@ public strictfp class LoggingWatcher ext
     protected final void starting(final Description description) {
         assertNull(logger.getFilter());
         logger.setFilter(this);
-        maximumLogCount = 0;
     }
 
     /**
@@ -114,26 +122,69 @@ public strictfp class LoggingWatcher ext
     }
 
     /**
-     * Invoked (indirectly) when a tested method has emitted a log message. This method verifies
-     * if we were expecting a log message, then decrements the {@link #maximumLogCount} value.
+     * Invoked (indirectly) when a tested method has emitted a log message.
+     * This method adds the logging message to the {@link #messages} list.
      */
     @Override
     public final boolean isLoggable(final LogRecord record) {
-        if (maximumLogCount <= 0) {
-            fail("Unexpected logging:\n" + formatter.format(record));
-        }
-        maximumLogCount--;
-        verifyMessage(formatter.formatMessage(record));
+        messages.add(formatter.formatMessage(record));
         return TestCase.VERBOSE;
     }
 
     /**
-     * Invoked by {@link #isLoggable(LogRecord)} when a tested method has emitted a log message.
-     * The default implementation does nothing. Subclasses can override this method in order
to
-     * perform additional check.
+     * Skips the next log messages if it contains all the given keywords.
+     * This method is used instead of {@link #assertNextLogContains(String...)} when a log
message may or
+     * may not be emitted during a test, depending on circumstances that the test method
does not control.
+     *
+     * @param keywords The keywords that are expected to exist in the next log message
+     *        if that log message has been emitted.
+     */
+    public void skipNextLogIfContains(final String... keywords) {
+        final String message = messages.peek();
+        if (message != null) {
+            for (final String word : keywords) {
+                if (!message.contains(word)) {
+                    return;
+                }
+            }
+            if (messages.remove() != message) {
+                throw new ConcurrentModificationException();
+            }
+        }
+    }
+
+    /**
+     * Verifies that the next logging message contains the given keywords.
+     * Each call of this method advances to the next log message.
      *
-     * @param message The logging message.
+     * @param keywords The keywords that are expected to exist in the next log message.
+     */
+    public void assertNextLogContains(final String... keywords) {
+        if (messages.isEmpty()) {
+            fail("Expected a logging messages but got no more.");
+        }
+        final String message = messages.remove();
+        for (final String word : keywords) {
+            if (!message.contains(word)) {
+                fail("Expected the logging message to contains the “"+ word + "” word
but got:\n" + message);
+            }
+        }
+    }
+
+    /**
+     * Verifies that there is no more log message.
+     */
+    public void assertNoUnexpectedLog() {
+        final String message = messages.peek();
+        if (message != null) {
+            fail("Unexpected logging message: " + message);
+        }
+    }
+
+    /**
+     * Discards all logging messages.
      */
-    protected void verifyMessage(final String message) {
+    public void clear() {
+        messages.clear();
     }
 }

Modified: sis/branches/JDK6/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/build.xml?rev=1731686&r1=1731685&r2=1731686&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK6/ide-project/NetBeans/build.xml Mon Feb 22 16:56:41 2016
@@ -45,11 +45,14 @@
     </copy>
     -->
 
-    <!-- Following are classical properties resources files. -->
+    <!-- Resources (properties files, SQL scripts). -->
     <copy todir="${build.classes.dir}">
       <fileset dir="${project.root}/core/sis-utility/src/main/resources">
         <include name="**/*.properties"/>
       </fileset>
+      <fileset dir="${project.root}/core/sis-referencing/src/main/resources">
+        <include name="**/*.sql"/>
+      </fileset>
       <fileset dir="${project.root}/application/sis-console/src/main/resources">
         <include name="**/*.properties"/>
       </fileset>

Modified: sis/branches/JDK6/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/pom.xml?rev=1731686&r1=1731685&r2=1731686&view=diff
==============================================================================
--- sis/branches/JDK6/pom.xml (original)
+++ sis/branches/JDK6/pom.xml Mon Feb 22 16:56:41 2016
@@ -209,6 +209,17 @@ Apache SIS is a free software, Java lang
         <role>committer</role>
       </roles>
     </developer>
+    <developer>
+      <name>Rémi Maréchal</name>
+      <id>rmarechal</id>
+      <email>remi.marechal@geomatys.com</email>
+      <organization>Geomatys</organization>
+      <organizationUrl>http://www.geomatys.com/</organizationUrl>
+      <timezone>+1</timezone>
+      <roles>
+        <role>developer</role>
+      </roles>
+    </developer>
   </developers>
 
   <contributors>



Mime
View raw message