Author: desruisseaux
Date: Sat Feb 13 18:57:32 2016
New Revision: 1730259
URL: http://svn.apache.org/viewvc?rev=1730259&view=rev
Log:
Verify the log messages emitted during execution of GIGS tests.
This implies another modification in the way we verify log messages in tests.
Modified:
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -219,7 +219,11 @@ public final strictfp class AllMetadataT
@Override
public void testPropertyValues() {
super.testPropertyValues();
- loggings.assertNoUnexpectedLogging(4);
+ loggings.assertNextLogContains("angularDistance", "distance");
+ loggings.assertNextLogContains("distance", "equivalentScale");
+ loggings.assertNextLogContains("equivalentScale", "levelOfDetail");
+ loggings.assertNextLogContains("levelOfDetail", "vertical");
+ loggings.assertNoUnexpectedLog();
}
/**
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -25,6 +25,7 @@ import org.apache.sis.internal.jaxb.Sche
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.Rule;
import org.junit.Test;
@@ -36,7 +37,7 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.6
+ * @version 0.7
* @module
*/
@DependsOn(DefaultRepresentativeFractionTest.class)
@@ -49,6 +50,14 @@ public final strictfp class DefaultResol
public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests the {@link DefaultResolution#DefaultResolution(RepresentativeFraction)} constructor.
*
* @see <a href="https://issues.apache.org/jira/browse/SIS-195">SIS-195</a>
@@ -61,7 +70,6 @@ public final strictfp class DefaultResol
scale.setDenominator(100);
final DefaultResolution metadata = new DefaultResolution(scale);
assertSame(scale, metadata.getEquivalentScale());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -77,13 +85,13 @@ public final strictfp class DefaultResol
metadata.setDistance(2.0);
assertEquals("distance", Double.valueOf(2.0), metadata.getDistance());
assertNull("equivalentScale", metadata.getEquivalentScale());
- loggings.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
metadata.setEquivalentScale(scale);
assertSame("equivalentScale", scale, metadata.getEquivalentScale());
assertNull("distance", metadata.getDistance());
- loggings.assertLoggingContains(0, "distance", "equivalentScale");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("distance", "equivalentScale");
+ loggings.assertNoUnexpectedLog();
metadata.setDistance(null); // Expected to be a no-op.
assertSame("equivalentScale", scale, metadata.getEquivalentScale());
@@ -92,7 +100,6 @@ public final strictfp class DefaultResol
metadata.setEquivalentScale(null);
assertNull("equivalentScale", metadata.getEquivalentScale());
assertNull("distance", metadata.getDistance());
- loggings.assertNoUnexpectedLogging(1);
}
/**
@@ -155,6 +162,5 @@ public final strictfp class DefaultResol
* Should not be a problem neither.
*/
assertEquals(resolution, XML.unmarshal(xml));
- loggings.assertNoUnexpectedLogging(0);
}
}
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -20,6 +20,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -43,6 +44,14 @@ public final strictfp class DefaultScope
public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests the various setter methods. Since they are exclusive properties,
* we expect any new property to replace the old one.
*/
@@ -51,21 +60,20 @@ public final strictfp class DefaultScope
final DefaultScopeDescription metadata = new DefaultScopeDescription();
metadata.setDataset("A dataset");
assertEquals("dataset", "A dataset", metadata.getDataset());
- loggings.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
metadata.setOther(new SimpleInternationalString("Other value"));
assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
- loggings.assertLoggingContains(0, "dataset", "other");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("dataset", "other");
+ loggings.assertNoUnexpectedLog();
- metadata.setDataset(null); // Expected to be a no-op.
+ metadata.setDataset(null); // Expected to be a no-op.
assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
metadata.setOther(null);
assertNull("other", metadata.getOther());
assertNull("dataset", metadata.getDataset());
- loggings.assertNoUnexpectedLogging(1);
}
}
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -21,6 +21,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -44,6 +45,14 @@ public final strictfp class DefaultGeore
public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests {@link DefaultGeorectified#isCheckPointAvailable()} and
* {@link DefaultGeorectified#setCheckPointAvailable(boolean)}.
*/
@@ -56,17 +65,16 @@ public final strictfp class DefaultGeore
// Setting the description shall set automatically the availability.
metadata.setCheckPointDescription(description);
assertTrue("checkPointAvailability", metadata.isCheckPointAvailable());
- loggings.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
// Setting the availability flag shall hide the description and logs a message.
metadata.setCheckPointAvailable(false);
assertNull("checkPointDescription", metadata.getCheckPointDescription());
- loggings.assertLoggingContains(0, "checkPointDescription", "checkPointAvailability");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("checkPointDescription", "checkPointAvailability");
+ loggings.assertNoUnexpectedLog();
// Setting the availability flag shall bring back the description.
metadata.setCheckPointAvailable(true);
assertSame("checkPointDescription", description, metadata.getCheckPointDescription());
- loggings.assertNoUnexpectedLogging(1);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -220,7 +220,7 @@ public enum CommonCRS {
* <tr><th>Semi-minor axis length:</th> <td>6356752 <i>(approximative)</i></td></tr>
* <tr><th>Inverse flattening:</th> <td>298.257222101 <i>(definitive)</i></td></tr>
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
- * <tr><th>UTM zones:</th> <td>28 to 38 in the North hemisphere</td></tr>
+ * <tr><th>UTM zones:</th> <td>28 to 37 in the North hemisphere</td></tr>
* </table></blockquote>
*
* <div class="note"><b>Note:</b>
@@ -229,7 +229,7 @@ public enum CommonCRS {
* while the {@code "IGNF:MILLER"} authority code uses the GRS80 datum.</div>
*/
ETRS89((short) 4258, (short) 4937, (short) 4936, (short) 6258, (short) 7019, // Geodetic info
- (short) 25800, (short) 0, (byte) 28, (byte) 38), // UTM info
+ (short) 25800, (short) 0, (byte) 28, (byte) 37), // UTM info
/**
* European Datum 1950.
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -31,6 +31,7 @@ import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.LoggingWatcher;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -61,6 +62,14 @@ public final strictfp class CC_GeneralOp
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();
+ }
+
+ /**
* Creates a parameter descriptor as unmarshalled by JAXB, without {@code valueClass}.
*
* @throws JAXBException if this method failed to create test data.
@@ -133,8 +142,6 @@ public final strictfp class CC_GeneralOp
provided = unmarshal("Optional parameter", "More details here.");
assertSame("With same remark.", complete, CC_GeneralOperationParameter.merge(provided, complete));
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -168,7 +175,6 @@ public final strictfp class CC_GeneralOp
assertEquals ("maximumOccurs", 1, merged.getMaximumOccurs());
assertEquals ("valueClass", Integer.class, merged.getValueClass());
assertSame ("remarks", provided.getRemarks(), merged.getRemarks());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -195,7 +201,6 @@ public final strictfp class CC_GeneralOp
create("Parameter D", "Remarks D.", false, 6));
assertSame(complete, CC_GeneralOperationParameter.merge(provided, complete));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -237,7 +242,6 @@ public final strictfp class CC_GeneralOp
verifyParameter(itc.next(), itm.next(), false, "Remarks C."); // Not same because different remarks.
assertTrue ("Missing descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -280,7 +284,6 @@ public final strictfp class CC_GeneralOp
verifyParameter(itc.next(), itm.next(), true, null);
assertFalse("Unexpected descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -305,7 +308,7 @@ public final strictfp class CC_GeneralOp
create("Parameter A", "Remarks A.", false, 3),
create("Parameter C", "Remarks C.", false, 4));
- loggings.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
final ParameterDescriptorGroup merged =
(ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
@@ -313,8 +316,8 @@ public final strictfp class CC_GeneralOp
assertSame ("remarks", complete.getRemarks(), merged.getRemarks());
assertEquals ("minimumOccurs", 1, merged.getMinimumOccurs());
assertEquals ("maximumOccurs", 2, merged.getMaximumOccurs());
- loggings.assertLoggingContains(0, "Parameter B", "Group");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("Parameter B", "Group");
+ loggings.assertNoUnexpectedLog();
final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
final Iterator<GeneralParameterDescriptor> itm = merged .descriptors().iterator();
@@ -327,7 +330,6 @@ public final strictfp class CC_GeneralOp
verifyParameter(itc.next(), itm.next(), true, "Remarks C.");
assertFalse("Unexpected descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
- loggings.assertNoUnexpectedLogging(1);
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -34,6 +34,7 @@ import org.apache.sis.referencing.factor
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -57,6 +58,14 @@ public final strictfp class AuthorityFac
public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests creation of {@code CRS:84} from various codes.
*
* @throws FactoryException if a CRS:84 creation failed.
@@ -79,7 +88,6 @@ public final strictfp class AuthorityFac
assertSame(crs, CRS.forCode("OGC:CRS84"));
assertNotDeepEquals(crs, CRS.forCode("CRS:83"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -92,25 +100,23 @@ public final strictfp class AuthorityFac
public void testVersionedEPSG() throws FactoryException {
final CRSAuthorityFactory factory = AuthorityFactories.ALL;
final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326");
- loggings.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326"));
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326"));
- loggings.assertLoggingContains(0, "6.11.2");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("6.11.2");
+ loggings.assertNoUnexpectedLog();
- loggings.messages.clear();
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.04:4326"));
- loggings.assertLoggingContains(0, "7.04");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("7.04");
+ loggings.assertNoUnexpectedLog();
- loggings.messages.clear();
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.10:4326"));
- loggings.assertLoggingContains(0, "7.10");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("7.10");
+ loggings.assertNoUnexpectedLog();
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG::4326"));
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -155,7 +161,6 @@ public final strictfp class AuthorityFac
// This is the expected exception.
assertEquals("FOO", exception.getAuthority());
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -192,7 +197,6 @@ public final strictfp class AuthorityFac
} catch (NoSuchAuthorityCodeException e) {
assertNotNull(e.getMessage());
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -207,7 +211,6 @@ public final strictfp class AuthorityFac
assertFalse(codes.isEmpty());
assertTrue(codes.contains("CRS:84"));
assertTrue(codes.contains("AUTO:42001") || codes.contains("AUTO2:42001"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -223,6 +226,5 @@ public final strictfp class AuthorityFac
assertNotNull("With scan allowed, should find the CRS.", find);
assertTrue(HardCodedCRS.WGS84.equals(find, ComparisonMode.DEBUG));
assertSame(factory.createCoordinateReferenceSystem("CRS:84"), find);
- loggings.assertNoUnexpectedLogging(0);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -42,6 +42,7 @@ import org.apache.sis.test.LoggingWatche
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.XMLTestCase;
+import org.junit.After;
import org.junit.Test;
import org.junit.Rule;
@@ -74,6 +75,14 @@ public final strictfp class DefaultProje
public final LoggingWatcher loggings = new LoggingWatcher(Loggers.COORDINATE_OPERATION);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* An XML file in this package containing a projected CRS definition.
*/
private static final String XML_FILE = "ProjectedCRS.xml";
@@ -127,8 +136,6 @@ public final strictfp class DefaultProje
" AXIS[“Northing”, NORTH],\n" +
" AUTHORITY[“EPSG”, “27572”]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -160,8 +167,6 @@ public final strictfp class DefaultProje
" AXIS[“Northing”, NORTH],\n" +
" AUTHORITY[“EPSG”, “27572”]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -196,8 +201,6 @@ public final strictfp class DefaultProje
" AXIS[“Northing”, NORTH],\n" +
" AUTHORITY[“EPSG”, “27572”]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -235,8 +238,6 @@ public final strictfp class DefaultProje
" Unit[“metre”, 1, Id[“EPSG”, 9001]],\n" +
" Id[“EPSG”, 27572]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -268,8 +269,6 @@ public final strictfp class DefaultProje
" Unit[“metre”, 1],\n" +
" Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
/*
* Try again, but with mixed units. It should force the formatter to add explicit
* unit declaration in PrimeMeridian[…] and some Parameter[…] elements.
@@ -295,8 +294,6 @@ public final strictfp class DefaultProje
" Unit[“metre”, 1],\n" +
" Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -329,8 +326,6 @@ public final strictfp class DefaultProje
" ID[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
crs);
- loggings.assertNoUnexpectedLogging(0);
-
assertWktEquals(Convention.WKT2_SIMPLIFIED,
"ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
" BaseGeodCRS[“NTF (Paris)”,\n" +
@@ -351,8 +346,6 @@ public final strictfp class DefaultProje
" Unit[“metre”, 1],\n" +
" Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -396,8 +389,8 @@ public final strictfp class DefaultProje
" AXIS[“Northing”, NORTH]]",
crs);
- loggings.assertLoggingContains(0, "semi_minor", "WGS84");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("semi_minor", "WGS84");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -435,8 +428,6 @@ public final strictfp class DefaultProje
" Axis[“Northing (N)”, north],\n" +
" Unit[“metre”, 1]]",
crs);
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -472,8 +463,6 @@ public final strictfp class DefaultProje
*/
assertMarshalEqualsFile(XML_FILE, crs, STRICT, new String[] {"gml:name"},
new String[] {"xmlns:*", "xsi:schemaLocation", "gml:id"});
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -493,6 +482,5 @@ public final strictfp class DefaultProje
assertTrue ("IGNORE_METADATA", ((LenientComparable) standard).equals(normalized, ComparisonMode.IGNORE_METADATA));
assertTrue ("APPROXIMATIVE", ((LenientComparable) standard).equals(normalized, ComparisonMode.APPROXIMATIVE));
assertTrue ("ALLOW_VARIANT", ((LenientComparable) standard).equals(normalized, ComparisonMode.ALLOW_VARIANT));
- loggings.assertNoUnexpectedLogging(0);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java [UTF-8] Sat Feb 13 18:57:32 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/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java [UTF-8] Sat Feb 13 18:57:32 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/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java [UTF-8] Sat Feb 13 18:57:32 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/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java [UTF-8] Sat Feb 13 18:57:32 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/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -43,6 +43,7 @@ import org.apache.sis.test.LoggingWatche
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;
@@ -67,6 +68,14 @@ public final strictfp class MultiAuthori
public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests consistency of the mock factory used by other tests in this class.
*
* @throws FactoryException if no object was found for a code.
@@ -91,7 +100,6 @@ public final strictfp class MultiAuthori
assertInstanceOf(code, type, factory.createObject(code));
}
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -106,7 +114,6 @@ public final strictfp class MultiAuthori
Arrays.asList(mock1, mock2), null,
Arrays.asList(mock1, mock3), null);
assertSetEquals(Arrays.asList("MOCK1", "MOCK2", "MOCK3"), factory.getCodeSpaces());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -144,7 +151,6 @@ public final strictfp class MultiAuthori
assertTrue(message, message.contains("MOCK1"));
assertTrue(message, message.contains("9.9"));
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -166,21 +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.assertNoUnexpectedLogging(0);
+ loggings.assertNoUnexpectedLog();
assertSame("MOCK3", mock3, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock3", null));
- loggings.assertLoggingContains(0, "CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK1", "2.3");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK1", "2.3");
+ loggings.assertNoUnexpectedLog();
- loggings.messages.clear();
assertSame("MOCK5", mock5, factory.getAuthorityFactory(CRSAuthorityFactory.class, "mock5", null));
- loggings.assertLoggingContains(0, "CRSAuthorityFactory", "AuthorityFactoryMock", "MOCK3");
- loggings.assertNoUnexpectedLogging(1);
+ 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.assertNoUnexpectedLogging(1);
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -211,7 +216,6 @@ public final strictfp class MultiAuthori
final String message = e.getMessage();
assertTrue(message, message.contains("MOCK2"));
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -241,7 +245,6 @@ public final strictfp class MultiAuthori
assertTrue(message, message.contains("datum"));
assertTrue(message, message.contains("GeographicCRS"));
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -268,7 +271,6 @@ public final strictfp class MultiAuthori
assertTrue(message, message.contains("crs"));
assertTrue(message, message.contains("Datum"));
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -292,7 +294,6 @@ public final strictfp class MultiAuthori
assertFalse("MOCK:6326", codes.contains("MOCK:6326")); // A geodetic datum.
assertFalse("isEmpty()", codes.isEmpty());
assertArrayEquals(new String[] {"MOCK:4979", "MOCK:84", "MOCK:4326", "MOCK:5714", "MOCK:9905"}, codes.toArray());
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -315,8 +316,8 @@ public final strictfp class MultiAuthori
* Following should log a warning telling that the authority factories do not match.
*/
assertTrue(factory.createFromCoordinateReferenceSystemCodes("MOCK:4326", "MOCK:2.3:84").isEmpty());
- loggings.assertLoggingContains(0, "MOCK:4326", "MOCK:2.3:84");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("MOCK:4326", "MOCK:2.3:84");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -332,6 +333,5 @@ public final strictfp class MultiAuthori
final MultiAuthoritiesFactory factory = new MultiAuthoritiesFactory(mock, null, mock, null);
final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
assertSame(HardCodedDatum.WGS72, finder.findSingleton(HardCodedDatum.WGS72));
- loggings.assertNoUnexpectedLogging(0);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Sat Feb 13 18:57:32 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;
@@ -137,13 +138,20 @@ public final strictfp class EPSGFactoryT
public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests {@link EPSGDataAccess#tableMatches(String, String)}.
*/
@Test
public void testTableMatches() {
assertTrue(EPSGDataAccess.tableMatches("Coordinate_Operation", "epsg_coordoperation"));
assertTrue(EPSGDataAccess.tableMatches("[Coordinate Reference System]", "epsg_coordinatereferencesystem"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -164,7 +172,6 @@ public final strictfp class EPSGFactoryT
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4326"));
assertSame("Shall accept \"::\"", crs, factory.createGeographicCRS("EPSG::4326"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -185,7 +192,6 @@ public final strictfp class EPSGFactoryT
assertTrue("Expected a transformation to WGS84.", bwp.length >= 1);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4274"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -204,7 +210,6 @@ public final strictfp class EPSGFactoryT
AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4993"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -222,7 +227,6 @@ public final strictfp class EPSGFactoryT
AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4915"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -244,7 +248,6 @@ public final strictfp class EPSGFactoryT
verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -93);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("2027"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -290,7 +293,6 @@ public final strictfp class EPSGFactoryT
assertEquals("false_northing", 0, parameters.parameter("false_northing" ).doubleValue(), STRICT);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("2442"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -329,7 +331,6 @@ public final strictfp class EPSGFactoryT
assertNotDeepEquals(crs.getConversionFromBase(), variant.getConversionFromBase());
assertNotDeepEquals(crs, variant);
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -359,7 +360,6 @@ public final strictfp class EPSGFactoryT
assertSame(crs, factory.createObject("NTF (Paris) / Lambert zone I"));
assertSame(crs, factory.createProjectedCRS("NTF Paris Lambert zone I"));
assertSame(crs, factory.createObject("NTF Paris Lambert zone I"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -381,7 +381,6 @@ public final strictfp class EPSGFactoryT
// TODO: test axis directions.
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3408"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -400,7 +399,6 @@ public final strictfp class EPSGFactoryT
assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3857"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -416,7 +414,6 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("Barcelona", 9301, crs.getDatum());
assertAxisDirectionsEqual("EPSG::4500", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("5801"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -432,7 +429,6 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("Black Sea", 5134, crs.getDatum());
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("5735"));
assertAxisDirectionsEqual("EPSG::6499", crs.getCoordinateSystem(), AxisDirection.UP);
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -464,7 +460,6 @@ public final strictfp class EPSGFactoryT
assertEquals("eastBoundLongitude", 8.23, bbox.getEastBoundLongitude(), STRICT);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("7400"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -483,9 +478,9 @@ public final strictfp class EPSGFactoryT
assertAxisDirectionsEqual(null, crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("63266405"));
- loggings.assertLoggingContains(0, "EPSG:6405"); // Coordinate System 6405 is no longer supported by EPSG
- loggings.assertLoggingContains(1, "EPSG:63266405", "4326"); // EPSG no longer support codes in the 60000000 series.
- loggings.assertNoUnexpectedLogging(2);
+ 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();
}
/**
@@ -504,10 +499,10 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("Equidistant Cylindrical (Spherical)", 9823, crs.getConversionFromBase().getMethod());
assertAxisDirectionsEqual("EPSG::4499", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
- loggings.assertLoggingContains(0, "EPSG:9823", "1029"); // Operation method 9823 has been replaced by 1029
- loggings.assertLoggingContains(1, "EPSG:19968", "4086"); // Coordinate Operation 19968 has been replaced by 4086
- loggings.assertLoggingContains(2, "EPSG:3786", "4088"); // Coordinate Reference System 3786 has been replaced by 4088
- loggings.assertNoUnexpectedLogging(3);
+ 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);
@@ -518,8 +513,6 @@ public final strictfp class EPSGFactoryT
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("3786"));
assertSame("CRS shall be cached", replacement, factory.createCoordinateReferenceSystem("4088"));
-
- loggings.assertNoUnexpectedLogging(3);
}
/**
@@ -552,7 +545,6 @@ public final strictfp class EPSGFactoryT
// This is the expected exception.
assertEquals("WGS83", e.getAuthorityCode());
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -719,8 +711,6 @@ public final strictfp class EPSGFactoryT
@SuppressWarnings({"unchecked","rawtypes"})
final Class<? extends IdentifiedObject> wrong = (Class) String.class;
assertTrue("Dummy type", factory.getAuthorityCodes(wrong).isEmpty());
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -737,7 +727,6 @@ public final strictfp class EPSGFactoryT
assertEquals("NTF (Paris) / Nord France", factory.getDescriptionText("27591").toString(Locale.US));
assertEquals("NTF (Paris) / France II", factory.getDescriptionText("27582").toString(Locale.US));
assertEquals("Ellipsoidal height", factory.getDescriptionText( "84").toString(Locale.US));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -794,7 +783,6 @@ public final strictfp class EPSGFactoryT
factory.printCacheContent(out);
throw error;
}
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -810,7 +798,6 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (2)", 1764, operation);
assertInstanceOf("EPSG:1764", Transformation.class, operation);
assertSame("Operation shall be cached", operation, factory.createCoordinateOperation("1764"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -828,7 +815,6 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("BD72 to WGS 84 (1)", 1609, operation);
assertEquals(1.0, ((AbstractCoordinateOperation) operation).getLinearAccuracy(), STRICT);
assertSame("Operation shall be cached", operation, factory.createCoordinateOperation("1609"));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -902,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.
}
/**
@@ -949,7 +936,6 @@ public final strictfp class EPSGFactoryT
*/
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
assertSame("The CRS should still in the cache.", found, finder.findSingleton(crs));
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -1004,6 +990,5 @@ public final strictfp class EPSGFactoryT
assertEpsgNameAndIdentifierEqual("Beijing 1954 / 3-degree Gauss-Kruger CM 135E", 2442, it.next());
assertEpsgNameAndIdentifierEqual("Beijing 1954 / Gauss-Kruger CM 135E", 21463, it.next());
assertFalse("Expected no more element.", it.hasNext());
- loggings.assertNoUnexpectedLogging(0);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -39,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;
@@ -73,6 +74,14 @@ public final strictfp class EPSGInstalle
public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
+
+ /**
* Tests the {@link EPSGInstaller#REPLACE_STATEMENT} pattern.
*/
@Test
@@ -96,8 +105,6 @@ public final strictfp class EPSGInstalle
assertTrue(Pattern.matches(EPSGInstaller.REPLACE_STATEMENT,
"UPDATE epsg.\"Coordinate Axis\"\n" +
"SET coord_axis_orientation = replace(coord_axis_orientation, CHR(182), CHR(10))"));
-
- loggings.assertNoUnexpectedLogging(0);
}
/**
@@ -126,8 +133,8 @@ public final strictfp class EPSGInstalle
} finally {
TestDatabase.drop(ds);
}
- loggings.assertLoggingContains(0, "EPSG", "jdbc:derby:memory:test");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("EPSG", "jdbc:derby:memory:test");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -153,8 +160,8 @@ public final strictfp class EPSGInstalle
s.execute("SHUTDOWN");
}
}
- loggings.assertLoggingContains(0, "EPSG", "jdbc:hsqldb:mem:test");
- loggings.assertNoUnexpectedLogging(1);
+ loggings.assertNextLogContains("EPSG", "jdbc:hsqldb:mem:test");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -168,7 +175,7 @@ public final strictfp class EPSGInstalle
assertNull(properties.put("dataSource", ds));
assertNull(properties.put("scriptProvider", scriptProvider));
assertEquals("Should not contain EPSG tables before we created them.", 0, countCRSTables(ds));
- loggings.assertNoUnexpectedLogging(0); // Should not yet have logged anything at this point.
+ loggings.assertNoUnexpectedLog(); // Should not yet have logged anything at this point.
try (EPSGFactory factory = new EPSGFactory(properties)) {
/*
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java [UTF-8] Sat Feb 13 18:57:32 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/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java?rev=1730259&r1=1730258&r2=1730259&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java [UTF-8] Sat Feb 13 18:57:32 2016
@@ -16,8 +16,9 @@
*/
package org.apache.sis.test;
-import java.util.List;
-import java.util.ArrayList;
+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;
@@ -37,19 +38,21 @@ import static org.junit.Assert.*;
* public final LoggingWatcher loggings = new LoggingWatcher(Logging.getLogger(Loggers.XML));
* }
*
- * In every tests that do not expect loggings, invoke the following method last:
+ * Recommended but not mandatory, ensure that there is no unexpected logging in any tests:
*
* {@preformat java
- * loggings.assertNoUnexpectedLogging(0);
+ * @After
+ * public void assertNoUnexpectedLog() {
+ * loggings.assertNoUnexpectedLog();
+ * }
* }
*
- * In tests that are expected to emit warnings, add the following lines
- * (replace 1 by a higher value if more than one logging is expected):
+ * In tests that are expected to emit warnings, add the following lines:
*
* {@preformat java
* // Do the test here.
- * loggings.assertLoggingContains(0, "Some keywords that are expected to be found in the message");
- * loggings.assertNoUnexpectedLogging(1);
+ * loggings.assertNextLogContains("Some keywords", "that are expected", "to be found in the message");
+ * loggings.assertNoUnexpectedLog();
* }
*
* @author Martin Desruisseaux (Geomatys)
@@ -61,7 +64,7 @@ public final strictfp class LoggingWatch
/**
* The logged messages.
*/
- public final List<String> messages = new ArrayList<>();
+ private final Queue<String> messages = new LinkedList<>();
/**
* The logger to watch.
@@ -129,17 +132,38 @@ public final strictfp class LoggingWatch
}
/**
- * Verifies that a logging message exists at the given index and contains the given keywords.
+ * 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 index Index of the logging message to verify.
- * @param keywords The keywords that we are expected to find in the logging message.
+ * @param keywords The keywords that are expected to exist in the next log message.
*/
- public void assertLoggingContains(final int index, final String... keywords) {
- final int size = messages.size();
- if (index >= size) {
- fail("Expected at least " + (index + 1) + " logging messages but got " + size);
+ public void assertNextLogContains(final String... keywords) {
+ if (messages.isEmpty()) {
+ fail("Expected a logging messages but got no more.");
}
- final String message = messages.get(index);
+ 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);
@@ -148,13 +172,19 @@ public final strictfp class LoggingWatch
}
/**
- * Verifies that no more than {@code maxCount} messages have been logged.
- *
- * @param maxCount The maximum number of logging messages.
+ * Verifies that there is no more log message.
*/
- public void assertNoUnexpectedLogging(final int maxCount) {
- if (messages.size() > maxCount) {
- fail("Unexpected logging message: " + messages.get(maxCount));
+ public void assertNoUnexpectedLog() {
+ final String message = messages.peek();
+ if (message != null) {
+ fail("Unexpected logging message: " + message);
}
}
+
+ /**
+ * Discards all logging messages.
+ */
+ public void clear() {
+ messages.clear();
+ }
}
|