You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/02/14 19:20:59 UTC
svn commit: r1730366 [2/2] - in /sis/branches/JDK7: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/
core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/
core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identi...
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -17,8 +17,12 @@
package org.apache.sis.referencing.factory;
import org.opengis.util.FactoryException;
+import org.apache.sis.internal.system.Loggers;
// Test imports
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
@@ -26,6 +30,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.LoggingWatcher;
/**
@@ -49,6 +54,13 @@ import org.apache.sis.test.DependsOn;
@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness
public final strictfp class GIGS2002 extends org.opengis.test.referencing.gigs.GIGS2002 {
/**
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
+ */
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
+
+ /**
* Creates a new test using the default authority factory.
*/
public GIGS2002() {
@@ -74,4 +86,36 @@ public final strictfp class GIGS2002 ext
public static void close() throws FactoryException {
GIGS2001.close();
}
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testClarkeMichigan() throws FactoryException {
+ super.testClarkeMichigan();
+ loggings.assertNextLogContains("EPSG:7009");
+ }
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testPopularVisualisationSphere() throws FactoryException {
+ super.testPopularVisualisationSphere();
+ loggings.assertNextLogContains("EPSG:7059");
+ }
+
+ /**
+ * Verifies that no unexpected warning has been emitted in this test.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -17,8 +17,12 @@
package org.apache.sis.referencing.factory;
import org.opengis.util.FactoryException;
+import org.apache.sis.internal.system.Loggers;
// Test imports
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
@@ -26,6 +30,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.LoggingWatcher;
/**
@@ -51,6 +56,13 @@ import org.apache.sis.test.DependsOn;
@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness
public final strictfp class GIGS2004 extends org.opengis.test.referencing.gigs.GIGS2004 {
/**
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
+ */
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
+
+ /**
* Creates a new test using the default authority factory.
*/
public GIGS2004() {
@@ -76,4 +88,40 @@ public final strictfp class GIGS2004 ext
public static void close() throws FactoryException {
GIGS2001.close();
}
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testNAD27_Michigan() throws FactoryException {
+ super.testNAD27_Michigan();
+ loggings.assertNextLogContains("EPSG:6268"); // Datum replaced by 6267
+ loggings.skipNextLogIfContains("EPSG:7009"); // Ellipsoid replaced by 7008 (may have been created by GIGS2002)
+ loggings.assertNextLogContains("EPSG:4268"); // CRS replaced by 4267
+ }
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testPopularVisualisation() throws FactoryException {
+ super.testPopularVisualisation();
+ loggings.assertNextLogContains("EPSG:6055");
+ loggings.skipNextLogIfContains("EPSG:7059"); // Ellipsoid may have been created by GIGS2002.
+ loggings.assertNextLogContains("EPSG:4055");
+ }
+
+ /**
+ * Verifies that no unexpected warning has been emitted in this test.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -17,8 +17,12 @@
package org.apache.sis.referencing.factory;
import org.opengis.util.FactoryException;
+import org.apache.sis.internal.system.Loggers;
// Test imports
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
@@ -26,6 +30,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.LoggingWatcher;
/**
@@ -50,6 +55,13 @@ import org.apache.sis.test.DependsOn;
@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness
public final strictfp class GIGS2005 extends org.opengis.test.referencing.gigs.GIGS2005 {
/**
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
+ */
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
+
+ /**
* Creates a new test using the default authority factory.
*/
public GIGS2005() {
@@ -75,4 +87,37 @@ public final strictfp class GIGS2005 ext
public static void close() throws FactoryException {
GIGS2001.close();
}
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testAustralianMapGridZones() throws FactoryException {
+ super.testAustralianMapGridZones();
+ loggings.assertNextLogContains("EPSG:17448"); // Falls outside EEZ area.
+ }
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testUSStatePlaneZones_LCC() throws FactoryException {
+ super.testUSStatePlaneZones_LCC();
+ loggings.assertNextLogContains("EPSG:12112"); // Method changed to accord with NGS practice.
+ loggings.assertNextLogContains("EPSG:12113");
+ }
+
+ /**
+ * Verifies that no unexpected warning has been emitted in this test.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -17,8 +17,12 @@
package org.apache.sis.referencing.factory;
import org.opengis.util.FactoryException;
+import org.apache.sis.internal.system.Loggers;
// Test imports
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
@@ -26,6 +30,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.LoggingWatcher;
/**
@@ -50,6 +55,13 @@ import org.apache.sis.test.DependsOn;
@FixMethodOrder(MethodSorters.JVM) // Intentionally want some randomness
public final strictfp class GIGS2006 extends org.opengis.test.referencing.gigs.GIGS2006 {
/**
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
+ */
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
+
+ /**
* Creates a new test using the default authority factory.
*/
public GIGS2006() {
@@ -75,4 +87,32 @@ public final strictfp class GIGS2006 ext
public static void close() throws FactoryException {
GIGS2001.close();
}
+
+ /**
+ * Overrides the GeoAPI test for verifying the log messages emitted during the construction of deprecated objects.
+ *
+ * @throws FactoryException if an error occurred while creating the object.
+ */
+ @Test
+ @Override
+ public void testNAD27_Michigan() throws FactoryException {
+ super.testNAD27_Michigan();
+ loggings.skipNextLogIfContains("EPSG:6268"); // Datum replaced by 6267
+ loggings.skipNextLogIfContains("EPSG:7009"); // Ellipsoid replaced by 7008
+ loggings.skipNextLogIfContains("EPSG:4268"); // CRS replaced by 4267
+ loggings.assertNextLogContains("EPSG:12111");
+ loggings.assertNextLogContains("EPSG:26811"); // ProjectedCRS (no replacement).
+ loggings.skipNextLogIfContains("EPSG:12112"); // Conversion replaced by 6198
+ loggings.assertNextLogContains("EPSG:26812"); // ProjectedCRS replaced by 6201
+ loggings.skipNextLogIfContains("EPSG:12113"); // Conversion replaced by 6199
+ loggings.assertNextLogContains("EPSG:26813"); // ProjectedCRS replaced by 6202
+ }
+
+ /**
+ * Verifies that no unexpected warning has been emitted in this test.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -39,11 +39,11 @@ import org.apache.sis.internal.system.Lo
import org.apache.sis.metadata.iso.extent.Extents;
import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.referencing.datum.HardCodedDatum;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -61,28 +61,18 @@ import static org.apache.sis.test.Assert
@DependsOn(AuthorityFactoryProxyTest.class)
public final strictfp class MultiAuthoritiesFactoryTest extends TestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public because JUnit requires
- * us to do so, but should be considered as an implementation details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new Listener();
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
- * Implementation of the {@link MultiAuthoritiesFactoryTest#listener} rule.
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
*/
- private static final class Listener extends LoggingWatcher {
- /** Expected keywords in the log message. */
- String[] expectedKeywords;
-
- /** Creates a new log listener. */
- Listener() {super(Logging.getLogger(Loggers.CRS_FACTORY));}
-
- /** Verifies the log message. */
- @Override protected void verifyMessage(final String message) {
- for (final String keyword : expectedKeywords) {
- assertTrue(message, message.contains(keyword));
- }
- }
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -182,20 +172,20 @@ public final strictfp class MultiAuthori
assertSame("MOCK1", mock1, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock1", null));
assertSame("MOCK1", mock1, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock1", "2.3"));
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
- ((Listener) listener).expectedKeywords = new String[] {"CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK1", "2.3"};
assertSame("MOCK3", mock3, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock3", null));
- assertEquals("Expected a warning about the extraneous MOCK1 factory.", 0, listener.maximumLogCount);
+ loggings.assertNextLogContains("CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK1", "2.3");
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
- ((Listener) listener).expectedKeywords = new String[] {"CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK3"};
assertSame("MOCK5", mock5, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock5", null));
- assertEquals("Expected a warning about the extraneous MOCK3 factory.", 0, listener.maximumLogCount);
+ loggings.assertNextLogContains("CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK3");
+ loggings.assertNoUnexpectedLog();
// Ask again the same factories. No logging should be emitted now, because we already logged.
assertSame("MOCK3", mock3, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock3", null));
assertSame("MOCK5", mock5, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock5", null));
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -325,10 +315,9 @@ public final strictfp class MultiAuthori
/*
* Following should log a warning telling that the authority factories do not match.
*/
- listener.maximumLogCount = 1;
- ((Listener) listener).expectedKeywords = new String[] {"MOCK:4326", "MOCK:2.3:84"};
assertTrue(factory.createFromCoordinateReferenceSystemCodes("MOCK:4326", "MOCK:2.3:84").isEmpty());
- assertEquals("Expected a warning about mismatched factories.", 0, listener.maximumLogCount);
+ loggings.assertNextLogContains("MOCK:4326", "MOCK:2.3:84");
+ loggings.assertNoUnexpectedLog();
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -63,6 +63,7 @@ import org.apache.sis.referencing.factor
import org.junit.Rule;
import org.junit.Test;
import org.junit.Ignore;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.apache.sis.test.TestCase;
@@ -130,29 +131,19 @@ public final strictfp class EPSGFactoryT
}
/**
- * Words that we expect to find in each log messages to be emitted.
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
- private String[][] expectedLogWords;
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
- * because JUnit requires us to do so, but should be considered as an implementation
- * details (it should have been a private field).
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
*/
- @Rule
- public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.CRS_FACTORY)) {
- /**
- * Ensures that the logging message contains some expected words.
- */
- @Override
- protected void verifyMessage(final String message) {
- if (expectedLogWords != null) {
- for (final String word : expectedLogWords[expectedLogWords.length - (maximumLogCount + 1)]) {
- assertTrue(message, message.contains(word));
- }
- }
- }
- };
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Tests {@link EPSGDataAccess#tableMatches(String, String)}.
@@ -164,7 +155,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "WGS 84" geographic CRS (EPSG::4326).
+ * Tests the "WGS 84" geographic CRS (EPSG:4326).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -174,16 +165,17 @@ public final strictfp class EPSGFactoryT
final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326");
assertEpsgNameAndIdentifierEqual("WGS 84", 4326, crs);
assertEpsgNameAndIdentifierEqual("World Geodetic System 1984", 6326, crs.getDatum());
- assertAxisDirectionsEqual("EPSG::6422", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
+ assertAxisDirectionsEqual("EPSG:6422", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
final BursaWolfParameters[] bwp = ((DefaultGeodeticDatum) crs.getDatum()).getBursaWolfParameters();
assertEquals("Expected no Bursa-Wolf parameters.", 0, bwp.length);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4326"));
+ assertSame("Shall accept \"::\"", crs, factory.createGeographicCRS("EPSG::4326"));
}
/**
- * Tests the "Datum 73" geographic CRS (EPSG::4274), which has a datum different than the WGS84 one.
+ * Tests the "Datum 73" geographic CRS (EPSG:4274), which has a datum different than the WGS84 one.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -203,7 +195,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "Lao 1997" geographic CRS (EPSG::4993) with an ellipsoidal height.
+ * Tests the "Lao 1997" geographic CRS (EPSG:4993) with an ellipsoidal height.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -221,7 +213,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "ITRF93" geocentric CRS (EPSG::4915).
+ * Tests the "ITRF93" geocentric CRS (EPSG:4915).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -238,7 +230,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "NAD27(76) / UTM zone 15N" projected CRS (EPSG::2027).
+ * Tests the "NAD27(76) / UTM zone 15N" projected CRS (EPSG:2027).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -274,7 +266,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "Beijing 1954 / 3-degree Gauss-Kruger CM 135E" projected CRS (EPSG::2442).
+ * Tests the "Beijing 1954 / 3-degree Gauss-Kruger CM 135E" projected CRS (EPSG:2442).
* This projected CRS has (North, East) axis orientations instead of (East, North).
*
* @throws FactoryException if an error occurred while querying the factory.
@@ -410,7 +402,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "Barcelona Grid B1" engineering CRS (EPSG::5801).
+ * Tests the "Barcelona Grid B1" engineering CRS (EPSG:5801).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -481,17 +473,14 @@ public final strictfp class EPSGFactoryT
public void testDeprecatedGeographic() throws FactoryException {
assumeNotNull(factory);
- listener.maximumLogCount = 2;
- expectedLogWords = new String[][] {
- {"EPSG:6405"}, // Coordinate System 6405 is no longer supported by EPSG
- {"EPSG:63266405", "4326"} // EPSG no longer support codes in the 60000000 series.
- };
-
final GeographicCRS crs = factory.createGeographicCRS("63266405");
assertEpsgNameAndIdentifierEqual("WGS 84 (deg)", 63266405, crs);
assertAxisDirectionsEqual(null, crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
-
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("63266405"));
+
+ loggings.assertNextLogContains("EPSG:6405"); // Coordinate System 6405 is no longer supported by EPSG
+ loggings.assertNextLogContains("EPSG:63266405", "4326"); // EPSG no longer support codes in the 60000000 series.
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -505,18 +494,15 @@ public final strictfp class EPSGFactoryT
public void testDeprecatedProjected() throws FactoryException {
assumeNotNull(factory);
- listener.maximumLogCount = 3;
- expectedLogWords = new String[][] {
- {"EPSG:9823", "1029"}, // Operation method 9823 has been replaced by 1029
- {"EPSG:19968", "4086"}, // Coordinate Operation 19968 has been replaced by 4086
- {"EPSG:3786", "4088"} // Coordinate Reference System 3786 has been replaced by 4088
- };
-
final ProjectedCRS crs = factory.createProjectedCRS("3786");
assertEpsgNameAndIdentifierEqual("World Equidistant Cylindrical (Sphere)", 3786, crs);
assertEpsgNameAndIdentifierEqual("Equidistant Cylindrical (Spherical)", 9823, crs.getConversionFromBase().getMethod());
assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
- assertEquals("All warnings should have been logged at this point.", 0, listener.maximumLogCount);
+
+ loggings.assertNextLogContains("EPSG:9823", "1029"); // Operation method 9823 has been replaced by 1029
+ loggings.assertNextLogContains("EPSG:19968", "4086"); // Coordinate Operation 19968 has been replaced by 4086
+ loggings.assertNextLogContains("EPSG:3786", "4088"); // Coordinate Reference System 3786 has been replaced by 4088
+ loggings.assertNoUnexpectedLog();
final ProjectedCRS replacement = factory.createProjectedCRS("4088");
assertEpsgNameAndIdentifierEqual("World Equidistant Cylindrical (Sphere)", 4088, replacement);
@@ -744,7 +730,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests the "UTM zone 10N" conversion (EPSG::16010).
+ * Tests the "UTM zone 10N" conversion (EPSG:16010).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@@ -790,7 +776,7 @@ public final strictfp class EPSGFactoryT
} catch (AssertionError error) {
out.println("The following contains more information about a JUnit test failure.");
out.println("See the JUnit report for the stack trace. Below is a cache dump.");
- out.println("See the operation method EPSG::9807 and compare with:");
+ out.println("See the operation method EPSG:9807 and compare with:");
out.print (" - Method obtained directly: "); out.println(System.identityHashCode(copMethod));
out.print (" - Method obtained indirectly: "); out.println(System.identityHashCode(crsMethod));
out.println("Content of EPSGFactory cache:");
@@ -800,7 +786,7 @@ public final strictfp class EPSGFactoryT
}
/**
- * Tests longitude rotation (EPSG::1764). This is a very simple case for checking
+ * Tests longitude rotation (EPSG:1764). This is a very simple case for checking
* that this part is okay before to try more complex transformations.
*
* @throws FactoryException if an error occurred while querying the factory.
@@ -810,13 +796,13 @@ public final strictfp class EPSGFactoryT
assumeNotNull(factory);
final CoordinateOperation operation = factory.createCoordinateOperation("1764");
assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (2)", 1764, operation);
- assertInstanceOf("EPSG::1764", Transformation.class, operation);
+ assertInstanceOf("EPSG:1764", Transformation.class, operation);
assertSame("Operation shall be cached", operation, factory.createCoordinateOperation("1764"));
}
/**
- * Tests "BD72 to WGS 84 (1)" (EPSG::1609) transformation. This one has an unusual unit for the
- * "Scale difference" parameter (EPSG::8611). The value is 0.999999 and the unit is "unity" (EPSG::9201)
+ * Tests "BD72 to WGS 84 (1)" (EPSG:1609) transformation. This one has an unusual unit for the
+ * "Scale difference" parameter (EPSG:8611). The value is 0.999999 and the unit is "unity" (EPSG:9201)
* instead of the usual "parts per million" (EPSG:9202).
*
* @throws FactoryException if an error occurred while querying the factory.
@@ -893,7 +879,6 @@ public final strictfp class EPSGFactoryT
assertTrue("contains(“EPSG::1989”)", all.contains(operation3));
int count = 0;
- listener.maximumLogCount = all.size(); // Ignore log message for unsupported operation methods.
for (final CoordinateOperation tr : all) {
assertSame("sourceCRS", sourceCRS, tr.getSourceCRS());
assertSame("targetCRS", targetCRS, tr.getTargetCRS());
@@ -903,6 +888,7 @@ public final strictfp class EPSGFactoryT
count++;
}
assertEquals(count, all.size()); // Size may have been modified after above loop.
+ loggings.clear(); // Too installation-dependent for testing them.
}
/**
@@ -925,7 +911,7 @@ public final strictfp class EPSGFactoryT
" AXIS[“Geodetic longitude”, EAST]]");
/*
* First, search for a CRS with axis order that does not match the ones in the EPSG database.
- * IdentifiedObjectFinder should not accept EPSG::4326 as a match for the given CRS.
+ * IdentifiedObjectFinder should not accept EPSG:4326 as a match for the given CRS.
*/
assertEquals("Full scan should be enabled by default.",
IdentifiedObjectFinder.Domain.VALID_DATASET, finder.getSearchDomain());
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -31,7 +31,6 @@ import org.opengis.referencing.crs.Geogr
import org.opengis.referencing.crs.ProjectedCRS;
import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.internal.system.Loggers;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
@@ -40,6 +39,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -65,22 +65,21 @@ import static org.junit.Assume.*;
public final strictfp class EPSGInstallerTest extends TestCase {
/**
* A JUnit rule for listening to log events emitted during execution of tests.
- * This rule verifies that the log message contains the expected information.
+ * This rule is used by tests that verifies the log message content.
*
* <p>This field is public because JUnit requires us to do so, but should be considered
* as an implementation details (it should have been a private field).</p>
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.CRS_FACTORY)) {
- @Override protected void verifyMessage(final String message) {
- log = message; // Verified later by the tests in the enclosing class.
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
- * The logging message caught by the {@link #listener}.
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
*/
- private String log;
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Tests the {@link EPSGInstaller#REPLACE_STATEMENT} pattern.
@@ -134,8 +133,8 @@ public final strictfp class EPSGInstalle
} finally {
TestDatabase.drop(ds);
}
- assertTrue(log, log.contains("EPSG"));
- assertTrue(log, log.contains("jdbc:derby:memory:test"));
+ loggings.assertNextLogContains("EPSG", "jdbc:derby:memory:test");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -161,8 +160,8 @@ public final strictfp class EPSGInstalle
s.execute("SHUTDOWN");
}
}
- assertTrue(log, log.contains("EPSG"));
- assertTrue(log, log.contains("jdbc:hsqldb:mem:test"));
+ loggings.assertNextLogContains("EPSG", "jdbc:hsqldb:mem:test");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -172,12 +171,12 @@ public final strictfp class EPSGInstalle
private void createAndTest(final DataSource ds, final InstallationScriptProvider scriptProvider)
throws SQLException, FactoryException
{
- listener.maximumLogCount = 100;
final Map<String,Object> properties = new HashMap<>();
assertNull(properties.put("dataSource", ds));
assertNull(properties.put("scriptProvider", scriptProvider));
assertEquals("Should not contain EPSG tables before we created them.", 0, countCRSTables(ds));
- assertEquals("Should not yet have logged anything at this point.", 100, listener.maximumLogCount);
+ loggings.assertNoUnexpectedLog(); // Should not yet have logged anything at this point.
+
try (EPSGFactory factory = new EPSGFactory(properties)) {
/*
* Fetch the "WGS 84" coordinate reference system.
@@ -208,7 +207,6 @@ public final strictfp class EPSGInstalle
assertFalse("4329", codes.contains("4329"));
}
assertEquals("Should contain EPSG tables after we created them.", 1, countCRSTables(ds));
- assertEquals("Should have logged a message about the database creation.", 99, listener.maximumLogCount);
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -95,6 +95,8 @@ public final strictfp class CoordinateRe
*/
private static final Map<String,String> SECTION_TITLES = new HashMap<>();
static {
+ rd("American Samoa 1962", "American Samoa");
+ rd("American Samoa Vertical Datum of 2002", "American Samoa");
rd("Arc 1950", "Arc");
rd("Arc 1960", "Arc");
rd("Ancienne Triangulation Francaise (Paris)", "Ancienne Triangulation Française");
@@ -117,6 +119,8 @@ public final strictfp class CoordinateRe
rd("CH1903", "Bern / CH1903");
rd("CH1903+", "Bern / CH1903");
rd("CH1903 (Bern)", "Bern / CH1903");
+ rd("Canadian Geodetic Vertical Datum of 1928", "Canadian Geodetic Vertical Datum");
+ rd("Canadian Geodetic Vertical Datum of 2013", "Canadian Geodetic Vertical Datum");
rd("Chatham Islands Datum 1971", "Chatham Islands Datum");
rd("Chatham Islands Datum 1979", "Chatham Islands Datum");
rd("Corrego Alegre 1961", "Corrego Alegre");
@@ -240,6 +244,7 @@ public final strictfp class CoordinateRe
rd("Naparima 1972", "Naparima");
rd("Nivellement General de la Corse 1948", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
rd("Nivellement General de la France - IGN69", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
+ rd("Nivellement General de la France - IGN78", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
rd("Nivellement General de la France - Lallemand", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
rd("Nivellement General de Nouvelle Caledonie", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
rd("Nivellement General de Polynesie Francaise", "Nivellement Général Corse / France / Nouvelle-Calédonie / Polynésie Française / Luxembourd / Guyanais");
@@ -254,6 +259,8 @@ public final strictfp class CoordinateRe
rd("Nord de Guerre (Paris)", "Ancienne Triangulation Française");
rd("Nouvelle Triangulation Francaise", "Nouvelle Triangulation Française");
rd("Nouvelle Triangulation Francaise (Paris)", "Nouvelle Triangulation Française");
+ rd("Norway Normal Null 1954", "Norway Normal Null");
+ rd("Norway Normal Null 2000", "Norway Normal Null");
rd("Ordnance Datum Newlyn (Orkney Isles)", "Ordnance Datum Newlyn");
rd("OSGB 1936", "OSGB");
rd("OSGB 1970 (SN)", "OSGB");
@@ -267,6 +274,7 @@ public final strictfp class CoordinateRe
rd("Posiciones Geodesicas Argentinas 1994", "Posiciones Geodesicas Argentinas");
rd("Posiciones Geodesicas Argentinas 1998", "Posiciones Geodesicas Argentinas");
rd("Posiciones Geodesicas Argentinas 2007", "Posiciones Geodesicas Argentinas");
+ rd("Puerto Rico Vertical Datum of 2002", "Puerto Rico");
rd("Qatar 1948", "Qatar");
rd("Qatar 1974", "Qatar");
rd("Qatar National Datum 1995", "Qatar");
@@ -324,8 +332,9 @@ public final strictfp class CoordinateRe
}
/**
- * The keywords before which to cut the CRS names. The main intend here is to preserve the
- * "far west", "west", "central west", "central", "central east", "east", "far east" order.
+ * The keywords before which to cut the CRS names when sorting by alphabetical order.
+ * The main intend here is to preserve the "far west", "west", "central west", "central",
+ * "central east", "east", "far east" order.
*/
private static final String[] CUT_BEFORE = {
" far west", // "MAGNA-SIRGAS / Colombia Far West zone"
@@ -339,7 +348,7 @@ public final strictfp class CoordinateRe
};
/**
- * The keywords after which to cut the CRS names.
+ * The keywords after which to cut the CRS names when sorting by alphabetical order.
*
* Note: alphabetical sorting of Roman numbers work for zones from I to VIII inclusive.
* If there is more zones (for example with "JGD2000 / Japan Plane Rectangular"), then
@@ -382,7 +391,7 @@ public final strictfp class CoordinateRe
properties.setProperty("PRODUCT.URL", "http://sis.apache.org");
properties.setProperty("JAVADOC.GEOAPI", "http://www.geoapi.org/snapshot/javadoc");
properties.setProperty("FACTORY.NAME", "EPSG");
- properties.setProperty("FACTORY.VERSION", "7.9");
+ properties.setProperty("FACTORY.VERSION", "8.8");
properties.setProperty("FACTORY.VERSION.SUFFIX", ", together with other sources");
properties.setProperty("DESCRIPTION", "<p><b>Notation:</b></p>\n" +
"<ul>\n" +
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -50,16 +50,20 @@ import org.apache.sis.referencing.cs.Def
import org.apache.sis.referencing.crs.DefaultVerticalCRS;
import org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata;
import org.apache.sis.internal.jaxb.gmx.Anchor;
+import org.apache.sis.internal.system.Loggers;
import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.xml.MarshallerPool;
import org.apache.sis.xml.IdentifierSpace;
+import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.XMLComparator;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
+import org.junit.After;
+import org.junit.Rule;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
@@ -85,6 +89,21 @@ import java.nio.charset.StandardCharsets
@DependsOn(ReferencingInMetadataTest.class)
public strictfp class DefaultMetadataTest extends XMLTestCase {
/**
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
+ */
+ @Rule
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.XML);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Sets the temporal extent. The current implementation does nothing, because {@code sis-metadata} does not have
* any dependency to {@code sis-temporal}. However a future version or an other module may implement this method.
*
@@ -401,5 +420,6 @@ public strictfp class DefaultMetadataTes
pool.recycle(unmarshaller);
final DefaultMetadata expected = createHardCoded();
assertTrue(metadata.equals(expected, ComparisonMode.DEBUG));
+ loggings.skipNextLogIfContains("sis-temporal");
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Conversion.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Conversion.xml?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Conversion.xml (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Conversion.xml Sun Feb 14 18:20:58 2016
@@ -26,7 +26,7 @@
xmlns:xlink = "http://www.w3.org/1999/xlink"
gml:id = "WorldMercator">
- <gml:identifier codeSpace="test">3395</gml:identifier> <!-- Not the real EPSG::3395 -->
+ <gml:identifier codeSpace="test">3395</gml:identifier> <!-- Not the real EPSG:3395 -->
<gml:name>World Mercator</gml:name>
<gml:domainOfValidity>
<gmd:EX_Extent>
@@ -64,7 +64,7 @@
</gml:coordinateOperationAccuracy>
<gml:method>
<gml:OperationMethod gml:id="Mercator">
- <gml:identifier codeSpace="test">19883</gml:identifier> <!-- Not the real EPSG::19883 -->
+ <gml:identifier codeSpace="test">19883</gml:identifier> <!-- Not the real EPSG:19883 -->
<gml:name>Mercator (1SP)</gml:name>
<gml:formula>See EPSG guide.</gml:formula>
<gml:sourceDimensions>2</gml:sourceDimensions>
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/SetOfUnknownSize.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/SetOfUnknownSize.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/SetOfUnknownSize.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/SetOfUnknownSize.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -149,7 +149,7 @@ public abstract class SetOfUnknownSize<E
* iterate over the elements of this Set. The reason is that this Set may compute the values dynamically and
* it is sometime difficult to ensure that this Set's iterator is fully consistent with the values recognized
* by the contains(Object) method. For example the iterator may return "EPSG:4326" while the contains(Object)
- * method may accept both "EPSG:4326" and "EPSG::4326". For this equals(Object) method, we consider the
+ * method may accept both "EPSG:4326" and "EPSG:4326". For this equals(Object) method, we consider the
* contains(Object) method of the other Set as more reliable.
*/
if (object == this) {
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -441,8 +441,10 @@ public final class DecimalFunctions exte
* <li>Otherwise this method returns {@code fractionDigits}.</li>
* </ul>
*
- * Examples:
+ * <div class="note"><b>Note:</b>
+ * The threshold of 4 trailing fraction digits is arbitrary and may change in any future SIS version.</div>
*
+ * <div class="note"><b>Examples:</b>
* <ul>
* <li>{@code fractionDigitsForValue(179.12499999999824)} returns 14,
* the amount of digits after the decimal separator.</li>
@@ -455,9 +457,7 @@ public final class DecimalFunctions exte
* <li>{@code fractionDigitsForValue(179.12499997999999, 3)} returns 14 because rounding the 3 last digits
* results in 179.12499997000. The condition for 4 trailing zero fraction digits is not meet.</li>
* </ul>
- *
- * <div class="note"><b>Note:</b>
- * The threshold of 4 trailing fraction digits is arbitrary and may change in any future SIS version.</div>
+ * </div>
*
* @param value The value for which to get the number of significant fraction fraction digits minus rounding error.
* @param uncertainDigits Number of trailing fraction digits which may be rounding error artefacts.
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -70,7 +70,7 @@ public final class Units extends Static
public static final Unit<Duration> MILLISECOND = SI.MetricPrefix.MILLI(SI.SECOND);
/**
- * The EPSG::1029 definition of year.
+ * The EPSG:1029 definition of year.
*/
private static final Unit<Duration> YEAR = SI.SECOND.divide(31556925.445);
@@ -593,8 +593,8 @@ public final class Units extends Static
*
* <p>The same unit may be represented by different EPSG codes depending on the context:</p>
* <ul>
- * <li>EPSG::9102 – <cite>degree</cite> – is used for prime meridian and coordinate operation parameters.</li>
- * <li>EPSG::9122 – <cite>degree (supplier to define representation)</cite> – is used for coordinate system axes.</li>
+ * <li>EPSG:9102 – <cite>degree</cite> – is used for prime meridian and coordinate operation parameters.</li>
+ * <li>EPSG:9122 – <cite>degree (supplier to define representation)</cite> – is used for coordinate system axes.</li>
* </ul>
*
* When such choice exists, the code to return is determined by the {@code inAxis} argument,
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Sun Feb 14 18:20:58 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;
/**
@@ -70,7 +72,7 @@ import org.apache.sis.internal.system.Lo
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.6
+ * @version 0.7
* @module
*/
public class IndexedResourceBundle extends ResourceBundle implements Localized {
@@ -411,12 +413,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/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] Sun Feb 14 18:20:58 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
* @Rule
- * public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.XML)) {
- * @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;
+ * @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<>();
/**
* 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();
}
}