diff --git a/ccm-core/src/site/apt/index.apt b/ccm-core/src/site/apt/index.apt new file mode 100644 index 000000000..dbae22e54 --- /dev/null +++ b/ccm-core/src/site/apt/index.apt @@ -0,0 +1,4 @@ +LibreCCM Core + + The module module (<<>>) for provides several + basic services for all other modules of LibreCCM. \ No newline at end of file diff --git a/ccm-core/src/site/site.xml b/ccm-core/src/site/site.xml index c2c0f1125..3c6e867a3 100644 --- a/ccm-core/src/site/site.xml +++ b/ccm-core/src/site/site.xml @@ -5,12 +5,15 @@ http://maven.apache.org/xsd/decoration-1.3.0.xsd"> + + + - + diff --git a/ccm-shortcuts/src/site/apt/index.apt b/ccm-shortcuts/src/site/apt/index.apt new file mode 100644 index 000000000..e3297909e --- /dev/null +++ b/ccm-shortcuts/src/site/apt/index.apt @@ -0,0 +1,4 @@ +The Shortcuts module + + This module (<<>> for is currently + work in progress. More details will come soon. \ No newline at end of file diff --git a/ccm-shortcuts/src/site/site.xml b/ccm-shortcuts/src/site/site.xml new file mode 100644 index 000000000..fd8ad57e7 --- /dev/null +++ b/ccm-shortcuts/src/site/site.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/ccm-testutils/pom.xml b/ccm-testutils/pom.xml index 770ca7456..545d45a6a 100644 --- a/ccm-testutils/pom.xml +++ b/ccm-testutils/pom.xml @@ -50,6 +50,13 @@ arquillian-persistence-dbunit + + net.sourceforge.findbugs + annotations + 1.3.2 + provided + + @@ -118,7 +125,7 @@ findbugs-maven-plugin 3.0.1 - /rulesets/java/naming.xml /rulesets/java/optimizations.xml /rulesets/java/strictexception.xml @@ -147,7 +154,7 @@ /rulesets/java/unusedcode.xml - --> + org.codehaus.mojo javancss-maven-plugin @@ -160,8 +167,8 @@ - diff --git a/ccm-testutils/src/main/java/org/libreccm/tests/categories/IntegrationTest.java b/ccm-testutils/src/main/java/org/libreccm/tests/categories/IntegrationTest.java index 11fbdd771..1a10148ef 100644 --- a/ccm-testutils/src/main/java/org/libreccm/tests/categories/IntegrationTest.java +++ b/ccm-testutils/src/main/java/org/libreccm/tests/categories/IntegrationTest.java @@ -19,7 +19,14 @@ package org.libreccm.tests.categories; /** - * + * A marker interface for use with JUnit's {@link Category} annotation to mark + * the tests which should be only executed when using one of the Arquillian + * profiles. + * + * Tests with this category are only executed in the Arquillian profiles and + * are executed by Arquillian inside a Java EE container. The tests are usually + * used to test CDI beans and EJBs. + * * @author Jens Pelzetter */ public interface IntegrationTest { diff --git a/ccm-testutils/src/main/java/org/libreccm/tests/categories/UnitTest.java b/ccm-testutils/src/main/java/org/libreccm/tests/categories/UnitTest.java index e452e15b2..bccfb4a79 100644 --- a/ccm-testutils/src/main/java/org/libreccm/tests/categories/UnitTest.java +++ b/ccm-testutils/src/main/java/org/libreccm/tests/categories/UnitTest.java @@ -19,7 +19,8 @@ package org.libreccm.tests.categories; /** - * A marker interface for use with JUnit's {@link Category} annotation. + * A marker interface for use with JUnit's {@link Category} annotation to mark + * the tests which should be executed in every case. * * Tests which are grouped into this category are used to test an * individual class. All external dependencies should be mocked. diff --git a/ccm-testutils/src/main/java/org/libreccm/tests/categories/package-info.java b/ccm-testutils/src/main/java/org/libreccm/tests/categories/package-info.java new file mode 100644 index 000000000..0decdba5b --- /dev/null +++ b/ccm-testutils/src/main/java/org/libreccm/tests/categories/package-info.java @@ -0,0 +1,5 @@ +/** + * The interfaces in this package are used to control which test are executed + * in the default module and which ones are executed in special profiles. + */ +package org.libreccm.tests.categories; 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 3a73f688d..7e8996c15 100644 --- a/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java +++ b/ccm-testutils/src/main/java/org/libreccm/testutils/DatasetsVerifier.java @@ -25,8 +25,6 @@ import org.dbunit.dataset.DataSetException; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet; import org.dbunit.operation.DatabaseOperation; -import org.jboss.arquillian.persistence.core.data.descriptor.Format; -import org.jboss.arquillian.persistence.dbunit.dataset.DataSetBuilder; import org.junit.Test; import java.io.IOException; @@ -40,24 +38,45 @@ import java.sql.SQLException; import org.h2.tools.RunScript; import org.jboss.arquillian.persistence.dbunit.dataset.json.JsonDataSet; - -import static org.junit.Assert.*; - -import java.io.BufferedReader; +import org.junit.runners.Parameterized; /** * + * For testing the CCM modules the Arquillian Persistence extension including + * the DBUnit integration is used. Unfortunately there are some issues with + * exception reporting if there errors in the datasets used for testing. + * Therefore we provide this utility class which can be used to implement + * test for the datasets outside of Arquillian. + * + * For testing an in-memory H2 + * database is used. The datasets are loaded into the database using + * DBUnit classes. Before loading the dataset this class creates the database + * schema. The SQL script for generating the schema is loaded via + * {@code getClass().getResource(/sql/ddl/auto/h2.sql).toURI()}. Therefore the + * utility expects to find the SQL for generating the database schema in the + * classpath at th path {@code /sql/ddl/auto/h2.sql}. The default + * {@code pom.xml} for modules take care of that. + * + * After each dataset the database is scrapped. To use this utility create + * a JUnit test class using the {@link Parameterized} test runner from JUnit. + * An example is the + * DatasetsTest + * in the {@code org.libreccm.core} package of the ccm-core module. + * * @author Jens Pelzetter */ public class DatasetsVerifier { - private final String datasetPath; + private final transient String datasetPath; public DatasetsVerifier(final String datasetsPath) { this.datasetPath = datasetsPath; } @Test + @edu.umd.cs.findbugs.annotations.SuppressWarnings( + value = "DMI_EMPTY_DB_PASSWORD", + justification = "H2 in mem database does not need a password") public void verifyDataset() throws SQLException, URISyntaxException, IOException, 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 1820fc656..d32dde961 100644 --- a/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java +++ b/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java @@ -33,11 +33,12 @@ import org.junit.runners.Parameterized; * the classes {@code Foo} and {@code Bar} (imports have been omitted): * *
- * @RunWith(Parameterized.class)
- * @Category(UnitTest.class)
+ * 
+ * @RunWith(Parameterized.class)
+ * @Category(UnitTest.class)
  * public class FooBarTest extends EqualsVerifier {
  * 
- *     @Parameterized.Parameters(name = "{0}")
+ *     @Parameterized.Parameters(name = "{0}")
  *     public static Collection> data() {
  *         return Arrays.asList(new Class[] {
  *             Foo.class,
@@ -49,13 +50,25 @@ import org.junit.runners.Parameterized;
  *         super(entityClass);
  *     }
  * }
+ * 
  * 
* + * An example in ccm-core is the + * EqualsAndHashCodeTest + * in the {@code org.libreccm.core} package. + * + * For testing {@code equals} and {@code hashCode} this class uses the + * http://www.jqno.nl/equalsverifier/ utility. If + * the classes to verify are part of complex inheritance hierarchy you may need + * to create your own test using the {@code EqualsVerifier}. An example in + * ccm-core is the ResourceEntityTest + * in the {@code org.libreccm.core} package. + * * @author Jens Pelzetter */ public class EqualsVerifier { - private final Class entityClass; + private final transient Class entityClass; public EqualsVerifier(final Class entityClass) { this.entityClass = entityClass; diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/ToStringVerifier.java b/ccm-testutils/src/main/java/org/libreccm/testutils/ToStringVerifier.java index 73b3dfbc6..c51622122 100644 --- a/ccm-testutils/src/main/java/org/libreccm/testutils/ToStringVerifier.java +++ b/ccm-testutils/src/main/java/org/libreccm/testutils/ToStringVerifier.java @@ -31,44 +31,45 @@ import java.lang.reflect.Modifier; /** * A base class for verifying the implementation of the {@code toString()} - * method of an object using the {@link Parameterized} - * test runner from JUnit. - * - * To use this class create a new JUnit test class which extends this class - * and which uses the {@link Parameterized} test runner. The class must have a + * method of an object using the {@link Parameterized} test runner from JUnit. + * + * To use this class create a new JUnit test class which extends this class and + * which uses the {@link Parameterized} test runner. The class must have a * static method which provides the classes to be tested. Example for testing * the classes {@code Foo} and {@code Bar} (imports have been omitted): - * + * *
- * @RunWith(Parameterized.class)
- * @Category(UnitTest.class)
- * public class FooBarTest extends ToStringVerifier {
- * 
- *     @Parameterized.Parameters(name = "{0}")
- *     public static Collection> data() {
- *         return Arrays.asList(new Class[] {
- *             Foo.class,
- *             Bar.class
- *         }); 
+ * 
+ * @RunWith(Parameterized.class)
+ * @Category(UnitTest.class) public class FooBarTest extends ToStringVerifier {
+ *
+ *     @Parameterized.Parameters(name = "{0}") public static Collection> data() {
+ *         return Arrays.asList(new Class[] { Foo.class, Bar.class });
  *     }
- * 
+ *
  *     public FooBarTest(final Class entityClass) {
  *         super(entityClass);
  *     }
  * }
+ * 
  * 
* + * An example can be found in the ccm-core module: ToStringTest + * * @author Jens Pelzetter */ public class ToStringVerifier { - - private final Class entityClass; - + + private final transient Class entityClass; + public ToStringVerifier(final Class entityClass) { this.entityClass = entityClass; } - + @Test + //We want to test if there occurs an NPE therefore we need catch the NPE. + @SuppressWarnings({"PMD.AvoidCatchingNPE", + "PMD.AvoidCatchingGenericException"}) public void verifyToString() throws IntrospectionException, InstantiationException, IllegalAccessException, @@ -77,7 +78,7 @@ public class ToStringVerifier { final Object obj = entityClass.newInstance(); final Field[] fields = entityClass.getDeclaredFields(); - for (Field field : fields) { + for (final Field field : fields) { if (!Modifier.isStatic(field.getModifiers()) && !field.getType().isPrimitive()) { field.setAccessible(true); @@ -99,5 +100,5 @@ public class ToStringVerifier { } } - + } diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/package-info.java b/ccm-testutils/src/main/java/org/libreccm/testutils/package-info.java new file mode 100644 index 000000000..30c300020 --- /dev/null +++ b/ccm-testutils/src/main/java/org/libreccm/testutils/package-info.java @@ -0,0 +1,4 @@ +/** + * This package provides several utilities for writing tests for CCM classes. + */ +package org.libreccm.testutils; diff --git a/ccm-testutils/src/site/apt/index.apt b/ccm-testutils/src/site/apt/index.apt new file mode 100644 index 000000000..0ae2e2845 --- /dev/null +++ b/ccm-testutils/src/site/apt/index.apt @@ -0,0 +1,42 @@ +LibreCCM TestUtils + + The TestUtils module <<>> package provides several utility + classes for writing tests for specific classes. This includes tests for + the implementations of <<>> and <<>> as well as + <<>>. Also a utility for testing datasets for DBUnit tests + is provided. + + Other modules should import this module for the test + scope only: + ++------------------------------------------------------------------------------+ +... + + ... + + org.libreccm + ccm-testutils + 6.7.0-SNAPSHOT + test + + ... + ++------------------------------------------------------------------------------+ + + At the moment the following utilities are provided: + + * {{{./apidocs/index.html?org/libreccm/testutils/DatasetsVerifier.html} DatasetsVerifier}} + + * {{{./apidocs/index.html?org/libreccm/testutils/EqualsVerifier.html} EqualsVerifier}} + + * {{{./apidocs/index.html?org/libreccm/testutils/ToStringVerifier.html} ToStringVerifier}} + + [] + + Also their are some categories for use with feature of JUnit 4. + They are used to control which tests are executed. At the moment their are + two categories: + + * {{{./apidocs/index.html?org/libreccm/tests/categories/IntegrationTest.html} IntegrationTest}} + + * {{{./apidocs/index.html?org/libreccm/tests/categories/UnitTest.html} UnitTest}} \ No newline at end of file diff --git a/ccm-testutils/src/site/site.xml b/ccm-testutils/src/site/site.xml new file mode 100644 index 000000000..ddb0d9e3b --- /dev/null +++ b/ccm-testutils/src/site/site.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt new file mode 100644 index 000000000..91eb20524 --- /dev/null +++ b/src/site/apt/index.apt @@ -0,0 +1,3 @@ +LibreCCM + + Bla Bla \ No newline at end of file diff --git a/src/site/resources/images/libreccm-logo.png b/src/site/resources/images/libreccm-logo.png new file mode 100644 index 000000000..b5bc33e48 Binary files /dev/null and b/src/site/resources/images/libreccm-logo.png differ diff --git a/src/site/site.xml b/src/site/site.xml index d98a745f8..7732ebc5b 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -4,7 +4,17 @@ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd"> + + LibreCCM + images/libreccm-logo.png + 150 + 100 + + + + +