From 19f02c350d07e9ebe1d3ed6d73f1801d10e78664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Prante?= Date: Tue, 24 Jan 2023 17:36:39 +0100 Subject: [PATCH] add logging.properties --- gradle/test/junit5.gradle | 22 +++++++++++++-- .../org/xbib/oai/client/DNBClientTest.java | 28 +++++++++++-------- .../src/test/resources/logging.properties | 11 ++++++++ 3 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 oai-client/src/test/resources/logging.properties diff --git a/gradle/test/junit5.gradle b/gradle/test/junit5.gradle index 81b99a6..21a428b 100644 --- a/gradle/test/junit5.gradle +++ b/gradle/test/junit5.gradle @@ -7,9 +7,28 @@ dependencies { test { useJUnitPlatform() - failFast = true + failFast = false + ignoreFailures = true + jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED', + '--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED', + '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED', + '--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED', + '--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED', + '--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED', + '--add-opens=java.base/java.lang=ALL-UNNAMED', + '--add-opens=java.base/java.lang.reflect=ALL-UNNAMED', + '--add-opens=java.base/java.io=ALL-UNNAMED', + '--add-opens=java.base/java.nio=ALL-UNNAMED', + '--add-opens=java.base/java.util=ALL-UNNAMED' + systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties' + systemProperty 'io.netty.tryReflectionSetAccessible', 'true' testLogging { events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED' + showStandardStreams = true + } + reports { + html.required = false + junitXml.outputLocation.set(layout.buildDirectory.dir("test-junit-xml")) } afterSuite { desc, result -> if (!desc.parent) { @@ -20,5 +39,4 @@ test { "${result.skippedTestCount} skipped" } } - jvmArgs '-Xmx2048m' } diff --git a/oai-client/src/test/java/org/xbib/oai/client/DNBClientTest.java b/oai-client/src/test/java/org/xbib/oai/client/DNBClientTest.java index daa6924..ede402a 100644 --- a/oai-client/src/test/java/org/xbib/oai/client/DNBClientTest.java +++ b/oai-client/src/test/java/org/xbib/oai/client/DNBClientTest.java @@ -32,17 +32,23 @@ class DNBClientTest { @Test void testBibdatSimpleMetadataHandler() throws Exception { OAIClient oaiClient = new OAIClient("http://services.dnb.de/oai/repository"); - IdentifyResponse identifyResponse = oaiClient.identify(); - String granularity = identifyResponse.getGranularity(); - logger.log(Level.INFO, "granularity = " + granularity); - DateTimeFormatter dateTimeFormatter = "YYYY-MM-DD".equals(granularity) ? - DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")) : null; - Handler handler = new Handler(); - oaiClient.listRecords("PicaPlus-xml", "bib", - dateTimeFormatter, Instant.parse("2016-01-01T00:00:00Z"), Instant.parse("2016-01-10T00:00:00Z"), null, - handler, null); - logger.log(Level.INFO, "count=" + handler.count()); - assertTrue(handler.count() > 0); + oaiClient.setUserAgent("Hochschulbibliothekszentrum Nordrhein-Westfalen (prante@hbz-nrw.de)"); + Instant base = Instant.parse("2010-01-01T00:00:00Z"); + + //IdentifyResponse identifyResponse = oaiClient.identify(); + //String granularity = identifyResponse.getGranularity(); + //logger.log(Level.INFO, "granularity = " + granularity); + //DateTimeFormatter dateTimeFormatter = "YYYY-MM-DD".equals(granularity) ? + // DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")) : null; + SplitWriter splitWriter = new SplitWriter("build/bibdat-test-%d.xml", -1, 8192, false); + oaiClient.setSplitWriter(splitWriter); + // Handler handler = new Handler(); + oaiClient.listRecords("PicaPlus-xml", "bib", null, + Instant.parse("2016-01-01T00:00:00Z"), + Instant.parse("2016-02-01T00:00:00Z"), + base, null, null); + //logger.log(Level.INFO, "count=" + handler.count()); + //assertTrue(handler.count() > 0); } static class Handler extends SimpleMetadataHandler { diff --git a/oai-client/src/test/resources/logging.properties b/oai-client/src/test/resources/logging.properties new file mode 100644 index 0000000..e1e91de --- /dev/null +++ b/oai-client/src/test/resources/logging.properties @@ -0,0 +1,11 @@ +handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler +.level=ALL +java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n +java.util.logging.ConsoleHandler.level=ALL +java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter +java.util.logging.FileHandler.level=ALL +java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter +java.util.logging.FileHandler.pattern=build/oai.log +jdk.event.security.level=INFO +jdk.internal.httpclient.hpack.debug.level=INFO +jdk.internal.httpclient.debug.level=INFO