diff --git a/ccm-testutils/pom.xml b/ccm-testutils/pom.xml
index 598e39091..8fcf6a067 100644
--- a/ccm-testutils/pom.xml
+++ b/ccm-testutils/pom.xml
@@ -59,6 +59,11 @@
provided
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven
+
+
@@ -155,11 +160,11 @@
-
+
org.apache.maven.plugins
maven-project-info-reports-plugin
diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java b/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java
index 6e41eb7f4..ae7143def 100644
--- a/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java
+++ b/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java
@@ -45,9 +45,8 @@ import static org.libreccm.testutils.DatasetType.*;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.jboss.arquillian.persistence.dbunit.dataset.yaml.YamlDataSet;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.List;
/**
*
@@ -121,7 +120,7 @@ public class DatasetsVerifier {
try (final Connection connection = DriverManager.getConnection(
connectionStr, "sa", "")) {
//Create DB tables etc
- for(final String ddlFile : getDdlFiles()) {
+ for (final String ddlFile : getDdlFiles()) {
processDdlFile(connection, ddlFile);
}
// final Path schemaPath = Paths.get(getClass().getResource(
@@ -132,25 +131,25 @@ public class DatasetsVerifier {
//Get dataset to test
final IDataSet dataSet;
- switch (getDatasetType()) {
- case FLAT_XML:
- final FlatXmlDataSetBuilder builder
- = new FlatXmlDataSetBuilder();
- dataSet = builder.build(getClass().getResourceAsStream(
- datasetPath));
- break;
- case JSON:
- dataSet = new JsonDataSet(getClass()
- .getResourceAsStream(datasetPath));
- break;
- case YAML:
- dataSet = new YamlDataSet(getClass()
- .getResourceAsStream(datasetPath));
- break;
- default:
- throw new IllegalArgumentException(String.format(
- "Unsupported DatasetType \"%s\"",
- getDatasetType()));
+ try (final InputStream inputStream = getClass().getResourceAsStream(
+ datasetPath)) {
+ switch (getDatasetType()) {
+ case FLAT_XML:
+ final FlatXmlDataSetBuilder builder
+ = new FlatXmlDataSetBuilder();
+ dataSet = builder.build(inputStream);
+ break;
+ case JSON:
+ dataSet = new JsonDataSet(inputStream);
+ break;
+ case YAML:
+ dataSet = new YamlDataSet(inputStream);
+ break;
+ default:
+ throw new IllegalArgumentException(String.format(
+ "Unsupported DatasetType \"%s\"",
+ getDatasetType()));
+ }
}
//Create DBUnit DB connection
diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/DependenciesHelpers.java b/ccm-testutils/src/main/java/org/libreccm/testutils/DependenciesHelpers.java
new file mode 100644
index 000000000..a5202ce5c
--- /dev/null
+++ b/ccm-testutils/src/main/java/org/libreccm/testutils/DependenciesHelpers.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2016 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+package org.libreccm.testutils;
+
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+/**
+ * Some static helper methods to deal with the dependencies in Arquillian tests.
+ *
+ * @author Jens Pelzetter
+ */
+public final class DependenciesHelpers {
+
+ /**
+ * Private constructor to avoid accidental instantiation of this class.
+ */
+ private DependenciesHelpers() {
+
+ }
+
+ /**
+ * This method implements the common part of the public methods in this
+ * class.
+ *
+ * @param pomPath The path of the POM file to use.
+ *
+ * @return The dependencies defined in the POM file including their
+ * transitive dependencies. All dependencies whose name starts with
+ * {@code ccm-} (which should be modules of {@code LibreCCM} are
+ * excluded. Classes from CCM modules which are required for tests
+ * have to be included manually using the {@code addPackage} or
+ * {@code addClass} methods from ShrinkWrap.
+ */
+ private static File[] getDependenciesFromPom(final String pomPath) {
+ final PomEquippedResolveStage pom = Maven
+ .resolver()
+ .loadPomFromFile(pomPath);
+ final PomEquippedResolveStage dependencies = pom
+ .importCompileAndRuntimeDependencies();
+ final File[] libFiles = dependencies.resolve().withTransitivity()
+ .asFile();
+
+ final File[] libs = Arrays.stream(libFiles)
+ .filter(lib -> !lib.getName().startsWith("ccm-"))
+ .collect(Collectors.toList()).toArray(new File[0]);
+ Arrays.stream(libs)
+ .forEach(lib -> System.err.printf(
+ "Found dependency '%s'...%n",
+ lib.getName()));
+
+ return libs;
+ }
+
+ /**
+ * Gets the dependencies of the current module.
+ *
+ * @return The dependencies of the current module.
+ *
+ * @see #getDependenciesFromPom(java.lang.String)
+ */
+ public static File[] getModuleDependencies() {
+ return getDependenciesFromPom("pom.xml");
+ }
+
+ /**
+ * Gets the dependencies for another CCM module.
+ *
+ * @param module The module
+ *
+ * @return The dependencies of the module.
+ *
+ * @see #getDependenciesFromPom(java.lang.String)
+ */
+ public static File[] getDependenciesFromModule(final String module) {
+ return getDependenciesFromPom(String.format("../%s/pom.xml",
+ module));
+ }
+
+ /**
+ * Convenient method for getting the the dependencies of the
+ * {@code ccm-core} module.
+ *
+ * @return The dependencies of the {@code ccm-core} module.
+ * @see #getDependenciesFromModule(java.lang.String)
+ * @see #getDependenciesFromPom(java.lang.String)
+ */
+ public static File[] getCcmCoreDependencies() {
+ return getDependenciesFromModule("ccm-core");
+ }
+
+}
diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java b/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
index 779f080c1..bb0d58d32 100644
--- a/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
+++ b/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
@@ -77,13 +77,13 @@ public class EqualsVerifier {
/**
* Overwrite this methods to suppress warnings from the
- * {@link nl.jqno.equalsverifier.EqualsVerifier}. Per default the following
+ * {@link nl.jqno.equalsverifier.EqualsVerifier}. Per default the following
* warnings are suppressed:
- *
+ *
*
- * - {@code Warning.Warning.STRICT_INHERITANCE}
- * - {@code Warning.NONFINAL_FIELDS}
- * - {@code Warning.ALL_FIELDS_SHOULD_BE_USED}
+ * - {@code Warning.Warning.STRICT_INHERITANCE}
+ * - {@code Warning.NONFINAL_FIELDS}
+ * - {@code Warning.ALL_FIELDS_SHOULD_BE_USED}
*
*
* @param verifier The verifier to which the suppression are added.
@@ -99,7 +99,7 @@ public class EqualsVerifier {
/**
* Use this method to add prefab values to the verifier.
- *
+ *
* @param verifier The verifier to which the prefab values are added.
*/
protected void addPrefabValues(
@@ -109,8 +109,8 @@ public class EqualsVerifier {
@Test
public void verifyEqualsAndHashCode() {
- nl.jqno.equalsverifier.EqualsVerifier> verifier
- = nl.jqno.equalsverifier.EqualsVerifier
+ final nl.jqno.equalsverifier.EqualsVerifier> verifier
+ = nl.jqno.equalsverifier.EqualsVerifier
.forClass(entityClass)
.withRedefinedSuperclass();