[Git][java-team/libmarc4j-java][master] 8 commits: New upstream version 2.9.5
Markus Koschany (@apo)
gitlab at salsa.debian.org
Mon Sep 11 13:24:09 BST 2023
Markus Koschany pushed to branch master at Debian Java Maintainers / libmarc4j-java
Commits:
fe6838e3 by Markus Koschany at 2023-09-11T13:55:00+02:00
New upstream version 2.9.5
- - - - -
d24ad712 by Markus Koschany at 2023-09-11T13:55:02+02:00
Update upstream source from tag 'upstream/2.9.5'
Update to upstream version '2.9.5'
with Debian dir b916cb981adcd0ba532769d5063429dd9e29ec80
- - - - -
181c0246 by Markus Koschany at 2023-09-11T13:55:57+02:00
Declare compliance with Debian Policy 4.6.2.
- - - - -
b26529c6 by Markus Koschany at 2023-09-11T13:56:15+02:00
Update copyright years
- - - - -
f24861c4 by Markus Koschany at 2023-09-11T13:56:50+02:00
Mark binary package Multi-Arch: foreign.
- - - - -
1d13de60 by Markus Koschany at 2023-09-11T13:57:40+02:00
Refresh build.patch
- - - - -
e5f0cc7e by Markus Koschany at 2023-09-11T13:58:10+02:00
Update changelog
- - - - -
a1ce1f4a by Markus Koschany at 2023-09-11T14:08:34+02:00
Override source-is-missing tag and explain why
- - - - -
18 changed files:
- build.xml
- debian/changelog
- debian/control
- debian/copyright
- debian/patches/build.patch
- + debian/source/lintian-overrides
- src/org/marc4j/MarcJsonWriter.java
- src/org/marc4j/MarcPermissiveStreamReader.java
- src/org/marc4j/MarcStreamReader.java
- + src/org/marc4j/callnum/NlmCallNumber.java
- + src/org/marc4j/util/Encoding.java
- src/org/marc4j/util/RecordIODriver.java
- + test/org/marc4j/callnum/NlmCallNumberTest.java
- test/src/org/marc4j/test/PermissiveReaderTest.java
- test/src/org/marc4j/test/RecordTest.java
- test/src/org/marc4j/test/utils/RecordTestingUtils.java
- test/src/org/marc4j/test/utils/TestUtils.java
- + test/src/org/marc4j/util/EncodingTest.java
Changes:
=====================================
build.xml
=====================================
@@ -281,8 +281,7 @@
<arg value="--detach-sign" />
<arg value="${jar.name}" />
</exec>
- <exec executable="C:/Program Files (x86)/GNU/GnuPG/pub/gpg" dir="${dist.dir}" searchpath="true" >
- <env key="PATH" path="C:/Program Files (x86)/GNU/GnuPG/pub" />
+ <exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
@@ -290,8 +289,7 @@
<arg value="--detach-sign" />
<arg value="${jar.sources.name}" />
</exec>
- <exec executable="C:/Program Files (x86)/GNU/GnuPG/pub/gpg" dir="${dist.dir}" searchpath="true" >
- <env key="PATH" path="C:/Program Files (x86)/GNU/GnuPG/pub" />
+ <exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
@@ -299,8 +297,7 @@
<arg value="--detach-sign" />
<arg value="${jar.javadoc.name}" />
</exec>
- <exec executable="C:/Program Files (x86)/GNU/GnuPG/pub/gpg" dir="${dist.dir}" searchpath="true" >
- <env key="PATH" path="C:/Program Files (x86)/GNU/GnuPG/pub" />
+ <exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+libmarc4j-java (2.9.5-1) unstable; urgency=medium
+
+ * New upstream version 2.9.5.
+ * Declare compliance with Debian Policy 4.6.2.
+ * Mark binary package Multi-Arch: foreign.
+ * Refresh build.patch.
+
+ -- Markus Koschany <apo at debian.org> Mon, 11 Sep 2023 13:57:52 +0200
+
libmarc4j-java (2.9.2-1) unstable; urgency=medium
* New upstream version 2.9.2.
=====================================
debian/control
=====================================
@@ -10,12 +10,13 @@ Build-Depends:
default-jdk,
maven-repo-helper,
javahelper
-Standards-Version: 4.6.0
+Standards-Version: 4.6.2
Vcs-Git: https://salsa.debian.org/java-team/libmarc4j-java.git
Vcs-Browser: https://salsa.debian.org/java-team/libmarc4j-java
Homepage: https://github.com/marc4j/marc4j
Package: libmarc4j-java
+Multi-Arch: foreign
Architecture: all
Depends:
${java:Depends},
=====================================
debian/copyright
=====================================
@@ -11,7 +11,7 @@ Copyright: Robert Haschart, Simon Spero, Kevin S. Clarke, Jonathan Rochkind,
License: LGPL-2.1+
Files: debian/*
-Copyright: 2021-2022, Markus Koschany <apo at debian.org>
+Copyright: 2021-2023, Markus Koschany <apo at debian.org>
License: LGPL-2.1+
License: LGPL-2.1+
=====================================
debian/patches/build.patch
=====================================
@@ -7,8 +7,6 @@ Forwarded: not-needed
build.xml | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
-diff --git a/build.xml b/build.xml
-index c91738f..683eac9 100644
--- a/build.xml
+++ b/build.xml
@@ -12,13 +12,12 @@
@@ -35,7 +33,7 @@ index c91738f..683eac9 100644
<attribute name="Specification-Vendor" value="org.marc4j"/>
<attribute name="Implementation-Title" value="marc4j"/>
-@@ -422,19 +421,15 @@
+@@ -419,19 +418,15 @@
</condition>
</target>
=====================================
debian/source/lintian-overrides
=====================================
@@ -0,0 +1,2 @@
+# Documentation files, not relevant for building libmarc4j-java from source
+source-is-missing
=====================================
src/org/marc4j/MarcJsonWriter.java
=====================================
@@ -3,7 +3,7 @@ package org.marc4j;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import org.marc4j.converter.CharConverter;
@@ -23,7 +23,7 @@ public class MarcJsonWriter implements MarcWriter {
*/
private CharConverter converter = null;
- private OutputStream os = null;
+ private final OutputStream os;
private int useJsonFormat = MARC_IN_JSON;
@@ -81,6 +81,7 @@ public class MarcJsonWriter implements MarcWriter {
* @param jsonFormat - whether to use the MARC_IN_JSON format (default) or the MARC_JSON format (1)
*/
public MarcJsonWriter(final OutputStream os, final CharConverter conv, final int jsonFormat) {
+ this.os = os;
setConverter(conv);
useJsonFormat = jsonFormat;
@@ -107,7 +108,7 @@ public class MarcJsonWriter implements MarcWriter {
indent(buf, "\n ");
- buf.append(ql + "leader" + ql + ":\"").append(record.getLeader().toString()).append("\",");
+ buf.append(ql + "leader" + ql + ":\"").append(unicodeEscape(record.getLeader().toString())).append("\",");
indent(buf, "\n ");
@@ -125,8 +126,10 @@ public class MarcJsonWriter implements MarcWriter {
firstField = false;
}
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if (!cf.getTag().matches("[A-Z0-9][A-Z0-9][A-Z0-9]")) {
+ throw new MarcException("Invalid tag: " + cf.getTag());
}
buf.append("{ " + ql + "tag" + ql + " : \"" + cf.getTag() + "\", " + ql + "data" + ql + " : ")
@@ -153,28 +156,26 @@ public class MarcJsonWriter implements MarcWriter {
firstField = false;
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("{");
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if (!df.getTag().matches("[A-Z0-9][A-Z0-9][A-Z0-9]")) {
+ throw new MarcException("Invalid tag: " + df.getTag());
}
- buf.append(ql + "tag" + ql + " : \"" + df.getTag() + "\", " + ql + "ind" + ql + " : \"" +
- df.getIndicator1() + df.getIndicator2() + "\",");
+ buf.append(ql + "tag" + ql + " : \"" + df.getTag() + "\", " + ql + "ind" + ql + " : \"");
+ unicodeEscape(buf, df.getIndicator1());
+ unicodeEscape(buf, df.getIndicator2());
+ buf.append("\",");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append(ql + "subfield" + ql + " :");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("[");
boolean firstSubfield = true;
@@ -186,23 +187,21 @@ public class MarcJsonWriter implements MarcWriter {
firstSubfield = false;
}
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if ((sf.getCode() < 'a' || 'z' < sf.getCode()) && (sf.getCode() < '0' || '9' < sf.getCode())) {
+ throw new MarcException("Invalid code: " + sf.getCode());
}
buf.append("{ " + ql + "code" + ql + " : \"" + sf.getCode() + "\", " + ql + "data" + ql + " : \"" +
unicodeEscape(sf.getData()) + "\" }");
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("]");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("}");
}
@@ -229,15 +228,15 @@ public class MarcJsonWriter implements MarcWriter {
final StringBuffer buf = new StringBuffer();
buf.append("{");
- indent(buf, "\n ");;
+ indent(buf, "\n ");
- buf.append(ql + "leader" + ql + ":\"").append(record.getLeader().toString()).append("\",");
+ buf.append(ql + "leader" + ql + ":\"").append(unicodeEscape(record.getLeader().toString())).append("\",");
- indent(buf, "\n ");;
+ indent(buf, "\n ");
buf.append(ql + "fields" + ql + ":");
- indent(buf, "\n ");;
+ indent(buf, "\n ");
buf.append("[");
boolean firstField = true;
@@ -249,21 +248,19 @@ public class MarcJsonWriter implements MarcWriter {
firstField = false;
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("{");
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if (!cf.getTag().matches("[A-Z0-9][A-Z0-9][A-Z0-9]")) {
+ throw new MarcException("Invalid tag: " + cf.getTag());
}
buf.append(ql + cf.getTag() + ql + ":").append("\"" + unicodeEscape(cf.getData()) + "\"");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("}");
}
@@ -275,29 +272,25 @@ public class MarcJsonWriter implements MarcWriter {
firstField = false;
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("{");
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if (!df.getTag().matches("[A-Z0-9][A-Z0-9][A-Z0-9]")) {
+ throw new MarcException("Invalid tag: " + df.getTag());
}
buf.append(ql + df.getTag() + ql + ":");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("{");
- // if (indent) buf.append("\n ");
+
buf.append(ql + "subfields" + ql + ":");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("[");
boolean firstSubfield = true;
@@ -309,61 +302,53 @@ public class MarcJsonWriter implements MarcWriter {
firstSubfield = false;
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("{");
- if (indent) {
- buf.append("\n ");
+ indent(buf, "\n ");
+
+ if ((sf.getCode() < 'a' || 'z' < sf.getCode()) && (sf.getCode() < '0' || '9' < sf.getCode())) {
+ throw new MarcException("Invalid code: " + sf.getCode());
}
buf.append(ql + sf.getCode() + ql + ":\"" + unicodeEscape(sf.getData()) + "\"");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("}");
}
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("],");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
- buf.append(ql + "ind1" + ql + ":\"" + df.getIndicator1() + "\",");
+ buf.append(ql + "ind1" + ql + ":\"");
+ unicodeEscape(buf, df.getIndicator1());
+ buf.append("\",");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
- buf.append(ql + "ind2" + ql + ":\"" + df.getIndicator2() + "\"");
+ buf.append(ql + "ind2" + ql + ":\"");
+ unicodeEscape(buf, df.getIndicator2());
+ buf.append("\"");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("}");
- if (indent) {
- buf.append("\n ");
- }
+ indent(buf, "\n ");
buf.append("}");
}
- indent(buf, "\n ");;
+ indent(buf, "\n ");
buf.append("]");
- indent(buf, "\n");;
+ indent(buf, "\n");
buf.append("}\n");
@@ -383,49 +368,50 @@ public class MarcJsonWriter implements MarcWriter {
for (int i = 0; i < data.length(); i++) {
final char c = data.charAt(i);
- switch (c) {
- case '/': {
- if (escapeSlash) {
- buffer.append("\\/");
- } else {
- buffer.append("/");
- }
+ unicodeEscape(buffer, c);
+ }
+ return buffer.toString();
+ }
+
+ private void unicodeEscape(StringBuffer buffer, char c) {
+ switch (c) {
+ case '/':
+ if (escapeSlash) {
+ buffer.append("\\/");
+ } else {
+ buffer.append("/");
}
- break;
- case '"':
- buffer.append("\\\"");
- break;
- case '\\':
- buffer.append("\\\\");
- break;
- case '\b':
- buffer.append("\\b");
- break;
- case '\f':
- buffer.append("\\f");
- break;
- case '\n':
- buffer.append("\\n");
- break;
- case '\r':
- buffer.append("\\r");
- break;
- case '\t':
- buffer.append("\\t");
- break;
- default: {
- if (c > 0xff || c < 0x1f) {
- final String val = "0000" + Integer.toHexString(c);
- buffer.append("\\u" + val.substring(val.length() - 4, val.length()));
- } else {
- buffer.append(c);
- }
-
- break;
+ break;
+ case '"':
+ buffer.append("\\\"");
+ break;
+ case '\\':
+ buffer.append("\\\\");
+ break;
+ case '\b':
+ buffer.append("\\b");
+ break;
+ case '\f':
+ buffer.append("\\f");
+ break;
+ case '\n':
+ buffer.append("\\n");
+ break;
+ case '\r':
+ buffer.append("\\r");
+ break;
+ case '\t':
+ buffer.append("\\t");
+ break;
+ default:
+ if (c > 0xff || c <= 0x1f) {
+ final String val = "0000" + Integer.toHexString(c);
+ buffer.append("\\u" + val.substring(val.length() - 4));
+ } else {
+ buffer.append(c);
}
- }
+ break;
}
- return (buffer.toString());
}
/**
@@ -480,11 +466,8 @@ public class MarcJsonWriter implements MarcWriter {
}
try {
- os.write(recordAsJson.getBytes("UTF-8"));
+ os.write(recordAsJson.getBytes(StandardCharsets.UTF_8));
os.flush();
- } catch (final UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
} catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
=====================================
src/org/marc4j/MarcPermissiveStreamReader.java
=====================================
@@ -721,7 +721,7 @@ public class MarcPermissiveStreamReader implements MarcReader, ConverterErrorHan
boolean doneWithDirectory = false;
int totalOffset = 0;
int offset = 0;
- for (int i = 0; !doneWithDirectory; i++) {
+ for (int i = 0; offset + 14 < recordBuf.length && !doneWithDirectory; i++) {
final int increment = 12;
final int prevOffset = offset;
final String dirEntry = new String(recordBuf, offsetToFT, 14);
@@ -831,6 +831,9 @@ public class MarcPermissiveStreamReader implements MarcReader, ConverterErrorHan
record.addError("n/a", "n/a", MarcError.MINOR_ERROR,
"Specified directory length not equal to actual directory length.");
}
+ if (size == 0) {
+ record.addError("n/a", "n/a", MarcError.MAJOR_ERROR, "Record comtains no directory or fields");
+ }
if (unsortedOffsets) {
Collections.sort(offsets);
=====================================
src/org/marc4j/MarcStreamReader.java
=====================================
@@ -40,6 +40,7 @@ import org.marc4j.marc.MarcFactory;
import org.marc4j.marc.Record;
import org.marc4j.marc.Subfield;
import org.marc4j.marc.impl.Verifier;
+import org.marc4j.util.Encoding;
/**
* An iterator over a collection of MARC records in ISO 2709 format.
@@ -78,7 +79,7 @@ public class MarcStreamReader implements MarcReader {
private final MarcFactory factory;
- private String encoding = "ISO8859_1";
+ private Encoding encoding = Encoding.ISO8859_1;
private boolean override = false;
@@ -103,8 +104,11 @@ public class MarcStreamReader implements MarcReader {
this.input = new DataInputStream(input.markSupported() ? input : new BufferedInputStream(input));
factory = MarcFactory.newInstance();
if (encoding != null) {
- this.encoding = encoding;
- override = true;
+ Encoding candidate = Encoding.get(encoding);
+ if (candidate != null) {
+ this.encoding = candidate;
+ override = true;
+ }
}
}
@@ -174,12 +178,12 @@ public class MarcStreamReader implements MarcReader {
switch (ldr.getCharCodingScheme()) {
case ' ':
if (!override) {
- encoding = "ISO-8859-1";
+ encoding = Encoding.ISO8859_1;
}
break;
case 'a':
if (!override) {
- encoding = "UTF8";
+ encoding = Encoding.UTF8;
}
}
@@ -402,26 +406,20 @@ public class MarcStreamReader implements MarcReader {
private String getDataAsString(final byte[] bytes) {
String dataElement = null;
- if (encoding.equals("UTF-8") || encoding.equals("UTF8")) {
+ if (encoding.equals(Encoding.UTF8) || encoding.equals(Encoding.ISO8859_1)) {
try {
- dataElement = new String(bytes, "UTF8");
+ dataElement = new String(bytes, encoding.getStandardName());
} catch (final UnsupportedEncodingException e) {
throw new MarcException("unsupported encoding", e);
}
- } else if (encoding.equals("MARC-8") || encoding.equals("MARC8")) {
+ } else if (encoding.equals(Encoding.MARC8)) {
if (converterAnsel == null) {
converterAnsel = new AnselToUnicode();
}
dataElement = converterAnsel.convert(bytes);
- } else if (encoding.equals("ISO-8859-1") || encoding.equals("ISO8859_1") || encoding.equals("ISO_8859_1")) {
- try {
- dataElement = new String(bytes, "ISO-8859-1");
- } catch (final UnsupportedEncodingException e) {
- throw new MarcException("unsupported encoding", e);
- }
} else if (override) {
try {
- dataElement = new String(bytes, encoding);
+ dataElement = new String(bytes, encoding.getStandardName());
} catch (final UnsupportedEncodingException e) {
throw new MarcException("unsupported encoding", e);
}
=====================================
src/org/marc4j/callnum/NlmCallNumber.java
=====================================
@@ -0,0 +1,40 @@
+package org.marc4j.callnum;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Parses and computes sort keys for National Library of Medicine call numbers.
+ * This class uses the same logic for computing sort keys as {@link LCCallNumber}
+ * but it has changes {@link #isValid()} method.NLM call numbers utilizes schedules QS-QZ and W-WZ
+ */
+public class NlmCallNumber extends LCCallNumber {
+
+ public NlmCallNumber(String rawCallNumber) {
+ super(rawCallNumber);
+ }
+
+ @Override
+ public boolean isValid() {
+ if (this.classLetters == null || this.classLetters.length() < 2 || this.classDigits == null) {
+ return false;
+ } else {
+ char firstChar = this.classLetters.charAt(0);
+ char secondChar = this.classLetters.charAt(1);
+ return firstChar == 'W' || (firstChar == 'Q' && (secondChar >= 'S' && secondChar <= 'Z'));
+ }
+ }
+}
=====================================
src/org/marc4j/util/Encoding.java
=====================================
@@ -0,0 +1,35 @@
+package org.marc4j.util;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum Encoding {
+ UTF8("UTF-8", "UTF8"),
+ MARC8("MARC-8", "MARC8"),
+ ISO8859_1("ISO-8859-1", "ISO8859_1", "ISO_8859_1")
+ ;
+
+ String standardName;
+ List<String> names;
+
+ Encoding(String... names) {
+ this.standardName = names[0];
+ this.names = Arrays.asList(names);
+ }
+
+ public static Encoding get(String encodingName) {
+ for (Encoding encoding : values())
+ for (String name : encoding.names)
+ if (name.equals(encodingName))
+ return encoding;
+ return null;
+ }
+
+ public String getStandardName() {
+ return standardName;
+ }
+
+ public List<String> getNames() {
+ return names;
+ }
+}
=====================================
src/org/marc4j/util/RecordIODriver.java
=====================================
@@ -171,6 +171,7 @@ public class RecordIODriver {
System.err.printf("Exception %s record: %s -- %s\n",
location, (location.equals("after") ? previousControlNumber : controlNumber), re.getMessage());
re.printStackTrace(System.err);
+ break;
}
previousControlNumber = controlNumber;
=====================================
test/org/marc4j/callnum/NlmCallNumberTest.java
=====================================
@@ -0,0 +1,51 @@
+package org.marc4j.callnum;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+
+public class NlmCallNumberTest {
+
+ private static final List<String> validNlmNumbers = Arrays.asList(
+ "QS 11 .GA1 E53 2005",
+ "QS 11 .GA1 F875d 1999",
+ "QS 11 .GA1 Q6 2012",
+ "QS 11 .GI8 P235s 2006",
+ "QS 124 B811m 1875",
+ "QT 104 B736 2003",
+ "QT 104 B736 2009",
+ "WA 102.5 B5315 2018",
+ "WA 102.5 B62 2018",
+ "WB 102.5 B62 2018",
+ "WC 250 M56 2011",
+ "WC 250 M6 2011"
+ );
+
+ private static final List<String> invalidNlmNumbers = Arrays.asList(
+ "QA 11 .GA1 E53 2005",
+ "QB 11 .GA1 F875d 1999",
+ "QC 11 .GA1 Q6 2012",
+ "QD 11 .GI8 P235s 2006",
+ "QG 124 B811m 1875",
+ "W 250 M56 2011",
+ "Z 250 M6 2011"
+ );
+
+ @Test
+ public void isValidNlmNumber() {
+ for (String validNlmNumber : validNlmNumbers) {
+ assertTrue(new NlmCallNumber(validNlmNumber).isValid());
+ }
+ }
+
+ @Test
+ public void isInvalidNlmNumber() {
+ for (String validNlmNumber : invalidNlmNumbers) {
+ assertFalse(new NlmCallNumber(validNlmNumber).isValid());
+ }
+ }
+
+}
=====================================
test/src/org/marc4j/test/PermissiveReaderTest.java
=====================================
@@ -9,6 +9,7 @@ import org.marc4j.MarcReader;
import org.marc4j.test.utils.RecordTestingUtils;
import org.marc4j.MarcStreamWriter;
+import org.marc4j.marc.Record;
import org.marc4j.marc.*;
import org.marc4j.test.utils.StaticTestRecords;
=====================================
test/src/org/marc4j/test/RecordTest.java
=====================================
@@ -2,6 +2,7 @@ package org.marc4j.test;
import org.junit.Test;
import org.marc4j.marc.*;
+import org.marc4j.marc.Record;
import org.marc4j.test.utils.StaticTestRecords;
import java.util.List;
=====================================
test/src/org/marc4j/test/utils/RecordTestingUtils.java
=====================================
@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.marc4j.MarcError;
import org.marc4j.marc.*;
+import org.marc4j.marc.Record;
import java.io.*;
import java.util.*;
=====================================
test/src/org/marc4j/test/utils/TestUtils.java
=====================================
@@ -1,6 +1,7 @@
package org.marc4j.test.utils;
import org.marc4j.marc.*;
+import org.marc4j.marc.Record;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
=====================================
test/src/org/marc4j/util/EncodingTest.java
=====================================
@@ -0,0 +1,53 @@
+package org.marc4j.util;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class EncodingTest {
+
+ @Test
+ public void testGet() {
+ assertEquals(Encoding.MARC8, Encoding.get("MARC8"));
+ assertEquals(Encoding.MARC8, Encoding.get("MARC-8"));
+ assertEquals(Encoding.UTF8, Encoding.get("UTF8"));
+ assertEquals(Encoding.UTF8, Encoding.get("UTF-8"));
+ assertEquals(Encoding.ISO8859_1, Encoding.get("ISO8859_1"));
+ assertEquals(Encoding.ISO8859_1, Encoding.get("ISO-8859-1"));
+ assertEquals(Encoding.ISO8859_1, Encoding.get("ISO_8859_1"));
+ assertNull(Encoding.get("non-existent"));
+ }
+
+ @Test
+ public void testValues() {
+ Encoding[] encodings = Encoding.values();
+ assertEquals(3, encodings.length);
+ assertEquals(Encoding.UTF8, encodings[0]);
+ assertEquals(Encoding.MARC8, encodings[1]);
+ assertEquals(Encoding.ISO8859_1, encodings[2]);
+ }
+
+ @Test
+ public void testValueOf() {
+ assertEquals(Encoding.MARC8, Encoding.valueOf("MARC8"));
+ assertEquals(Encoding.UTF8, Encoding.valueOf("UTF8"));
+ assertEquals(Encoding.ISO8859_1, Encoding.valueOf("ISO8859_1"));
+ }
+
+ @Test
+ public void testGetStandardName() {
+ assertEquals("MARC-8", Encoding.MARC8.getStandardName());
+ assertEquals("UTF-8", Encoding.UTF8.getStandardName());
+ assertEquals("ISO-8859-1", Encoding.ISO8859_1.getStandardName());
+ }
+
+ @Test
+ public void testGetNames() {
+ assertEquals(Arrays.asList("MARC-8", "MARC8"), Encoding.MARC8.getNames());
+ assertEquals(Arrays.asList("UTF-8", "UTF8"), Encoding.UTF8.getNames());
+ assertEquals(Arrays.asList("ISO-8859-1", "ISO8859_1", "ISO_8859_1"), Encoding.ISO8859_1.getNames());
+ }
+}
\ No newline at end of file
View it on GitLab: https://salsa.debian.org/java-team/libmarc4j-java/-/compare/7c2d30878041f49eafbb4117a8414bb42f1efd20...a1ce1f4ae37f27e27738fd2f0d4eb36413b152c8
--
View it on GitLab: https://salsa.debian.org/java-team/libmarc4j-java/-/compare/7c2d30878041f49eafbb4117a8414bb42f1efd20...a1ce1f4ae37f27e27738fd2f0d4eb36413b152c8
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20230911/9ca3b6cf/attachment.htm>
More information about the pkg-java-commits
mailing list