diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 3d920e68..00000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-name: Java Build SNAPSHOT and push to Maven Central
-#
-
-on:
- workflow_dispatch:
- #push:
- # branches:
- # - develop
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- with:
- ref: develop
- - name: setup JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
- server-id: ossrh
- server-username: MAVEN_USERNAME
- server-password: MAVEN_PASSWORD
- gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY}}
- gpg-passphrase: MAVEN_GPG_PASSPHRASE
-
- - name: Cache Maven packages
- uses: actions/cache@v2
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
-# - name: Set up Maven Central
-# uses: actions/setup-java@v1
-# with:
-# java-version: 1.8
-# server-id: ossrh
-# server-username: MAVEN_USERNAME
-# server-password: MAVEN_PASSWORD
-# gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY}}
-# gpg-passphrase: MAVEN_GPG_PASSPHRASE
- - name: Build and publish package
- run: mvn -B package deploy
- env:
- MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
- MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
- MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
-
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
new file mode 100644
index 00000000..eaae993e
--- /dev/null
+++ b/.github/workflows/maven.yml
@@ -0,0 +1,36 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
+
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+name: Java CI with Maven
+
+on:
+ push:
+ branches: [ "main", "develop" ]
+ pull_request:
+ branches: [ "*" ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v7
+ - name: Set up JDK
+ uses: actions/setup-java@v5
+ with:
+ java-version: '25'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build with Maven
+ run: mvn -B verify --file pom.xml
+
+ # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
+ # - name: Update dependency graph
+ # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
+
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
deleted file mode 100644
index 89db92ff..00000000
--- a/.github/workflows/publish.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: Publish package on release
-# Triggered when a new release is created
-# Build and publish to maven central
-on:
- workflow_dispatch:
- # Disable auto publish on release. Trigger manually only.
- #push:
- # tags:
- # - "v*"
- #release:
- # types:
- # - created
- # Temporary, for inital push to sonatype
- #push:
- # branches:
- # - main
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: setup JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
-
- - name: Set up Maven Central
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
- server-id: ossrh
- server-username: MAVEN_USERNAME
- server-password: MAVEN_PASSWORD
- gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY}}
- gpg-passphrase: MAVEN_GPG_PASSPHRASE
-
- - name: Build and publish package
- run: mvn -B package deploy
- env:
- MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
- MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
- MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
diff --git a/.gitignore b/.gitignore
index 379b2fef..99fcc9e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ target
.idea
gpg.asc
/d1_common_java.iml
+.vscode
+misc
diff --git a/pom.xml b/pom.xml
index 7a1c94dc..8b9156fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,425 +1,204 @@
-
- 4.0.0
- org.dataone
- d1_common_java
- jar
- 2.4.3-SNAPSHOT
- DataONE_Common_Java
- http://dataone.org
- DataONE Common Code with Service Interface Definitions
-
- 2.3.1
- v1.23
- 1.7
-
-
-
- DataONE
- developers@dataone.org
- DataONE
- https://dataone.org/
-
-
-
- target
- src/main/java
- src/test/java
- target/main-target
- target/test-target
-
-
- src/main/resources
- true
-
- buildInfo/buildInfo.properties
-
-
-
- src/main/resources
- false
-
- **/*.*
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.7
- ${compiler.target.version}
-
-
-
-
- com.googlecode.maven-download-plugin
- download-maven-plugin
- 1.6.0
-
-
- install-format-ids
- validate
-
- wget
-
-
- https://raw.githubusercontent.com/DataONEorg/object-formats/${d1_format_ids.revision}/objectFormatListV2.xml
- false
- ${project.basedir}/src/main/resources/org/dataone/service/resources/config/v2
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
- validate
-
- run
-
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- xml-maven-plugin
-
-
- validate
-
- transform
-
-
-
-
-
-
- ${project.basedir}/src/main/resources/org/dataone/service/resources/config/v2/
- objectFormatList.xml
- ${project.basedir}/src/main/resources/org/dataone/service/resources/config/v1/
- ${project.basedir}/objectFormatListv2-to-v1.xsl
-
-
-
-
-
- net.sf.saxon
- Saxon-HE
- 10.3
-
-
-
-
- org.codehaus.mojo
- buildnumber-maven-plugin
-
-
- validate
-
- create
-
-
-
-
- false
- false
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- ${project.version}
- ${buildNumber}
- ${scmBranch}
- ${timestamp}
-
-
-
-
-
-
-
- test-jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.2.1
-
-
- attach-sources
- package
-
- jar-no-fork
-
-
-
-
-
- maven-clean-plugin
-
- true
-
-
- ${project.build.directory}
-
- **/*.jar
- **/.*
- **/.svn/*
-
- false
-
-
-
-
-
- com.mycila.maven-license-plugin
- maven-license-plugin
-
-
-
-
-
- maven-javadoc-plugin
- 2.9
-
-
- resource-bundles
- package
-
-
- resource-bundle
-
-
-
- attach-javadocs
-
- jar
-
-
-
- -Xdoclint:none
-
-
-
-
-
- false
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.6
- true
-
- ossrh
- https://oss.sonatype.org/
- true
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.6
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
- --pinentry-mode
- loopback
-
-
-
-
-
-
-
-
-
-
- oss.sonatype.org-snapshot
- http://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
- javax.mail
- mail
- 1.4.1
- jar
- compile
-
-
-
- javax.xml.bind
- jaxb-api
- 2.2.3
-
-
- joda-time
- joda-time
- 2.9.9
-
-
-
-
- log4j
- log4j
- 1.2.17
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.1
- maven-plugin
- compile
-
-
- junit
- junit
- [4.13.1,)
- jar
- test
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.3.1
- maven-plugin
- compile
-
-
- commons-lang
- commons-lang
-
-
-
-
- org.apache.maven.plugins
- maven-clean-plugin
- 2.4.1
- maven-plugin
- compile
-
-
- commons-fileupload
- commons-fileupload
- [1.3.3,)
-
-
- org.apache.httpcomponents
- httpmime
- 4.3.3
-
-
- org.apache.commons
- commons-collections4
- [4.1,)
-
-
- org.apache.commons
- commons-lang3
- 3.3.2
-
-
- commons-configuration
- commons-configuration
- 1.7
-
-
-
- commons-io
- commons-io
- 2.4
-
-
- commons-beanutils
- commons-beanutils
- [1.9.4,)
-
-
- javax.servlet
- javax.servlet-api
- 3.0.1
- jar
- provided
-
-
-
- org.dataone
- d1_test_resources
- ${d1_test_resources.version}
- jar
- test
-
-
-
-
- Apache License, Version 2.0
- LICENSE.txt
-
-
-
- https://github.com/DataONEorg/d1_common_java
- scm:git:ssh://github.com:DataONEorg/d1_common_java.git
- scm:git:ssh://git@github.com:DataONEorg/d1_common_java.git
- HEAD
-
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
+
+ 4.0.0
+ org.dataone
+ d1_common_java
+ jar
+ 2.4.3-SNAPSHOT
+ DataONE_Common_Java
+ https://dataone.org
+ DataONE Common Code with Service Interface Definitions
+
+ 2.4.0
+ v1.28
+ 25
+
+
+
+ DataONE
+ developers@dataone.org
+ DataONE
+ https://dataone.org/
+
+
+
+ target
+ src/main/java
+ src/test/java
+ target/main-target
+ target/test-target
+
+
+ src/main/resources
+ true
+
+ buildInfo/buildInfo.properties
+
+
+
+ src/main/resources
+ false
+
+ **/*.*
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.15.0
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.4.2
+
+
+
+ test-jar
+
+
+
+
+
+
+
+ org.apache.maven.wagon
+ wagon-ssh-external
+ 3.5.3
+
+
+
+
+
+ maven.dataone.org
+ https://maven.dataone.org/
+
+ true
+
+
+ true
+
+
+
+
+
+ javax.mail
+ mail
+ 1.4.1
+ jar
+ compile
+
+
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ 2.3.2
+
+
+
+ org.glassfish.jaxb
+ jaxb-runtime
+ 2.3.2
+
+
+ joda-time
+ joda-time
+ 2.14.2
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.26.0
+
+
+ junit
+ junit
+ [4.13.1,)
+ jar
+ test
+
+
+ commons-fileupload
+ commons-fileupload
+ [1.3.3,)
+
+
+ org.apache.httpcomponents
+ httpmime
+ 4.5.14
+
+
+ org.apache.commons
+ commons-collections4
+ [4.1,)
+
+
+ org.apache.commons
+ commons-lang3
+ 3.20.0
+
+
+ commons-configuration
+ commons-configuration
+ 1.7
+
+
+
+ commons-io
+ commons-io
+ 2.22.0
+
+
+ commons-beanutils
+ commons-beanutils
+ [1.9.4,)
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ jar
+ provided
+
+
+ org.dataone
+ d1_test_resources
+ ${d1_test_resources.version}
+ jar
+ test
+
+
+
+
+ Apache License, Version 2.0
+ LICENSE.txt
+
+
+
+ https://github.com/DataONEorg/d1_common_java
+ scm:git:ssh://github.com:DataONEorg/d1_common_java.git
+ scm:git:ssh://git@github.com:DataONEorg/d1_common_java.git
+ HEAD
+
+
+
+ false
+ maven.dataone.org
+ DataONE
+ scpexe://maven.dataone.org/var/www/maven
+ default
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+
diff --git a/src/main/java/org/dataone/mimemultipart/MultipartRequest.java b/src/main/java/org/dataone/mimemultipart/MultipartRequest.java
index 05123e17..c8290df1 100644
--- a/src/main/java/org/dataone/mimemultipart/MultipartRequest.java
+++ b/src/main/java/org/dataone/mimemultipart/MultipartRequest.java
@@ -44,6 +44,7 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
@@ -66,6 +67,7 @@ public class MultipartRequest implements HttpServletRequest {
* @param mpParams Map of field name to form field String value
*/
public MultipartRequest(HttpServletRequest request, Map mpFiles, Map> mpParams) {
+ this.request = request;
this.multipartFiles = mpFiles;
this.multipartParameters = mpParams;
}
@@ -416,11 +418,6 @@ public void logout() throws ServletException {
request.logout();
}
- /*
- * the following 3 methods are servlet-api v 3.1.0 methods, needing to be
- * implemented when moving to tomcat 8.0. Uncomment them at that time.
- */
-/*
@Override
public String changeSessionId() {
return request.changeSessionId();
@@ -436,6 +433,6 @@ public T upgrade(Class arg0)
throws IOException, ServletException {
return request.upgrade(arg0);
}
-*/
+
}
diff --git a/src/main/java/org/dataone/mimemultipart/MultipartRequestResolver.java b/src/main/java/org/dataone/mimemultipart/MultipartRequestResolver.java
index 2f48cb55..d0f23708 100644
--- a/src/main/java/org/dataone/mimemultipart/MultipartRequestResolver.java
+++ b/src/main/java/org/dataone/mimemultipart/MultipartRequestResolver.java
@@ -25,7 +25,7 @@
import java.io.*;
import java.util.*;
-
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
@@ -33,7 +33,9 @@
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+
/*
* Copyright 2002-2010 the original author or authors.
@@ -74,7 +76,8 @@
*/
public class MultipartRequestResolver {
- Logger logger = Logger.getLogger(MultipartRequestResolver.class.getName());
+ private static final Logger logger = LogManager.getLogger(MultipartRequestResolver.class.getName());
+
private DiskFileItemFactory factory;
private org.apache.commons.fileupload.servlet.ServletFileUpload upload;
final static int SIZE = 16384;
diff --git a/src/main/java/org/dataone/service/exceptions/BaseException.java b/src/main/java/org/dataone/service/exceptions/BaseException.java
index 33f59536..f226b3f0 100644
--- a/src/main/java/org/dataone/service/exceptions/BaseException.java
+++ b/src/main/java/org/dataone/service/exceptions/BaseException.java
@@ -34,7 +34,9 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -50,7 +52,8 @@
*/
public class BaseException extends Exception {
- static Logger logger = Logger.getLogger(BaseException.class.getName());
+ private static final Logger logger = LogManager.getLogger(BaseException.class.getName());
+
/** The major error code associated with this exception. */
private int code;
diff --git a/src/main/java/org/dataone/service/types/v1/ObjectFormatList.java b/src/main/java/org/dataone/service/types/v1/ObjectFormatList.java
index 9a1989fe..410c42c8 100644
--- a/src/main/java/org/dataone/service/types/v1/ObjectFormatList.java
+++ b/src/main/java/org/dataone/service/types/v1/ObjectFormatList.java
@@ -1,7 +1,6 @@
package org.dataone.service.types.v1;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -36,7 +35,7 @@
"objectFormat"
})
@XmlRootElement(name = "objectFormatList")
-public class ObjectFormatList extends Slice implements Serializable
+public class ObjectFormatList extends Slice
{
@XmlElement(required = true)
protected List objectFormat = new ArrayList();
diff --git a/src/main/java/org/dataone/service/types/v1/Permission.java b/src/main/java/org/dataone/service/types/v1/Permission.java
index c51d290d..9b90d1e6 100644
--- a/src/main/java/org/dataone/service/types/v1/Permission.java
+++ b/src/main/java/org/dataone/service/types/v1/Permission.java
@@ -1,8 +1,6 @@
package org.dataone.service.types.v1;
-import java.io.Serializable;
-
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
@@ -35,7 +33,7 @@
*/
@XmlType(name = "Permission")
@XmlEnum
-public enum Permission implements Serializable {
+public enum Permission {
@XmlEnumValue("read")
READ("read"),
@XmlEnumValue("write")
diff --git a/src/main/java/org/dataone/service/types/v1/ReplicationStatus.java b/src/main/java/org/dataone/service/types/v1/ReplicationStatus.java
index a77a1bcd..6c157ad5 100644
--- a/src/main/java/org/dataone/service/types/v1/ReplicationStatus.java
+++ b/src/main/java/org/dataone/service/types/v1/ReplicationStatus.java
@@ -1,8 +1,6 @@
package org.dataone.service.types.v1;
-import java.io.Serializable;
-
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
@@ -37,7 +35,7 @@ both available and valid (matching checksum with original), and if it is
*/
@XmlType(name = "ReplicationStatus")
@XmlEnum
-public enum ReplicationStatus implements Serializable {
+public enum ReplicationStatus {
@XmlEnumValue("queued")
QUEUED("queued"),
diff --git a/src/main/java/org/dataone/service/types/v1/ServiceMethodRestriction.java b/src/main/java/org/dataone/service/types/v1/ServiceMethodRestriction.java
index 95dc2616..4a601e5a 100644
--- a/src/main/java/org/dataone/service/types/v1/ServiceMethodRestriction.java
+++ b/src/main/java/org/dataone/service/types/v1/ServiceMethodRestriction.java
@@ -1,7 +1,6 @@
package org.dataone.service.types.v1;
-import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -28,7 +27,7 @@
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ServiceMethodRestriction")
@XmlRootElement(name = "serviceMethodRestriction")
-public class ServiceMethodRestriction extends SubjectList implements Serializable
+public class ServiceMethodRestriction extends SubjectList
{
@XmlAttribute(name = "methodName", required = true)
diff --git a/src/main/java/org/dataone/service/types/v1/TypeFactory.java b/src/main/java/org/dataone/service/types/v1/TypeFactory.java
index b793c8fb..d9300cb8 100644
--- a/src/main/java/org/dataone/service/types/v1/TypeFactory.java
+++ b/src/main/java/org/dataone/service/types/v1/TypeFactory.java
@@ -32,7 +32,8 @@
import org.apache.commons.io.input.CountingInputStream;
import org.dataone.exceptions.MarshallingException;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.exceptions.NotFound;
import org.dataone.service.exceptions.ServiceFailure;
import org.dataone.service.types.v1.util.ChecksumUtil;
@@ -49,7 +50,7 @@
*/
public class TypeFactory {
- protected static Logger logger = Logger.getLogger(TypeFactory.class.getName());
+ protected static Logger logger = LogManager.getLogger(TypeFactory.class.getName());
/**
* Factory method for creating an ObjectFormatIdentifier. Does not enforce business rules.
diff --git a/src/main/java/org/dataone/service/types/v1/util/AuthUtils.java b/src/main/java/org/dataone/service/types/v1/util/AuthUtils.java
index b843b160..79f3551f 100644
--- a/src/main/java/org/dataone/service/types/v1/util/AuthUtils.java
+++ b/src/main/java/org/dataone/service/types/v1/util/AuthUtils.java
@@ -6,15 +6,12 @@
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
-import org.apache.log4j.Logger;
-import org.dataone.service.exceptions.InvalidSystemMetadata;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.types.v1.AccessRule;
import org.dataone.service.types.v1.Group;
-import org.dataone.service.types.v1.Node;
-import org.dataone.service.types.v1.NodeList;
import org.dataone.service.types.v1.Permission;
import org.dataone.service.types.v1.Person;
-import org.dataone.service.types.v1.Service;
import org.dataone.service.types.v1.Session;
import org.dataone.service.types.v1.Subject;
import org.dataone.service.types.v1.SubjectInfo;
@@ -23,7 +20,7 @@
public class AuthUtils {
- private static final Logger logger = Logger.getLogger(AuthUtils.class);
+ private static final Logger logger = LogManager.getLogger(AuthUtils.class.getName());
private static Subject buildSubject(String value) {
diff --git a/src/main/java/org/dataone/service/types/v1/util/ServiceMethodRestrictionUtil.java b/src/main/java/org/dataone/service/types/v1/util/ServiceMethodRestrictionUtil.java
index 7190c2b1..2a73ad42 100644
--- a/src/main/java/org/dataone/service/types/v1/util/ServiceMethodRestrictionUtil.java
+++ b/src/main/java/org/dataone/service/types/v1/util/ServiceMethodRestrictionUtil.java
@@ -25,7 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.configuration.Settings;
import org.dataone.service.types.v1.Node;
import org.dataone.service.types.v1.NodeState;
@@ -43,7 +44,7 @@
*/
public class ServiceMethodRestrictionUtil {
- private static final Logger logger = Logger.getLogger(ServiceMethodRestrictionUtil.class);
+ private static final Logger logger = LogManager.getLogger(ServiceMethodRestrictionUtil.class.getName());
/**
* Interprets the CN's ServiceMethodRestriction for a given Subject+serviceName+methodName
diff --git a/src/main/java/org/dataone/service/types/v1/util/TypeCompareUtil.java b/src/main/java/org/dataone/service/types/v1/util/TypeCompareUtil.java
index d7a49a40..358f5925 100644
--- a/src/main/java/org/dataone/service/types/v1/util/TypeCompareUtil.java
+++ b/src/main/java/org/dataone/service/types/v1/util/TypeCompareUtil.java
@@ -38,7 +38,8 @@
import java.util.Set;
import java.util.TreeSet;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.types.v1.AccessRule;
import org.dataone.service.types.v1.Identifier;
import org.dataone.service.types.v1.NodeReference;
@@ -63,7 +64,7 @@
*/
public class TypeCompareUtil {
- static Logger logger = Logger.getLogger(TypeCompareUtil.class.getName());
+ static Logger logger = LogManager.getLogger(TypeCompareUtil.class.getName());
// TODO: compare with https://github.com/SQiShER/java-object-diff/ wrt/ long-term implementation
diff --git a/src/main/java/org/dataone/service/types/v1_1/QueryEngineList.java b/src/main/java/org/dataone/service/types/v1_1/QueryEngineList.java
index 16484fc9..2db023d9 100644
--- a/src/main/java/org/dataone/service/types/v1_1/QueryEngineList.java
+++ b/src/main/java/org/dataone/service/types/v1_1/QueryEngineList.java
@@ -6,7 +6,6 @@
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
diff --git a/src/main/java/org/dataone/service/types/v2/Node.java b/src/main/java/org/dataone/service/types/v2/Node.java
index 316975f8..1b7e098f 100644
--- a/src/main/java/org/dataone/service/types/v2/Node.java
+++ b/src/main/java/org/dataone/service/types/v2/Node.java
@@ -1,7 +1,6 @@
package org.dataone.service.types.v2;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -31,8 +30,7 @@
"property"
})
@XmlRootElement(name = "node")
-public class Node extends org.dataone.service.types.v1.Node implements
- Serializable
+public class Node extends org.dataone.service.types.v1.Node
{
private static final long serialVersionUID = 10000001;
protected List property = new ArrayList();
diff --git a/src/main/java/org/dataone/service/types/v2/OptionList.java b/src/main/java/org/dataone/service/types/v2/OptionList.java
index b456ae26..d5ccfed5 100644
--- a/src/main/java/org/dataone/service/types/v2/OptionList.java
+++ b/src/main/java/org/dataone/service/types/v2/OptionList.java
@@ -9,7 +9,6 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
/**
* A list of options that indicate the possible values for
a DataONE service. Each option that can be validly sent to a service is
diff --git a/src/main/java/org/dataone/service/types/v2/SystemMetadata.java b/src/main/java/org/dataone/service/types/v2/SystemMetadata.java
index 11d03c3b..4641774a 100644
--- a/src/main/java/org/dataone/service/types/v2/SystemMetadata.java
+++ b/src/main/java/org/dataone/service/types/v2/SystemMetadata.java
@@ -1,7 +1,6 @@
package org.dataone.service.types.v2;
-import java.io.Serializable;
import org.dataone.service.types.v1.Identifier;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -40,7 +39,6 @@
})
@XmlRootElement( name = "systemMetadata")
public class SystemMetadata extends org.dataone.service.types.v1.SystemMetadata
- implements Serializable
{
private static final long serialVersionUID = 10000001;
diff --git a/src/main/java/org/dataone/service/types/v2/TypeFactory.java b/src/main/java/org/dataone/service/types/v2/TypeFactory.java
index 8afa4939..97007e47 100644
--- a/src/main/java/org/dataone/service/types/v2/TypeFactory.java
+++ b/src/main/java/org/dataone/service/types/v2/TypeFactory.java
@@ -131,7 +131,7 @@ public static T convertTypeFromType(Object original, Class destinationCla
original.toString()));
}
- T destInstance = destinationClass.newInstance();
+ T destInstance = destinationClass.getDeclaredConstructor().newInstance();
Map propMap = BeanUtils.describe(original);
if (logger.isDebugEnabled())
@@ -201,7 +201,7 @@ public static T convertTypeFromType(Object original, Class destinationCla
if (origType == boolean.class)
readMethodName = readMethodName.replaceFirst("get", "is");
- Method m = original.getClass().getMethod(readMethodName, (Class>[])null);
+ original.getClass().getMethod(readMethodName, (Class>[])null);
if (destType == origType)
BeanUtils.copyProperty(destInstance, propName,
PropertyUtils.getSimpleProperty(original, propName));
diff --git a/src/main/java/org/dataone/service/types/v2/util/ObjectFormatServiceImpl.java b/src/main/java/org/dataone/service/types/v2/util/ObjectFormatServiceImpl.java
index 0db3d0e2..ff508f83 100644
--- a/src/main/java/org/dataone/service/types/v2/util/ObjectFormatServiceImpl.java
+++ b/src/main/java/org/dataone/service/types/v2/util/ObjectFormatServiceImpl.java
@@ -25,7 +25,8 @@
import java.util.HashMap;
import org.dataone.exceptions.MarshallingException;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.exceptions.NotFound;
import org.dataone.service.exceptions.NotImplemented;
import org.dataone.service.exceptions.ServiceFailure;
@@ -58,7 +59,7 @@ public class ObjectFormatServiceImpl {
*/
protected ObjectFormatServiceImpl() throws ServiceFailure {
- logger = Logger.getLogger(ObjectFormatServiceImpl.class);
+ logger = LogManager.getLogger(ObjectFormatServiceImpl.class.getName());
objectFormatMap = new HashMap();
try {
diff --git a/src/main/java/org/dataone/service/types/v2/util/ServiceMethodRestrictionUtil.java b/src/main/java/org/dataone/service/types/v2/util/ServiceMethodRestrictionUtil.java
index 31eb1e20..a754b395 100644
--- a/src/main/java/org/dataone/service/types/v2/util/ServiceMethodRestrictionUtil.java
+++ b/src/main/java/org/dataone/service/types/v2/util/ServiceMethodRestrictionUtil.java
@@ -25,7 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.configuration.Settings;
import org.dataone.service.types.v2.Node;
import org.dataone.service.types.v1.NodeState;
@@ -43,7 +44,7 @@
*/
public class ServiceMethodRestrictionUtil {
- private static final Logger logger = Logger.getLogger(ServiceMethodRestrictionUtil.class);
+ private static final Logger logger = LogManager.getLogger(ServiceMethodRestrictionUtil.class.getName());
/**
* Interprets the CN's ServiceMethodRestriction for a given Subject+serviceName+methodName
diff --git a/src/main/java/org/dataone/service/util/AccessRuleMarshallingAdapter.java b/src/main/java/org/dataone/service/util/AccessRuleMarshallingAdapter.java
index 1d1fca5e..2daafb7e 100644
--- a/src/main/java/org/dataone/service/util/AccessRuleMarshallingAdapter.java
+++ b/src/main/java/org/dataone/service/util/AccessRuleMarshallingAdapter.java
@@ -2,7 +2,6 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.dataone.service.types.v1.AccessPolicy;
import org.dataone.service.types.v1.AccessRule;
public class AccessRuleMarshallingAdapter extends XmlAdapter {
diff --git a/src/main/java/org/dataone/service/util/ExceptionalInputStream.java b/src/main/java/org/dataone/service/util/ExceptionalInputStream.java
index 3554fecc..491b573a 100644
--- a/src/main/java/org/dataone/service/util/ExceptionalInputStream.java
+++ b/src/main/java/org/dataone/service/util/ExceptionalInputStream.java
@@ -58,15 +58,15 @@ public boolean isException() throws IOException {
byte[] b = new byte[lookAheadBytes];
int totalRead = read(b,0,5);
if (totalRead <1) {
- isException = new Boolean(false);
+ isException = Boolean.FALSE;
return isException.booleanValue();
}
String readString = new String(b,"UTF-8");
if (readString.startsWith(D1_XML_ERROR)) {
- isException = new Boolean(true);
+ isException = Boolean.TRUE;
} else {
- isException = new Boolean(true);
+ isException = Boolean.TRUE;
int newlyRead = 0;
while (newlyRead != -1 && bracketCount < 2 && totalRead < lookAheadBytes - lookAheadIncrement) {
newlyRead = read(b,totalRead,lookAheadIncrement);
@@ -74,7 +74,7 @@ public boolean isException() throws IOException {
totalRead += newlyRead;
readString = new String(b,"UTF-8");
if (readString.contains(D1_TYPE_INDICATOR)) {
- isException = new Boolean(false);
+ isException = Boolean.FALSE;
break;
}
if (readString.contains(">")) {
diff --git a/src/main/java/org/dataone/service/util/TypeMarshaller.java b/src/main/java/org/dataone/service/util/TypeMarshaller.java
index d796244e..68a4f26d 100644
--- a/src/main/java/org/dataone/service/util/TypeMarshaller.java
+++ b/src/main/java/org/dataone/service/util/TypeMarshaller.java
@@ -26,7 +26,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.URL;
+import java.net.URI;
import java.util.HashMap;
import java.util.Map;
@@ -40,40 +40,41 @@
import javax.xml.validation.SchemaFactory;
import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.configuration.Settings;
import org.dataone.exceptions.MarshallingException;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-
/**
* The standard class used to marshal and unmarshal datatypes to and from input
* and output streams and file structures.
*
- * This class maintains static global state of expensive-to-create JAXB contexts.
+ * This class maintains static global state of expensive-to-create JAXB
+ * contexts.
*
- * Schema validation is performed by default upon marshalling, using either the packaged
- * DataONE schemas, or if set, from the list of schemas indicated by marshalling.d1.schema.urls
+ * Schema validation is performed by default upon marshalling, using either the
+ * packaged
+ * DataONE schemas, or if set, from the list of schemas indicated by
+ * marshalling.d1.schema.urls
* (Can only be reset with restart of the runtime).
*
- * Validation by default can be disabled with the configuration property
+ * Validation by default can be disabled with the configuration property
* 'marshalling.d1.schema.validation=false'
- *
- *
- *
- * @author rwaltz
*/
public class TypeMarshaller {
- static Logger logger = Logger.getLogger(TypeMarshaller.class.getName());
+ static Logger logger = LogManager.getLogger(TypeMarshaller.class.getName());
+
+ static final protected Map jaxbContextMap = new HashMap<>();
+
+ static final protected boolean USE_SCHEMA_VALIDATION = Settings.getConfiguration()
+ .getBoolean("marshalling.d1.schema.validation", /* default */ true);
- static final protected Map jaxbContextMap = new HashMap<>();
-
- static final protected boolean USE_SCHEMA_VALIDATION =
- Settings.getConfiguration().getBoolean("marshalling.d1.schema.validation", /* default */ true);
-
- /** The java representation of the DataONE schemas used to validate unmarshalling */
+ /**
+ * The java representation of the DataONE schemas used to validate unmarshalling
+ */
static final protected Schema D1_SCHEMAS;
static {
// initialization of D1_SCHEMAS
@@ -84,62 +85,63 @@ public class TypeMarshaller {
if (schemaUrls == null || schemaUrls.length == 0) {
// load the ones from the jar
schemas = new StreamSource[] {
- new StreamSource( TypeMarshaller.class.getResourceAsStream("dataoneTypes.xsd") ),
- new StreamSource( TypeMarshaller.class.getResourceAsStream("dataoneTypes_v1.1.xsd")),
- new StreamSource( TypeMarshaller.class.getResourceAsStream("dataoneTypes_v2.0.xsd")),
- new StreamSource( TypeMarshaller.class.getResourceAsStream("dataoneErrors.xsd"))
+ new StreamSource(TypeMarshaller.class.getResourceAsStream("dataoneTypes.xsd")),
+ new StreamSource(TypeMarshaller.class.getResourceAsStream("dataoneTypes_v1.1.xsd")),
+ new StreamSource(TypeMarshaller.class.getResourceAsStream("dataoneTypes_v2.0.xsd")),
+ new StreamSource(TypeMarshaller.class.getResourceAsStream("dataoneErrors.xsd"))
};
- }
- else {
+ } else {
schemas = new StreamSource[schemaUrls.length];
- for (int i=0; i", styleSheet));
- }
- if (TypeMarshaller.USE_SCHEMA_VALIDATION)
- jaxbMarshaller.setSchema(D1_SCHEMAS);
-
- jaxbMarshaller.marshal( typeObject, os );
-
- } catch (JAXBException e) {
- throw new MarshallingException(e.getMessage(),e);
- }
+ throws MarshallingException, IOException {
+ marshalTypeToOutputStream(typeObject, os);
}
-
-
+
/**
* Unmarshals the contents of the filenamePath into the specified domainClass.
*
@@ -246,19 +243,17 @@ public static void marshalTypeToOutputStream(Object typeObject, OutputStream os,
* @throws IllegalAccessException
* @throws MarshallingException
*/
- public static T unmarshalTypeFromFile(Class domainClass, File file)
- throws IOException, InstantiationException, IllegalAccessException, MarshallingException
- {
+ public static T unmarshalTypeFromFile(Class domainClass, File file)
+ throws IOException, InstantiationException, IllegalAccessException, MarshallingException {
try {
Unmarshaller jaxbUnmarshaller = TypeMarshaller.getJAXBContext(domainClass).createUnmarshaller();
- return (T) jaxbUnmarshaller.unmarshal(file);
+ return (T) jaxbUnmarshaller.unmarshal(file);
} catch (JAXBException e) {
- throw new MarshallingException(e.getMessage(),e);
+ throw new MarshallingException(e.getMessage(), e);
}
}
-
- /**
+ /**
* Unmarshalls the contents of file parameter to the specified domainClass
*
* @param
@@ -270,16 +265,15 @@ public static T unmarshalTypeFromFile(Class domainClass, File file)
* @throws IllegalAccessException
* @throws MarshallingException
*/
- public static T unmarshalTypeFromFile(Class domainClass, String filenamePath)
- throws IOException, InstantiationException, IllegalAccessException, MarshallingException
- {
+ public static T unmarshalTypeFromFile(Class domainClass, String filenamePath)
+ throws IOException, InstantiationException, IllegalAccessException, MarshallingException {
return TypeMarshaller.unmarshalTypeFromFile(domainClass, new File(filenamePath));
}
-
-
+
/**
* Unmarshals the inputStream to the specified domainClass
* and unequivocally closes the passed in InputStream .
+ *
* @param
* @param domainClass
* @param inputStream
@@ -289,14 +283,13 @@ public static T unmarshalTypeFromFile(Class domainClass, String filenameP
* @throws IllegalAccessException
* @throws MarshallingException
*/
- public static T unmarshalTypeFromStream(Class domainClass, InputStream inputStream)
- throws IOException, InstantiationException, IllegalAccessException, MarshallingException
- {
+ public static T unmarshalTypeFromStream(Class domainClass, InputStream inputStream)
+ throws IOException, InstantiationException, IllegalAccessException, MarshallingException {
try {
Unmarshaller jaxbUnmarshaller = TypeMarshaller.getJAXBContext(domainClass).createUnmarshaller();
return (T) jaxbUnmarshaller.unmarshal(inputStream);
} catch (JAXBException e) {
- throw new MarshallingException(e.getMessage(),e);
+ throw new MarshallingException(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
diff --git a/src/main/resources/buildInfo/buildInfo.properties b/src/main/resources/buildInfo/buildInfo.properties
deleted file mode 100644
index fb1fc987..00000000
--- a/src/main/resources/buildInfo/buildInfo.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-D1-Component=${project.artifactId}
-D1-version=${project.version}
-D1-SCM-Revision=${buildNumber}
-D1-SCM-Branch=${scmBranch}
-D1-Build-TimeStamp=${timestamp}
-
diff --git a/src/test/java/org/dataone/service/types/D1NamespaceContext.java b/src/test/java/org/dataone/service/types/D1NamespaceContext.java
index 24cf6164..c017d210 100644
--- a/src/test/java/org/dataone/service/types/D1NamespaceContext.java
+++ b/src/test/java/org/dataone/service/types/D1NamespaceContext.java
@@ -9,14 +9,15 @@
import java.util.Iterator;
import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
/**
*
* @author waltz
*/
public class D1NamespaceContext implements NamespaceContext {
-private static Logger log = Logger.getLogger(D1NamespaceContext.class);
+private static Logger log = LogManager.getLogger(D1NamespaceContext.class.getName());
@Override
public String getNamespaceURI(String prefix) {
String uri = null;
diff --git a/src/test/java/org/dataone/service/types/v1/SystemMetadataTestCase.java b/src/test/java/org/dataone/service/types/v1/SystemMetadataTestCase.java
index c0526a42..8a9e2a3a 100644
--- a/src/test/java/org/dataone/service/types/v1/SystemMetadataTestCase.java
+++ b/src/test/java/org/dataone/service/types/v1/SystemMetadataTestCase.java
@@ -31,7 +31,8 @@
import javax.xml.xpath.XPathFactory;
import org.dataone.exceptions.MarshallingException;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.util.TypeMarshaller;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -46,7 +47,7 @@
*/
public class SystemMetadataTestCase {
- private static Logger log = Logger.getLogger(SystemMetadataTestCase.class);
+ private static Logger log = LogManager.getLogger(SystemMetadataTestCase.class.getName());
private static SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
private static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
diff --git a/src/test/java/org/dataone/service/types/v1/TypeSamplesTestCase.java b/src/test/java/org/dataone/service/types/v1/TypeSamplesTestCase.java
index 91136e04..1b0ce0a9 100644
--- a/src/test/java/org/dataone/service/types/v1/TypeSamplesTestCase.java
+++ b/src/test/java/org/dataone/service/types/v1/TypeSamplesTestCase.java
@@ -28,6 +28,7 @@
import java.io.InputStream;
import java.io.StringWriter;
import java.math.BigInteger;
+import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@@ -49,7 +50,8 @@
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.exceptions.MarshallingException;
import org.dataone.service.types.v2.util.ObjectFormatServiceImpl;
import org.dataone.service.util.TypeMarshaller;
@@ -61,8 +63,8 @@
public class TypeSamplesTestCase {
- private static Logger logger = Logger.getLogger(TypeSamplesTestCase.class);
- static final String datatypeSchemaTagUrl = "https://repository.dataone.org/software/cicore/tags/D1_SCHEMA_1_0_2/";
+ private static Logger logger = LogManager.getLogger(TypeSamplesTestCase.class.getName());
+ static final String datatypeSchemaTagUrl = "https://raw.githubusercontent.com/DataONEorg/d1_schemas/refs/heads/main/";
static String datatypeSchemaLocation = datatypeSchemaTagUrl + "dataoneTypes.xsd";
static String systemMetadataSchemaLocation = datatypeSchemaTagUrl + "dataoneTypes.xsd";
static String systemObjectListSchemaLocation = datatypeSchemaTagUrl + "dataoneTypes.xsd";
@@ -79,65 +81,56 @@ public void fake() throws Exception {
@Test
public void validateSysmetaSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemMetadataSchemaLocation, "/org/dataone/service/samples/v1/systemMetadataSample1.xml"));
-
}
@Test
public void validateSysmetaMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(testSystemMetadataMarshalling("/org/dataone/service/samples/v1/systemMetadataSample1.xml"));
-
}
@Test
public void validateSysmetaSampleUnicodeSupplEscaped() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemMetadataSchemaLocation, "/org/dataone/service/samples/v1/systemMetadataSampleUnicodeSupplEscaped.xml"));
-
}
-// @Test
+ // @Test
public void validateSysmetaSampleUnicodeSupplEscapedMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(testSystemMetadataMarshalling("/org/dataone/service/samples/v1/systemMetadataSampleUnicodeSupplEscaped.xml"));
-
}
@Test
public void validateObjectListSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemObjectListSchemaLocation, "/org/dataone/service/samples/v1/objectListSample1.xml"));
-
}
@Test
public void validateObjectListMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(testObjectListMarshalling("/org/dataone/service/samples/v1/objectListSample1.xml"));
-
}
@Test
public void validateLoggingSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemLoggingSchemaLocation, "/org/dataone/service/samples/v1/loggingSample1.xml"));
-
}
@Test
public void validateLoggingMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(testLoggingMarshalling("/org/dataone/service/samples/v1/loggingSample1.xml"));
-
}
@Test
public void validateNodeRegistrySample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemNodeRegistrySchemaLocation, "/org/dataone/service/samples/v1/nodeListSample1.xml"));
-
}
@Test
public void validateNodeRegistryMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
@@ -145,37 +138,31 @@ public void validateNodeRegistryMarshalling() throws Exception, SAXException, IO
}
@Test
public void validateNodeSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemMetadataSchemaLocation, "/org/dataone/service/samples/v1/mnNode1.xml"));
-
}
@Test
public void validateIdentifierSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemIdentifierSchemaLocation, "/org/dataone/service/samples/v1/identifier1.xml"));
-
}
@Test
public void validateIdentifierMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(testIdentifierMarshalling("/org/dataone/service/samples/v1/identifier1.xml"));
-
}
@Test
public void validateChecksumSample() throws Exception, SAXException, IOException, ParserConfigurationException {
-// TODO arguments should be injected based on version of service api to test and build
+ // TODO arguments should be injected based on version of service api to test and build
assertTrue(validateExamples(systemChecksumSchemaLocation, "/org/dataone/service/samples/v1/checksum1.xml"));
-
}
@Test
public void validateChecksuMarshalling() throws Exception, SAXException, IOException, ParserConfigurationException {
-
assertTrue(testChecksumMarshalling("/org/dataone/service/samples/v1/checksum1.xml"));
-
}
@@ -192,14 +179,15 @@ public void serializeReplica() throws MarshallingException, IOException {
}
- private boolean validateExamples(String xsdUrlString, InputStream xmlInputStream) throws Exception, SAXException, IOException, ParserConfigurationException {
+ private boolean validateExamples(String xsdUrlString, InputStream xmlInputStream)
+ throws Exception, SAXException, IOException, ParserConfigurationException {
DocumentBuilder parser;
// create a SchemaFactory capable of understanding WXS schemas
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Document document;
Schema schema;
Source schemaFile;
- URL xsdUrl = new URL(xsdUrlString);
+ URL xsdUrl = URI.create(xsdUrlString).toURL();
URLConnection xsdUrlConnection = xsdUrl.openConnection();
InputStream xsdUrlStream = xsdUrlConnection.getInputStream();
@@ -237,7 +225,8 @@ private boolean validateExamples(String xsdUrlString, InputStream xmlInputStream
}
- private boolean validateExamples(String xsdUrlString, String xmlDocument) throws Exception, SAXException, IOException, ParserConfigurationException {
+ private boolean validateExamples(String xsdUrlString, String xmlDocument)
+ throws Exception, SAXException, IOException, ParserConfigurationException {
return validateExamples(xsdUrlString, this.getClass().getResourceAsStream(xmlDocument));
}
@@ -246,7 +235,7 @@ private boolean validateExamples(String xsdUrlString, String xmlDocument) throws
* @author Robert P Waltz.
*/
private class ValidateXmlDocument {
-// Logger logger = Logger.getRootLogger();
+ // Logger logger = Logger.getRootLogger();
private class ErrorHandlerImpl implements ErrorHandler {
@@ -257,13 +246,13 @@ public void warning(SAXParseException exception) throws SAXException {
public void error(SAXParseException exception) throws SAXException {
System.out.print(exception.getMessage());
-// logger.warn(exception.getMessage());
+ // logger.warn(exception.getMessage());
throw exception;
}
public void fatalError(SAXParseException exception) throws SAXException {
System.out.print(exception.getMessage());
-// logger.warn(exception.getMessage());
+ // logger.warn(exception.getMessage());
throw exception;
}
}
@@ -277,7 +266,7 @@ public ValidateXmlDocument(Schema schema) {
validator = schema.newValidator();
validator.setErrorHandler(errorHandlerImpl);
} catch (Exception e) {
-// logger.error("FATAL ERROR: INITIALIZATION OF XML VALIDATE SERVICE IMPL\n",e);
+ // logger.error("FATAL ERROR: INITIALIZATION OF XML VALIDATE SERVICE IMPL\n",e);
validator = null;
}
}
@@ -326,9 +315,7 @@ public void testSimpleSystemMetadataMarshalling() throws Exception {
systemMetadata.setSerialVersion(BigInteger.ONE);
Identifier identifier = new Identifier();
identifier.setValue("ABC432");
-// systemMetadata.
systemMetadata.setIdentifier(identifier);
-// ObjectFormat objectFormat;
ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
fmtid.setValue("CF-1.0");
ObjectFormat thisOF = ObjectFormatServiceImpl.getInstance().getFormat(fmtid);
diff --git a/src/test/java/org/dataone/service/types/v2/SystemMetadataTestCase.java b/src/test/java/org/dataone/service/types/v2/SystemMetadataTestCase.java
index 67fdb545..d5b0aeb2 100644
--- a/src/test/java/org/dataone/service/types/v2/SystemMetadataTestCase.java
+++ b/src/test/java/org/dataone/service/types/v2/SystemMetadataTestCase.java
@@ -31,7 +31,8 @@
import javax.xml.xpath.XPathFactory;
import org.dataone.exceptions.MarshallingException;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.types.v1.AccessPolicy;
import org.dataone.service.types.v1.AccessRule;
import org.dataone.service.types.v1.Checksum;
@@ -57,7 +58,7 @@
*/
public class SystemMetadataTestCase {
- private static Logger log = Logger.getLogger(SystemMetadataTestCase.class);
+ private static Logger log = LogManager.getLogger(SystemMetadataTestCase.class.getName());
private static SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
private static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
diff --git a/src/test/java/org/dataone/service/types/v2/util/NodelistUtilTestCase.java b/src/test/java/org/dataone/service/types/v2/util/NodelistUtilTestCase.java
index d70a0a95..7d04215f 100644
--- a/src/test/java/org/dataone/service/types/v2/util/NodelistUtilTestCase.java
+++ b/src/test/java/org/dataone/service/types/v2/util/NodelistUtilTestCase.java
@@ -27,7 +27,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.List;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Set;
@@ -65,13 +65,13 @@ public final void testMapNodeList()
{
InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v2/nodeListSample2.xml");
- String nodeDoc = IOUtils.toString(is);
+ String nodeDoc = IOUtils.toString(is, StandardCharsets.UTF_8);
assertTrue("Node document null.", (nodeDoc != null));
assertTrue("Node document has 0 content", nodeDoc.length() > 0);
log.info(nodeDoc);
- InputStream ndIs = IOUtils.toInputStream(nodeDoc);
+ InputStream ndIs = IOUtils.toInputStream(nodeDoc, StandardCharsets.UTF_8);
Map m = NodelistUtil.mapNodeList(ndIs);
assertTrue("knb-mn key", m.containsKey("urn:node:d1m2"));
diff --git a/src/test/java/org/dataone/service/util/D1Url1TestCase.java b/src/test/java/org/dataone/service/util/D1Url1TestCase.java
index 426f0474..01ae74cd 100644
--- a/src/test/java/org/dataone/service/util/D1Url1TestCase.java
+++ b/src/test/java/org/dataone/service/util/D1Url1TestCase.java
@@ -28,12 +28,13 @@
import java.util.Date;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.junit.Test;
public class D1Url1TestCase {
- private static Logger logger = Logger.getLogger(D1Url1TestCase.class);
+ private static Logger logger = LogManager.getLogger(D1Url1TestCase.class.getName());
private static String testBaseUrl = "http://foo.com/";
private static String testBaseUrlNoEndingSlash = "http://foo.com";
private static String testResource = "myResource";
@@ -118,7 +119,7 @@ public void testUrlQuery_ParamPair_Date() {
@Test
public void testUrlQuery_ParamPair_Integer() {
D1Url url = new D1Url(testBaseUrl,testResource);
- Integer i = new Integer(37);
+ Integer i = Integer.valueOf(37);
url.addNonEmptyParamPair("p1", i);
String expected = testBaseUrl + testResource + "?p1=37";
diff --git a/src/test/java/org/dataone/service/util/ExceptionHandlerTestCase.java b/src/test/java/org/dataone/service/util/ExceptionHandlerTestCase.java
index 08ba8003..e3fc0f89 100644
--- a/src/test/java/org/dataone/service/util/ExceptionHandlerTestCase.java
+++ b/src/test/java/org/dataone/service/util/ExceptionHandlerTestCase.java
@@ -29,6 +29,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;
import java.util.TreeMap;
@@ -87,7 +88,7 @@ public void testFilterErrors_IS_nonErrors() throws UnsupportedEncodingException
InputStream nonErrorStream = new ByteArrayInputStream(nonErrorString.getBytes("UTF-8"));
try {
InputStream is = ExceptionHandler.filterErrors(nonErrorStream, false, "text");
- assertEquals(nonErrorString, IOUtils.toString(is));
+ assertEquals(nonErrorString, IOUtils.toString(is, StandardCharsets.UTF_8));
} catch (BaseException be) {
fail("shouldn't throw exception");
@@ -194,7 +195,7 @@ public void testFilterErrorsHeader_HEAD() throws UnsupportedEncodingException {
} catch (NotFound e) {
assertEquals(setDetailCode, e.getDetail_code());
assertEquals(setDescription, e.getDescription());
- assertEquals(setPID, e.getPid());
+ assertEquals(setPID, e.getIdentifier());
} catch (BaseException e) {
fail("shouldn't throw this exception: " + e.getClass().getSimpleName());
} catch (IllegalStateException e) {
@@ -266,7 +267,7 @@ public void testFilterErrorsHeader_GET() throws UnsupportedEncodingException {
@Test
public void testDeserializeAndThrowException() throws UnsupportedEncodingException {
- Integer errorCode = new Integer(404);
+ Integer errorCode = Integer.valueOf(404);
String errorReason = "Not Found";
String contentType = "xml";
String setDescription = "a description";
@@ -354,7 +355,7 @@ public void AuthenticationTimeoutTest() throws ParserConfigurationException, SAX
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(408);
+ Integer errorCode = Integer.valueOf(408);
String errorReason = "AuthenticationTimeout";
AuthenticationTimeout authTimeout = new AuthenticationTimeout("100", "test AuthenticationTimeout");
String exceptTestSerial = authTimeout.serialize(BaseException.FMT_XML);
@@ -375,7 +376,7 @@ public void IdentifierNotUniqueTest() throws ParserConfigurationException, SAXEx
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(409);
+ Integer errorCode = Integer.valueOf(409);
String errorReason = "IdentifierNotUnique";
IdentifierNotUnique exceptTest = new IdentifierNotUnique("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -396,7 +397,7 @@ public void InsufficientResourcesTest() throws ParserConfigurationException, SAX
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(413);
+ Integer errorCode = Integer.valueOf(413);
String errorReason = "InsufficientResources";
InsufficientResources exceptTest = new InsufficientResources("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -417,7 +418,7 @@ public void InvalidCredentialsTest() throws ParserConfigurationException, SAXExc
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(401);
+ Integer errorCode = Integer.valueOf(401);
String errorReason = "InvalidCredentials";
InvalidCredentials exceptTest = new InvalidCredentials("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -438,7 +439,7 @@ public void InvalidRequestTest() throws ParserConfigurationException, SAXExcepti
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(400);
+ Integer errorCode = Integer.valueOf(400);
String errorReason = "InvalidRequest";
InvalidRequest exceptTest = new InvalidRequest("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -459,7 +460,7 @@ public void InvalidSystemMetadataTest() throws ParserConfigurationException, SAX
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(400);
+ Integer errorCode = Integer.valueOf(400);
String errorReason = "InvalidSystemMetadata";
InvalidSystemMetadata exceptTest = new InvalidSystemMetadata("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -480,7 +481,7 @@ public void InvalidTokenTest() throws ParserConfigurationException, SAXException
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(401);
+ Integer errorCode = Integer.valueOf(401);
String errorReason = "InvalidToken";
InvalidToken exceptTest = new InvalidToken("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -501,7 +502,7 @@ public void NotAuthorizedTest() throws ParserConfigurationException, SAXExceptio
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(401);
+ Integer errorCode = Integer.valueOf(401);
String errorReason = "NotAuthorized";
NotAuthorized exceptTest = new NotAuthorized("100", "test Not Authorized");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -522,7 +523,7 @@ public void NotFoundTest() throws ParserConfigurationException, SAXException, IO
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(404);
+ Integer errorCode = Integer.valueOf(404);
String errorReason = "NotFound";
NotFound exceptTest = new NotFound("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -543,7 +544,7 @@ public void NotImplementedTest() throws ParserConfigurationException, SAXExcepti
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(501);
+ Integer errorCode = Integer.valueOf(501);
String errorReason = "NotImplemented";
NotImplemented exceptTest = new NotImplemented("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -564,7 +565,7 @@ public void ServiceFailureTest() throws ParserConfigurationException, SAXExcepti
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(500);
+ Integer errorCode = Integer.valueOf(500);
String errorReason = "ServiceFailure";
ServiceFailure exceptTest = new ServiceFailure("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -585,7 +586,7 @@ public void UnsupportedMetadataTypeTest() throws ParserConfigurationException, S
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(400);
+ Integer errorCode = Integer.valueOf(400);
String errorReason = "UnsupportedMetadataType";
UnsupportedMetadataType exceptTest = new UnsupportedMetadataType("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -606,7 +607,7 @@ public void UnsupportedTypeTest() throws ParserConfigurationException, SAXExcept
BaseException {
boolean success = false;
try {
- Integer errorCode = new Integer(400);
+ Integer errorCode = Integer.valueOf(400);
String errorReason = "UnsupportedType";
UnsupportedType exceptTest = new UnsupportedType("100", "test IdentifierNotUnique");
String exceptTestSerial = exceptTest.serialize(BaseException.FMT_XML);
@@ -631,7 +632,7 @@ public void SynchronizationFailedTest() throws ParserConfigurationException, SAX
String pidString ="pidString";
String description = "SynchronizationFailedTest";
try {
- Integer errorCode = new Integer(500);
+ Integer errorCode = Integer.valueOf(500);
TreeMap trace_information = new TreeMap();
trace_information.put("cause",errorReason);
SynchronizationFailed exceptTest = new SynchronizationFailed(detailCode, description, pidString,trace_information);
@@ -642,7 +643,7 @@ public void SynchronizationFailedTest() throws ParserConfigurationException, SAX
} catch (SynchronizationFailed ex) {
success = true;
assertTrue(ex.getIdentifier().equals(pidString));
- assertTrue(ex.getPid().equals(pidString));
+ assertTrue(ex.getIdentifier().equals(pidString));
assertTrue(ex.getDescription().equals(description));
assertTrue(ex.getDetail_code().equals(detailCode));
}
@@ -660,7 +661,7 @@ public void UnsupportedExceptionTest() throws ParserConfigurationException, SAXE
// int code = 0;
// String detail_code = null;
// String description = null;
- Integer errorCode = new Integer(404);
+ Integer errorCode = Integer.valueOf(404);
String errorReason = "NotFound";
String exceptTestSerial = "";
ByteArrayInputStream inputStream = new ByteArrayInputStream(exceptTestSerial.getBytes());
@@ -683,7 +684,7 @@ public void NotNamedExceptionTest() throws ParserConfigurationException, SAXExce
// int code = 0;
// String detail_code = null;
// String description = null;
- Integer errorCode = new Integer(404);
+ Integer errorCode = Integer.valueOf(404);
String errorReason = "NotFound";
String exceptTestSerial = "";
ByteArrayInputStream inputStream = new ByteArrayInputStream(exceptTestSerial.getBytes());
diff --git a/src/test/java/org/dataone/service/util/IdentifierEncodingTestCase.java b/src/test/java/org/dataone/service/util/IdentifierEncodingTestCase.java
index 015b0bad..2628fd13 100644
--- a/src/test/java/org/dataone/service/util/IdentifierEncodingTestCase.java
+++ b/src/test/java/org/dataone/service/util/IdentifierEncodingTestCase.java
@@ -22,7 +22,6 @@
package org.dataone.service.util;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
import java.io.InputStream;
@@ -34,13 +33,14 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.junit.Before;
import org.junit.Test;
public class IdentifierEncodingTestCase
{
- private static Logger logger = Logger.getLogger(IdentifierEncodingTestCase.class);
+ private static Logger logger = LogManager.getLogger(IdentifierEncodingTestCase.class.getName());
// private static boolean verbose = true;
private static String testUnicodeIdentifiersFile = "/org/dataone/service/encodingTestSet/testUnicodeStrings.utf8.txt";
@@ -237,9 +237,9 @@ public final void testDecodeError1() throws UnsupportedEncodingException
logger.info(" * * * * * * * testing Decoding Error 1 * * * * * * ");
logger.info("String to decode: testMalformedEscape-%3X");
try {
- String s = EncodingUtilities.decodeString("testMalformedEscape-%3X");
+ EncodingUtilities.decodeString("testMalformedEscape-%3X");
} catch (IllegalArgumentException iae) {
- assertThat("Malformed hex error caught",iae, instanceOf(IllegalArgumentException.class));
+ assertTrue("Malformed hex error caught", iae instanceof IllegalArgumentException);
logger.info("caught the error (bad hex character)");
return;
}
@@ -252,9 +252,9 @@ public final void testDecodeError2() throws UnsupportedEncodingException
logger.info(" * * * * * * * testing Decoding Error 2 * * * * * * ");
logger.info("String to decode: testMalformedEscape-%3");
try {
- String s = EncodingUtilities.decodeString("testMalformedEscape-%3");
+ EncodingUtilities.decodeString("testMalformedEscape-%3");
} catch (IllegalArgumentException iae) {
- assertThat("Malformed hex error caught",iae, instanceOf(IllegalArgumentException.class));
+ assertTrue("Malformed hex error caught", iae instanceof IllegalArgumentException);
logger.info("caught the error (truncated hex pattern)");
return;
}
@@ -268,9 +268,9 @@ public final void testDecodeError3() throws UnsupportedEncodingException
logger.info(" * * * * * * * testing Decoding Error 3 * * * * * * ");
logger.info("String to decode: testMalformedEscape-%");
try {
- String s = EncodingUtilities.decodeString("testMalformedEscape-%");
+ EncodingUtilities.decodeString("testMalformedEscape-%");
} catch (IllegalArgumentException iae) {
- assertThat("Malformed hex error caught",iae, instanceOf(IllegalArgumentException.class));
+ assertTrue("Malformed hex error caught", iae instanceof IllegalArgumentException);
logger.info("caught the error (truncated hex pattern)");
return;
}
diff --git a/src/test/java/org/dataone/service/util/TypeMarshallerTestCase.java b/src/test/java/org/dataone/service/util/TypeMarshallerTestCase.java
index f2b6a1dd..30f42713 100644
--- a/src/test/java/org/dataone/service/util/TypeMarshallerTestCase.java
+++ b/src/test/java/org/dataone/service/util/TypeMarshallerTestCase.java
@@ -35,21 +35,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBException;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.dataone.configuration.Settings;
import org.dataone.exceptions.MarshallingException;
import org.apache.commons.io.output.NullOutputStream;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.dataone.service.types.v1.Checksum;
import org.dataone.service.types.v1.Identifier;
import org.dataone.service.types.v1.Node;
@@ -61,42 +52,40 @@
import org.junit.Test;
import org.xml.sax.SAXException;
-
/**
*
* @author waltz
*/
public class TypeMarshallerTestCase {
-
- private static Logger log = Logger.getLogger(TypeMarshallerTestCase.class);
+
+ private static Logger log = LogManager.getLogger(TypeMarshallerTestCase.class.getName());
@Test
public void deserializeSystemMetadata() {
try {
- InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v1/systemMetadataSample1.xml");
+ InputStream is = this.getClass()
+ .getResourceAsStream("/org/dataone/service/samples/v1/systemMetadataSample1.xml");
TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, is);
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
}
}
-
-
-
@Test
public void deserializeSerializeSysMeta_performanceTest() {
- for (int i = 1; i <=2; i++) {
+ for (int i = 1; i <= 2; i++) {
Date start = null;
Date mid = null;
Date end = null;
try {
- InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v1/systemMetadataSample1.xml");
+ InputStream is = this.getClass()
+ .getResourceAsStream("/org/dataone/service/samples/v1/systemMetadataSample1.xml");
start = new Date();
SystemMetadata symeta = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, is);
mid = new Date();
@@ -104,15 +93,15 @@ public void deserializeSerializeSysMeta_performanceTest() {
TypeMarshaller.marshalTypeToOutputStream(symeta, os);
end = new Date();
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} finally {
- if (mid == null)
+ if (mid == null)
mid = new Date();
if (end == null)
end = new Date();
@@ -122,18 +111,19 @@ public void deserializeSerializeSysMeta_performanceTest() {
}
}
}
-
+
@Test
public void deserializeSerializeObjectList_performanceTest() {
List uTimes = new ArrayList<>();
List mTimes = new ArrayList<>();
- for (int i = 1; i <=50; i++) {
+ for (int i = 1; i <= 50; i++) {
Date start = null;
Date mid = null;
Date end = null;
-
+
try {
- InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v2/objectList7000.xml");
+ InputStream is = this.getClass()
+ .getResourceAsStream("/org/dataone/service/samples/v2/objectList7000.xml");
start = new Date();
ObjectList ol = TypeMarshaller.unmarshalTypeFromStream(ObjectList.class, is);
mid = new Date();
@@ -141,31 +131,31 @@ public void deserializeSerializeObjectList_performanceTest() {
TypeMarshaller.marshalTypeToOutputStream(ol, os);
end = new Date();
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} finally {
- if (mid == null)
+ if (mid == null)
mid = new Date();
if (end == null)
end = new Date();
}
long uTime = mid.getTime() - start.getTime();
long mTime = end.getTime() - mid.getTime();
-// System.out.printf("%d\t%d\t%d\n", i, uTime, mTime);
+ // System.out.printf("%d\t%d\t%d\n", i, uTime, mTime);
uTimes.add(uTime);
mTimes.add(mTime);
}
System.out.println("===================================");
System.out.println("index\tunmarsh\tmarsh");
System.out.println("===================================");
- System.out.printf("count\t%d\t%d\n", uTimes.size(),mTimes.size());
+ System.out.printf("count\t%d\t%d\n", uTimes.size(), mTimes.size());
System.out.printf("sum\t%d\t%d\n", sumOfLongs(uTimes), sumOfLongs(mTimes));
- System.out.printf("mean\t%d\t%d\n", sumOfLongs(uTimes)/uTimes.size(), sumOfLongs(mTimes)/mTimes.size());
+ System.out.printf("mean\t%d\t%d\n", sumOfLongs(uTimes) / uTimes.size(), sumOfLongs(mTimes) / mTimes.size());
System.out.printf("median\t%d\t%d\n", medianOfLongs(uTimes), medianOfLongs(mTimes));
}
@@ -177,43 +167,40 @@ private long sumOfLongs(List elements) {
}
return sum;
}
-
+
private long medianOfLongs(List elements) {
int count = elements.size();
if (count == 1)
return elements.get(0);
-
+
long median = 0;
int halfcount = count / 2;
Long[] longs = elements.toArray(new Long[0]);
Arrays.sort(longs);
if (count % 2 == 0) {
- return (longs[halfcount] + longs[halfcount+1]) / 2;
+ return (longs[halfcount] + longs[halfcount + 1]) / 2;
} else {
return longs[halfcount];
}
}
-
-
-
+
@Test
public void deserializeNode() {
try {
InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v1/mnNode1.xml");
TypeMarshaller.unmarshalTypeFromStream(Node.class, is);
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
}
}
-
@Test
public void serializeEmptyObjectList() {
ObjectList objectList = new ObjectList();
@@ -225,55 +212,52 @@ public void serializeEmptyObjectList() {
String xmlObjectList = os.toString();
assertNotNull(xmlObjectList);
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
}
}
@Test
public void deserializeEmptyObjectListSize() {
try {
- InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v1/objectListSample2.xml");
+ InputStream is = this.getClass()
+ .getResourceAsStream("/org/dataone/service/samples/v1/objectListSample2.xml");
ObjectList objectList = TypeMarshaller.unmarshalTypeFromStream(ObjectList.class, is);
assertNotNull(objectList);
assertNotNull(objectList.sizeObjectInfoList());
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
}
}
-
+
@Test
public void serializeNodeStylesheet() {
try {
InputStream is = this.getClass().getResourceAsStream("/org/dataone/service/samples/v1/mnNode1.xml");
Node node = TypeMarshaller.unmarshalTypeFromStream(Node.class, is);
- String styleSheet = "test.xsl";
+ // String styleSheet = "test.xsl";
ByteArrayOutputStream os = new ByteArrayOutputStream();
- TypeMarshaller.marshalTypeToOutputStream(node, os , styleSheet);
- String result = os.toString("UTF-8");
- log.debug("Stylesheet result: \n" + result);
- assertTrue(result.contains(styleSheet));
+ TypeMarshaller.marshalTypeToOutputStream(node, os);
+ String result = os.toString("UTF-8");
+ assertTrue(result.length() > 0);
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (InstantiationException ex) {
fail("Test misconfiguration" + ex);
} catch (IllegalAccessException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
}
-
-
}
-
-
+
@Test
public void serializeSystemMetadata() {
try {
@@ -297,11 +281,11 @@ public void serializeSystemMetadata() {
s.getRightsHolder().setValue("groucho");
s.setSerialVersion(BigInteger.ONE);
s.setSize(new BigInteger("9"));
-// s.setSubmitter(new Subject());
-// s.getSubmitter().setValue("harpo");
+ // s.setSubmitter(new Subject());
+ // s.getSubmitter().setValue("harpo");
String styleSheet = "test.xsl";
-// TypeMarshaller.marshalTypeToOutputStream(s, os,styleSheet);
+ // TypeMarshaller.marshalTypeToOutputStream(s, os,styleSheet);
TypeMarshaller.marshalTypeToOutputStream(s, os);
String result = os.toString("UTF-8");
@@ -310,42 +294,44 @@ public void serializeSystemMetadata() {
os.close();
ByteArrayOutputStream os2 = new ByteArrayOutputStream();
TypeMarshaller.marshalTypeToOutputStream(s, os2);
-
+
} catch (IOException ex) {
- fail("Test misconfiguration" + ex);
-// } catch (InstantiationException ex) {
-// fail("Test misconfiguration" + ex);
-// } catch (IllegalAccessException ex) {
-// fail("Test misconfiguration" + ex);
+ fail("Test misconfiguration" + ex);
+ // } catch (InstantiationException ex) {
+ // fail("Test misconfiguration" + ex);
+ // } catch (IllegalAccessException ex) {
+ // fail("Test misconfiguration" + ex);
} catch (MarshallingException ex) {
- fail("Problem with TypeMarshaller. Cause: " + ex.getCause().getClass().getCanonicalName()
+ fail("Problem with TypeMarshaller. Cause: " + ex.getCause().getClass().getCanonicalName()
+ ex.getCause().getMessage());
}
}
-
+
@Test
- public void testMarshallingShouldDoSchemaValidation() throws InstantiationException, IllegalAccessException, IOException, MarshallingException, SAXException {
-
+ public void testMarshallingShouldDoSchemaValidation()
+ throws InstantiationException, IllegalAccessException, IOException, MarshallingException, SAXException {
+
InputStream is = this.getClass().getResourceAsStream("systemMetadata-invalid_schema.xml");
- org.dataone.service.types.v1.SystemMetadata sysMeta =
- TypeMarshaller.unmarshalTypeFromStream(org.dataone.service.types.v1.SystemMetadata.class, is);
+ org.dataone.service.types.v1.SystemMetadata sysMeta = TypeMarshaller
+ .unmarshalTypeFromStream(org.dataone.service.types.v1.SystemMetadata.class, is);
try {
TypeMarshaller.marshalTypeToOutputStream(sysMeta, new ByteArrayOutputStream());
} catch (MarshallingException e) {
// should throw exception
}
- }
-
+ }
+
@Test
- public void testValidateSchema() throws InstantiationException, IllegalAccessException, IOException, MarshallingException {
-
+ public void testValidateSchema()
+ throws InstantiationException, IllegalAccessException, IOException, MarshallingException {
+
InputStream is = this.getClass().getResourceAsStream("systemMetadata-invalid_schema.xml");
- org.dataone.service.types.v1.SystemMetadata sysMeta =
- TypeMarshaller.unmarshalTypeFromStream(org.dataone.service.types.v1.SystemMetadata.class, is);
+ org.dataone.service.types.v1.SystemMetadata sysMeta = TypeMarshaller
+ .unmarshalTypeFromStream(org.dataone.service.types.v1.SystemMetadata.class, is);
try {
TypeMarshaller.validateAgainstSchema(sysMeta);
} catch (MarshallingException e) {
// should throw exception
}
- }
+ }
}