Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
package org.jvnet.hyperjaxb3.ejb.test;

import java.io.File;
import java.util.Collection;
import java.io.FilenameFilter;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.lang3.SystemUtils;
import org.junit.jupiter.api.Test;
import org.jvnet.jaxb.test.AbstractSamplesTest;
import org.jvnet.jaxb.xml.bind.ContextPathAware;

public abstract class AbstractEntityManagerSamplesTest extends
AbstractEntityManagerTest implements ContextPathAware {

private final static IOFileFilter JAVA_1_5_SAMPLES = FileFilterUtils
.andFileFilter(FileFilterUtils.suffixFileFilter(".xml"),
FileFilterUtils.notFileFilter(

FileFilterUtils.suffixFileFilter("1.6.xml")));

private final static IOFileFilter JAVA_1_6_SAMPLES = FileFilterUtils
.andFileFilter(FileFilterUtils.suffixFileFilter(".xml"),
FileFilterUtils.notFileFilter(

FileFilterUtils.suffixFileFilter("1.5.xml")));

private final static IOFileFilter SAMPLES = SystemUtils.IS_JAVA_1_5 ? JAVA_1_5_SAMPLES
: JAVA_1_6_SAMPLES;

private AbstractSamplesTest samplesTest;

@Override
Expand Down Expand Up @@ -123,15 +103,19 @@ protected File getSamplesDirectory() {

protected File[] getSampleFiles() {
File samplesDirectory = getSamplesDirectory();
logger.debug("Sample directory [" + samplesDirectory.getAbsolutePath()
+ "].");
if (samplesDirectory == null || !samplesDirectory.isDirectory()) {
if (samplesDirectory == null) {
return new File[] {};
}
logger.debug("Sample directory [" + samplesDirectory.getAbsolutePath() + "].");
if (!samplesDirectory.isDirectory()) {
return new File[] {};
} else {

final Collection<File> files = FileUtils.listFiles(
samplesDirectory, SAMPLES, TrueFileFilter.INSTANCE);
return files.toArray(new File[files.size()]);
return samplesDirectory.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name != null && name.endsWith(".xml") && !name.endsWith("1.5.xml");
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<include name="junit-*.jar"/>
<include name="jaxb2-basics-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-collections-*.jar"/>
Expand Down
1 change: 0 additions & 1 deletion hyperjaxb/ejb/samples/po-initial/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<include name="junit-*.jar"/>
<include name="jaxb2-basics-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-collections-*.jar"/>
Expand Down
1 change: 0 additions & 1 deletion hyperjaxb/ejb/samples/uniprot/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<include name="junit-*.jar"/>
<include name="jaxb2-basics-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-collections-*.jar"/>
Expand Down
5 changes: 0 additions & 5 deletions hyperjaxb/ejb/schemas/customizations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
<groupId>org.jvnet.jaxb</groupId>
<artifactId>hyperjaxb3-ejb-schemas-persistence</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
</reporting>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.Validate;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -25,21 +24,14 @@ protected JAXBContext getContext() {
protected Persistence unmarshal(String resourceName) throws IOException,
JAXBException {
Validate.notNull(resourceName);
final InputStream is;
if (resourceName.startsWith("/")) {
is = getClass().getClassLoader().getResourceAsStream(
resourceName.substring(1));
} else {
is = getClass().getResourceAsStream(resourceName);
}
Assertions.assertNotNull(is);
try {
try (final InputStream is = resourceName.startsWith("/")
? getClass().getClassLoader().getResourceAsStream(resourceName.substring(1))
: getClass().getResourceAsStream(resourceName)) {
Assertions.assertNotNull(is);
@SuppressWarnings("unchecked")
final JAXBElement<Persistence> persistenceElement = (JAXBElement<Persistence>) getContext()
.createUnmarshaller().unmarshal(is);
return persistenceElement.getValue();
} finally {
IOUtils.closeQuietly(is);
}
}

Expand Down
1 change: 0 additions & 1 deletion hyperjaxb/ejb/templates/basic/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<include name="junit-*.jar"/>
<include name="jaxb2-basics-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-collections-*.jar"/>
Expand Down
4 changes: 0 additions & 4 deletions jaxb-annox-parent/jaxb-annox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
<artifactId>jaxb-runtime</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.jvnet.jaxb.annox.parser.tests;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.annotation.Annotation;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.jvnet.jaxb.annox.model.XAnnotation;
Expand All @@ -18,36 +19,36 @@
public class XAnnotationParserAnnotationExprTest {

public Element getElement(final String resourceName) throws Exception {
InputStream is = null;
try {
is = getClass().getResourceAsStream(resourceName);
try (InputStream is = getClass().getResourceAsStream(resourceName)){
final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
.newInstance();
documentBuilderFactory.setNamespaceAware(true);
final DocumentBuilder documentBuilder = documentBuilderFactory
.newDocumentBuilder();
final Document document = documentBuilder.parse(is);
return document.getDocumentElement();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException ioe) {
// ignore
}
}

}

public String getAnnotationString(final String resourceName)
throws Exception {
try (InputStream is = getClass().getResourceAsStream(resourceName)) {
final String text = IOUtils.toString(is, "UTF-8");
return text;
return readFromInputStream(is);
}
}

private String readFromInputStream(InputStream inputStream)
throws IOException {
StringBuilder resultStringBuilder = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going forward, use StandardCharsets.UTF_8 constant

String line;
while ((line = br.readLine()) != null) {
resultStringBuilder.append(line).append("\n");
}
}
return resultStringBuilder.toString();
}

public void check(String javaResourceName, String xmlResourceName,
Class<?> clazz, Class<? extends Annotation> annotationClazz)
throws Exception {
Expand Down
2 changes: 0 additions & 2 deletions jaxb-annox-parent/samples/po/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<include name="junit-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-text-*.jar"/>
<include name="slf4j-*.jar"/>
Expand Down Expand Up @@ -61,7 +60,6 @@
<include name="junit-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="commons-text-*.jar"/>
<include name="slf4j-*.jar"/>
Expand Down
4 changes: 0 additions & 4 deletions jaxb-plugins-parent/jaxb-plugins-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-plugins-tools</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.jvnet.jaxb.test;

import java.io.File;
import java.util.Collection;
import java.io.FilenameFilter;
import java.util.Map;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -72,11 +71,13 @@ protected String getSamplesDirectoryName() {

protected File[] getSampleFiles() {
File samplesDirectory = getSamplesDirectory();
logger.debug("Sample directory [" + samplesDirectory.getAbsolutePath()
+ "].");
final Collection<File> files = FileUtils.listFiles(samplesDirectory,
new String[] { "xml" }, true);
return files.toArray(new File[files.size()]);
logger.debug("Sample directory [" + samplesDirectory.getAbsolutePath() + "].");
return samplesDirectory.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return name != null && name.endsWith("xml");
}
});
}

protected ClassLoader getContextClassLoader() {
Expand Down
2 changes: 0 additions & 2 deletions jaxb-plugins-parent/samples/basic/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand All @@ -55,7 +54,6 @@
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand Down
2 changes: 0 additions & 2 deletions jaxb-plugins-parent/samples/po-simple/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<include name="junit-*.jar"/>
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand All @@ -54,7 +53,6 @@
<include name="junit-*.jar"/>
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand Down
2 changes: 0 additions & 2 deletions jaxb-plugins-parent/samples/po/project-build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand All @@ -54,7 +53,6 @@
<include name="jaxb-plugins-testing-*.jar"/>
<include name="xmlunit-*.jar"/>
<include name="codemodel-*.jar"/>
<include name="commons-io-*.jar"/>
<include name="commons-lang3-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="jcl-over-slf4j-*.jar"/>
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
<jaxb.version>4.0.5</jaxb.version>

<commons-beanutils.version>1.9.4</commons-beanutils.version>
<commons-io.version>2.19.0</commons-io.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-text.version>1.10.0</commons-text.version>
<hamcrest.version>3.0</hamcrest.version>
Expand Down Expand Up @@ -350,11 +349,6 @@
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Loading