From 03df23e89cbf03382930a5a2a1bd47c217eda928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Fri, 15 Mar 2019 14:32:29 +0100 Subject: [PATCH] fixes for tests and logging --- build.gradle | 3 +-- .../test/java/org/xbib/z3950/client/test}/SearchTest.java | 7 ++++--- z3950-client/src/test/resources/logging.properties | 5 +++++ .../src/test/java/org/xbib/z3950/common/Bib1Test.java | 7 +++++-- .../src/test/java/org/xbib/z3950/common/ParserTest.java | 2 +- .../test/java/org/xbib/z3950/common/cql/CQL2RPNTest.java | 1 - .../test/java/org/xbib/z3950/common/pqf/PQFParserTest.java | 2 +- z3950-common/src/test/resources/logging.properties | 5 +++++ 8 files changed, 22 insertions(+), 10 deletions(-) rename {z3950-common/src/test/java/org/xbib/z3950/common => z3950-client/src/test/java/org/xbib/z3950/client/test}/SearchTest.java (91%) create mode 100644 z3950-client/src/test/resources/logging.properties create mode 100644 z3950-common/src/test/resources/logging.properties diff --git a/build.gradle b/build.gradle index 9675ec2..7d917c5 100644 --- a/build.gradle +++ b/build.gradle @@ -25,8 +25,7 @@ subprojects { apply plugin: 'checkstyle' apply plugin: 'pmd' apply plugin: "com.github.spotbugs" - - + configurations { wagon } diff --git a/z3950-common/src/test/java/org/xbib/z3950/common/SearchTest.java b/z3950-client/src/test/java/org/xbib/z3950/client/test/SearchTest.java similarity index 91% rename from z3950-common/src/test/java/org/xbib/z3950/common/SearchTest.java rename to z3950-client/src/test/java/org/xbib/z3950/client/test/SearchTest.java index 57cd917..181848c 100644 --- a/z3950-common/src/test/java/org/xbib/z3950/common/SearchTest.java +++ b/z3950-client/src/test/java/org/xbib/z3950/client/test/SearchTest.java @@ -1,9 +1,9 @@ -package org.xbib.z3950.common; +package org.xbib.z3950.client.test; import org.junit.Test; import org.xbib.z3950.common.exceptions.MessageSizeTooSmallException; import org.xbib.z3950.common.exceptions.NoRecordsReturnedException; -import org.xbib.z3950.common.DefaultClient; +import org.xbib.z3950.client.DefaultClient; import java.util.Collections; import java.util.logging.Level; @@ -22,7 +22,8 @@ public class SearchTest { int port = 210; String database = "COPAC"; String query = "@attr 1=1 smith"; - String preferredRecordSyntax = "1.2.840.10003.5.109.10"; // xml // "1.2.840.10003.5.10"; // MARC + // "1.2.840.10003.5.10"; // MARC + String preferredRecordSyntax = "1.2.840.10003.5.109.10"; // xml int from = 1; int length = 1; try { diff --git a/z3950-client/src/test/resources/logging.properties b/z3950-client/src/test/resources/logging.properties new file mode 100644 index 0000000..00dad08 --- /dev/null +++ b/z3950-client/src/test/resources/logging.properties @@ -0,0 +1,5 @@ +handlers = java.util.logging.ConsoleHandler +.level = ALL +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.SimpleFormatter.format = %1$tFT%1$tT.%1$tL%1$tz [%4$-11s] [%3$s] %5$s %6$s%n diff --git a/z3950-common/src/test/java/org/xbib/z3950/common/Bib1Test.java b/z3950-common/src/test/java/org/xbib/z3950/common/Bib1Test.java index 50b1867..54e31b8 100644 --- a/z3950-common/src/test/java/org/xbib/z3950/common/Bib1Test.java +++ b/z3950-common/src/test/java/org/xbib/z3950/common/Bib1Test.java @@ -5,22 +5,25 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.ResourceBundle; +import java.util.logging.Logger; /** * */ public class Bib1Test { + private static final Logger logger = Logger.getLogger(Bib1Test.class.getName()); + @Test public void testBibUse() { - ResourceBundle bundle = ResourceBundle.getBundle("org.xbib.io.iso23950.bib-1"); + ResourceBundle bundle = ResourceBundle.getBundle("org.xbib.z3950.common.bib-1"); ArrayList values = new ArrayList<>(); for (String key : bundle.keySet()) { values.add(bundle.getString(key) + "=" + key); } Collections.sort(values); for (Object v : values) { - //logger.info(v.toString()); + logger.info(v.toString()); } } } diff --git a/z3950-common/src/test/java/org/xbib/z3950/common/ParserTest.java b/z3950-common/src/test/java/org/xbib/z3950/common/ParserTest.java index 978e8dc..280e0c4 100644 --- a/z3950-common/src/test/java/org/xbib/z3950/common/ParserTest.java +++ b/z3950-common/src/test/java/org/xbib/z3950/common/ParserTest.java @@ -25,7 +25,7 @@ public abstract class ParserTest extends Assert { protected Iterable readFromResource(String path) throws IOException { final ArrayList lines = new ArrayList<>(); - InputStream in = getClass().getClassLoader().getResourceAsStream(path); + InputStream in = getClass().getResourceAsStream(path); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; while ((line = br.readLine()) != null) { diff --git a/z3950-common/src/test/java/org/xbib/z3950/common/cql/CQL2RPNTest.java b/z3950-common/src/test/java/org/xbib/z3950/common/cql/CQL2RPNTest.java index 968b511..2f50c4c 100644 --- a/z3950-common/src/test/java/org/xbib/z3950/common/cql/CQL2RPNTest.java +++ b/z3950-common/src/test/java/org/xbib/z3950/common/cql/CQL2RPNTest.java @@ -2,7 +2,6 @@ package org.xbib.z3950.common.cql; import org.junit.Test; import org.xbib.cql.CQLParser; -import org.xbib.z3950.common.cql.CQLRPNGenerator; /** * diff --git a/z3950-common/src/test/java/org/xbib/z3950/common/pqf/PQFParserTest.java b/z3950-common/src/test/java/org/xbib/z3950/common/pqf/PQFParserTest.java index 81f9ef4..66e64c2 100644 --- a/z3950-common/src/test/java/org/xbib/z3950/common/pqf/PQFParserTest.java +++ b/z3950-common/src/test/java/org/xbib/z3950/common/pqf/PQFParserTest.java @@ -19,7 +19,7 @@ public class PQFParserTest extends ParserTest { public void testSucceed() throws SyntaxException, IOException { int ok = 0; int errors = 0; - for (String q : readFromResource("org/xbib/io/iso23950/pqf/pqf-must-succeed")) { + for (String q : readFromResource("pqf-must-succeed")) { PQFParser parser = new PQFParser(new StringReader(q)); try { parser.parse(); diff --git a/z3950-common/src/test/resources/logging.properties b/z3950-common/src/test/resources/logging.properties new file mode 100644 index 0000000..00dad08 --- /dev/null +++ b/z3950-common/src/test/resources/logging.properties @@ -0,0 +1,5 @@ +handlers = java.util.logging.ConsoleHandler +.level = ALL +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.SimpleFormatter.format = %1$tFT%1$tT.%1$tL%1$tz [%4$-11s] [%3$s] %5$s %6$s%n