CCM NG: Primarily documentation
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3507 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
e1e7d936be
commit
34e42a81d5
|
|
@ -0,0 +1,4 @@
|
|||
LibreCCM Core
|
||||
|
||||
The <Core> module module (<<<ccm-core>>>) for <LibreCCM> provides several
|
||||
basic services for all other modules of LibreCCM.
|
||||
|
|
@ -5,12 +5,15 @@
|
|||
http://maven.apache.org/xsd/decoration-1.3.0.xsd">
|
||||
|
||||
<body>
|
||||
<menu name="Overview">
|
||||
<item name="The Core module" href="index.html"/>
|
||||
</menu>
|
||||
<menu ref="reports"/>
|
||||
</body>
|
||||
<skin>
|
||||
<!--<skin>
|
||||
<groupId>org.apache.maven.skins</groupId>
|
||||
<artifactId>maven-fluido-skin</artifactId>
|
||||
<version>1.4</version>
|
||||
</skin>
|
||||
</skin>-->
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
The Shortcuts module
|
||||
|
||||
This <Shortcuts> module (<<<ccm-shortucts>>> for <LibreCCM> is currently
|
||||
work in progress. More details will come soon.
|
||||
|
|
@ -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>
|
||||
|
|
@ -50,6 +50,13 @@
|
|||
<artifactId>arquillian-persistence-dbunit</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.findbugs</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
@ -118,7 +125,7 @@
|
|||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<!--<plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.4</version>
|
||||
|
|
@ -136,7 +143,7 @@
|
|||
<ruleset>/rulesets/java/finalizers.xml</ruleset>
|
||||
<ruleset>/rulesets/java/imports.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/optimizations.xml</ruleset>
|
||||
<ruleset>/rulesets/java/strictexception.xml</ruleset>
|
||||
|
|
@ -147,7 +154,7 @@
|
|||
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
|
||||
</rulesets>
|
||||
</configuration>
|
||||
</plugin>-->
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>javancss-maven-plugin</artifactId>
|
||||
|
|
@ -160,8 +167,8 @@
|
|||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<!--<report>dependencies</report>
|
||||
<report>project-team</report>
|
||||
<report>dependencies</report>
|
||||
<!--<report>project-team</report>
|
||||
<report>mailing-list</report>
|
||||
<report>cim</report>
|
||||
<report>issue-tracking</report>-->
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@
|
|||
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>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
* <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>
|
||||
*/
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -33,11 +33,12 @@ import org.junit.runners.Parameterized;
|
|||
* the classes {@code Foo} and {@code Bar} (imports have been omitted):
|
||||
*
|
||||
* <pre>
|
||||
* @RunWith(Parameterized.class)
|
||||
* @Category(UnitTest.class)
|
||||
* <code>
|
||||
* @RunWith(Parameterized.class)
|
||||
* @Category(UnitTest.class)
|
||||
* public class FooBarTest extends EqualsVerifier {
|
||||
*
|
||||
* @Parameterized.Parameters(name = "{0}")
|
||||
* @Parameterized.Parameters(name = "{0}")
|
||||
* public static Collection<Class<?>> data() {
|
||||
* return Arrays.asList(new Class<?>[] {
|
||||
* Foo.class,
|
||||
|
|
@ -49,13 +50,25 @@ import org.junit.runners.Parameterized;
|
|||
* super(entityClass);
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
* </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>
|
||||
*/
|
||||
public class EqualsVerifier {
|
||||
|
||||
private final Class<?> entityClass;
|
||||
private final transient Class<?> entityClass;
|
||||
|
||||
public EqualsVerifier(final Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* 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
|
||||
* 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):
|
||||
*
|
||||
* <pre>
|
||||
* @RunWith(Parameterized.class)
|
||||
* @Category(UnitTest.class)
|
||||
* public class FooBarTest extends ToStringVerifier {
|
||||
* <code>
|
||||
* @RunWith(Parameterized.class)
|
||||
* @Category(UnitTest.class) public class FooBarTest extends ToStringVerifier {
|
||||
*
|
||||
* @Parameterized.Parameters(name = "{0}")
|
||||
* public static Collection<Class<?>> data() {
|
||||
* return Arrays.asList(new Class<?>[] {
|
||||
* Foo.class,
|
||||
* Bar.class
|
||||
* });
|
||||
* @Parameterized.Parameters(name = "{0}") public static Collection<Class<?>> data() {
|
||||
* return Arrays.asList(new Class<?>[] { Foo.class, Bar.class });
|
||||
* }
|
||||
*
|
||||
* public FooBarTest(final Class<?> entityClass) {
|
||||
* super(entityClass);
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
* </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>
|
||||
*/
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* This package provides several utilities for writing tests for CCM classes.
|
||||
*/
|
||||
package org.libreccm.testutils;
|
||||
|
|
@ -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}}
|
||||
|
|
@ -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>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
LibreCCM
|
||||
|
||||
Bla Bla
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
|
|
@ -4,7 +4,17 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0
|
||||
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>
|
||||
<menu name="Overview">
|
||||
<item name="Overview" href="index.html"/>
|
||||
</menu>
|
||||
<menu ref="modules"/>
|
||||
<menu ref="reports"/>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue