Java named module, Gradle 6.4.1, JUnit 5 tests

This commit is contained in:
Jörg Prante 2020-05-19 23:40:25 +02:00
parent 970f62f44f
commit c7d2aa3c87
63 changed files with 788 additions and 1320 deletions

View file

@ -1,22 +1,32 @@
plugins {
id "org.sonarqube" version "2.6.1"
id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.1"
id "com.github.spotbugs" version "2.0.1"
id "org.xbib.gradle.plugin.asciidoctor" version "1.6.0.1"
}
wrapper {
gradleVersion = "${rootProject.property('gradle.wrapper.version')}"
distributionType = Wrapper.DistributionType.ALL
}
ext {
user = 'xbib'
name = 'marc'
description = 'MARC bibliographic data processing library for Java'
inceptionYear = '2016'
url = 'https://github.com/' + user + '/' + name
scmUrl = 'https://github.com/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git'
issueManagementSystem = 'Github'
issueManagementUrl = ext.scmUrl + '/issues'
licenseName = 'The Apache License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
apply plugin: "io.codearte.nexus-staging"
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.property('junit.version')}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${project.property('junit.version')}"
testImplementation "junit:junit:${project.property('junit4.version')}"
testImplementation "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}"
testImplementation "org.xbib:content-core:${project.property('xbib-content.version')}"
testImplementation "xalan:xalan:${project.property('xalan.version')}"
@ -30,182 +40,7 @@ dependencies {
testImplementation "org.marc4j:marc4j:${project.property('marc4j.version')}"
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all"
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}
clean {
delete 'out'
}
test {
useJUnitPlatform()
systemProperty 'java.util.logging.config.file',
project.file('src/test/resources/logging.properties').toString()
failFast = false
testLogging {
showStandardStreams = true
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
// massive heap for for xmlunit DOM comparer
jvmArgs '-Xmx2048m'
}
asciidoctor {
attributes toc: 'left',
doctype: 'book',
icons: 'font',
encoding: 'utf-8',
sectlink: true,
sectanchors: true,
linkattrs: true,
imagesdir: 'img',
'source-highlighter': 'coderay'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
}
artifacts {
archives sourcesJar, javadocJar
}
ext {
user = 'xbib'
projectName = 'marc'
projectDescription = 'MARC bibliographic data processing library for Java'
scmUrl = 'https://github.com/xbib/marc'
scmConnection = 'scm:git:git://github.com/xbib/marc.git'
scmDeveloperConnection = 'scm:git:git://github.com/xbib/marc.git'
}
spotbugs {
effort = "max"
reportLevel = "low"
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
ignoreFailures = true
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.withType(Pmd) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
tasks.withType(Checkstyle) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
pmd {
toolVersion = '6.11.0'
ruleSets = ['category/java/bestpractices.xml']
}
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
ignoreFailures = true
showViolations = true
}
sonarqube {
properties {
property "sonar.projectName", "${project.group} ${project.name}"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.tests", "src/test/java"
property "sonar.scm.provider", "git"
property "sonar.junit.reportsPath", "build/test-results/test/"
}
}
task sonatypeUpload(type: Upload) {
group = 'publish'
configuration = configurations.archives
uploadDescriptor = true
repositories {
if (project.hasProperty('ossrhUsername')) {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: uri(ossrhReleaseUrl)) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: uri(ossrhSnapshotUrl)) {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name projectName
description projectDescription
packaging 'jar'
inceptionYear '2016'
url scmUrl
organization {
name 'xbib'
url 'http://xbib.org'
}
developers {
developer {
id user
name 'Jörg Prante'
email 'joergprante@gmail.com'
url 'https://github.com/jprante'
}
}
scm {
url scmUrl
connection scmConnection
developerConnection scmDeveloperConnection
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
}
}
}
}
}
nexusStaging {
packageGroup = "org.xbib"
}
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')

View file

@ -1,16 +1,10 @@
group = org.xbib
name = marc
version = 2.2.1
version = 2.3.0
# main
xbib-content.version = 2.0.5
# runtime
gradle.wrapper.version = 6.4.1
xbib-content.version = 2.2.0
xbib-bibliographic-character-sets.version = 1.0.0
# test
junit.version = 5.5.2
junit4.version = 4.12
xalan.version = 2.7.2
xmlunit-matchers.version = 2.6.3
system-rules.version = 1.19.0

View file

@ -0,0 +1,39 @@
spotbugs {
effort = "max"
reportLevel = "low"
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
ignoreFailures = true
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.withType(Pmd) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
tasks.withType(Checkstyle) {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
pmd {
toolVersion = '6.11.0'
ruleSets = ['category/java/bestpractices.xml']
}
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
ignoreFailures = true
showViolations = true
}

View file

@ -0,0 +1,35 @@
apply plugin: 'java-library'
java {
modularity.inferModulePath.set(true)
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
jar {
manifest {
attributes('Implementation-Version': project.version)
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
}
artifacts {
archives sourcesJar, javadocJar
}

View file

@ -0,0 +1,34 @@
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
configurations {
asciidoclet
}
dependencies {
asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}"
}
/*
javadoc {
options.docletpath = configurations.asciidoclet.files.asType(List)
options.doclet = 'org.asciidoctor.Asciidoclet'
//options.overview = "src/docs/asciidoclet/overview.adoc"
options.addStringOption "-base-dir", "${projectDir}"
options.addStringOption "-attribute",
"name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}"
configure(options) {
noTimestamp = true
}
}*/
asciidoctor {
attributes 'source-highlighter': 'coderay',
toc: 'left',
doctype: 'book',
icons: 'font',
encoding: 'utf-8',
sectlink: true,
sectanchors: true,
linkattrs: true,
imagesdir: 'img'
}

13
gradle/ide/idea.gradle Normal file
View file

@ -0,0 +1,13 @@
apply plugin: 'idea'
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/java/test')
}
}
if (project.convention.findPlugin(JavaPluginConvention)) {
//sourceSets.main.output.classesDirs = file("build/classes/java/main")
//sourceSets.test.output.classesDirs = file("build/classes/java/test")
}

View file

@ -0,0 +1,64 @@
apply plugin: "de.marcphilipp.nexus-publish"
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = project.name
description = rootProject.ext.description
url = rootProject.ext.url
inceptionYear = rootProject.ext.inceptionYear
packaging = 'jar'
organization {
name = 'xbib'
url = 'https://xbib.org'
}
developers {
developer {
id = 'jprante'
name = 'Jörg Prante'
email = 'joergprante@gmail.com'
url = 'https://github.com/jprante'
}
}
scm {
url = rootProject.ext.scmUrl
connection = rootProject.ext.scmConnection
developerConnection = rootProject.ext.scmDeveloperConnection
}
issueManagement {
system = rootProject.ext.issueManagementSystem
url = rootProject.ext.issueManagementUrl
}
licenses {
license {
name = rootProject.ext.licenseName
url = rootProject.ext.licenseUrl
distribution = 'repo'
}
}
}
}
}
}
if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
signing {
sign publishing.publications.mavenJava
}
}
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}
}

View file

@ -0,0 +1,11 @@
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
apply plugin: 'io.codearte.nexus-staging'
nexusStaging {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}

29
gradle/test/junit5.gradle Normal file
View file

@ -0,0 +1,29 @@
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}"
}
test {
useJUnitPlatform()
failFast = true
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
}
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
// massive heap for for xmlunit DOM comparer
jvmArgs '-Xmx2048m'
}

Binary file not shown.

View file

@ -1,6 +1,5 @@
#Fri Sep 13 21:19:04 CEST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

31
gradlew vendored
View file

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

4
gradlew.bat vendored
View file

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View file

@ -0,0 +1,20 @@
module org.xbib.marc {
exports org.xbib.marc;
exports org.xbib.marc.dialects.aleph;
exports org.xbib.marc.dialects.bibliomondo;
exports org.xbib.marc.dialects.mab;
exports org.xbib.marc.dialects.mab.xml;
exports org.xbib.marc.dialects.mab.diskette;
exports org.xbib.marc.dialects.pica;
exports org.xbib.marc.dialects.sisis;
exports org.xbib.marc.io;
exports org.xbib.marc.json;
exports org.xbib.marc.label;
exports org.xbib.marc.tools;
exports org.xbib.marc.transformer;
exports org.xbib.marc.transformer.field;
exports org.xbib.marc.transformer.value;
exports org.xbib.marc.xml;
requires java.logging;
requires java.xml;
}

View file

@ -1,25 +1,8 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.json.MarcJsonWriter;
import org.xbib.marc.xml.MarcXchangeWriter;

View file

@ -1,30 +1,16 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.util.TreeSet;
/**
*
*/
public class MarcFieldTest extends Assert {
public class MarcFieldTest {
@Test
public void testFieldData() {
@ -221,5 +207,4 @@ public class MarcFieldTest extends Assert {
assertNull(marcField.getFirstSubfield().getValue());
assertNull(marcField.getLastSubfield().getValue());
}
}

View file

@ -1,23 +1,11 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.marc.label.RecordLabel;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
@ -35,7 +23,7 @@ import java.util.regex.Pattern;
/**
*
*/
public class MarcRecordTest extends Assert {
public class MarcRecordTest {
@Test
public void testMarcRecordLabel() {
@ -223,5 +211,4 @@ public class MarcRecordTest extends Assert {
assertThat(file, CompareMatcher.isIdenticalTo(getClass().getResource(s + ".xml").openStream()));
}
}
}

View file

@ -1,11 +1,9 @@
package org.xbib.marc;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -65,7 +63,6 @@ public class MarcRoundTripTest {
.writeCollection();
}
// compare both to expected file structure
assertThat(file, CompareMatcher.isIdenticalTo(getClass().getResource(s + ".xml").openStream()));
assertThat(file2, CompareMatcher.isIdenticalTo(getClass().getResource(s + ".xml").openStream()));
}

View file

@ -1,33 +1,15 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.marc.io.ReplaceStringInputStream;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.transformer.value.Xml10MarcValueCleaner;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

View file

@ -1,38 +1,17 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.xbib.marc.MarcXchangeConstants.MARC21_FORMAT;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.xbib.marc.xml.Sax2Dom;
import org.xml.sax.InputSource;
import org.xmlunit.matchers.CompareMatcher;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;

View file

@ -1,27 +1,11 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -32,7 +16,7 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
public class MarcWriterTest extends Assert {
public class MarcWriterTest {
@Test
public void testUtf8MarcWriter() throws Exception {

View file

@ -1,27 +1,11 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@ -32,7 +16,7 @@ import java.util.zip.GZIPInputStream;
/**
*
*/
public class MarcXchangeWriterTest extends Assert {
public class MarcXchangeWriterTest {
@Test
public void splitMarcXchange() throws Exception {

View file

@ -1,17 +1,13 @@
package org.xbib.marc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class SWBTest {
@Test
@ -48,7 +44,7 @@ public class SWBTest {
try (InputStream in = getClass().getResource(file).openStream()) {
Marc.Builder builder = Marc.builder()
.setInputStream(in)
.setCharset(Charset.forName("UTF-8"));
.setCharset(StandardCharsets.UTF_8);
for (MarcRecord marcRecord : builder.iterable()) {
count++;
}

View file

@ -16,8 +16,7 @@
*/
package org.xbib.marc;
import org.junit.Assert;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -29,7 +28,7 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
public class StreamMatcher extends Assert {
public class StreamMatcher {
public static void assertStream(String name, InputStream expected, String actual) throws IOException {
assertStream(name, expected, new ByteArrayInputStream(actual.getBytes(StandardCharsets.UTF_8)));

View file

@ -1,33 +1,15 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.xbib.marc.StreamMatcher.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.json.MarcJsonWriter;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
@ -38,9 +20,6 @@ import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.util.EnumSet;
/**
*
*/
public class ZDBTest {
private final StringBuilder sb = new StringBuilder();

View file

@ -1,24 +1,7 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.aleph;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcXchangeConstants;
import org.xbib.marc.xml.MarcXchangeWriter;
@ -29,9 +12,6 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class AlephSequentialTest {
@Test

View file

@ -1,28 +1,9 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.bibliomondo;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.Charset;
@ -30,13 +11,10 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
*
*/
public class BiblioMondoInputStreamTest extends Assert {
public class BiblioMondoInputStreamTest {
@Test
@Ignore("skip this because data license is unclear")
@Disabled("skip this because data license is unclear")
public void biblioMondoRecords() throws Exception {
Path path = Paths.get("/data/fix/DE-380/Stbib_Fernleihe_20150427.MARC");
Path out = Paths.get("/var/tmp/Stbib_Fernleihe_20150427.marcxchange");

View file

@ -1,20 +1,15 @@
package org.xbib.marc.dialects.mab;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcRecord;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class HBZTest {
@Test

View file

@ -1,28 +1,11 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.mab;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.xbib.marc.StreamMatcher.assertStream;
import static org.xbib.marc.transformer.field.MarcFieldTransformer.Operator.HEAD;
import static org.xbib.marc.transformer.field.MarcFieldTransformer.Operator.TAIL;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcField;
import org.xbib.marc.MarcListener;
@ -36,7 +19,6 @@ import org.xbib.marc.xml.MarcContentHandler;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xml.sax.InputSource;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
@ -45,9 +27,6 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern;
/**
*
*/
public class MabTest {
private final StringBuilder sb = new StringBuilder();
@ -165,7 +144,6 @@ public class MabTest {
writer.endCollection();
sw.close();
assertNull(writer.getException());
assertStream(s,
getClass().getResource("HT016424175-combined-keyvalue.txt").openStream(), sb.toString());
assertThat(sw.toString(),

View file

@ -1,9 +1,8 @@
package org.xbib.marc.dialects.mab;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.xbib.marc.StreamMatcher.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.dialects.mab.xml.MabXMLContentHandler;
import org.xbib.marc.json.MarcJsonWriter;
@ -11,7 +10,6 @@ import org.xbib.marc.xml.MarcContentHandler;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xml.sax.InputSource;
import org.xmlunit.matchers.CompareMatcher;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -20,9 +18,6 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.EnumSet;
/**
*
*/
public class MabXmlTest {
@Test

View file

@ -1,21 +1,16 @@
package org.xbib.marc.dialects.mab;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcRecord;
import org.xbib.marc.label.RecordLabel;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class OBVSGTest {
@Test

View file

@ -1,37 +1,19 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.mab.diskette;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.Charset;
/**
*
*/
public class MabDisketteTest extends Assert {
public class MabDisketteTest {
@Test
public void testMABDiskette() throws Exception {

View file

@ -1,40 +1,19 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.pica;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.xbib.marc.StreamMatcher.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcField;
import org.xbib.marc.MarcListener;
import org.xbib.marc.MarcXchangeConstants;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class PicaTest {
@Test

View file

@ -1,30 +1,14 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.sisis;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcXchangeConstants;
import org.xbib.marc.transformer.field.MarcFieldTransformer;
import org.xbib.marc.transformer.field.MarcFieldTransformers;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
@ -32,10 +16,7 @@ import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class SisisTest extends Assert {
public class SisisTest {
/**
* Test file donated from DE-A96.

View file

@ -1,36 +1,17 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.dialects.unimarc;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.xml.MarcXchangeWriter;
import org.xmlunit.matchers.CompareMatcher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class UnimarcTest extends Assert {
public class UnimarcTest {
/**
* UNIMARC test.

View file

@ -1,6 +1,6 @@
package org.xbib.marc.filter;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.XContentBuilder;
import org.xbib.content.json.JsonXContent;
import org.xbib.marc.Marc;

View file

@ -1,14 +1,12 @@
package org.xbib.marc.filter;
import static org.xbib.content.json.JsonXContent.contentBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.content.XContentBuilder;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcField;
import org.xbib.marc.MarcFieldAdapter;
import org.xbib.marc.MarcListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

View file

@ -1,34 +1,13 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.io;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class BufferedSeparatorInputStreamTest {
private int dataCount = 0;

View file

@ -1,31 +1,10 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.io;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class BytesStreamOutputTest {
/**

View file

@ -1,26 +1,8 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.io;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -28,9 +10,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class PatternInputStreamTest {
@Test
@ -47,7 +26,6 @@ public class PatternInputStreamTest {
}
separatorStream.close();
assertEquals("{1=5, 2=5}", map.toString());
;
}
@Test
@ -64,7 +42,6 @@ public class PatternInputStreamTest {
}
separatorStream.close();
assertEquals("{1=5, 2=5}", map.toString());
;
}
@Test
@ -100,7 +77,6 @@ public class PatternInputStreamTest {
}
separatorStream.close();
assertEquals(20000, count.get());
;
}
@Test
@ -119,7 +95,6 @@ public class PatternInputStreamTest {
});
separatorStream.close();
assertEquals(20000, count.get());
;
}
}

View file

@ -1,33 +1,12 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.io;
import static org.xbib.marc.StreamMatcher.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
*
*/
public class ReplaceStringInputStreamTest {
@Test

View file

@ -1,28 +1,8 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.io;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.Test;
/**
*
*/
public class ScanBufferTest {
@Test

View file

@ -1,7 +1,7 @@
package org.xbib.marc.io;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.marc4j.MarcPermissiveStreamReader;
import org.marc4j.MarcReader;
import org.marc4j.marc.Record;
@ -18,7 +18,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
@Ignore
@Disabled("large file")
public class UncompressLargeFileTest {
private static final Logger logger = Logger.getLogger(UncompressLargeFileTest.class.getName());

View file

@ -1,42 +1,22 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
/**
*
*/
public class JsonArrayTest extends TestUtil {
public class JsonArrayTest {
private JsonArray array;
@ -48,18 +28,18 @@ public class JsonArrayTest extends TestUtil {
return array;
}
@Before
@BeforeEach
public void setUp() {
array = new JsonArray();
}
@Test
public void copyConstructorfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> new JsonArray(null));
public void copyConstructorFailsWithNull() {
Assertions.assertThrows(NullPointerException.class, () -> new JsonArray(null));
}
@Test
public void copyConstructorhasSameValues() {
public void copyConstructorHasSameValues() {
array.add(23);
JsonArray copy = new JsonArray(array);
assertEquals(array.values(), copy.values());
@ -80,7 +60,6 @@ public class JsonArrayTest extends TestUtil {
@Test
public void isEmptyisFalseAfterAdd() {
array.add(true);
assertFalse(array.isEmpty());
}
@ -109,19 +88,23 @@ public class JsonArrayTest extends TestUtil {
assertFalse(iterator.hasNext());
}
@Test(expected = UnsupportedOperationException.class)
@Test
public void iteratordoesNotAllowModification() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
array.add(23);
Iterator<JsonValue> iterator = array.iterator();
iterator.next();
iterator.remove();
});
}
@Test(expected = ConcurrentModificationException.class)
@Test
public void iteratordetectsConcurrentModification() {
Assertions.assertThrows(ConcurrentModificationException.class, () -> {
Iterator<JsonValue> iterator = array.iterator();
array.add(23);
iterator.next();
});
}
@Test
@ -156,9 +139,9 @@ public class JsonArrayTest extends TestUtil {
assertEquals(Json.of(23), value);
}
@Test(expected = IndexOutOfBoundsException.class)
@Test
public void getfailsWithInvalidIndex() {
array.get(0);
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> array.get(0));
}
@Test
@ -258,7 +241,7 @@ public class JsonArrayTest extends TestUtil {
@Test
public void addjsonfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> array.add((JsonValue) null));
Assertions.assertThrows(NullPointerException.class, () -> array.add((JsonValue) null));
}
@Test
@ -395,12 +378,14 @@ public class JsonArrayTest extends TestUtil {
@Test
public void setJsonFailsWithNull() {
array.add(false);
assertException(NullPointerException.class, null, (Runnable) () -> array.set(0, (JsonValue) null));
Assertions.assertThrows(NullPointerException.class, () ->
array.set(0, (JsonValue) null));
}
@Test(expected = IndexOutOfBoundsException.class)
@Test
public void setjsonfailsWithInvalidIndex() {
array.set(0, JsonLiteral.NULL);
Assertions.assertThrows(IndexOutOfBoundsException.class, () ->
array.set(0, JsonLiteral.NULL));
}
@Test
@ -416,9 +401,11 @@ public class JsonArrayTest extends TestUtil {
assertEquals("[3,4,5]", array.toString());
}
@Test(expected = IndexOutOfBoundsException.class)
@Test
public void removefailsWithInvalidIndex() {
array.remove(0);
Assertions.assertThrows(IndexOutOfBoundsException.class, () ->
array.remove(0)
);
}
@Test

View file

@ -1,39 +1,18 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.xbib.marc.json.JsonLiteral.FALSE;
import static org.xbib.marc.json.JsonLiteral.NULL;
import static org.xbib.marc.json.JsonLiteral.TRUE;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
/**
*
*/
public class JsonLiteralTest {
@Test
@ -129,5 +108,4 @@ public class JsonLiteralTest {
assertNotEquals(FALSE, Boolean.FALSE);
assertNotEquals(NULL, Json.of("false"));
}
}

View file

@ -1,40 +1,21 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
/**
*
*/
public class JsonNumberTest extends TestUtil {
public class JsonNumberTest {
private StringWriter output;
private JsonWriter writer;
@Before
@BeforeEach
public void setUp() {
output = new StringWriter();
writer = new JsonWriter(output);
@ -42,7 +23,7 @@ public class JsonNumberTest extends TestUtil {
@Test
public void constructorfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> new JsonNumber(null));
Assertions.assertThrows(NullPointerException.class, () -> new JsonNumber(null));
}
@Test
@ -66,19 +47,25 @@ public class JsonNumberTest extends TestUtil {
assertEquals(23, new JsonNumber("23").asInt());
}
@Test(expected = NumberFormatException.class)
@Test
public void asIntfailsWithExceedingValues() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("10000000000").asInt();
});
}
@Test(expected = NumberFormatException.class)
@Test
public void asIntfailsWithExponent() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("1e5").asInt();
});
}
@Test(expected = NumberFormatException.class)
@Test
public void asIntfailsWithFractional() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("23.5").asInt();
});
}
@Test
@ -86,19 +73,25 @@ public class JsonNumberTest extends TestUtil {
assertEquals(23L, new JsonNumber("23").asLong());
}
@Test(expected = NumberFormatException.class)
@Test
public void asLongfailsWithExceedingValues() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("10000000000000000000").asLong();
});
}
@Test(expected = NumberFormatException.class)
@Test
public void asLongfailsWithExponent() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("1e5").asLong();
});
}
@Test(expected = NumberFormatException.class)
@Test
public void asLongfailsWithFractional() {
Assertions.assertThrows(NumberFormatException.class, () -> {
new JsonNumber("23.5").asLong();
});
}
@Test

View file

@ -1,45 +1,25 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
/**
*
*/
public class JsonObjectTest extends TestUtil {
public class JsonObjectTest {
private JsonObject object;
@ -51,21 +31,20 @@ public class JsonObjectTest extends TestUtil {
return object;
}
@Before
@BeforeEach
public void setUp() {
object = new JsonObject();
}
@Test
public void copyConstructorfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> new JsonObject(null));
Assertions.assertThrows(NullPointerException.class, () -> new JsonObject(null));
}
@Test
public void copyConstructorhasSameValues() {
object.add("foo", 23);
JsonObject copy = new JsonObject(object);
assertEquals(object.names(), copy.names());
assertSame(object.get("foo"), copy.get("foo"));
}
@ -74,7 +53,6 @@ public class JsonObjectTest extends TestUtil {
public void copyConstructorworksOnSafeCopy() {
JsonObject copy = new JsonObject(object);
object.add("foo", 23);
assertTrue(copy.isEmpty());
}
@ -86,7 +64,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void isEmptyfalseAfterAdd() {
object.add("a", true);
assertFalse(object.isEmpty());
}
@ -98,7 +75,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void sizeoneAfterAdd() {
object.add("a", true);
assertEquals(1, object.size());
}
@ -106,7 +82,6 @@ public class JsonObjectTest extends TestUtil {
public void keyRepetitionallowsMultipleEntries() {
object.add("a", true);
object.add("a", "value");
assertEquals(2, object.size());
}
@ -114,7 +89,6 @@ public class JsonObjectTest extends TestUtil {
public void keyRepetitiongetsLastEntry() {
object.add("a", true);
object.add("a", "value");
assertEquals("value", object.getString("a", "missing"));
}
@ -122,11 +96,9 @@ public class JsonObjectTest extends TestUtil {
public void keyRepetitionequalityConsidersRepetitions() {
object.add("a", true);
object.add("a", "value");
JsonObject onlyFirstProperty = new JsonObject();
onlyFirstProperty.add("a", true);
assertNotEquals(onlyFirstProperty, object);
JsonObject bothProperties = new JsonObject();
bothProperties.add("a", true);
bothProperties.add("a", "value");
@ -141,7 +113,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void namescontainsNameAfterAdd() {
object.add("foo", true);
List<String> names = object.names();
assertEquals(1, names.size());
assertEquals("foo", names.get(0));
@ -150,18 +121,17 @@ public class JsonObjectTest extends TestUtil {
@Test
public void namesreflectsChanges() {
List<String> names = object.names();
object.add("foo", true);
assertEquals(1, names.size());
assertEquals("foo", names.get(0));
}
@Test(expected = UnsupportedOperationException.class)
@Test
public void namespreventsModification() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
List<String> names = object.names();
names.add("foo");
});
}
@Test
@ -193,30 +163,37 @@ public class JsonObjectTest extends TestUtil {
assertEquals(new JsonObject.Member("b", JsonLiteral.FALSE), iterator.next());
}
@Test(expected = NoSuchElementException.class)
@Test
public void iteratornextFailsAtEnd() {
Assertions.assertThrows(NoSuchElementException.class, () -> {
Iterator<JsonObject.Member> iterator = object.iterator();
iterator.next();
});
}
@Test(expected = UnsupportedOperationException.class)
@Test
public void iteratordoesNotAllowModification() {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
object.add("a", 23);
Iterator<JsonObject.Member> iterator = object.iterator();
iterator.next();
iterator.remove();
});
}
@Test(expected = ConcurrentModificationException.class)
@Test
public void iteratordetectsConcurrentModification() {
Assertions.assertThrows(ConcurrentModificationException.class, () -> {
Iterator<JsonObject.Member> iterator = object.iterator();
object.add("a", 23);
iterator.next();
});
}
@Test
public void getfailsWithNullName() {
assertException(NullPointerException.class, null, (Runnable) () -> object.get(null));
Assertions.assertThrows(NullPointerException.class, () -> object.get(null));
}
@Test
@ -310,13 +287,12 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addfailsWithNullName() {
assertException(NullPointerException.class, "name is null", (Runnable) () -> object.add(null, 23));
Assertions.assertThrows(NullPointerException.class, () -> object.add(null, 23));
}
@Test
public void addint() {
object.add("a", 23);
assertEquals("{\"a\":23}", object.toString());
}
@ -328,7 +304,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addlong() {
object.add("a", 23L);
assertEquals("{\"a\":23}", object.toString());
}
@ -340,7 +315,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addfloat() {
object.add("a", 3.14f);
assertEquals("{\"a\":3.14}", object.toString());
}
@ -352,7 +326,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void adddouble() {
object.add("a", 3.14d);
assertEquals("{\"a\":3.14}", object.toString());
}
@ -364,7 +337,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addboolean() {
object.add("a", true);
assertEquals("{\"a\":true}", object.toString());
}
@ -376,14 +348,12 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addstring() {
object.add("a", "foo");
assertEquals("{\"a\":\"foo\"}", object.toString());
}
@Test
public void addstringtoleratesNull() {
object.add("a", (String) null);
assertEquals("{\"a\":null}", object.toString());
}
@ -395,21 +365,18 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addjsonNull() {
object.add("a", JsonLiteral.NULL);
assertEquals("{\"a\":null}", object.toString());
}
@Test
public void addjsonArray() {
object.add("a", new JsonArray());
assertEquals("{\"a\":[]}", object.toString());
}
@Test
public void addjsonObject() {
object.add("a", new JsonObject());
assertEquals("{\"a\":{}}", object.toString());
}
@ -420,16 +387,15 @@ public class JsonObjectTest extends TestUtil {
@Test
public void addjsonfailsWithNull() {
assertException(NullPointerException.class, "value is null", (Runnable) () -> object.add("a", (JsonValue) null));
Assertions.assertThrows(NullPointerException.class, () ->
object.add("a", (JsonValue) null));
}
@Test
public void addjsonnestedArray() {
JsonArray innerArray = new JsonArray();
innerArray.add(23);
object.add("a", innerArray);
assertEquals("{\"a\":[23]}", object.toString());
}
@ -437,9 +403,7 @@ public class JsonObjectTest extends TestUtil {
public void addjsonnestedArraymodifiedAfterAdd() {
JsonArray innerArray = new JsonArray();
object.add("a", innerArray);
innerArray.add(23);
assertEquals("{\"a\":[23]}", object.toString());
}
@ -447,9 +411,7 @@ public class JsonObjectTest extends TestUtil {
public void addjsonnestedObject() {
JsonObject innerObject = new JsonObject();
innerObject.add("a", 23);
object.add("a", innerObject);
assertEquals("{\"a\":{\"a\":23}}", object.toString());
}
@ -457,16 +419,13 @@ public class JsonObjectTest extends TestUtil {
public void addjsonnestedObjectmodifiedAfterAdd() {
JsonObject innerObject = new JsonObject();
object.add("a", innerObject);
innerObject.add("a", 23);
assertEquals("{\"a\":{\"a\":23}}", object.toString());
}
@Test
public void setint() {
object.set("a", 23);
assertEquals("{\"a\":23}", object.toString());
}
@ -478,7 +437,6 @@ public class JsonObjectTest extends TestUtil {
@Test
public void setlong() {
object.set("a", 23L);
assertEquals("{\"a\":23}", object.toString());
}
@ -589,7 +547,7 @@ public class JsonObjectTest extends TestUtil {
@Test
public void removefailsWithNullName() {
assertException(NullPointerException.class, null, (Runnable) () -> object.remove(null));
Assertions.assertThrows(NullPointerException.class, () -> object.remove(null));
}
@Test
@ -645,7 +603,7 @@ public class JsonObjectTest extends TestUtil {
@Test
public void mergefailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> object.merge(null));
Assertions.assertThrows(NullPointerException.class, () -> object.merge(null));
}
@Test

View file

@ -1,37 +1,17 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.xbib.marc.json.Json.parse;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringReader;
/**
*
*/
public class JsonReaderTest extends TestUtil {
public class JsonReaderTest {
private static String join(String... strings) {
StringBuilder builder = new StringBuilder();
@ -41,27 +21,35 @@ public class JsonReaderTest extends TestUtil {
return builder.toString();
}
@Test(expected = NullPointerException.class)
@Test
public void constructorRejectsNullHandler() {
Assertions.assertThrows(NullPointerException.class, () -> {
new JsonReader<>(null, null);
});
}
@Test(expected = NullPointerException.class)
public void parseStringrRjectsNull() throws IOException {
@Test
public void parseStringrRejectsNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(null), new TestHandler());
reader.parse();
});
}
@Test(expected = NullPointerException.class)
public void parseReaderRejectsNull() throws IOException {
@Test
public void parseReaderRejectsNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
JsonReader<Object, Object> reader = new JsonReader<>(null, new TestHandler());
reader.parse();
});
}
@Test(expected = IllegalArgumentException.class)
public void parseReaderRejectsNegativeBufferSize() throws IOException {
@Test
public void parseReaderRejectsNegativeBufferSize() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader("[]"), new TestHandler());
reader.parse(-1);
});
}
@Test
@ -72,7 +60,7 @@ public class JsonReaderTest extends TestUtil {
@Test
public void parseReaderRejectsEmpty() {
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(""), new TestHandler());
JsonException exception = assertException(JsonException.class, (RunnableEx) reader::parse);
JsonException exception = Assertions.assertThrows(JsonException.class, reader::parse);
assertThat(exception.getMessage(), startsWith("Unexpected end of input"));
}
@ -253,7 +241,7 @@ public class JsonReaderTest extends TestUtil {
final String input = "{\n \"a\": 23,\n \"b\": 42,\n}";
TestHandler handler = new TestHandler();
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(input), handler);
assertException(JsonException.class, (RunnableEx) () -> reader.parse(3));
Assertions.assertThrows(JsonException.class, () -> reader.parse(3));
}
@Test
@ -265,7 +253,7 @@ public class JsonReaderTest extends TestUtil {
final String input = array.toString();
TestHandler handler = new TestHandler();
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(input), handler);
JsonException exception = assertException(JsonException.class, (RunnableEx) reader::parse);
JsonException exception = Assertions.assertThrows(JsonException.class, reader::parse);
assertEquals("Nesting too deep", exception.getMessage());
}
@ -278,7 +266,7 @@ public class JsonReaderTest extends TestUtil {
final String input = object.toString();
TestHandler handler = new TestHandler();
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(input), handler);
JsonException exception = assertException(JsonException.class, (RunnableEx) reader::parse);
JsonException exception = Assertions.assertThrows(JsonException.class, reader::parse);
assertEquals("Nesting too deep", exception.getMessage());
}
@ -291,7 +279,7 @@ public class JsonReaderTest extends TestUtil {
final String input = value.toString();
TestHandler handler = new TestHandler();
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(input), handler);
JsonException exception = assertException(JsonException.class, (RunnableEx) reader::parse);
JsonException exception = Assertions.assertThrows(JsonException.class, reader::parse);
assertEquals("Nesting too deep", exception.getMessage());
}
@ -686,8 +674,7 @@ public class JsonReaderTest extends TestUtil {
private void assertParseException(int offset, String message, final String json) {
TestHandler handler = new TestHandler();
JsonReader<Object, Object> reader = new JsonReader<>(new StringReader(json), handler);
JsonException exception = assertException(JsonException.class, (Runnable) () -> {
JsonException exception = Assertions.assertThrows(JsonException.class, () -> {
try {
reader.parse();
} catch (IOException e) {

View file

@ -1,65 +1,42 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
/**
*
*/
public class JsonStringTest extends TestUtil {
public class JsonStringTest {
private StringWriter stringWriter;
private JsonWriter jsonWriter;
@Before
@BeforeEach
public void setUp() {
stringWriter = new StringWriter();
jsonWriter = new JsonWriter(stringWriter);
}
@Test
public void constructor_failsWithNull() {
assertException(NullPointerException.class, null, new Runnable() {
public void run() {
public void constructorFailsWithNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
new JsonString(null);
}
});
}
@Test
public void write() throws IOException {
new JsonString("foo").write(jsonWriter);
assertEquals("\"foo\"", stringWriter.toString());
}
@Test
public void write_escapesStrings() throws IOException {
public void writeEscapesStrings() throws IOException {
new JsonString("foo\\bar").write(jsonWriter);
assertEquals("\"foo\\\\bar\"", stringWriter.toString());
}
@ -74,41 +51,40 @@ public class JsonStringTest extends TestUtil {
}
@Test
public void equals_trueForSameInstance() {
public void equalsTrueForSameInstance() {
JsonString string = new JsonString("foo");
assertEquals(string, string);
}
@Test
public void equals_trueForEqualStrings() {
public void equalsTrueForEqualStrings() {
assertEquals(new JsonString("foo"), new JsonString("foo"));
}
@Test
public void equals_falseForDifferentStrings() {
public void equalsFalseForDifferentStrings() {
assertNotEquals(new JsonString(""), new JsonString("foo"));
assertNotEquals(new JsonString("foo"), new JsonString("bar"));
}
@Test
public void equals_falseForNull() {
public void equalsFalseForNull() {
assertNotEquals(null, new JsonString("foo"));
}
@Test
public void equals_falseForSubclass() {
public void equalsFalseForSubclass() {
assertNotEquals(new JsonString("foo"), new JsonString("foo") {
});
}
@Test
public void hashCode_equalsForEqualStrings() {
public void hashCodeEqualsForEqualStrings() {
assertEquals(new JsonString("foo").hashCode(), new JsonString("foo").hashCode());
}
@Test
public void hashCode_differsForDifferentStrings() {
public void hashCodeDiffersForDifferentStrings() {
assertNotEquals(new JsonString("").hashCode(), new JsonString("foo").hashCode());
assertNotEquals(new JsonString("foo").hashCode(), new JsonString("bar").hashCode());
}

View file

@ -1,35 +1,15 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
/**
*
*/
public class JsonTest extends TestUtil {
public class JsonTest {
@Test
public void literalConstants() {
@ -72,14 +52,15 @@ public class JsonTest extends TestUtil {
@Test
public void valueFloatFailsWithInfinity() {
String message = "Infinite and NaN values not permitted in JSON";
assertException(IllegalArgumentException.class, message,
(Runnable) () -> Json.of(Float.POSITIVE_INFINITY));
Assertions.assertThrows(IllegalArgumentException.class,
() -> Json.of(Float.POSITIVE_INFINITY), message);
}
@Test
public void valuefloatfailsWithNaN() {
String message = "Infinite and NaN values not permitted in JSON";
assertException(IllegalArgumentException.class, message, (Runnable) () -> Json.of(Float.NaN));
Assertions.assertThrows(IllegalArgumentException.class,
() -> Json.of(Float.NaN), message);
}
@Test
@ -100,13 +81,15 @@ public class JsonTest extends TestUtil {
@Test
public void valuedoublefailsWithInfinity() {
String message = "Infinite and NaN values not permitted in JSON";
assertException(IllegalArgumentException.class, message, (Runnable) () -> Json.of(Double.POSITIVE_INFINITY));
Assertions.assertThrows(IllegalArgumentException.class,
() -> Json.of(Double.POSITIVE_INFINITY), message);
}
@Test
public void valuedoublefailsWithNaN() {
String message = "Infinite and NaN values not permitted in JSON";
assertException(IllegalArgumentException.class, message, (Runnable) () -> Json.of(Double.NaN));
Assertions.assertThrows(IllegalArgumentException.class,
() -> Json.of(Double.NaN), message);
}
@Test
@ -140,7 +123,7 @@ public class JsonTest extends TestUtil {
@Test
public void arrayintfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((int[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((int[]) null));
}
@Test
@ -151,7 +134,7 @@ public class JsonTest extends TestUtil {
@Test
public void arraylongfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((long[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((long[]) null));
}
@Test
@ -162,7 +145,7 @@ public class JsonTest extends TestUtil {
@Test
public void arrayfloatfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((float[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((float[]) null));
}
@Test
@ -173,7 +156,7 @@ public class JsonTest extends TestUtil {
@Test
public void arraydoublefailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((double[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((double[]) null));
}
@Test
@ -184,7 +167,7 @@ public class JsonTest extends TestUtil {
@Test
public void arraybooleanfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((boolean[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((boolean[]) null));
}
@Test
@ -195,7 +178,7 @@ public class JsonTest extends TestUtil {
@Test
public void arraystringfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> Json.array((String[]) null));
Assertions.assertThrows(NullPointerException.class, () -> Json.array((String[]) null));
}
@Test
@ -210,13 +193,7 @@ public class JsonTest extends TestUtil {
@Test
public void parsestringfailsWithNull() {
assertException(NullPointerException.class, null, (Runnable) () -> {
try {
Json.parse((String) null);
} catch (IOException e) {
//
}
});
Assertions.assertThrows(NullPointerException.class, () -> Json.parse((String) null));
}
@Test

View file

@ -1,42 +1,22 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
/**
*
*/
public class JsonWriterTest {
private StringWriter output;
private JsonWriter writer;
private static String string(char... chars) {
return String.valueOf(chars);
}
@Before
@BeforeEach
public void setUp() {
output = new StringWriter();
writer = new JsonWriter(output);

View file

@ -1,34 +1,16 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.xbib.marc.StreamMatcher.assertStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcRecordAdapter;
import org.xbib.marc.MarcXchangeConstants;
import org.xbib.marc.transformer.value.MarcValueTransformers;
import org.xbib.marc.xml.MarcContentHandler;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -37,9 +19,6 @@ import java.nio.charset.Charset;
import java.text.Normalizer;
import java.util.EnumSet;
/**
*
*/
public class MarcJsonWriterTest {
/**

View file

@ -1,38 +1,17 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.xbib.marc.json.JsonWriterConfig.prettyPrint;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Locale;
/**
*
*/
public class PrettyPrintTest {
@Test

View file

@ -1,23 +1,7 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -46,7 +30,7 @@ public class TestUtil {
public static <T extends Exception> T assertException(Class<T> type, RunnableEx runnable) {
T exception = catchException(runnable, type);
assertNotNull("Expected exception: " + type.getName(), exception);
assertNotNull(exception, "Expected exception: " + type.getName());
return exception;
}

View file

@ -1,24 +1,8 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.label;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
*
@ -37,10 +21,12 @@ public class RecordLabelTest {
assertEquals(2, recordLabel.getIndicatorLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testIllegalIndicatorLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setIndicatorLength(10).build();
assertEquals(10, recordLabel.getIndicatorLength());
});
}
@Test
@ -49,15 +35,19 @@ public class RecordLabelTest {
assertEquals(2, recordLabel.getSubfieldIdentifierLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testIllegalSubfieldIdentifierLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setSubfieldIdentifierLength(10).build();
assertEquals(10, recordLabel.getSubfieldIdentifierLength());
});
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testNegativeMaxRecordLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setRecordLength(-1).build();
});
}
@Test
@ -66,9 +56,11 @@ public class RecordLabelTest {
assertEquals(9999, recordLabel.getRecordLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testOverflowRecordLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setRecordLength(10000).build();
});
}
@Test
@ -83,10 +75,12 @@ public class RecordLabelTest {
assertEquals(5, recordLabel.getDataFieldLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testIllegalDataFieldLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setDataFieldLength(10).build();
assertEquals(10, recordLabel.getDataFieldLength());
});
}
@Test
@ -95,10 +89,12 @@ public class RecordLabelTest {
assertEquals(4, recordLabel.getStartingCharacterPositionLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testIllegalStartingCharacterPositionLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setStartingCharacterPositionLength(10).build();
assertEquals(10, recordLabel.getStartingCharacterPositionLength());
});
}
@Test
@ -107,10 +103,12 @@ public class RecordLabelTest {
assertEquals(2, recordLabel.getSegmentIdentifierLength());
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testIllegalSegmentIdentifierLength() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RecordLabel recordLabel = RecordLabel.builder().setSegmentIdentifierLength(10).build();
assertEquals(10, recordLabel.getSegmentIdentifierLength());
});
}
@Test

View file

@ -0,0 +1,130 @@
package org.xbib.marc.tools;
import org.junit.contrib.java.lang.system.internal.CheckExitCalled;
import org.junit.contrib.java.lang.system.internal.NoExitSecurityManager;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolver;
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
import org.junit.platform.commons.support.ReflectionSupport;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.System.getSecurityManager;
import static java.lang.System.setSecurityManager;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* This class is original inspired from project {@code system-rules},
* rewrite it to JUnit5. It is a JUnit Jupiter extension that allows
* in-test specification of expected {@code System.exit(...)} calls.
*/
@Target({TYPE, METHOD})
@Retention(RUNTIME)
@ExtendWith(ExpectedSystemExit.Extension.class)
public @interface ExpectedSystemExit {
class Extension implements BeforeEachCallback,
AfterEachCallback,
BeforeAllCallback,
ParameterResolver,
TestExecutionExceptionHandler {
private NoExitSecurityManager noExitSecurityManager;
private SecurityManager originalManager;
@Override
public void beforeAll(ExtensionContext context) {
noExitSecurityManager = new NoExitSecurityManager(getSecurityManager());
}
@Override
public void beforeEach(ExtensionContext context) {
originalManager = getSecurityManager();
setSecurityManager(noExitSecurityManager);
}
@Override
public void afterEach(ExtensionContext context) {
NoExitSecurityManager securityManager = (NoExitSecurityManager) getSecurityManager();
ExitCapture exitCapture = getExitCapture(context);
if (exitCapture.expectExit) {
checkSystemExit(securityManager, exitCapture);
}
setSecurityManager(originalManager);
}
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
boolean isTestMethodLevel = extensionContext.getTestMethod().isPresent();
boolean isOutputCapture = parameterContext.getParameter().getType() == ExitCapture.class;
return isTestMethodLevel && isOutputCapture;
}
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
return getExitCapture(extensionContext);
}
@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
ExitCapture exitCapture = getExitCapture(context);
if (!(throwable instanceof CheckExitCalled) || !exitCapture.expectExit) {
throw throwable;
}
}
private void checkSystemExit(NoExitSecurityManager securityManager, ExitCapture exitCapture) {
if (securityManager.isCheckExitCalled()) {
exitCapture.handleSystemExitWithStatus(securityManager.getStatusOfFirstCheckExitCall());
} else {
exitCapture.handleMissingSystemExit();
}
}
private ExitCapture getExitCapture(ExtensionContext context) {
Store store = context.getStore(Namespace.create(getClass(), context.getRequiredTestMethod()));
return store.getOrComputeIfAbsent(ExitCapture.class, ReflectionSupport::newInstance, ExitCapture.class);
}
}
class ExitCapture {
private boolean expectExit = false;
private Integer expectedStatus = null;
public void expectSystemExit() {
expectExit = true;
}
public void expectSystemExitWithStatus(int status) {
expectSystemExit();
expectedStatus = status;
}
private void handleMissingSystemExit() {
if (expectExit) {
fail("System.exit has not been called.");
}
}
private void handleSystemExitWithStatus(int status) {
if (!expectExit) {
fail("Unexpected call of System.exit(" + status + ").");
} else if (expectedStatus != null) {
assertEquals(expectedStatus, Integer.valueOf(status), "Wrong exit status");
}
}
}
}

View file

@ -1,45 +1,25 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.tools;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
/**
*/
public class ToolTest {
@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
@Test
public void testToolSimple() throws Exception {
@ExpectedSystemExit
public void testToolSimple(ExpectedSystemExit.ExitCapture exitCapture) {
String[] args = {
"--in", "src/test/resources/org/xbib/marc/chabon.mrc",
"--charset", "ANSEL",
"--out", "build/chabon.mrc.xml"
};
exit.expectSystemExitWithStatus(0);
exitCapture.expectSystemExitWithStatus(0);
MarcTool.main(args);
}
@Test
public void testToolStylesheet() throws Exception {
@ExpectedSystemExit
public void testToolStylesheet(ExpectedSystemExit.ExitCapture exitCapture) {
String[] args = {
"--in", "src/test/resources/org/xbib/marc/summerland.mrc",
"--out", "build/summerland.mrc.xml",
@ -48,7 +28,7 @@ public class ToolTest {
"--stylesheet", "http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3.xsl",
"--result", "build/summerland.mods"
};
exit.expectSystemExitWithStatus(0);
exitCapture.expectSystemExitWithStatus(0);
MarcTool.main(args);
}
}

View file

@ -1,27 +1,9 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.transformer;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.marc.MarcField;
import org.xbib.marc.transformer.field.MarcFieldTransformer;
import java.util.HashMap;
import java.util.Map;

View file

@ -1,36 +1,16 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.transformer;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xbib.marc.transformer.field.MarcFieldTransformer.Operator.HEAD;
import static org.xbib.marc.transformer.field.MarcFieldTransformer.Operator.TAIL;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.xbib.marc.MarcField;
import org.xbib.marc.transformer.field.MarcFieldTransformer;
import org.xbib.marc.transformer.field.MarcFieldTransformers;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
/**
*/
public class MarcFieldTransformersTest {
@Test

View file

@ -1,15 +1,11 @@
package org.xbib.marc.transformer;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.xbib.marc.MarcField;
import org.xbib.marc.transformer.value.MarcValueTransformer;
import org.xbib.marc.transformer.value.MarcValueTransformers;
/**
*
*/
public class MarcValueTransformerTest {
@Test

View file

@ -1,26 +1,10 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.xml;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xmlunit.matchers.CompareMatcher;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
@ -28,7 +12,7 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
public class MarcEventConsumerTest extends Assert {
public class MarcEventConsumerTest {
/**
* Parsing XML by STAX (streaming XML) from Aleph publishing interface (hbz dialect).

View file

@ -1,28 +1,11 @@
/*
Copyright 2016 Jörg Prante
Licensed 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.
*/
package org.xbib.marc.xml;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
import org.xbib.marc.Marc;
import org.xbib.marc.MarcXchangeConstants;
import org.xmlunit.matchers.CompareMatcher;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
@ -30,7 +13,7 @@ import java.nio.charset.StandardCharsets;
/**
*
*/
public class MarcXMLTest extends Assert {
public class MarcXMLTest {
/**
* Parsing MARC XML embedded in OAI response from DNB/ZDB.
@ -66,7 +49,6 @@ public class MarcXMLTest extends Assert {
}
assertThat(sw.toString(),
CompareMatcher.isIdenticalTo(getClass().getResource(s + "-marcxchange.xml").openStream()));
}
/**

View file

@ -1,5 +0,0 @@
handlers = java.util.logging.ConsoleHandler
.level = INFO
java.util.logging.ConsoleHandler.level = INFO
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