This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 54f785e8f6 Tune the log messages: more appropriate logger in
`AbstractProvider`, fix the locale used by WKT store, catch more logs during
the tests. Opportunistically add a link to metadata in Landsat Javadoc.
54f785e8f6 is described below
commit 54f785e8f62796ddb4c5659dc7b87dc0da67ef0b
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Feb 24 12:35:40 2024 +0100
Tune the log messages: more appropriate logger in `AbstractProvider`,
fix the locale used by WKT store, catch more logs during the tests.
Opportunistically add a link to metadata in Landsat Javadoc.
---
.../apache/sis/console/MetadataCommandTest.java | 10 +++++--
.../operation/provider/AbstractProvider.java | 5 ++--
.../test/org/apache/sis/io/wkt/WKTParserTest.java | 34 ++++++++++++++++++++++
.../sis/referencing/EPSGFactoryFallbackTest.java | 14 +++++++--
.../apache/sis/storage/landsat/LandsatStore.java | 2 ++
.../apache/sis/storage/netcdf/NetcdfStoreTest.java | 9 ++++--
.../org/apache/sis/storage/wkt/StoreFormat.java | 2 +-
.../org/apache/sis/storage/folder/StoreTest.java | 9 ++++--
8 files changed, 74 insertions(+), 11 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
index 9fe1d84362..65c9b4725f 100644
---
a/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
+++
b/endorsed/src/org.apache.sis.console/test/org/apache/sis/console/MetadataCommandTest.java
@@ -17,11 +17,12 @@
package org.apache.sis.console;
import java.net.URL;
+import org.apache.sis.system.Loggers;
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestCaseWithLogs;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
import org.opengis.test.dataset.TestData;
@@ -32,11 +33,12 @@ import org.opengis.test.dataset.TestData;
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class MetadataCommandTest extends TestCase {
+public final class MetadataCommandTest extends TestCaseWithLogs {
/**
* Creates a new test case.
*/
public MetadataCommandTest() {
+ super(Loggers.CRS_FACTORY);
}
/**
@@ -50,6 +52,8 @@ public final class MetadataCommandTest extends TestCase {
var test = new MetadataCommand(0, new String[] {CommandRunner.TEST,
url.toString()});
test.run();
verifyNetCDF("Metadata", test.outputBuffer.toString());
+ loggings.skipNextLogIfContains("EPSG:4019"); // Warning
about deprecated EPSG code.
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -74,5 +78,7 @@ public final class MetadataCommandTest extends TestCase {
var test = new MetadataCommand(0, new String[] {CommandRunner.TEST,
url.toString(), "--format", "XML"});
test.run();
verifyNetCDF("<?xml", test.outputBuffer.toString());
+ loggings.skipNextLogIfContains("EPSG:4019"); // Warning
about deprecated EPSG code.
+ loggings.assertNoUnexpectedLog();
}
}
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java
index 9aa1f91739..3240d371a6 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/provider/AbstractProvider.java
@@ -62,9 +62,10 @@ public abstract class AbstractProvider extends
DefaultOperationMethod implements
private static final long serialVersionUID = 1165868434518724597L;
/**
- * The logger for coordinate operations.
+ * The logger for the creation of coordinate operation. The logger name is
{@value Loggers#CRS_FACTORY}
+ * because the logs should be emitted in the context of some {@code
FooFactory.createBar(…)} methods.
*/
- public static final Logger LOGGER =
Logger.getLogger(Loggers.COORDINATE_OPERATION);
+ public static final Logger LOGGER = Logger.getLogger(Loggers.CRS_FACTORY);
/**
* The base interface of the {@code CoordinateOperation} instances that
use this method.
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java
index 84e00b0ce9..3a22d58215 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/WKTParserTest.java
@@ -22,13 +22,16 @@ import org.opengis.referencing.datum.VerticalDatumType;
import org.opengis.util.FactoryException;
import org.apache.sis.metadata.internal.AxisNames;
import org.apache.sis.referencing.factory.GeodeticObjectFactory;
+import org.apache.sis.system.Loggers;
// Test dependencies
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Disabled;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.opengis.test.wkt.CRSParserTest;
+import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.FailureDetailsReporter;
@@ -40,6 +43,12 @@ import org.apache.sis.test.FailureDetailsReporter;
*/
@ExtendWith(FailureDetailsReporter.class)
public final class WKTParserTest extends CRSParserTest {
+ /**
+ * A JUnit extension for listening to log events.
+ */
+ @RegisterExtension
+ public final LoggingWatcher loggings;
+
/**
* Whether the test should replace the curly quotation marks “ and ” by
the straight quotation mark ".
* The ISO 19162 specification uses only straight quotation marks, but SIS
supports both.
@@ -52,6 +61,7 @@ public final class WKTParserTest extends CRSParserTest {
*/
public WKTParserTest() {
super(GeodeticObjectFactory.provider());
+ loggings = new LoggingWatcher(Loggers.WKT);
}
/**
@@ -115,6 +125,7 @@ public final class WKTParserTest extends CRSParserTest {
verifyEllipsoidalCS();
useStraightQuotes = true;
super.testGeographic3D(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -142,6 +153,7 @@ public final class WKTParserTest extends CRSParserTest {
verifyEllipsoidalCS();
useStraightQuotes = true;
super.testGeographicWithUnicode(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -169,6 +181,7 @@ public final class WKTParserTest extends CRSParserTest {
verifyEllipsoidalCS();
useStraightQuotes = true;
super.testGeographicWithIdentifier(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -196,6 +209,7 @@ public final class WKTParserTest extends CRSParserTest {
verifyEllipsoidalCS();
useStraightQuotes = true;
super.testGeographicWithGradUnits(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -232,6 +246,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testGeocentric(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -288,6 +303,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testProjectedWithFootUnits(); // Test again
with “ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -327,6 +343,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testProjectedWithImplicitParameterUnits(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -352,6 +369,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testVertical(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -375,6 +393,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testTemporal(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -400,6 +419,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testParametric(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -428,6 +448,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testEngineering(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -444,6 +465,9 @@ public final class WKTParserTest extends CRSParserTest {
* TIMEEXTENT[“date/time t1”,“date/time t2”]]
* }
*
+ * In current Apache SIS version, this test produces a logs a warning
saying
+ * that the {@code TimeExtent[…]} element is not yet supported.
+ *
* @throws FactoryException if an error occurred during the WKT parsing.
*/
@Test
@@ -453,9 +477,12 @@ public final class WKTParserTest extends CRSParserTest {
final CoordinateSystem cs = object.getCoordinateSystem();
assertEquals("site east", cs.getAxis(0).getName().getCode(), "name");
assertEquals("site north", cs.getAxis(1).getName().getCode(), "name");
+ loggings.assertNextLogContains("A construction site CRS",
"TimeExtent[String,String]");
useStraightQuotes = true;
super.testEngineeringRotated(); // Test again with
“ and ” replaced by ".
+ loggings.assertNextLogContains("A construction site CRS",
"TimeExtent[String,String]");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -490,6 +517,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testEngineeringForShip(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -524,6 +552,7 @@ public final class WKTParserTest extends CRSParserTest {
verifyEllipsoidalCS();
useStraightQuotes = true;
super.testDerivedGeodetic(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -563,6 +592,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testDerivedEngineeringFromGeodetic(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -587,6 +617,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testDerivedEngineeringFromProjected(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -624,6 +655,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testCompoundWithVertical(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -659,6 +691,7 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testCompoundWithTime(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -696,5 +729,6 @@ public final class WKTParserTest extends CRSParserTest {
useStraightQuotes = true;
super.testCompoundWithParametric(); // Test again with
“ and ” replaced by ".
+ loggings.assertNoUnexpectedLog();
}
}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
index e045f53a60..b440fdda89 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
@@ -36,6 +36,7 @@ import org.opengis.referencing.datum.Ellipsoid;
import org.opengis.referencing.datum.PrimeMeridian;
import org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
import org.apache.sis.system.Configuration;
+import org.apache.sis.system.Loggers;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.Utilities;
@@ -43,7 +44,7 @@ import org.apache.sis.util.Utilities;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.parallel.Isolated;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestCaseWithLogs;
import org.apache.sis.test.TestUtilities;
import static org.apache.sis.test.Assertions.assertEqualsIgnoreMetadata;
import static org.apache.sis.test.Assertions.assertSetEquals;
@@ -55,11 +56,12 @@ import static
org.apache.sis.test.Assertions.assertSetEquals;
* @author Martin Desruisseaux (Geomatys)
*/
@Isolated("Temporarily modifies the system-wide EPSG factory.")
-public final class EPSGFactoryFallbackTest extends TestCase {
+public final class EPSGFactoryFallbackTest extends TestCaseWithLogs {
/**
* Creates a new test case.
*/
public EPSGFactoryFallbackTest() {
+ super(Loggers.CRS_FACTORY);
}
/**
@@ -93,6 +95,7 @@ public final class EPSGFactoryFallbackTest extends TestCase {
final Set<String> codes =
EPSGFactoryFallback.INSTANCE.getAuthorityCodes(ProjectedCRS.class);
assertTrue(codes.containsAll(List.of("5041", "5042", "32601", "32660",
"32701", "32760")));
assertTrue(Collections.disjoint(codes, List.of("7030", "6326", "4326",
"4978", "32600", "32700", "5714")));
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -103,6 +106,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
@Test
public void testCreatePrimeMeridian() throws FactoryException {
verifyCreatePrimeMeridian(CommonCRS.WGS84.primeMeridian(),
StandardDefinitions.GREENWICH);
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -118,6 +122,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
verifyCreateEllipsoid(CommonCRS.NAD27 .ellipsoid(), "7008");
verifyCreateEllipsoid(CommonCRS.ED50 .ellipsoid(), "7022");
verifyCreateEllipsoid(CommonCRS.SPHERE.ellipsoid(), "7048");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -133,6 +138,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
verifyCreateDatum(CommonCRS.NAD27 .datum(), "6267");
verifyCreateDatum(CommonCRS.ED50 .datum(), "6230");
verifyCreateDatum(CommonCRS.SPHERE.datum(), "6047");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -145,6 +151,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
verifyCreateCS(CommonCRS.DEFAULT.geographic(), "6422");
verifyCreateCS(CommonCRS.DEFAULT.geographic3D(), "6423");
verifyCreateCS(CommonCRS.DEFAULT.spherical(), "6404");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -176,6 +183,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
verifyCreateCRS(CommonCRS.WGS84 .universal( 40, 14), "32633");
verifyCreateCRS(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "5714");
verifyCreateCRS(CommonCRS.Vertical.DEPTH.crs(), "5715");
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -254,5 +262,7 @@ public final class EPSGFactoryFallbackTest extends TestCase
{
} finally {
setEPSGFactory(EPSG);
}
+ loggings.skipNextLogIfContains("EPSG:4019"); // Deprecated EPSG
entry.
+ loggings.assertNoUnexpectedLog();
}
}
diff --git
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
index 74ab128a7d..7b3a786340 100644
---
a/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
+++
b/endorsed/src/org.apache.sis.storage.earthobservation/main/org/apache/sis/storage/landsat/LandsatStore.java
@@ -252,6 +252,8 @@ public class LandsatStore extends DataStore implements
Aggregate {
*
* @return information about the dataset.
* @throws DataStoreException if an error occurred while reading the
metadata.
+ *
+ * @see <a href="doc-files/MetadataMapping.html">Mapping from Landsat to
ISO 19115 metadata</a>
*/
@Override
public synchronized Metadata getMetadata() throws DataStoreException {
diff --git
a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
index aa9c5ac188..540ec9a3a9 100644
---
a/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
+++
b/endorsed/src/org.apache.sis.storage.netcdf/test/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
@@ -19,12 +19,13 @@ package org.apache.sis.storage.netcdf;
import org.opengis.metadata.Metadata;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.system.Loggers;
import org.apache.sis.util.Version;
// Test dependencies
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestCaseWithLogs;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
import org.opengis.test.dataset.TestData;
@@ -35,11 +36,12 @@ import org.opengis.test.dataset.TestData;
*
* @author Martin Desruisseaux (Geomatys)
*/
-public final class NetcdfStoreTest extends TestCase {
+public final class NetcdfStoreTest extends TestCaseWithLogs {
/**
* Creates a new test case.
*/
public NetcdfStoreTest() {
+ super(Loggers.CRS_FACTORY);
}
/**
@@ -65,6 +67,8 @@ public final class NetcdfStoreTest extends TestCase {
assertSame(metadata, store.getMetadata(), "Should be cached.");
}
MetadataReaderTest.compareToExpected(metadata).assertMetadataEquals();
+ loggings.skipNextLogIfContains("EPSG:4019"); // Deprecated EPSG
code.
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -80,5 +84,6 @@ public final class NetcdfStoreTest extends TestCase {
}
assertEquals(1, version.getMajor());
assertEquals(4, version.getMinor());
+ loggings.assertNoUnexpectedLog();
}
}
diff --git
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java
index 8220a5e57b..5f420045f6 100644
---
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java
+++
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/wkt/StoreFormat.java
@@ -147,7 +147,7 @@ public final class StoreFormat extends WKTFormat {
}
if (parsed instanceof CoordinateReferenceSystem) try {
final DefinitionVerifier v = DefinitionVerifier.withAuthority(
- (CoordinateReferenceSystem) parsed, null, false,
getLocale());
+ (CoordinateReferenceSystem) parsed, null, false,
listeners.getLocale());
if (v != null) {
final LogRecord record = v.warning(false);
if (record != null) {
diff --git
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
index ccd89be0dd..263304b846 100644
---
a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
+++
b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/folder/StoreTest.java
@@ -35,7 +35,7 @@ import org.apache.sis.storage.StorageConnector;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
-import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestCaseWithLogs;
/**
@@ -44,11 +44,12 @@ import org.apache.sis.test.TestCase;
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
*/
-public final class StoreTest extends TestCase {
+public final class StoreTest extends TestCaseWithLogs {
/**
* Creates a new test case.
*/
public StoreTest() {
+ super("ucar.nc2.NetcdfFile");
}
/**
@@ -81,6 +82,9 @@ public final class StoreTest extends TestCase {
if (!identifiers.isEmpty()) {
fail("Missing resources: " + identifiers);
}
+ loggings.skipNextLogIfContains("ucar.unidata");
+ loggings.skipNextLogIfContains("ucar.unidata"); // Logs emitted by
UCAR. There is two files to skip.
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -104,6 +108,7 @@ public final class StoreTest extends TestCase {
if (!identifiers.isEmpty()) {
fail("Missing resources: " + identifiers);
}
+ loggings.assertNoUnexpectedLog();
}
/**