update to OpenJDK 17, Gradle 7.5.1, add Groovy example
This commit is contained in:
parent
28a2ea875b
commit
dcea5cc021
22 changed files with 334 additions and 82 deletions
|
@ -4,7 +4,7 @@ plugins {
|
|||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion = "${project.property('gradle.wrapper.version')}"
|
||||
gradleVersion = libs.versions.gradle.get()
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,9 @@ ext {
|
|||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java-library'
|
||||
apply from: rootProject.file('gradle/ide/idea.gradle')
|
||||
apply from: rootProject.file('gradle/compile/java.gradle')
|
||||
apply from: rootProject.file('gradle/test/junit5.gradle')
|
||||
apply from: rootProject.file('gradle/publishing/publication.gradle')
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/publishing/sonatype.gradle')
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
group = org.xbib
|
||||
name = z3950
|
||||
version = 2.4.0
|
||||
version = 5.0.0
|
||||
|
||||
gradle.wrapper.version = 7.3.2
|
||||
netty.version = 4.1.74.Final
|
||||
xbib-cql.version = 3.1.2
|
||||
xbib-bibliographic-character-sets.version = 2.0.0
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
30
gradle/compile/groovy-dynamic.gradle
Normal file
30
gradle/compile/groovy-dynamic.gradle
Normal file
|
@ -0,0 +1,30 @@
|
|||
apply plugin: 'groovy'
|
||||
|
||||
dependencies {
|
||||
implementation libs.groovy
|
||||
}
|
||||
|
||||
compileGroovy {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileTestGroovy {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
tasks.withType(GroovyCompile) {
|
||||
if (!options.compilerArgs.contains("-processor")) {
|
||||
options.compilerArgs.add('-proc:none')
|
||||
}
|
||||
}
|
||||
|
||||
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
|
||||
from groovydoc.destinationDir
|
||||
archiveClassifier.set('groovydoc')
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives groovydocJar
|
||||
}
|
30
gradle/compile/groovy.gradle
Normal file
30
gradle/compile/groovy.gradle
Normal file
|
@ -0,0 +1,30 @@
|
|||
apply plugin: 'groovy'
|
||||
|
||||
dependencies {
|
||||
implementation libs.groovy
|
||||
}
|
||||
|
||||
compileGroovy {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileTestGroovy {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
tasks.withType(GroovyCompile) {
|
||||
options.compilerArgs
|
||||
if (!options.compilerArgs.contains("-processor")) {
|
||||
options.compilerArgs << '-proc:none'
|
||||
}
|
||||
}
|
||||
|
||||
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
|
||||
from groovydoc.destinationDir
|
||||
archiveClassifier.set('javadoc')
|
||||
}
|
||||
|
||||
// BUG! exception in phase 'instruction selection' in source unit 'graphics/graphics-pdfbox-groovy/src/main/groovy/org/xbib/graphics/pdfbox/groovy/render/RowRenderer.groovy' unexpected NullPointerException
|
||||
//compileGroovy.groovyOptions.configurationScript = rootProject.file('gradle/compile/groovyc.groovy')
|
7
gradle/compile/groovyc.groovy
Normal file
7
gradle/compile/groovyc.groovy
Normal file
|
@ -0,0 +1,7 @@
|
|||
import groovy.transform.TypeChecked
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
withConfig(configuration) {
|
||||
ast(TypeChecked)
|
||||
ast(CompileStatic)
|
||||
}
|
|
@ -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,7 @@ jar {
|
|||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier 'sources'
|
||||
from sourceSets.main.allSource
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
|
@ -35,9 +36,11 @@ artifacts {
|
|||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << '-Xlint:all,-fallthrough'
|
||||
options.compilerArgs.add('-Xlint:all,-exports')
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
|
||||
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.6.2'
|
||||
def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2'
|
||||
|
||||
dependencies {
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
|
||||
testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||
testImplementation libs.junit.jupiter.api
|
||||
testImplementation libs.junit.jupiter.params
|
||||
testImplementation libs.hamcrest
|
||||
testRuntimeOnly libs.junit.jupiter.engine
|
||||
}
|
||||
|
||||
test {
|
||||
|
@ -24,6 +20,4 @@ test {
|
|||
"${result.skippedTestCount} skipped"
|
||||
}
|
||||
}
|
||||
// massive heap for for xmlunit DOM comparer
|
||||
jvmArgs '-Xmx2048m'
|
||||
}
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
6
gradlew
vendored
6
gradlew
vendored
|
@ -205,6 +205,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
10
gradlew.bat
vendored
10
gradlew.bat
vendored
|
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
version('gradle', '7.5.1')
|
||||
version('groovy', '4.0.7')
|
||||
version('junit', '5.9.2')
|
||||
version('junit4', '4.13.2')
|
||||
version('netty', '4.1.87.Final')
|
||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
||||
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
|
||||
library('junit-jupiter-vintage', 'org.junit.vintage', 'junit-vintage-engine').versionRef('junit4')
|
||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||
library('cql-common', 'org.xbib', 'cql-common').version('5.0.0')
|
||||
library('netty-transport', 'io.netty', 'netty-transport').versionRef('netty')
|
||||
library('netty-handler', 'io.netty', 'netty-handler').versionRef('netty')
|
||||
library('netty-common', 'io.netty', 'netty-common').versionRef('netty')
|
||||
library('netty-buffer', 'io.netty', 'netty-buffer').versionRef('netty')
|
||||
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
||||
library('groovy', 'org.apache.groovy', 'groovy').versionRef('groovy')
|
||||
library('groovy-xml', 'org.apache.groovy', 'groovy-xml').versionRef('groovy')
|
||||
library('groovy-json', 'org.apache.groovy', 'groovy-json').versionRef('groovy')
|
||||
library('groovy-nio', 'org.apache.groovy', 'groovy-nio').versionRef('groovy')
|
||||
library('groovy-sql', 'org.apache.groovy', 'groovy-sql').versionRef('groovy')
|
||||
library('groovy-macro', 'org.apache.groovy', 'groovy-macro').versionRef('groovy')
|
||||
library('groovy-templates', 'org.apache.groovy', 'groovy-templates').versionRef('groovy')
|
||||
library('groovy-test', 'org.apache.groovy', 'groovy-test').versionRef('groovy')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include 'z3950-asn1'
|
||||
include 'z3950-api'
|
||||
include 'z3950-common'
|
||||
|
@ -5,3 +36,4 @@ include 'z3950-client-api'
|
|||
include 'z3950-client-jdk'
|
||||
include 'z3950-client-netty'
|
||||
include 'z3950-sru'
|
||||
include 'z3950-groovy'
|
|
@ -1,4 +1,4 @@
|
|||
dependencies {
|
||||
api project(':z3950-client-api')
|
||||
testImplementation "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}"
|
||||
testImplementation libs.charactersets
|
||||
}
|
||||
|
|
|
@ -9,12 +9,9 @@ import java.util.Collections;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class SearchTest {
|
||||
class COPACTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SearchTest.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(COPACTest.class.getName());
|
||||
|
||||
@Test
|
||||
void testCopac() throws Exception {
|
||||
|
@ -35,7 +32,7 @@ class SearchTest {
|
|||
.build();
|
||||
client.searchPQF(query, from, length,
|
||||
(status, total, returned, elapsedMillis) -> logger.log(Level.INFO, "total records = " + total),
|
||||
record -> logger.log(Level.INFO, "found record " + record),
|
||||
record -> logger.log(Level.INFO, "found record " + record), // MODS
|
||||
() -> logger.log(Level.WARNING, "timeout"));
|
||||
client.close();
|
||||
} catch (NoRecordsReturnedException | MessageSizeTooSmallException e) {
|
|
@ -1,5 +1,6 @@
|
|||
package org.xbib.z3950.client.jdk.test;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.z3950.client.jdk.JDKZClient;
|
||||
|
||||
|
@ -39,6 +40,7 @@ class GBVZClientTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled("unsupported search")
|
||||
void testControlNumberZDB() {
|
||||
String serviceName = "GBV";
|
||||
String query = "bib.controlNumberZDB = 1413423-8";
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package org.xbib.z3950.client.jdk.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.z3950.client.jdk.JDKZClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
class LIBRISClientTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(LIBRISClientTest.class.getName());
|
||||
|
||||
@Test
|
||||
void testCQL() {
|
||||
String serviceName = "LIBRIS";
|
||||
String query = "bib.identifierISSN = 00280836";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
try (JDKZClient client = newZClient(serviceName)) {
|
||||
logger.log(Level.INFO, "executing CQL " + serviceName);
|
||||
int count = client.searchCQL(query, from, size,
|
||||
(status, total, returned, elapsedMillis) ->
|
||||
logger.log(Level.INFO, serviceName + " total results = " + total),
|
||||
record -> logger.log(Level.INFO, "record = " + record),
|
||||
() -> logger.log(Level.INFO, "timeout"));
|
||||
logger.log(Level.INFO, "returned records = " + count);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPQF() {
|
||||
String serviceName = "LIBRIS";
|
||||
String query = "@attr 1=8 \"00280836\"";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
try (JDKZClient client = newZClient(serviceName)) {
|
||||
logger.log(Level.INFO, "executing PQF " + serviceName);
|
||||
int count = client.searchPQF(query, from, size,
|
||||
(status, total, returned, elapsedMillis) ->
|
||||
logger.log(Level.INFO, serviceName + " status = " + status + " total results = " + total),
|
||||
record -> logger.log(Level.INFO, "record = " + record.toString(Charset.forName(client.getEncoding()))),
|
||||
() -> logger.log(Level.WARNING, "timeout"));
|
||||
logger.log(Level.INFO, "returned records = " + count);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private JDKZClient newZClient(String name) throws IOException {
|
||||
return newZClient(getProperties(name));
|
||||
}
|
||||
|
||||
private Properties getProperties(String name) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream inputStream = getClass().getResourceAsStream(name + ".properties")) {
|
||||
properties.load(inputStream);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static JDKZClient newZClient(Properties properties) {
|
||||
JDKZClient.Builder builder = JDKZClient.builder();
|
||||
if (properties.containsKey("host")) {
|
||||
builder.setHost(properties.getProperty("host"));
|
||||
}
|
||||
if (properties.containsKey("port")) {
|
||||
builder.setPort(Integer.parseInt(properties.getProperty("port")));
|
||||
}
|
||||
if (properties.containsKey("user")) {
|
||||
builder.setUser(properties.getProperty("user"));
|
||||
}
|
||||
if (properties.containsKey("pass")) {
|
||||
builder.setPass(properties.getProperty("pass"));
|
||||
}
|
||||
if (properties.containsKey("database")) {
|
||||
builder.setDatabases(Collections.singletonList(properties.getProperty("database")));
|
||||
}
|
||||
if (properties.containsKey("elementsetname")) {
|
||||
builder.setElementSetName(properties.getProperty("elementsetname"));
|
||||
}
|
||||
if (properties.containsKey("preferredrecordsyntax")) {
|
||||
builder.setPreferredRecordSyntax(properties.getProperty("preferredrecordsyntax"));
|
||||
}
|
||||
if (properties.containsKey("resultsetname")) {
|
||||
builder.setResultSetName(properties.getProperty("resultsetname"));
|
||||
}
|
||||
if (properties.containsKey("encoding")) {
|
||||
builder.setEncoding(properties.getProperty("encoding"));
|
||||
}
|
||||
if (properties.containsKey("format")) {
|
||||
builder.setFormat(properties.getProperty("format"));
|
||||
}
|
||||
if (properties.containsKey("type")) {
|
||||
builder.setType(properties.getProperty("type"));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package org.xbib.z3950.client.jdk.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.z3950.client.jdk.JDKZClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -11,17 +8,16 @@ import java.util.Collections;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.z3950.client.jdk.JDKZClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DefaultClientTest {
|
||||
class SWBClientTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DefaultClientTest.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(SWBClientTest.class.getName());
|
||||
|
||||
@Test
|
||||
void testCQL() {
|
||||
for (String serviceName : Arrays.asList("LIBRIS", "SWB")) {
|
||||
String serviceName = "SWB";
|
||||
String query = "bib.identifierISSN = 00280836";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
|
@ -37,11 +33,10 @@ class DefaultClientTest {
|
|||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPQF() {
|
||||
for (String serviceName : Arrays.asList("LIBRIS", "SWB")) {
|
||||
String serviceName = "SWB";
|
||||
String query = "@attr 1=8 \"00280836\"";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
|
@ -57,7 +52,6 @@ class DefaultClientTest {
|
|||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JDKZClient newZClient(String name) throws IOException {
|
||||
return newZClient(getProperties(name));
|
|
@ -1,8 +1,8 @@
|
|||
dependencies {
|
||||
api project(':z3950-client-api')
|
||||
implementation "io.netty:netty-buffer:${project.property('netty.version')}"
|
||||
implementation "io.netty:netty-common:${project.property('netty.version')}"
|
||||
implementation "io.netty:netty-handler:${project.property('netty.version')}"
|
||||
implementation "io.netty:netty-transport:${project.property('netty.version')}"
|
||||
testImplementation "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}"
|
||||
implementation libs.netty.buffer
|
||||
implementation libs.netty.common
|
||||
implementation libs.netty.handler
|
||||
implementation libs.netty.transport
|
||||
testImplementation libs.charactersets
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
api project(':z3950-api')
|
||||
api "org.xbib:cql-common:${project.property('xbib-cql.version')}"
|
||||
api libs.cql.common
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.xbib.z3950.common;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.xbib.z3950.api.Record;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -37,4 +38,9 @@ public class DefaultRecord implements Record {
|
|||
public String toString(Charset charset) {
|
||||
return new String(content, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
|
14
z3950-groovy/build.gradle
Normal file
14
z3950-groovy/build.gradle
Normal file
|
@ -0,0 +1,14 @@
|
|||
apply from: rootProject.file('gradle/compile/groovy.gradle')
|
||||
|
||||
dependencies {
|
||||
api project(':z3950-client-jdk')
|
||||
api libs.groovy.xml
|
||||
testRuntimeOnly libs.junit.jupiter.vintage
|
||||
testImplementation libs.groovy
|
||||
testImplementation libs.groovy.json
|
||||
testImplementation libs.groovy.nio
|
||||
testImplementation libs.groovy.sql
|
||||
testImplementation libs.groovy.macro
|
||||
testImplementation libs.groovy.templates
|
||||
testImplementation libs.groovy.test
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.xbib.z3950.groovy
|
||||
|
||||
import groovy.util.logging.Log
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.xbib.z3950.client.jdk.JDKZClient
|
||||
|
||||
import java.util.logging.Level
|
||||
|
||||
@Log
|
||||
class COPACTest {
|
||||
|
||||
@Test
|
||||
void testCOPAC() {
|
||||
String host = "z3950.copac.ac.uk"
|
||||
int port = 210
|
||||
String database = "COPAC"
|
||||
String query = "@attr 1=1 smith"
|
||||
// "1.2.840.10003.5.10"; // MARC
|
||||
String preferredRecordSyntax = "1.2.840.10003.5.109.10" // xml
|
||||
int from = 1
|
||||
int length = 1
|
||||
JDKZClient client = JDKZClient.builder()
|
||||
.setHost(host)
|
||||
.setPort(port)
|
||||
.setDatabases(Collections.singletonList(database))
|
||||
.setPreferredRecordSyntax(preferredRecordSyntax)
|
||||
.build()
|
||||
client.withCloseable {cl ->
|
||||
cl.searchPQF(query, from, length,
|
||||
(status, total, returned, elapsedMillis) -> log.log(Level.INFO, "total records = " + total),
|
||||
record -> log.log(Level.INFO, "found record " + record), // MODS
|
||||
() -> log.log(Level.WARNING, "timeout"))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue