CCM NG: Primarily documentation

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3507 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2015-06-26 18:26:42 +00:00
parent e1e7d936be
commit 34e42a81d5
17 changed files with 200 additions and 43 deletions

View File

@ -0,0 +1,4 @@
LibreCCM Core
The <Core> module module (<<<ccm-core>>>) for <LibreCCM> provides several
basic services for all other modules of LibreCCM.

View File

@ -5,12 +5,15 @@
http://maven.apache.org/xsd/decoration-1.3.0.xsd"> http://maven.apache.org/xsd/decoration-1.3.0.xsd">
<body> <body>
<menu name="Overview">
<item name="The Core module" href="index.html"/>
</menu>
<menu ref="reports"/> <menu ref="reports"/>
</body> </body>
<skin> <!--<skin>
<groupId>org.apache.maven.skins</groupId> <groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId> <artifactId>maven-fluido-skin</artifactId>
<version>1.4</version> <version>1.4</version>
</skin> </skin>-->
</project> </project>

View File

@ -0,0 +1,4 @@
The Shortcuts module
This <Shortcuts> module (<<<ccm-shortucts>>> for <LibreCCM> is currently
work in progress. More details will come soon.

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0
http://maven.apache.org/xsd/decoration-1.3.0.xsd">
<body>
<menu name="Overview">
<item name="The Shortcuts module"
href="index.html"/>
</menu>
<menu ref="reports"/>
</body>
</project>

View File

@ -50,6 +50,13 @@
<artifactId>arquillian-persistence-dbunit</artifactId> <artifactId>arquillian-persistence-dbunit</artifactId>
</dependency> </dependency>
<dependency>
<groupId>net.sourceforge.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>1.3.2</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -118,7 +125,7 @@
<artifactId>findbugs-maven-plugin</artifactId> <artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version> <version>3.0.1</version>
</plugin> </plugin>
<!--<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId> <artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version> <version>3.4</version>
@ -136,7 +143,7 @@
<ruleset>/rulesets/java/finalizers.xml</ruleset> <ruleset>/rulesets/java/finalizers.xml</ruleset>
<ruleset>/rulesets/java/imports.xml</ruleset> <ruleset>/rulesets/java/imports.xml</ruleset>
<ruleset>/rulesets/java/javabeans.xml</ruleset> <ruleset>/rulesets/java/javabeans.xml</ruleset>
<ruleset>/rulesets/java/junit.xml</ruleset> <!--<ruleset>/rulesets/java/junit.xml</ruleset>-->
<ruleset>/rulesets/java/naming.xml</ruleset> <ruleset>/rulesets/java/naming.xml</ruleset>
<ruleset>/rulesets/java/optimizations.xml</ruleset> <ruleset>/rulesets/java/optimizations.xml</ruleset>
<ruleset>/rulesets/java/strictexception.xml</ruleset> <ruleset>/rulesets/java/strictexception.xml</ruleset>
@ -147,7 +154,7 @@
<ruleset>/rulesets/java/unusedcode.xml</ruleset> <ruleset>/rulesets/java/unusedcode.xml</ruleset>
</rulesets> </rulesets>
</configuration> </configuration>
</plugin>--> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId> <artifactId>javancss-maven-plugin</artifactId>
@ -160,8 +167,8 @@
<reportSets> <reportSets>
<reportSet> <reportSet>
<reports> <reports>
<!--<report>dependencies</report> <report>dependencies</report>
<report>project-team</report> <!--<report>project-team</report>
<report>mailing-list</report> <report>mailing-list</report>
<report>cim</report> <report>cim</report>
<report>issue-tracking</report>--> <report>issue-tracking</report>-->

View File

@ -19,6 +19,13 @@
package org.libreccm.tests.categories; 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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -19,7 +19,8 @@
package org.libreccm.tests.categories; 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 * Tests which are grouped into this category are used to test an
* individual class. All external dependencies should be mocked. * individual class. All external dependencies should be mocked.

View File

@ -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;

View File

@ -25,8 +25,6 @@ import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.operation.DatabaseOperation; 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 org.junit.Test;
import java.io.IOException; import java.io.IOException;
@ -40,24 +38,45 @@ import java.sql.SQLException;
import org.h2.tools.RunScript; import org.h2.tools.RunScript;
import org.jboss.arquillian.persistence.dbunit.dataset.json.JsonDataSet; import org.jboss.arquillian.persistence.dbunit.dataset.json.JsonDataSet;
import org.junit.runners.Parameterized;
import static org.junit.Assert.*;
import java.io.BufferedReader;
/** /**
*
* 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
* <a href="../../../../../ccm-core/xref-test/org/libreccm/core/DatasetsTest.html"><code>DatasetsTest</code></a>
* in the {@code org.libreccm.core} package of the ccm-core module.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class DatasetsVerifier { public class DatasetsVerifier {
private final String datasetPath; private final transient String datasetPath;
public DatasetsVerifier(final String datasetsPath) { public DatasetsVerifier(final String datasetsPath) {
this.datasetPath = datasetsPath; this.datasetPath = datasetsPath;
} }
@Test @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, public void verifyDataset() throws SQLException,
URISyntaxException, URISyntaxException,
IOException, IOException,

View File

@ -33,11 +33,12 @@ import org.junit.runners.Parameterized;
* the classes {@code Foo} and {@code Bar} (imports have been omitted): * the classes {@code Foo} and {@code Bar} (imports have been omitted):
* *
* <pre> * <pre>
* @RunWith(Parameterized.class) * <code>
* @Category(UnitTest.class) * &#x40;RunWith(Parameterized.class)
* &#x40;Category(UnitTest.class)
* public class FooBarTest extends EqualsVerifier { * public class FooBarTest extends EqualsVerifier {
* *
* @Parameterized.Parameters(name = "{0}") * &#x40;Parameterized.Parameters(name = "{0}")
* public static Collection<Class<?>> data() { * public static Collection<Class<?>> data() {
* return Arrays.asList(new Class<?>[] { * return Arrays.asList(new Class<?>[] {
* Foo.class, * Foo.class,
@ -49,13 +50,25 @@ import org.junit.runners.Parameterized;
* super(entityClass); * super(entityClass);
* } * }
* } * }
* </code>
* </pre> * </pre>
* *
* An example in ccm-core is the
* <a href="../../../../../ccm-core/xref-test/org/libreccm/core/EqualsAndHashCodeTest.html"><code>EqualsAndHashCodeTest</code></a>
* in the {@code org.libreccm.core} package.
*
* For testing {@code equals} and {@code hashCode} this class uses the
* <a href="EqualsVerifier">http://www.jqno.nl/equalsverifier/</a> 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 <a href="../../../../../ccm-core/xref-test/org/libreccm/core/ResourceEntityTest.html"><code>ResourceEntityTest</code></a>
* in the {@code org.libreccm.core} package.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class EqualsVerifier { public class EqualsVerifier {
private final Class<?> entityClass; private final transient Class<?> entityClass;
public EqualsVerifier(final Class<?> entityClass) { public EqualsVerifier(final Class<?> entityClass) {
this.entityClass = entityClass; this.entityClass = entityClass;

View File

@ -31,44 +31,45 @@ import java.lang.reflect.Modifier;
/** /**
* A base class for verifying the implementation of the {@code toString()} * A base class for verifying the implementation of the {@code toString()}
* method of an object using the {@link Parameterized} * method of an object using the {@link Parameterized} test runner from JUnit.
* test runner from JUnit.
* *
* To use this class create a new JUnit test class which extends this class * To use this class create a new JUnit test class which extends this class and
* and which uses the {@link Parameterized} test runner. The class must have a * which uses the {@link Parameterized} test runner. The class must have a
* static method which provides the classes to be tested. Example for testing * static method which provides the classes to be tested. Example for testing
* the classes {@code Foo} and {@code Bar} (imports have been omitted): * the classes {@code Foo} and {@code Bar} (imports have been omitted):
* *
* <pre> * <pre>
* @RunWith(Parameterized.class) * <code>
* @Category(UnitTest.class) * &#x40;RunWith(Parameterized.class)
* public class FooBarTest extends ToStringVerifier { * &#x40;Category(UnitTest.class) public class FooBarTest extends ToStringVerifier {
* *
* @Parameterized.Parameters(name = "{0}") * &#x40;Parameterized.Parameters(name = "{0}") public static Collection<Class<?>> data() {
* public static Collection<Class<?>> data() { * return Arrays.asList(new Class<?>[] { Foo.class, Bar.class });
* return Arrays.asList(new Class<?>[] {
* Foo.class,
* Bar.class
* });
* } * }
* *
* public FooBarTest(final Class<?> entityClass) { * public FooBarTest(final Class<?> entityClass) {
* super(entityClass); * super(entityClass);
* } * }
* } * }
* </code>
* </pre> * </pre>
* *
* An example can be found in the ccm-core module: <a href="../../../../../ccm-core/xref-test/org/libreccm/core/ToStringTest.html"><code>ToStringTest</code></a>
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class ToStringVerifier { public class ToStringVerifier {
private final Class<?> entityClass; private final transient Class<?> entityClass;
public ToStringVerifier(final Class<?> entityClass) { public ToStringVerifier(final Class<?> entityClass) {
this.entityClass = entityClass; this.entityClass = entityClass;
} }
@Test @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, public void verifyToString() throws IntrospectionException,
InstantiationException, InstantiationException,
IllegalAccessException, IllegalAccessException,
@ -77,7 +78,7 @@ public class ToStringVerifier {
final Object obj = entityClass.newInstance(); final Object obj = entityClass.newInstance();
final Field[] fields = entityClass.getDeclaredFields(); final Field[] fields = entityClass.getDeclaredFields();
for (Field field : fields) { for (final Field field : fields) {
if (!Modifier.isStatic(field.getModifiers()) if (!Modifier.isStatic(field.getModifiers())
&& !field.getType().isPrimitive()) { && !field.getType().isPrimitive()) {
field.setAccessible(true); field.setAccessible(true);

View File

@ -0,0 +1,4 @@
/**
* This package provides several utilities for writing tests for CCM classes.
*/
package org.libreccm.testutils;

View File

@ -0,0 +1,42 @@
LibreCCM TestUtils
The TestUtils module <<<ccm-testutils>>> package provides several utility
classes for writing tests for specific classes. This includes tests for
the implementations of <<<equals>>> and <<<hashCode>>> as well as
<<<toString>>>. Also a utility for testing datasets for DBUnit tests
is provided.
Other modules should import this module for the test
scope only:
+------------------------------------------------------------------------------+
...
<dependencies>
...
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-testutils</artifactId>
<version>6.7.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
...
</dependencies>
+------------------------------------------------------------------------------+
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 <Category> 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}}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0
http://maven.apache.org/xsd/decoration-1.3.0.xsd">
<body>
<menu name="Overview">
<item name="The TestUtils module" href="index.html"/>
</menu>
<menu ref="reports"/>
</body>
<!--<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.4</version>
</skin>-->
</project>

View File

@ -0,0 +1,3 @@
LibreCCM
Bla Bla

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -4,7 +4,17 @@
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0
http://maven.apache.org/xsd/decoration-1.3.0.xsd"> http://maven.apache.org/xsd/decoration-1.3.0.xsd">
<bannerLeft>
<name>LibreCCM</name>
<src>images/libreccm-logo.png</src>
<width>150</width>
<height>100</height>
</bannerLeft>
<body> <body>
<menu name="Overview">
<item name="Overview" href="index.html"/>
</menu>
<menu ref="modules"/> <menu ref="modules"/>
<menu ref="reports"/> <menu ref="reports"/>
</body> </body>