update to Java 17, add Alma XML, relax label value interpretation with # symbol
This commit is contained in:
parent
4cb84894db
commit
ee55fa7ff8
12 changed files with 105 additions and 17 deletions
|
@ -1,13 +1,13 @@
|
|||
group = org.xbib
|
||||
name = marc
|
||||
version = 2.6.0
|
||||
version = 2.7.0
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
gradle.wrapper.version = 7.3.2
|
||||
gradle.wrapper.version = 7.5.1
|
||||
xbib-content.version = 4.0.0
|
||||
xbib-bibliographic-character-sets.version = 2.0.0
|
||||
xalan.version = 2.7.2
|
||||
xmlunit-matchers.version = 2.6.3
|
||||
xmlunit-matchers.version = 2.8.4
|
||||
system-rules.version = 1.19.0
|
||||
mockito.version = 3.3.3
|
||||
marc4j.version = 2.9.2
|
||||
|
|
|
@ -6,13 +6,13 @@ java {
|
|||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -24,6 +24,17 @@ test {
|
|||
"${result.skippedTestCount} skipped"
|
||||
}
|
||||
}
|
||||
// massive heap for for xmlunit DOM comparer
|
||||
jvmArgs '-Xmx2048m'
|
||||
jvmArgs '-Xmx2048m',
|
||||
'--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'
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public enum Encoding {
|
|||
public static Encoding from(char ch) {
|
||||
switch (ch) {
|
||||
case ' ':
|
||||
case '#':
|
||||
return MARC8;
|
||||
case 'a':
|
||||
return UCS_UNICODE;
|
||||
|
|
|
@ -106,6 +106,7 @@ public enum EncodingLevel {
|
|||
public static EncodingLevel from(char ch) {
|
||||
switch (ch) {
|
||||
case ' ':
|
||||
case '#':
|
||||
return FULL;
|
||||
case '1':
|
||||
return FULL_NOT_EXAMINED;
|
||||
|
@ -125,6 +126,14 @@ public enum EncodingLevel {
|
|||
return UNKNOWN;
|
||||
case 'z':
|
||||
return NOT_APPLICABLE;
|
||||
case 'I':
|
||||
return LESS_THAN_FULL_NOT_EXAMINED;
|
||||
case 'K':
|
||||
return LESS_THAN_FULL_NOT_EXAMINED;
|
||||
case 'M':
|
||||
return LESS_THAN_FULL_NOT_EXAMINED;
|
||||
case 'U':
|
||||
return UNKNOWN;
|
||||
default:
|
||||
logger.log(Level.FINEST, () -> "unknown encoding level " + ch);
|
||||
return FULL;
|
||||
|
|
|
@ -63,6 +63,7 @@ public enum MultipartResourceRecordLevel {
|
|||
public static MultipartResourceRecordLevel from(char ch) {
|
||||
switch (ch) {
|
||||
case ' ':
|
||||
case '#':
|
||||
return NOT_SPECIFIED;
|
||||
case 'a':
|
||||
return SET;
|
||||
|
|
|
@ -51,6 +51,7 @@ public enum TypeOfControl {
|
|||
public static TypeOfControl from(char ch) {
|
||||
switch (ch) {
|
||||
case ' ':
|
||||
case '#':
|
||||
return UNSPECIFIED;
|
||||
case 'a':
|
||||
return ARCHIVAL;
|
||||
|
|
|
@ -166,6 +166,7 @@ public enum TypeOfRecord {
|
|||
static TypeOfRecord from(char ch) {
|
||||
switch (ch) {
|
||||
case ' ':
|
||||
case '#':
|
||||
return UNSPECIFIED;
|
||||
case 'a':
|
||||
return LANGUAGE_MATERIAL;
|
||||
|
|
|
@ -119,11 +119,11 @@ public class MarcContentHandler
|
|||
|
||||
/**
|
||||
* Set MARC record listener..
|
||||
* @param listener the MARC recordlistener
|
||||
* @param marcRecordListener the MARC recordlistener
|
||||
* @return this handler
|
||||
*/
|
||||
public MarcContentHandler setMarcRecordListener(MarcRecordListener listener) {
|
||||
this.marcRecordListener = listener;
|
||||
public MarcContentHandler setMarcRecordListener(MarcRecordListener marcRecordListener) {
|
||||
this.marcRecordListener = marcRecordListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class MarcContentHandler
|
|||
public void beginCollection() {
|
||||
// early setup of MARC listener, even before beginRecord(format, type), it works only
|
||||
// if type is set to this handler.
|
||||
this.marcListener = listeners.get(this.type);
|
||||
marcListener = listeners.get(this.type);
|
||||
if (marcListener != null) {
|
||||
marcListener.beginCollection();
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ public class MarcContentHandler
|
|||
}
|
||||
switch (localName) {
|
||||
case COLLECTION: {
|
||||
if (!isCollection) {
|
||||
if (!isCollection) {;
|
||||
beginCollection();
|
||||
isCollection = true;
|
||||
}
|
||||
|
@ -485,6 +485,6 @@ public class MarcContentHandler
|
|||
}
|
||||
|
||||
protected boolean isNamespace(String uri) {
|
||||
return validNamespaces.contains(uri);
|
||||
return uri.isEmpty() || validNamespaces.contains(uri);
|
||||
}
|
||||
}
|
||||
|
|
53
src/test/java/org/xbib/marc/xml/AlmaXMLTest.java
Normal file
53
src/test/java/org/xbib/marc/xml/AlmaXMLTest.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package org.xbib.marc.xml;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.marc.Marc;
|
||||
import org.xbib.marc.MarcRecord;
|
||||
import org.xbib.marc.MarcRecordListener;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class AlmaXMLTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AlmaXMLTest.class.getName());
|
||||
|
||||
@Test
|
||||
public void testAlmaRecordListener() throws Exception {
|
||||
String s = "alma.xml";
|
||||
InputStream in = getClass().getResourceAsStream(s);
|
||||
AtomicBoolean found = new AtomicBoolean();
|
||||
MarcRecordListener marcRecordListener = new MarcRecordListener() {
|
||||
@Override
|
||||
public void beginCollection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void record(MarcRecord marcRecord) {
|
||||
logger.log(Level.INFO, "record = " + marcRecord);
|
||||
found.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endCollection() {
|
||||
}
|
||||
};
|
||||
// attach record listener
|
||||
MarcContentHandler marcListener = new MarcContentHandler();
|
||||
marcListener.setMarcRecordListener(marcRecordListener);
|
||||
|
||||
Marc.builder()
|
||||
.setInputStream(in)
|
||||
.setCharset(StandardCharsets.UTF_8)
|
||||
.setContentHandler(marcListener)
|
||||
.build()
|
||||
.xmlReader()
|
||||
.parse();
|
||||
assertTrue(found.get());
|
||||
}
|
||||
}
|
9
src/test/resources/logging.properties
Normal file
9
src/test/resources/logging.properties
Normal file
|
@ -0,0 +1,9 @@
|
|||
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/marc.log
|
||||
jdk.event.security.level=INFO
|
2
src/test/resources/org/xbib/marc/xml/alma.xml
Normal file
2
src/test/resources/org/xbib/marc/xml/alma.xml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue