You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/02/04 19:59:29 UTC
[maven-doxia] 02/02: [DOXIA-644] Replace Plexus Annotations with Java Inject along with JUnit 5
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 9e998a51e60724ed396fb207d4987ea3d04f4b07
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Feb 3 11:45:40 2022 +0100
[DOXIA-644] Replace Plexus Annotations with Java Inject along with JUnit 5
This closes #92
---
doxia-core/pom.xml | 13 +-
.../java/org/apache/maven/doxia/DefaultDoxia.java | 10 +-
.../org/apache/maven/doxia/macro/EchoMacro.java | 5 +-
.../doxia/macro/manager/DefaultMacroManager.java | 9 +-
.../maven/doxia/macro/snippet/SnippetMacro.java | 6 +-
.../org/apache/maven/doxia/macro/toc/TocMacro.java | 6 +-
.../apache/maven/doxia/parser/AbstractParser.java | 9 +-
.../doxia/parser/manager/DefaultParserManager.java | 9 +-
.../parser/module/DefaultParserModuleManager.java | 10 +-
.../org/apache/maven/doxia/AbstractModuleTest.java | 10 +-
.../org/apache/maven/doxia/DefaultDoxiaTest.java | 31 +--
.../apache/maven/doxia/index/IndexEntryTest.java | 6 +-
.../apache/maven/doxia/macro/EchoMacroTest.java | 4 +-
.../doxia/macro/manager/MacroManagerTest.java | 27 +--
.../doxia/macro/snippet/SnippetMacroTest.java | 21 +-
.../doxia/macro/snippet/SnippetReaderTest.java | 7 +-
.../apache/maven/doxia/macro/toc/TocMacroTest.java | 4 +-
.../maven/doxia/module/AbstractIdentityTest.java | 10 +-
.../maven/doxia/parser/AbstractParserTest.java | 31 +--
.../maven/doxia/parser/AbstractParserTestCase.java | 8 +-
.../maven/doxia/parser/Xhtml5BaseParserTest.java | 38 +++-
.../maven/doxia/parser/XhtmlBaseParserTest.java | 38 +++-
.../maven/doxia/sink/impl/AbstractSinkTest.java | 142 ++++++++-----
.../doxia/sink/impl/AbstractSinkTestCase.java | 8 +-
.../maven/doxia/sink/impl/AbstractXmlSinkTest.java | 4 +-
.../doxia/sink/impl/RandomAccessSinkTest.java | 4 +-
.../maven/doxia/sink/impl/SinkAdapterTest.java | 2 +-
.../doxia/sink/impl/SinkEventAttributeSetTest.java | 8 +-
.../maven/doxia/sink/impl/SinkUtilsTest.java | 8 +-
.../maven/doxia/sink/impl/TestAbstractSink.java | 4 +-
.../maven/doxia/sink/impl/Xhtml5BaseSinkTest.java | 9 +-
.../maven/doxia/sink/impl/XhtmlBaseSinkTest.java | 11 +-
.../maven/doxia/util/ByLineReaderSourceTest.java | 4 +-
.../apache/maven/doxia/util/DoxiaUtilsTest.java | 79 +++----
.../org/apache/maven/doxia/util/HtmlToolsTest.java | 17 +-
.../apache/maven/doxia/util/XmlValidatorTest.java | 8 +-
.../maven/doxia/xsd/AbstractXmlValidator.java | 34 ++--
doxia-modules/doxia-module-apt/pom.xml | 9 +
.../apache/maven/doxia/module/apt/AptParser.java | 6 +-
.../maven/doxia/module/apt/AptParserModule.java | 6 +-
.../maven/doxia/module/apt/AptSinkFactory.java | 6 +-
.../maven/doxia/module/apt/AptParserTest.java | 226 +++++++++++----------
.../apache/maven/doxia/module/apt/AptSinkTest.java | 9 +-
.../maven/doxia/module/apt/AptUtilsTest.java | 52 ++---
doxia-modules/doxia-module-fml/pom.xml | 9 +
.../apache/maven/doxia/module/fml/FmlParser.java | 5 +-
.../maven/doxia/module/fml/FmlParserModule.java | 6 +-
.../maven/doxia/module/fml/FmlParserTest.java | 24 ++-
.../maven/doxia/module/fml/FmlValidatorTest.java | 4 +
doxia-modules/doxia-module-markdown/pom.xml | 9 +
.../doxia/module/markdown/MarkdownParser.java | 12 +-
.../module/markdown/MarkdownParserModule.java | 6 +-
.../markdown/FlexmarkDoxiaLinkResolverTest.java | 5 +-
.../module/markdown/MarkdownParserModuleTest.java | 23 +--
.../doxia/module/markdown/MarkdownParserTest.java | 84 ++++----
doxia-modules/doxia-module-xdoc/pom.xml | 9 +
.../apache/maven/doxia/module/xdoc/XdocParser.java | 5 +-
.../maven/doxia/module/xdoc/XdocParserModule.java | 6 +-
.../maven/doxia/module/xdoc/XdocSinkFactory.java | 6 +-
.../maven/doxia/module/xdoc/XdocIdentityTest.java | 3 +-
.../maven/doxia/module/xdoc/XdocParserTest.java | 105 ++++++----
.../maven/doxia/module/xdoc/XdocSinkTest.java | 4 +
.../maven/doxia/module/xdoc/XdocValidatorTest.java | 2 +
doxia-modules/doxia-module-xhtml/pom.xml | 9 +
.../maven/doxia/module/xhtml/XhtmlParser.java | 6 +-
.../doxia/module/xhtml/XhtmlParserModule.java | 6 +-
.../maven/doxia/module/xhtml/XhtmlSinkFactory.java | 6 +-
.../doxia/module/xhtml/XhtmlIdentityTest.java | 3 +-
.../maven/doxia/module/xhtml/XhtmlParserTest.java | 19 +-
.../maven/doxia/module/xhtml/XhtmlSinkTest.java | 11 +-
doxia-modules/doxia-module-xhtml5/pom.xml | 9 +
.../maven/doxia/module/xhtml5/Xhtml5Parser.java | 6 +-
.../doxia/module/xhtml5/Xhtml5ParserModule.java | 6 +-
.../doxia/module/xhtml5/Xhtml5SinkFactory.java | 6 +-
.../doxia/module/xhtml5/Xhtml5IdentityTest.java | 4 +-
.../doxia/module/xhtml5/Xhtml5ParserTest.java | 19 +-
.../maven/doxia/module/xhtml5/Xhtml5SinkTest.java | 11 +-
doxia-modules/pom.xml | 4 -
pom.xml | 30 ++-
79 files changed, 868 insertions(+), 582 deletions(-)
diff --git a/doxia-core/pom.xml b/doxia-core/pom.xml
index 1064864..0a7d4c4 100644
--- a/doxia-core/pom.xml
+++ b/doxia-core/pom.xml
@@ -43,6 +43,10 @@ under the License.
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
@@ -51,10 +55,6 @@ under the License.
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.3</version>
@@ -62,6 +62,11 @@ under the License.
<!-- test -->
<dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<classifier>no_aop</classifier>
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
index 90fd183..a4b1d17 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
@@ -19,15 +19,15 @@ package org.apache.maven.doxia;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.manager.ParserManager;
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
import org.apache.maven.doxia.sink.Sink;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-
import java.io.Reader;
/**
@@ -37,11 +37,11 @@ import java.io.Reader;
* @author Jason van Zyl
* @since 1.0
*/
-@Component( role = Doxia.class )
+@Named
public class DefaultDoxia
implements Doxia
{
- @Requirement
+ @Inject
private ParserManager parserManager;
// ----------------------------------------------------------------------
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/EchoMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/EchoMacro.java
index 5791805..5b34b0a 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/EchoMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/EchoMacro.java
@@ -19,14 +19,15 @@ package org.apache.maven.doxia.macro;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.codehaus.plexus.component.annotations.Component;
/**
* A simple macro that prints out the key and value of some supplied parameters.
*/
-@Component( role = Macro.class, hint = "echo" )
+@Named( "echo" )
public class EchoMacro
extends AbstractMacro
{
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/manager/DefaultMacroManager.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/manager/DefaultMacroManager.java
index e240d5a..50b8234 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/manager/DefaultMacroManager.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/manager/DefaultMacroManager.java
@@ -19,9 +19,10 @@ package org.apache.maven.doxia.macro.manager;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import org.apache.maven.doxia.macro.Macro;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
import java.util.Map;
@@ -31,12 +32,12 @@ import java.util.Map;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @since 1.0
*/
-@Component( role = MacroManager.class )
+@Named
public class DefaultMacroManager
implements MacroManager
{
@SuppressWarnings( "MismatchedQueryAndUpdateOfCollection" )
- @Requirement( role = Macro.class )
+ @Inject
private Map<String, Macro> macros;
/** {@inheritDoc} */
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
index b3007a2..e69744f 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
@@ -19,13 +19,13 @@ package org.apache.maven.doxia.macro.snippet;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.macro.AbstractMacro;
-import org.apache.maven.doxia.macro.Macro;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +40,7 @@ import java.util.Map;
/**
* A macro that prints out the content of a file or a URL.
*/
-@Component( role = Macro.class, hint = "snippet" )
+@Named( "snippet" )
public class SnippetMacro
extends AbstractMacro
{
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java b/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
index c96a84e..2b94937 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
@@ -19,12 +19,13 @@ package org.apache.maven.doxia.macro.toc;
* under the License.
*/
+import javax.inject.Named;
+
import java.io.StringReader;
import org.apache.maven.doxia.index.IndexEntry;
import org.apache.maven.doxia.index.IndexingSink;
import org.apache.maven.doxia.macro.AbstractMacro;
-import org.apache.maven.doxia.macro.Macro;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.util.HtmlTools;
@@ -32,7 +33,6 @@ import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
/**
@@ -76,7 +76,7 @@ import org.codehaus.plexus.util.StringUtils;
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-@Component( role = Macro.class, hint = "toc" )
+@Named( "toc" )
public class TocMacro
extends AbstractMacro
{
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
index ee032e7..776ab2f 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.parser;
* under the License.
*/
+import javax.inject.Inject;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -33,7 +35,6 @@ import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.macro.manager.MacroManager;
import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
import org.apache.maven.doxia.sink.Sink;
-import org.codehaus.plexus.component.annotations.Requirement;
/**
* An abstract base class that defines some convenience methods for parsers.
@@ -48,7 +49,7 @@ public abstract class AbstractParser
/** Indicates that a second parsing is required. */
private boolean secondParsing = false;
- @Requirement
+ @Inject
private MacroManager macroManager;
/**
@@ -160,8 +161,6 @@ public abstract class AbstractParser
}
/**
- * {@inheritDoc}
- *
* Convenience method to parse an arbitrary string and emit events into the given sink.
*
* @param string a string that provides the source input
@@ -176,8 +175,6 @@ public abstract class AbstractParser
}
/**
- * {@inheritDoc}
- *
* Convenience method to parse an arbitrary string and emit events into the given sink.
*
* @param string a string that provides the source input
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/manager/DefaultParserManager.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/manager/DefaultParserManager.java
index ac602f7..90c938e 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/manager/DefaultParserManager.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/manager/DefaultParserManager.java
@@ -19,9 +19,10 @@ package org.apache.maven.doxia.parser.manager;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.Parser;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
import java.util.Map;
@@ -31,12 +32,12 @@ import java.util.Map;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @since 1.0
*/
-@Component( role = ParserManager.class )
+@Named
public class DefaultParserManager
implements ParserManager
{
@SuppressWarnings( "MismatchedQueryAndUpdateOfCollection" )
- @Requirement( role = Parser.class )
+ @Inject
private Map<String, Parser> parsers;
/** {@inheritDoc} */
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/DefaultParserModuleManager.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/DefaultParserModuleManager.java
index 3aac039..665bee3 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/DefaultParserModuleManager.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/module/DefaultParserModuleManager.java
@@ -19,24 +19,24 @@ package org.apache.maven.doxia.parser.module;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-
/**
* Simple implementation of the ParserModuleManager interface.
*
* @since 1.6
*/
-@Component( role = ParserModuleManager.class )
+@Named
public class DefaultParserModuleManager
implements ParserModuleManager
{
@SuppressWarnings( "MismatchedQueryAndUpdateOfCollection" )
- @Requirement( role = ParserModule.class )
+ @Inject
private Map<String, ParserModule> parserModules;
private Collection<ParserModule> parserModulesValues;
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
index 79249a5..d7d7774 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/AbstractModuleTest.java
@@ -21,7 +21,7 @@ package org.apache.maven.doxia;
import org.apache.maven.doxia.markup.Markup;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.WriterFactory;
import java.io.File;
@@ -32,15 +32,19 @@ import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/**
* Provide some common convenience methods to test Doxia modules (parsers and sinks).
*
* @since 1.0
*/
+@PlexusTest
public abstract class AbstractModuleTest
- extends PlexusTestCase
implements Markup
{
+
/*
* Set the system properties:
* <ul>
@@ -171,7 +175,7 @@ public abstract class AbstractModuleTest
Thread.currentThread().getContextClassLoader().getResourceAsStream(
baseName + "." + extension );
- assertNotNull( "Could not find resource: " + baseName + "." + extension, is );
+ assertNotNull( is, "Could not find resource: " + baseName + "." + extension );
return new InputStreamReader( is, StandardCharsets.UTF_8 );
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java
index 2075b7f..7bc2222 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java
@@ -19,13 +19,24 @@ package org.apache.maven.doxia;
* under the License.
*/
+import javax.inject.Inject;
+
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
-import org.codehaus.plexus.PlexusTestCase;
-import org.junit.Test;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-public class DefaultDoxiaTest extends PlexusTestCase
+
+@PlexusTest
+public class DefaultDoxiaTest
{
+ @Inject
+ private Doxia doxia;
+
@Test
public void testCreatesDefaultDoxia()
{
@@ -38,17 +49,9 @@ public class DefaultDoxiaTest extends PlexusTestCase
public void testFailsWhenParserIdDoesNotExist() throws Exception
{
final String parserId = "a-parser";
- final Doxia doxia = lookup( Doxia.class );
-
- try
- {
- doxia.getParser( parserId );
- fail( "Call should fail with ParserNotFoundException" );
- }
- catch ( ParserNotFoundException e )
- {
- assertEquals( "Cannot find parser with id = a-parser", e.getMessage() );
- }
+ ParserNotFoundException e = assertThrows( ParserNotFoundException.class,
+ () -> doxia.getParser( parserId ) );
+ assertEquals( "Cannot find parser with id = " + parserId, e.getMessage() );
}
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/index/IndexEntryTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/index/IndexEntryTest.java
index d8913f7..6f48f42 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/index/IndexEntryTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/index/IndexEntryTest.java
@@ -19,10 +19,10 @@ package org.apache.maven.doxia.index;
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a>
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
index 5098069..639a241 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
@@ -29,9 +29,9 @@ import org.apache.maven.doxia.parser.XhtmlBaseParser;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test echo macro.
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/manager/MacroManagerTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/manager/MacroManagerTest.java
index 6331d9a..ad357c3 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/manager/MacroManagerTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/manager/MacroManagerTest.java
@@ -19,37 +19,38 @@ package org.apache.maven.doxia.macro.manager;
* under the License.
*/
+import javax.inject.Inject;
+
import org.apache.maven.doxia.macro.Macro;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/** @author Jason van Zyl */
+@PlexusTest
public class MacroManagerTest
- extends PlexusTestCase
{
+
+ @Inject
+ private MacroManager mm;
+
/**
* Test MacroManager.
*
* @throws java.lang.Exception if any.
*/
+ @Test
public void testMacroManager()
throws Exception
{
- MacroManager mm = lookup( MacroManager.class );
-
assertNotNull( mm );
Macro macro = mm.getMacro( "snippet" );
assertNotNull( macro );
- try
- {
- mm.getMacro( "weirdId" );
- fail( "should not exist!" );
- }
- catch ( MacroNotFoundException macroNotFoundException )
- {
- assertNotNull( macroNotFoundException );
- }
+ assertThrows( MacroNotFoundException.class, () -> mm.getMacro( "weirdId" ) );
}
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
index d1f8926..7987817 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
@@ -30,23 +30,31 @@ import org.apache.maven.doxia.parser.XhtmlBaseParser;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
import org.hamcrest.CoreMatchers;
+import org.junit.jupiter.api.Test;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test snippet macro.
*
* @author ltheussl
*/
+@PlexusTest
public class SnippetMacroTest
- extends PlexusTestCase
{
/**
* Test of execute method, of class SnippetMacro.
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testExecute()
throws MacroExecutionException
{
@@ -128,17 +136,10 @@ public class SnippetMacroTest
macroParameters.put( "id", "first" );
macroParameters.put( "verbatim", "" );
macroParameters.put( "ignoreDownloadError", "false" );
- try
- {
- executeSnippetMacro( macroParameters );
- fail();
- }
- catch ( Exception e )
- {
- // good
- }
+ assertThrows( Exception.class, () -> executeSnippetMacro( macroParameters ) );
}
+ @Test
public void testIgnoreDownloadError()
throws Exception
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetReaderTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetReaderTest.java
index 0282ab4..3cb486c 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetReaderTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetReaderTest.java
@@ -18,10 +18,11 @@ package org.apache.maven.doxia.macro.snippet;
* specific language governing permissions and limitations
* under the License.
*/
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class SnippetReaderTest
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
index 2cb1d9a..51accbe 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
@@ -33,9 +33,9 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test toc macro.
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
index a3713d6..6a78a16 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/module/AbstractIdentityTest.java
@@ -32,7 +32,9 @@ import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkTestDocument;
import org.apache.maven.doxia.sink.impl.TextSink;
-import org.codehaus.plexus.DefaultPlexusContainer;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* If a module provides both Parser and Sink, this class
@@ -79,6 +81,7 @@ public abstract class AbstractIdentityTest
* @throws IOException if there's a problem reading/writing a test file.
* @throws ParseException if a model cannot be parsed.
*/
+ @Test
public void testIdentity()
throws IOException, ParseException
{
@@ -120,8 +123,9 @@ public abstract class AbstractIdentityTest
if ( assertIdentity )
{
// TODO: make this work for at least apt and xdoc modules?
- assertEquals( "Identity test failed! See results in " + getTestWriterFile( "actual" ).getParent(),
- getExpected(), actual );
+ assertEquals( getExpected(), actual,
+ "Identity test failed! See results in "
+ + getTestWriterFile( "actual" ).getParent() );
}
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
index 78d29d5..625ed68 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTest.java
@@ -25,13 +25,16 @@ import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.TextSink;
import org.apache.maven.doxia.sink.impl.WellformednessCheckingSink;
import org.apache.maven.doxia.sink.Sink;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Iterator;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Test the parsing of sample input files.
* <br>
@@ -67,6 +70,7 @@ public abstract class AbstractParserTest
* @throws IOException if the test document cannot be read.
* @throws ParseException if the test document cannot be parsed.
*/
+ @Test
public final void testParser()
throws IOException, ParseException
{
@@ -76,8 +80,8 @@ public abstract class AbstractParserTest
{
createParser().parse( reader, sink );
- assertTrue( "Parser output not well-formed, last offending element: " + sink.getOffender(),
- sink.isWellformed() );
+ assertTrue( sink.isWellformed(),
+ "Parser output not well-formed, last offending element: " + sink.getOffender() );
}
}
@@ -89,6 +93,7 @@ public abstract class AbstractParserTest
* @throws IOException if the test document cannot be read.
* @throws ParseException if the test document cannot be parsed.
*/
+ @Test
public final void testDocument()
throws IOException, ParseException
{
@@ -100,20 +105,20 @@ public abstract class AbstractParserTest
}
}
- protected void assertEquals( SinkEventElement element, String name, Object... args )
+ protected static void assertSinkEquals( SinkEventElement element, String name, Object... args )
{
- assertEquals( "Name of element doesn't match", name, element.getName() );
- Assert.assertArrayEquals( "Arguments don't match", args, element.getArgs() );
+ Assertions.assertEquals( name, element.getName(), "Name of element doesn't match" );
+ Assertions.assertArrayEquals( args, element.getArgs(), "Arguments don't match" );
}
- protected void assertAttributeEquals( SinkEventElement element, String name, String attr, String value )
+ protected static void assertSinkAttributeEquals( SinkEventElement element, String name, String attr, String value )
{
- assertEquals( name, element.getName() );
+ Assertions.assertEquals( name, element.getName() );
SinkEventAttributeSet atts = (SinkEventAttributeSet) element.getArgs()[0];
- assertEquals( value, atts.getAttribute( attr ) );
+ Assertions.assertEquals( value, atts.getAttribute( attr ) );
}
- protected void assertEquals( Iterator<SinkEventElement> it, String... names )
+ protected static void assertSinkEquals( Iterator<SinkEventElement> it, String... names )
{
StringBuilder expected = new StringBuilder();
StringBuilder actual = new StringBuilder();
@@ -128,10 +133,10 @@ public abstract class AbstractParserTest
actual.append( it.next().getName() ).append( '\n' );
}
- assertEquals( expected.toString(), actual.toString() );
+ Assertions.assertEquals( expected.toString(), actual.toString() );
}
- protected void assertStartsWith( Iterator<SinkEventElement> it, String... names )
+ protected static void assertSinkStartsWith( Iterator<SinkEventElement> it, String... names )
{
StringBuilder expected = new StringBuilder();
StringBuilder actual = new StringBuilder();
@@ -144,6 +149,6 @@ public abstract class AbstractParserTest
actual.append( it.next().getName() ).append( '\n' );
}
}
- assertEquals( expected.toString(), actual.toString() );
+ Assertions.assertEquals( expected.toString(), actual.toString() );
}
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java
index 3097bad..acfdcd4 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/AbstractParserTestCase.java
@@ -22,10 +22,15 @@ package org.apache.maven.doxia.parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkAdapter;
import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
import java.io.FileReader;
import java.io.Reader;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
+
/**
* Test the parsing of sample input files
*
@@ -33,8 +38,8 @@ import java.io.Reader;
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
* @since 1.0
*/
+@PlexusTest
public abstract class AbstractParserTestCase
- extends PlexusTestCase
{
/**
* Parser to use to convert input to sink events
@@ -66,6 +71,7 @@ public abstract class AbstractParserTestCase
*
* @throws Exception if any.
*/
+ @Test
public void testParser()
throws Exception
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
index 950c627..7f54ce8 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
@@ -24,8 +24,10 @@ import java.util.Iterator;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for XhtmlBaseParser.
@@ -50,22 +52,22 @@ public class Xhtml5BaseParserTest
return "xhtml";
}
- @Override
+ @BeforeEach
protected void setUp() throws Exception
{
- super.setUp();
-
parser = new Xhtml5BaseParser();
sink.reset();
}
/** Test Doxia version. */
+ @Test
public void testDoxiaVersion()
{
assertNotNull( XhtmlBaseParser.doxiaVersion() );
assertNotEquals( "unknown", XhtmlBaseParser.doxiaVersion() );
}
+ @Test
public void testHeadingEventsList()
throws Exception
{
@@ -106,6 +108,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testNestedHeadingEventsList()
throws Exception
{
@@ -145,6 +148,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testFigureEventsList()
throws Exception
{
@@ -158,6 +162,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testTableEventsList()
throws Exception
{
@@ -187,6 +192,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testSignificantWhiteSpace()
throws Exception
{
@@ -259,6 +265,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testPreFormattedText()
throws Exception
{
@@ -295,6 +302,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testPreEOL()
throws Exception
{
@@ -317,6 +325,7 @@ public class Xhtml5BaseParserTest
assertEquals( "verbatim_", it.next().getName() );
}
+ @Test
public void testDoxia250()
throws Exception
{
@@ -357,6 +366,7 @@ public class Xhtml5BaseParserTest
assertEquals( "paragraph_", event.getName() );
}
+ @Test
public void testEntities()
throws Exception
{
@@ -425,6 +435,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testXhtmlEntities()
throws Exception
{
@@ -465,6 +476,7 @@ public class Xhtml5BaseParserTest
assertFalse( it.hasNext() );
}
+ @Test
public void testLists()
throws Exception
{
@@ -494,6 +506,7 @@ public class Xhtml5BaseParserTest
assertEquals( "division_", it.next().getName() );
}
+ @Test
public void testSimpleTags()
throws Exception
{
@@ -509,6 +522,7 @@ public class Xhtml5BaseParserTest
assertEquals( "division_", it.next().getName() );
}
+ @Test
public void testSemanticTags()
throws Exception
{
@@ -664,6 +678,7 @@ public class Xhtml5BaseParserTest
}
+ @Test
public void testSpecial()
throws Exception
{
@@ -680,6 +695,7 @@ public class Xhtml5BaseParserTest
assertEquals( "paragraph_", it.next().getName() );
}
+ @Test
public void testTable()
throws Exception
{
@@ -708,6 +724,7 @@ public class Xhtml5BaseParserTest
assertEquals( "table_", it.next().getName() );
}
+ @Test
public void testFigure()
throws Exception
{
@@ -722,6 +739,7 @@ public class Xhtml5BaseParserTest
assertEquals( "figure_", it.next().getName() );
}
+ @Test
public void testAnchorLink()
throws Exception
{
@@ -783,6 +801,7 @@ public class Xhtml5BaseParserTest
*
* @throws java.lang.Exception if any.
*/
+ @Test
public void testAttributeEntities()
throws Exception
{
@@ -814,6 +833,7 @@ public class Xhtml5BaseParserTest
assertEquals( "http://ex.com/ex.jpg?v=l&l=e", attribs.getAttribute( "src" ) );
}
+ @Test
public void testUnbalancedDefinitionListItem() throws Exception
{
String text = "<body><dl><dt>key</dt><dd>value</dd></dl>" +
@@ -825,14 +845,14 @@ public class Xhtml5BaseParserTest
parser.parse( text, sink );
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definition", "text", "definition_", "definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
"definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionList_" );
- assertEquals( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
+ assertSinkStartsWith( it, "definitionList", "definitionList_" );
+ assertSinkEquals( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
"definitionListItem_", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definitionListItem_", "definitionList_" );
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
index 1175974..34eb8e8 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
@@ -24,8 +24,10 @@ import java.util.Iterator;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for XhtmlBaseParser.
@@ -53,16 +55,15 @@ public class XhtmlBaseParserTest
return "xhtml";
}
- @Override
+ @BeforeEach
protected void setUp() throws Exception
{
- super.setUp();
-
parser = new XhtmlBaseParser();
sink.reset();
}
/** Test Doxia version. */
+ @Test
public void testDoxiaVersion()
{
assertNotNull( XhtmlBaseParser.doxiaVersion() );
@@ -70,6 +71,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testHeadingEventsList()
throws Exception
{
@@ -111,6 +113,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testNestedHeadingEventsList()
throws Exception
{
@@ -151,6 +154,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testFigureEventsList()
throws Exception
{
@@ -165,6 +169,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testTableEventsList()
throws Exception
{
@@ -195,6 +200,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testSignificantWhiteSpace()
throws Exception
{
@@ -268,6 +274,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testPreFormattedText()
throws Exception
{
@@ -305,6 +312,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testPreEOL()
throws Exception
{
@@ -328,6 +336,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testDoxia250()
throws Exception
{
@@ -369,6 +378,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testEntities()
throws Exception
{
@@ -436,6 +446,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testXhtmlEntities()
throws Exception
{
@@ -490,6 +501,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testLists()
throws Exception
{
@@ -518,6 +530,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testSimpleTags()
throws Exception
{
@@ -531,6 +544,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testSemanticTags()
throws Exception
{
@@ -587,6 +601,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testSpecial()
throws Exception
{
@@ -604,6 +619,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testTable()
throws Exception
{
@@ -633,6 +649,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testFigure()
throws Exception
{
@@ -648,6 +665,7 @@ public class XhtmlBaseParserTest
}
/** @throws Exception */
+ @Test
public void testAnchorLink()
throws Exception
{
@@ -703,6 +721,7 @@ public class XhtmlBaseParserTest
*
* @throws java.lang.Exception if any.
*/
+ @Test
public void testAttributeEntities()
throws Exception
{
@@ -734,6 +753,7 @@ public class XhtmlBaseParserTest
assertEquals( "http://ex.com/ex.jpg?v=l&l=e", attribs.getAttribute( "src" ) );
}
+ @Test
public void testUnbalancedDefinitionListItem() throws Exception
{
String text = "<body><dl><dt>key</dt><dd>value</dd></dl>" +
@@ -745,14 +765,14 @@ public class XhtmlBaseParserTest
parser.parse( text, sink );
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definition", "text", "definition_", "definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
"definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
+ assertSinkStartsWith( it, "definitionList", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definitionListItem_", "definitionList_" );
- assertStartsWith( it, "definitionList", "definitionList_" );
- assertEquals( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
+ assertSinkStartsWith( it, "definitionList", "definitionList_" );
+ assertSinkEquals( it, "definitionList", "definitionListItem", "definition", "text", "definition_",
"definitionListItem_", "definitionListItem", "definedTerm", "text", "definedTerm_",
"definitionListItem_", "definitionList_" );
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTest.java
index ff6d4dc..e642459 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTest.java
@@ -27,8 +27,11 @@ import org.apache.maven.doxia.AbstractModuleTest;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.codehaus.plexus.util.IOUtil;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.xmlunit.matchers.CompareMatcher.isIdenticalTo;
/**
@@ -42,17 +45,10 @@ public abstract class AbstractSinkTest
/**
* Resets the writer and creates a new sink with it.
- *
- * {@inheritDoc}
- *
- * @throws java.lang.Exception if something goes wrong.
*/
- @Override
+ @BeforeEach
protected void setUp()
- throws Exception
{
- super.setUp();
-
testWriter.reset();
sink = createSink( testWriter );
}
@@ -114,6 +110,7 @@ public abstract class AbstractSinkTest
* @see #getTestWriter(String)
* @see #getXmlTestWriter(String)
*/
+ @Test
public final void testTestDocument() throws IOException
{
Writer writer = ( isXmlSink() ? getXmlTestWriter( "testDocument" ) : getTestWriter( "testDocument" ) );
@@ -135,6 +132,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getTitleBlock getTitleBlock}( title ).
*/
+ @Test
public void testTitle()
{
String title = "Grodek";
@@ -147,7 +145,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getTitleBlock( title );
- assertEquals( "Wrong title!", expected, actual );
+ assertEquals( expected, actual, "Wrong title!" );
}
/**
@@ -155,6 +153,7 @@ public abstract class AbstractSinkTest
* </code>, invoked on the current sink, produces the same result as
* {@link #getAuthorBlock getAuthorBlock}( author ).
*/
+ @Test
public void testAuthor()
{
String author = "Georg_Trakl";
@@ -167,7 +166,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getAuthorBlock( author );
- assertEquals( "Wrong author!", expected, actual );
+ assertEquals( expected, actual, "Wrong author!" );
}
/**
@@ -175,6 +174,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getDateBlock getDateBlock}( date ).
*/
+ @Test
public void testDate()
{
String date = "1914";
@@ -187,7 +187,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getDateBlock( date );
- assertEquals( "Wrong date!", expected, actual );
+ assertEquals( expected, actual, "Wrong date!" );
}
/**
@@ -195,6 +195,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getHeadBlock getHeadBlock()}.
*/
+ @Test
public void testHead()
{
sink.head();
@@ -205,7 +206,7 @@ public abstract class AbstractSinkTest
String actual = normalizeLineEnds( testWriter.toString() );
String expected = normalizeLineEnds( getHeadBlock() );
- assertEquals( "Wrong head!", expected, actual );
+ assertEquals( expected, actual, "Wrong head!" );
}
/**
@@ -213,6 +214,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getBodyBlock getBodyBlock()}.
*/
+ @Test
public void testBody()
{
sink.body();
@@ -223,7 +225,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getBodyBlock();
- assertEquals( "Wrong body!", expected, actual );
+ assertEquals( expected, actual, "Wrong body!" );
}
/**
@@ -231,6 +233,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getArticleBlock getArticleBlock()}.
*/
+ @Test
public void testArticle()
{
sink.article();
@@ -241,7 +244,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getArticleBlock();
- assertEquals( "Wrong article!", expected, actual );
+ assertEquals( expected, actual, "Wrong article!" );
}
/**
@@ -249,6 +252,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getNavigationBlock getNavigationBlock()}.
*/
+ @Test
public void testNavigation()
{
sink.navigation();
@@ -259,7 +263,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getNavigationBlock();
- assertEquals( "Wrong navigation!", expected, actual );
+ assertEquals( expected, actual, "Wrong navigation!" );
}
/**
@@ -267,6 +271,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getSidebarBlock getSidebarBlock()}.
*/
+ @Test
public void testSidebar()
{
sink.sidebar();
@@ -277,7 +282,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSidebarBlock();
- assertEquals( "Wrong sidebar!", expected, actual );
+ assertEquals( expected, actual, "Wrong sidebar!" );
}
/**
@@ -286,6 +291,7 @@ public abstract class AbstractSinkTest
* the same result as
* {@link #getSectionTitleBlock getSectionTitleBlock}( title ).
*/
+ @Test
public void testSectionTitle()
{
String title = "Title";
@@ -298,7 +304,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSectionTitleBlock( title );
- assertEquals( "Wrong sectionTitle!", expected, actual );
+ assertEquals( expected, actual, "Wrong sectionTitle!" );
}
/**
@@ -307,6 +313,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getSection1Block getSection1Block}( title ).
*/
+ @Test
public void testSection1()
{
String title = "Title1";
@@ -323,7 +330,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSection1Block( title );
- assertEquals( "Wrong section1 block!", expected, actual );
+ assertEquals( expected, actual, "Wrong section1 block!" );
}
/**
@@ -332,6 +339,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getSection2Block getSection2Block}( title ).
*/
+ @Test
public void testSection2()
{
String title = "Title2";
@@ -348,7 +356,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSection2Block( title );
- assertEquals( "Wrong section2 block!", expected, actual );
+ assertEquals( expected, actual, "Wrong section2 block!" );
}
/**
@@ -357,6 +365,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getSection3Block getSection3Block}( title ).
*/
+ @Test
public void testSection3()
{
String title = "Title3";
@@ -373,7 +382,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSection3Block( title );
- assertEquals( "Wrong section3 block!", expected, actual );
+ assertEquals( expected, actual, "Wrong section3 block!" );
}
/**
@@ -383,6 +392,7 @@ public abstract class AbstractSinkTest
* {@link #getSection4Block getSection4Block}( title ).
*
*/
+ @Test
public void testSection4()
{
String title = "Title4";
@@ -399,7 +409,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSection4Block( title );
- assertEquals( "Wrong section4 block!", expected, actual );
+ assertEquals( expected, actual, "Wrong section4 block!" );
}
/**
@@ -408,6 +418,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getSection5Block getSection5Block}( title ).
*/
+ @Test
public void testSection5()
{
String title = "Title5";
@@ -424,7 +435,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getSection5Block( title );
- assertEquals( "Wrong section5 block!", expected, actual );
+ assertEquals( expected, actual, "Wrong section5 block!" );
}
/**
@@ -432,6 +443,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getHeaderBlock getHeaderBlock()}.
*/
+ @Test
public void testHeader()
{
sink.header();
@@ -442,7 +454,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getHeaderBlock();
- assertEquals( "Wrong header!", expected, actual );
+ assertEquals( expected, actual, "Wrong header!" );
}
/**
@@ -450,6 +462,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getContentBlock getContentBlock()}.
*/
+ @Test
public void testContent()
{
sink.content();
@@ -462,7 +475,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getContentBlock();
- assertEquals( "Wrong content!", expected, actual );
+ assertEquals( expected, actual, "Wrong content!" );
}
/**
@@ -470,6 +483,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getHeaderBlock getHeaderBlock()}.
*/
+ @Test
public void testFooter()
{
sink.footer();
@@ -480,7 +494,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getFooterBlock();
- assertEquals( "Wrong footer!", expected, actual );
+ assertEquals( expected, actual, "Wrong footer!" );
}
/**
@@ -489,6 +503,7 @@ public abstract class AbstractSinkTest
* the same result as {@link #getListBlock getListBlock}( item ).
*
*/
+ @Test
public void testList()
{
String item = "list_item";
@@ -503,7 +518,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getListBlock( item );
- assertEquals( "Wrong list!", expected, actual );
+ assertEquals( expected, actual, "Wrong list!" );
}
/**
@@ -513,6 +528,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getNumberedListBlock getNumberedListBlock}( item ).
*/
+ @Test
public void testNumberedList()
{
String item = "numbered_list_item";
@@ -527,7 +543,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getNumberedListBlock( item );
- assertEquals( "Wrong numbered list!", expected, actual );
+ assertEquals( expected, actual, "Wrong numbered list!" );
}
/**
@@ -538,6 +554,7 @@ public abstract class AbstractSinkTest
* result as {@link #getDefinitionListBlock getDefinitionListBlock}
* ( definum, definition ).
*/
+ @Test
public void testDefinitionList()
{
String definum = "definum";
@@ -558,7 +575,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getDefinitionListBlock( definum, definition );
- assertEquals( "Wrong definition list!", expected, actual );
+ assertEquals( expected, actual, "Wrong definition list!" );
}
/**
@@ -567,6 +584,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getFigureBlock getFigureBlock}( source, caption ).
*/
+ @Test
public void testFigure()
{
String source = "figure.jpg";
@@ -594,6 +612,7 @@ public abstract class AbstractSinkTest
}
+ @Test
public void testFigureWithoutCaption()
{
String source = "figure.jpg";
@@ -615,6 +634,7 @@ public abstract class AbstractSinkTest
assertEquals( actual, expected );
}
}
+ @Test
public void testFigureFromUrl()
{
String source = "http://www.gravatar.com/avatar/cdbe99fe3d6af6a18dd8c35b0687a50b?d=mm&s=60";
@@ -645,6 +665,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getTableBlock getTableBlock}( cell, caption ).
*/
+ @Test
public void testTable()
{
String cell = "cell";
@@ -683,6 +704,7 @@ public abstract class AbstractSinkTest
* paragraph_()]</code>, invoked on the current sink, produces
* the same result as {@link #getParagraphBlock getParagraphBlock}( text ).
*/
+ @Test
public void testParagraph()
{
String text = "Text";
@@ -695,7 +717,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getParagraphBlock( text );
- assertEquals( "Wrong paragraph!", expected, actual );
+ assertEquals( expected, actual, "Wrong paragraph!" );
}
/**
@@ -703,6 +725,7 @@ public abstract class AbstractSinkTest
* data_()]</code>, invoked on the current sink, produces
* the same result as {@link #getDataBlock getDataBlock}( text ).
*/
+ @Test
public void testData()
{
String value = "Value";
@@ -716,7 +739,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getDataBlock( value, text );
- assertEquals( "Wrong data!", expected, actual );
+ assertEquals( expected, actual, "Wrong data!" );
}
/**
@@ -724,6 +747,7 @@ public abstract class AbstractSinkTest
* time_()]</code>, invoked on the current sink, produces
* the same result as {@link #getTimeBlock getTimeBlock}( text ).
*/
+ @Test
public void testTime()
{
String datetime = "DateTime";
@@ -737,7 +761,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getTimeBlock( datetime, text );
- assertEquals( "Wrong time!", expected, actual );
+ assertEquals( expected, actual, "Wrong time!" );
}
/**
@@ -745,6 +769,7 @@ public abstract class AbstractSinkTest
* address_()]</code>, invoked on the current sink, produces
* the same result as {@link #getAddressBlock getAddressBlock}( text ).
*/
+ @Test
public void testAddress()
{
String text = "Text";
@@ -757,7 +782,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getAddressBlock( text );
- assertEquals( "Wrong address!", expected, actual );
+ assertEquals( expected, actual, "Wrong address!" );
}
/**
@@ -765,6 +790,7 @@ public abstract class AbstractSinkTest
* blockquote_()]</code>, invoked on the current sink, produces
* the same result as {@link #getBlockquoteBlock}( text ).
*/
+ @Test
public void testBlockquote()
{
String text = "Text";
@@ -777,7 +803,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getBlockquoteBlock( text );
- assertEquals( "Wrong blockquote!", expected, actual );
+ assertEquals( expected, actual, "Wrong blockquote!" );
}
/**
@@ -785,6 +811,7 @@ public abstract class AbstractSinkTest
* division_()]</code>, invoked on the current sink, produces
* the same result as {@link #getDivisionBlock getDivisionBlock}( text ).
*/
+ @Test
public void testDivider()
{
String text = "Text";
@@ -797,7 +824,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getDivisionBlock( text );
- assertEquals( "Wrong division!", expected, actual );
+ assertEquals( expected, actual, "Wrong division!" );
}
/**
@@ -805,6 +832,7 @@ public abstract class AbstractSinkTest
* verbatim_()]</code>, invoked on the current sink, produces the
* same result as {@link #getVerbatimBlock getVerbatimBlock}( text ).
*/
+ @Test
public void testVerbatim()
{
String text = "Text";
@@ -817,7 +845,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getVerbatimBlock( text );
- assertEquals( "Wrong verbatim!", expected, actual );
+ assertEquals( expected, actual, "Wrong verbatim!" );
}
/**
@@ -825,6 +853,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getHorizontalRuleBlock getHorizontalRuleBlock()}.
*/
+ @Test
public void testHorizontalRule()
{
sink.horizontalRule();
@@ -834,7 +863,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getHorizontalRuleBlock();
- assertEquals( "Wrong horizontal rule!", expected, actual );
+ assertEquals( expected, actual, "Wrong horizontal rule!" );
}
/**
@@ -842,6 +871,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getPageBreakBlock getPageBreakBlock()}.
*/
+ @Test
public void testPageBreak()
{
sink.pageBreak();
@@ -851,7 +881,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getPageBreakBlock();
- assertEquals( "Wrong pageBreak!", expected, actual );
+ assertEquals( expected, actual, "Wrong pageBreak!" );
}
/**
@@ -859,6 +889,7 @@ public abstract class AbstractSinkTest
* anchor_()]</code>, invoked on the current sink, produces the same
* result as {@link #getAnchorBlock getAnchorBlock}( anchor ).
*/
+ @Test
public void testAnchor()
{
String anchor = "Anchor";
@@ -871,7 +902,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getAnchorBlock( anchor );
- assertEquals( "Wrong anchor!", expected, actual );
+ assertEquals( expected, actual, "Wrong anchor!" );
}
/**
@@ -879,6 +910,7 @@ public abstract class AbstractSinkTest
* link_()]</code>, invoked on the current sink, produces the same
* result as {@link #getLinkBlock getLinkBlock}( link, text ).
*/
+ @Test
public void testLink()
{
String link = "#Link";
@@ -892,7 +924,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getLinkBlock( link, text );
- assertEquals( "Wrong link!", expected, actual );
+ assertEquals( expected, actual, "Wrong link!" );
}
/**
@@ -900,6 +932,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getInlineBlock getInlineBlock}( text ).
*/
+ @Test
public void testInline()
{
String text = "Inline";
@@ -912,7 +945,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getInlineBlock( text );
- assertEquals( "Wrong inline!", expected, actual );
+ assertEquals( expected, actual, "Wrong inline!" );
}
/**
@@ -920,6 +953,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getInlineBoldBlock getInlineBoldBlock}( text ).
*/
+ @Test
public void testInlineBold()
{
String text = "InlineBold";
@@ -932,7 +966,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getInlineBoldBlock( text );
- assertEquals( "Wrong inline bold!", expected, actual );
+ assertEquals( expected, actual, "Wrong inline bold!" );
}
/**
@@ -940,6 +974,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getInlineBoldBlock getInlineBoldBlock}( text ).
*/
+ @Test
public void testInlineItalic()
{
String text = "InlineItalic";
@@ -952,7 +987,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getInlineItalicBlock( text );
- assertEquals( "Wrong inline italic!", expected, actual );
+ assertEquals( expected, actual, "Wrong inline italic!" );
}
/**
@@ -960,6 +995,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getInlineBoldBlock getInlineBoldBlock}( text ).
*/
+ @Test
public void testInlineCode()
{
String text = "InlineCode";
@@ -972,7 +1008,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getInlineCodeBlock( text );
- assertEquals( "Wrong inline code!", expected, actual );
+ assertEquals( expected, actual, "Wrong inline code!" );
}
/**
@@ -980,6 +1016,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getLineBreakBlock getLineBreakBlock()}.
*/
+ @Test
public void testLineBreak()
{
sink.lineBreak();
@@ -989,7 +1026,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getLineBreakBlock();
- assertEquals( "Wrong lineBreak!", expected, actual );
+ assertEquals( expected, actual, "Wrong lineBreak!" );
}
/**
@@ -997,6 +1034,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getLineBreakOpportunityBlock getLineBreakOpportunityBlock()}.
*/
+ @Test
public void testLineBreakOpportunity()
{
sink.lineBreakOpportunity();
@@ -1006,7 +1044,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getLineBreakOpportunityBlock();
- assertEquals( "Wrong lineBreakOpportunity!", expected, actual );
+ assertEquals( expected, actual, "Wrong lineBreakOpportunity!" );
}
/**
@@ -1014,6 +1052,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getNonBreakingSpaceBlock getNonBreakingSpaceBlock()}.
*/
+ @Test
public void testNonBreakingSpace()
{
sink.nonBreakingSpace();
@@ -1023,7 +1062,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getNonBreakingSpaceBlock();
- assertEquals( "Wrong nonBreakingSpace!", expected, actual );
+ assertEquals( expected, actual, "Wrong nonBreakingSpace!" );
}
/**
@@ -1031,6 +1070,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getTextBlock getTextBlock()}.
*/
+ @Test
public void testText()
{
String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
@@ -1041,7 +1081,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getTextBlock( text );
- assertEquals( "Wrong text!", expected, actual );
+ assertEquals( expected, actual, "Wrong text!" );
}
/**
@@ -1049,6 +1089,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getRawTextBlock getRawTextBlock}( text ).
*/
+ @Test
public void testRawText()
{
String text = "~,_=,_-,_+,_*,_[,_],_<,_>,_{,_},_\\";
@@ -1059,7 +1100,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getRawTextBlock( text );
- assertEquals( "Wrong rawText!", expected, actual );
+ assertEquals( expected, actual, "Wrong rawText!" );
}
/**
@@ -1068,6 +1109,7 @@ public abstract class AbstractSinkTest
* {@link #getCommentBlock getCommentBlock}( comment ).
* @since 1.1.1
*/
+ @Test
public void testComment()
{
String comment = "Simple comment with ----";
@@ -1078,7 +1120,7 @@ public abstract class AbstractSinkTest
String actual = testWriter.toString();
String expected = getCommentBlock( comment );
- assertEquals( "Wrong comment!", expected, actual );
+ assertEquals( expected, actual, "Wrong comment!" );
testWriter.reset();
sink = createSink( testWriter );
@@ -1091,7 +1133,7 @@ public abstract class AbstractSinkTest
actual = testWriter.toString();
expected = getCommentBlock( comment );
- assertEquals( "Wrong comment!", expected, actual );
+ assertEquals( expected, actual, "Wrong comment!" );
}
// ----------------------------------------------------------------------
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTestCase.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTestCase.java
index 1ffd78c..cc07079 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTestCase.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractSinkTestCase.java
@@ -29,14 +29,17 @@ import java.util.Objects;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @since 1.0
*/
+@PlexusTest
public abstract class AbstractSinkTestCase
- extends PlexusTestCase
{
private Writer testWriter;
@@ -50,6 +53,7 @@ public abstract class AbstractSinkTestCase
*
* @throws java.lang.Exception if anything goes wrong.
*/
+ @Test
public void testApt()
throws Exception
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
index 07c6cc9..7752110 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/AbstractXmlSinkTest.java
@@ -24,9 +24,9 @@ import javax.swing.text.html.HTML.Tag;
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
*
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/RandomAccessSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/RandomAccessSinkTest.java
index dce1f54..43e164b 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/RandomAccessSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/RandomAccessSinkTest.java
@@ -28,9 +28,9 @@ import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class RandomAccessSinkTest
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java
index 9f28fa7..e29bcc8 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkAdapterTest.java
@@ -22,7 +22,7 @@ import org.apache.maven.doxia.sink.impl.SinkAdapter;
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventAttributeSetTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventAttributeSetTest.java
index e628d5f..99cedd7 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventAttributeSetTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkEventAttributeSetTest.java
@@ -25,10 +25,10 @@ import javax.swing.text.AttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test SinkEventAttributeSet.
@@ -39,7 +39,7 @@ public class SinkEventAttributeSetTest
{
private SinkEventAttributeSet sinkEventAttributeSet;
- @Before
+ @BeforeEach
public void setUp()
{
this.sinkEventAttributeSet = new SinkEventAttributeSet();
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkUtilsTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkUtilsTest.java
index e990c27..3eb8a7c 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkUtilsTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/SinkUtilsTest.java
@@ -24,10 +24,10 @@ import javax.swing.text.MutableAttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
*
@@ -69,7 +69,7 @@ public class SinkUtilsTest
@Test
public void testFilterAttributes()
{
- Assert.assertNull( SinkUtils.filterAttributes( null, null ) );
+ assertNull( SinkUtils.filterAttributes( null, null ) );
AttributeSet attributes = new SinkEventAttributeSet( 1 );
String[] valids = null;
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TestAbstractSink.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TestAbstractSink.java
index cec63b0..f32f87e 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TestAbstractSink.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TestAbstractSink.java
@@ -18,9 +18,9 @@ package org.apache.maven.doxia.sink.impl;
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestAbstractSink
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
index 3913825..d854e82 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
@@ -27,11 +27,10 @@ import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for Xhtml5BaseSink.
@@ -45,7 +44,7 @@ public class Xhtml5BaseSinkTest
String EOL = System.lineSeparator();
- @Before
+ @BeforeEach
public void setUp()
{
writer = new StringWriter();
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java
index 838ea0d..e02da96 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/XhtmlBaseSinkTest.java
@@ -27,11 +27,12 @@ import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for XhtmlBaseSink.
@@ -46,7 +47,7 @@ public class XhtmlBaseSinkTest
private XhtmlBaseSink sink;
private Writer writer;
- @Before
+ @BeforeEach
public void setUp()
{
writer = new StringWriter();
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/util/ByLineReaderSourceTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/util/ByLineReaderSourceTest.java
index ca4b8df..8d3a9dd 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/util/ByLineReaderSourceTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/util/ByLineReaderSourceTest.java
@@ -23,9 +23,9 @@ import java.io.StringReader;
import org.apache.maven.doxia.parser.ParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Unit test for {@link org.apache.maven.doxia.util.ByLineReaderSource}.
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java
index 1666b37..126bd7e 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java
@@ -25,128 +25,113 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test case for <code>DoxiaUtils</code>.
*
* @author ltheussl
*/
+@PlexusTest
public class DoxiaUtilsTest
- extends PlexusTestCase
{
/**
* Verify the expected results.
*/
+ @Test
public void testIsInternalLink()
{
String link = "#anchor";
- assertTrue( "Should be an internal link: " + link,
- DoxiaUtils.isInternalLink( link ) );
+ assertTrue( DoxiaUtils.isInternalLink( link ), "Should be an internal link: " + link );
link = "http://maven.apache.org/index.html#anchor";
- assertFalse( "Should NOT be an internal link: " + link,
- DoxiaUtils.isInternalLink( link ) );
+ assertFalse( DoxiaUtils.isInternalLink( link ), "Should NOT be an internal link: " + link );
link = "./index.html";
- assertFalse( "Should NOT be an internal link: " + link,
- DoxiaUtils.isInternalLink( link ) );
+ assertFalse( DoxiaUtils.isInternalLink( link ), "Should NOT be an internal link: " + link );
}
/**
* Verify the expected results.
*/
+ @Test
public void testIsExternalLink()
{
String link = "http://maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "https://maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "HTTPS://MAVEN.APACHE.ORG/";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "ftp:/maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "mailto:maven@apache.org";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "file:/index.html";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "resource_type://domain:port/filepathname?query_string#anchor";
- assertTrue( "Should be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertTrue( DoxiaUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "example.pdf";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "./index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "../index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
// Windows style separators "\" are not allowed
link = "file:\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = ".\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "..\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- DoxiaUtils.isExternalLink( link ) );
+ assertFalse( DoxiaUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
}
/**
* Verify the expected results.
*/
+ @Test
public void testIsLocalLink()
{
String link = "index.html";
- assertTrue( "Should be a local link: " + link,
- DoxiaUtils.isLocalLink( link ) );
+ assertTrue( DoxiaUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "./index.html";
- assertTrue( "Should be a local link: " + link,
- DoxiaUtils.isLocalLink( link ) );
+ assertTrue( DoxiaUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "../index.html";
- assertTrue( "Should be a local link: " + link,
- DoxiaUtils.isLocalLink( link ) );
+ assertTrue( DoxiaUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "#anchor";
- assertFalse( "Should NOT be a local link: " + link,
- DoxiaUtils.isLocalLink( link ) );
+ assertFalse( DoxiaUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
link = "http://maven.apache.org/";
- assertFalse( "Should NOT be a local link: " + link,
- DoxiaUtils.isLocalLink( link ) );
+ assertFalse( DoxiaUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
}
/**
* Verify the expected results.
*/
+ @Test
public void testEncodeId()
{
assertNull( DoxiaUtils.encodeId( null ) );
@@ -169,6 +154,7 @@ public class DoxiaUtilsTest
/**
* Verify the expected results.
*/
+ @Test
public void testIsValidId()
{
assertFalse( DoxiaUtils.isValidId( null ) );
@@ -195,6 +181,7 @@ public class DoxiaUtilsTest
/**
* Verify the expected results.
*/
+ @Test
public void testParseDate()
{
final int year = 1973;
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/util/HtmlToolsTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/util/HtmlToolsTest.java
index f592abb..b2e4924 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/util/HtmlToolsTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/util/HtmlToolsTest.java
@@ -21,19 +21,27 @@ package org.apache.maven.doxia.util;
import java.net.URLEncoder;
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for <code>HtmlTools</code>.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
+@PlexusTest
public class HtmlToolsTest
- extends PlexusTestCase
{
/**
* Verify the expected results.
*/
+ @Test
public void testEscapeHTML()
{
assertEquals( HtmlTools.escapeHTML( null ), "" );
@@ -60,6 +68,7 @@ public class HtmlToolsTest
/**
* Verify the expected results.
*/
+ @Test
public void testUnescapeHTML()
{
assertNull( HtmlTools.unescapeHTML( null ) );
@@ -89,6 +98,7 @@ public class HtmlToolsTest
/**
* Verify the expected results.
*/
+ @Test
public void testEncodeId()
{
assertNull( HtmlTools.encodeId( null ) );
@@ -110,6 +120,7 @@ public class HtmlToolsTest
*
* @throws Exception should not happen.
*/
+ @Test
public void testEncodeURL()
throws Exception
{
@@ -128,6 +139,7 @@ public class HtmlToolsTest
/**
* Verify the expected results.
*/
+ @Test
public void testIsId()
{
assertFalse( HtmlTools.isId( null ) );
@@ -150,6 +162,7 @@ public class HtmlToolsTest
/**
* Verify the expected results.
*/
+ @Test
public void testGetHtmlTag()
{
assertNull( HtmlTools.getHtmlTag( null ) );
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/util/XmlValidatorTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/util/XmlValidatorTest.java
index 4c1f700..a08e653 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/util/XmlValidatorTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/util/XmlValidatorTest.java
@@ -19,20 +19,22 @@ package org.apache.maven.doxia.util;
* under the License.
*/
-import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.XmlStreamReader;
+import org.junit.jupiter.api.Test;
/**
* Test case for <code>XmlValidator</code>.
*
* @author Hervé Boutemy
*/
+@PlexusTest
public class XmlValidatorTest
-extends PlexusTestCase
{
+ @Test
public void testValidate()
- throws Exception
+ throws Exception
{
String xml = IOUtil.toString( new XmlStreamReader( this.getClass().getResourceAsStream( "/test.xhtml" ) ) );
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java b/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
index 7290559..4ac46a5 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
@@ -26,14 +26,12 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import junit.framework.AssertionFailedError;
-
-import org.apache.maven.doxia.parser.Parser;
-
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -44,6 +42,8 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
+import static org.junit.jupiter.api.Assertions.fail;
+
/**
* Abstract class to validate XML files.
*
@@ -51,11 +51,14 @@ import org.xml.sax.helpers.XMLReaderFactory;
*
* @since 1.2
*/
+@PlexusTest
public abstract class AbstractXmlValidator
- extends PlexusTestCase
{
+
protected static final String EOL = System.getProperty( "line.separator" );
+ protected final Logger logger = LoggerFactory.getLogger( getClass() );
+
/** XMLReader to validate xml file */
private XMLReader xmlReader;
@@ -79,12 +82,9 @@ public abstract class AbstractXmlValidator
|| message.contains( "cvc-attribute.3:" ) ); // Doxia allow space
}
- @Override
+ @AfterEach
protected void tearDown()
- throws Exception
{
- super.tearDown();
-
xmlReader = null;
}
@@ -96,12 +96,10 @@ public abstract class AbstractXmlValidator
* @see #addNamespaces(String)
* @see #getTestDocuments()
*/
+ @Test
public void testValidateFiles()
throws Exception
{
- final Logger logger =
- ( (DefaultPlexusContainer) getContainer() ).getLoggerManager().getLoggerForComponent( Parser.ROLE );
-
for ( Map.Entry<String, String> entry : getTestDocuments().entrySet() )
{
if ( logger.isDebugEnabled() )
@@ -182,15 +180,15 @@ public abstract class AbstractXmlValidator
}
catch ( SAXNotRecognizedException e )
{
- throw new AssertionFailedError( "SAXNotRecognizedException: " + e.getMessage() );
+ fail( "SAXNotRecognizedException: " + e.getMessage() );
}
catch ( SAXNotSupportedException e )
{
- throw new AssertionFailedError( "SAXNotSupportedException: " + e.getMessage() );
+ fail( "SAXNotSupportedException: " + e.getMessage() );
}
catch ( SAXException e )
{
- throw new AssertionFailedError( "SAXException: " + e.getMessage() );
+ fail( "SAXException: " + e.getMessage() );
}
}
diff --git a/doxia-modules/doxia-module-apt/pom.xml b/doxia-modules/doxia-module-apt/pom.xml
index 296246c..ff0e96d 100644
--- a/doxia-modules/doxia-module-apt/pom.xml
+++ b/doxia-modules/doxia-module-apt/pom.xml
@@ -51,6 +51,10 @@ under the License.
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<classifier>no_aop</classifier>
@@ -71,5 +75,10 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
index f36b8cd..63786e3 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
@@ -19,19 +19,19 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
import org.apache.maven.doxia.parser.AbstractTextParser;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkAdapter;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.util.DoxiaUtils;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
@@ -52,7 +52,7 @@ import java.util.StringTokenizer;
*
* @since 1.0
*/
-@Component( role = Parser.class, hint = "apt" )
+@Named( "apt" )
public class AptParser
extends AbstractTextParser
implements AptMarkup
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParserModule.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParserModule.java
index f8b4114..f433a0f 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParserModule.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParserModule.java
@@ -19,16 +19,16 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* <p>AptParserModule class.</p>
*
* @since 1.6
*/
-@Component( role = ParserModule.class, hint = "apt" )
+@Named( "apt" )
public class AptParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
index 82847fc..300e230 100644
--- a/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
+++ b/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSinkFactory.java
@@ -19,12 +19,12 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
+import javax.inject.Named;
+
import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
import org.apache.maven.doxia.sink.impl.AbstractTextSinkFactory;
-import org.codehaus.plexus.component.annotations.Component;
/**
* APT implementation of the Sink factory.
@@ -32,7 +32,7 @@ import org.codehaus.plexus.component.annotations.Component;
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @since 1.0
*/
-@Component( role = SinkFactory.class, hint = "apt" )
+@Named( "apt" )
public class AptSinkFactory
extends AbstractTextSinkFactory
{
diff --git a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
index da243f8..00f1f99 100644
--- a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
+++ b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
+import javax.inject.Inject;
+
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
@@ -33,6 +35,13 @@ import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
@@ -41,17 +50,9 @@ public class AptParserTest
extends AbstractParserTest
{
+ @Inject
private AptParser parser;
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- parser = (AptParser) lookup( Parser.class, "apt" );
- }
-
protected Parser createParser()
{
return parser;
@@ -69,6 +70,7 @@ public class AptParserTest
}
}
+ @Test
public void testLineBreak()
throws Exception
{
@@ -77,6 +79,7 @@ public class AptParserTest
assertTrue( linebreak.contains( "Line\\" + EOL + "break." ) );
}
+ @Test
public void testSnippetMacro()
throws Exception
{
@@ -85,6 +88,7 @@ public class AptParserTest
assertTrue( macro.contains( "<modelVersion\\>4.0.0\\</modelVersion\\>" ) );
}
+ @Test
public void testCommentsBeforeTitle()
throws Exception
{
@@ -94,6 +98,7 @@ public class AptParserTest
+ EOL + " -----" + EOL + " Test DOXIA-379" ) );
}
+ @Test
public void testSnippet()
throws Exception
{
@@ -107,11 +112,12 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "list", "listItem", "text", "verbatim", "text", "verbatim_",
+ assertSinkEquals( it, "head", "head_", "body", "list", "listItem", "text", "verbatim", "text", "verbatim_",
"paragraph", "text", "paragraph_", "listItem_", "listItem", "text", "verbatim", "text",
"verbatim_", "paragraph", "text", "paragraph_", "listItem_", "list_", "body_" );
}
+ @Test
public void testSnippetTrailingSpace()
throws Exception
{
@@ -124,9 +130,10 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "verbatim", "text", "verbatim_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "verbatim", "text", "verbatim_", "body_" );
}
+ @Test
public void testTocMacro()
throws Exception
{
@@ -144,6 +151,7 @@ public class AptParserTest
* @throws IOException if the test file cannot be read.
* @throws ParseException if the test file cannot be parsed.
*/
+ @Test
public void testTestDocument()
throws IOException, ParseException
{
@@ -155,6 +163,7 @@ public class AptParserTest
}
}
+ @Test
public void testBoxedVerbatim()
throws Exception
{
@@ -167,14 +176,15 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body" );
- assertEquals( it.next(), "verbatim", SinkEventAttributeSet.BOXED );
- assertStartsWith( it, "text", "verbatim_" );
+ assertSinkStartsWith( it, "head", "head_", "body" );
+ assertSinkEquals( it.next(), "verbatim", SinkEventAttributeSet.BOXED );
+ assertSinkStartsWith( it, "text", "verbatim_" );
- assertEquals( it.next(), "verbatim", new Object[] { null } );
- assertEquals( it, "text", "verbatim_", "body_" );
+ assertSinkEquals( it.next(), "verbatim", new Object[] { null } );
+ assertSinkEquals( it, "text", "verbatim_", "body_" );
}
+ @Test
public void testMultiLinesInTableCells()
throws Exception
{
@@ -195,36 +205,37 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 1, 1" );
+ assertSinkStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 1, 1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 1,2" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 1,2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 1,3" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 1,3" );
- assertStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 2,1" );
+ assertSinkStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 2,1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 2, 2" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 2, 2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 2,3" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 2,3" );
- assertStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 3,1" );
+ assertSinkStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 3,1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 3,2" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 3,2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 3, 3" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(), "text", "cell 3, 3" );
- assertEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
+ assertSinkEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
}
+ @Test
public void testLineBreakInTableCells()
throws Exception
{
@@ -245,45 +256,46 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 1,\u00A0" );
+ assertSinkStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 1,\u00A0" );
assertEquals( it.next().getName(), "lineBreak" );
- assertEquals( it.next(), "text", "1" );
+ assertSinkEquals( it.next(),"text", "1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 1,2" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 1,2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 1,3" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 1,3" );
- assertStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 2,1" );
+ assertSinkStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 2,1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 2,\u00A0" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 2,\u00A0" );
assertEquals( it.next().getName(), "lineBreak" );
- assertEquals( it.next(), "text", "2" );
+ assertSinkEquals( it.next(),"text", "2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 2,3" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 2,3" );
- assertStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell 3,1" );
+ assertSinkStartsWith( it, "tableCell_", "tableRow_", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 3,1" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 3,2" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 3,2" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "cell 3,\u00A0" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell 3,\u00A0" );
assertEquals( it.next().getName(), "lineBreak" );
- assertEquals( it.next(), "text", "3" );
+ assertSinkEquals( it.next(),"text", "3" );
- assertEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
+ assertSinkEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
}
+ @Test
public void testDOXIA38()
throws Exception
{
@@ -300,32 +312,33 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
- assertEquals( it.next(), "text", "Centered" );
+ assertSinkStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
+ assertSinkEquals( it.next(),"text", "Centered" );
assertEquals( it.next().getName(), "tableCell_" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
- assertEquals( it.next(), "text", "Centered" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
+ assertSinkEquals( it.next(),"text", "Centered" );
assertEquals( it.next().getName(), "tableCell_" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
- assertEquals( it.next(), "text", "Centered" );
- assertStartsWith( it, "tableCell_", "tableRow_", "tableRow" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
+ assertSinkEquals( it.next(),"text", "Centered" );
+ assertSinkStartsWith( it, "tableCell_", "tableRow_", "tableRow" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
- assertEquals( it.next(), "text", "Centered" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "center" );
+ assertSinkEquals( it.next(),"text", "Centered" );
assertEquals( it.next().getName(), "tableCell_" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "left" );
- assertEquals( it.next(), "text", "Left-aligned" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "left" );
+ assertSinkEquals( it.next(),"text", "Left-aligned" );
assertEquals( it.next().getName(), "tableCell_" );
- assertAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "right" );
- assertEquals( it.next(), "text", "Right-aligned" );
- assertEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
+ assertSinkAttributeEquals( it.next(), "tableCell", SinkEventAttributeSet.ALIGN, "right" );
+ assertSinkEquals( it.next(),"text", "Right-aligned" );
+ assertSinkEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
}
+ @Test
public void testSpecialCharactersInTables()
throws Exception
{
@@ -342,15 +355,16 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "paragraph" );
- assertEquals( it.next(), "text", "~ = - + * [ ] < > { } \\ \u2713" );
+ assertSinkStartsWith( it, "head", "head_", "body", "paragraph" );
+ assertSinkEquals( it.next(),"text", "~ = - + * [ ] < > { } \\ \u2713" );
- assertStartsWith( it, "paragraph_", "table", "tableRows", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "~ = - + * [ ] < > { } \\ \u2713" );
+ assertSinkStartsWith( it, "paragraph_", "table", "tableRows", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(),"text", "~ = - + * [ ] < > { } \\ \u2713" );
- assertEquals( it, "tableCell_", "tableCell", "text", "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
+ assertSinkEquals( it, "tableCell_", "tableCell", "text", "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
}
+ @Test
public void testSpacesAndBracketsInAnchors()
throws Exception
{
@@ -364,24 +378,25 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "paragraph" );
- assertEquals( it.next(), "anchor", "Anchor_with_spaces_and_brackets" );
+ assertSinkStartsWith( it, "head", "head_", "body", "paragraph" );
+ assertSinkEquals( it.next(),"anchor", "Anchor_with_spaces_and_brackets" );
- assertEquals( it.next(), "text", "Anchor with spaces (and brackets)" );
+ assertSinkEquals( it.next(),"text", "Anchor with spaces (and brackets)" );
- assertStartsWith( it, "anchor_", "text" );
- assertEquals( it.next(), "link", "#Anchor_with_spaces_and_brackets" );
+ assertSinkStartsWith( it, "anchor_", "text" );
+ assertSinkEquals( it.next(),"link", "#Anchor_with_spaces_and_brackets" );
- assertEquals( it.next(), "text", "Anchor with spaces (and brackets)" );
+ assertSinkEquals( it.next(),"text", "Anchor with spaces (and brackets)" );
- assertStartsWith( it, "link_", "text" );
- assertEquals( it.next(), "link", "http://fake.api#method(with, args)" );
+ assertSinkStartsWith( it, "link_", "text" );
+ assertSinkEquals( it.next(),"link", "http://fake.api#method(with, args)" );
- assertEquals( it.next(), "text", "method(with, args)" );
+ assertSinkEquals( it.next(),"text", "method(with, args)" );
- assertEquals( it, "link_", "paragraph_", "body_" );
+ assertSinkEquals( it, "link_", "paragraph_", "body_" );
}
+ @Test
public void testSectionTitleAnchors()
throws Exception
{
@@ -395,10 +410,11 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "section1", "sectionTitle1", "text", "sectionTitle1_", "section1_",
+ assertSinkEquals( it, "head", "head_", "body", "section1", "sectionTitle1", "text", "sectionTitle1_", "section1_",
"section1", "sectionTitle1", "anchor", "text", "anchor_", "sectionTitle1_", "section1_", "body_" );
}
-
+
+ @Test
public void testTableHeaders() throws Exception
{
// DOXIA-404
@@ -416,16 +432,17 @@ public class AptParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "table", "tableRows" );
- assertStartsWith( it, "tableRow", "tableHeaderCell", "text", "tableHeaderCell_", "tableHeaderCell", "text",
+ assertSinkStartsWith( it, "head", "head_", "body", "table", "tableRows" );
+ assertSinkStartsWith( it, "tableRow", "tableHeaderCell", "text", "tableHeaderCell_", "tableHeaderCell", "text",
"tableHeaderCell_", "tableRow_" );
- assertStartsWith( it, "tableRow", "tableCell", "text", "tableCell_", "tableCell", "text", "tableCell_",
+ assertSinkStartsWith( it, "tableRow", "tableCell", "text", "tableCell_", "tableCell", "text", "tableCell_",
"tableRow_" );
- assertStartsWith( it, "tableRow", "tableCell", "text", "tableCell_", "tableCell", "text", "tableCell_",
+ assertSinkStartsWith( it, "tableRow", "tableCell", "text", "tableCell_", "tableCell", "text", "tableCell_",
"tableRow_" );
- assertEquals( it, "tableRows_", "table_", "body_" );
+ assertSinkEquals( it, "tableRows_", "table_", "body_" );
}
-
+
+ @Test
public void testEscapedPipeInTableCell() throws Exception
{
// DOXIA-479
@@ -438,13 +455,14 @@ public class AptParserTest
parser.parse( text, sink );
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
- assertEquals( it.next(), "text", "cell | pipe" );
- assertStartsWith( it, "tableCell_", "tableCell" );
- assertEquals( it.next(), "text", "next cell" );
- assertEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
+ assertSinkStartsWith( it, "head", "head_", "body", "table", "tableRows", "tableRow", "tableCell" );
+ assertSinkEquals( it.next(),"text", "cell | pipe" );
+ assertSinkStartsWith( it, "tableCell_", "tableCell" );
+ assertSinkEquals( it.next(),"text", "next cell" );
+ assertSinkEquals( it, "tableCell_", "tableRow_", "tableRows_", "table_", "body_" );
}
+ @Test
public void testLiteralAnchor()
throws Exception
{
@@ -457,11 +475,11 @@ public class AptParserTest
parser.parse( text, sink );
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "head", "head_", "body", "section1", "sectionTitle1" );
- assertEquals( it.next(), "link",
+ assertSinkStartsWith( it, "head", "head_", "body", "section1", "sectionTitle1" );
+ assertSinkEquals( it.next(),"link",
"../apidocs/groovyx/net/http/ParserRegistry.html#parseText(org.apache.http.HttpResponse)" );
- assertEquals( it.next(), "text", "ParserRegistry" );
- assertEquals( it, "link_", "sectionTitle1_", "section1_", "body_" );
+ assertSinkEquals( it.next(),"text", "ParserRegistry" );
+ assertSinkEquals( it, "link_", "sectionTitle1_", "section1_", "body_" );
}
protected String outputExtension()
diff --git a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
index de18ee8..108d369 100644
--- a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
+++ b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptSinkTest.java
@@ -25,6 +25,9 @@ import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test the <code>AptSink</code> class
@@ -372,6 +375,7 @@ public class AptSinkTest extends AbstractSinkTest
/**
* test for DOXIA-497.
*/
+ @Test
public void testLinksAndParagraphsInTableCells()
{
final String linkTarget = "target";
@@ -420,9 +424,10 @@ public class AptSinkTest extends AbstractSinkTest
AptMarkup.STAR +
EOL;
- assertEquals( "Wrong link or paragraph markup in table cell", expected, getSinkContent() );
+ assertEquals( expected, getSinkContent(), "Wrong link or paragraph markup in table cell" );
}
+ @Test
public void testTableCellsWithJustification()
{
final String linkTarget = "target";
@@ -467,6 +472,6 @@ public class AptSinkTest extends AbstractSinkTest
AptMarkup.TABLE_COL_LEFT_ALIGNED_MARKUP +
EOL;
- assertEquals( "Wrong justification in table cells", expected, getSinkContent() );
+ assertEquals( expected, getSinkContent(), "Wrong justification in table cells" );
}
}
diff --git a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java
index 4f6e330..bdb4f4c 100644
--- a/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java
+++ b/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptUtilsTest.java
@@ -19,9 +19,9 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test AptUtils.
@@ -37,48 +37,48 @@ public class AptUtilsTest
public void testIsExternalLink()
{
String link = "http://maven.apache.org/";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "https://maven.apache.org/";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "HTTPS://MAVEN.APACHE.ORG/";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "ftp:/maven.apache.org/";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "mailto:maven@apache.org";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "file:/index.html";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "resource_type://domain:port/filepathname?query_string#anchor";
- assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertTrue( AptUtils.isExternalLink( link ), "Should be an external link: " + link );
link = "index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "example.pdf";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "./index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "../index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
// Windows style separators "\" are not allowed
link = "file:\\index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = ".\\index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
link = "..\\index.html";
- assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
+ assertFalse( AptUtils.isExternalLink( link ), "Should NOT be an external link: " + link );
}
/**
@@ -88,11 +88,11 @@ public class AptUtilsTest
public void testIsInternalLink()
{
String link = "index.html";
- assertTrue( "Should be an internal link: " + link, AptUtils.isInternalLink( link ) );
+ assertTrue( AptUtils.isInternalLink( link ), "Should be an internal link: " + link );
link = "file:/index.html";
- assertFalse( "Should NOT be an internal link: " + link, AptUtils.isInternalLink( link ) );
+ assertFalse( AptUtils.isInternalLink( link ), "Should NOT be an internal link: " + link );
link = "./index.html";
- assertFalse( "Should NOT be an internal link: " + link, AptUtils.isInternalLink( link ) );
+ assertFalse( AptUtils.isInternalLink( link ), "Should NOT be an internal link: " + link );
}
/**
@@ -102,25 +102,25 @@ public class AptUtilsTest
public void testIsLocalLink()
{
String link = "/index.html";
- assertTrue( "Should be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertTrue( AptUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "./index.html";
- assertTrue( "Should be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertTrue( AptUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "../index.html";
- assertTrue( "Should be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertTrue( AptUtils.isLocalLink( link ), "Should be a local link: " + link );
link = "index.html";
- assertFalse( "Should NOT be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertFalse( AptUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
link = ".\\index.html";
- assertFalse( "Should NOT be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertFalse( AptUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
link = "\\index.html";
- assertFalse( "Should NOT be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertFalse( AptUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
link = "..\\index.html";
- assertFalse( "Should NOT be a local link: " + link, AptUtils.isLocalLink( link ) );
+ assertFalse( AptUtils.isLocalLink( link ), "Should NOT be a local link: " + link );
}
/**
diff --git a/doxia-modules/doxia-module-fml/pom.xml b/doxia-modules/doxia-module-fml/pom.xml
index 156b306..7b445f6 100644
--- a/doxia-modules/doxia-module-fml/pom.xml
+++ b/doxia-modules/doxia-module-fml/pom.xml
@@ -46,6 +46,10 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
<!-- test -->
<dependency>
@@ -64,6 +68,11 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
index 3068d96..a7a6223 100644
--- a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
+++ b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import javax.inject.Named;
import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.macro.MacroExecutionException;
@@ -37,13 +38,11 @@ import org.apache.maven.doxia.module.fml.model.Faqs;
import org.apache.maven.doxia.module.fml.model.Part;
import org.apache.maven.doxia.parser.AbstractXmlParser;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
import org.apache.maven.doxia.util.DoxiaUtils;
import org.apache.maven.doxia.util.HtmlTools;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -58,7 +57,7 @@ import org.slf4j.LoggerFactory;
* @author ltheussl
* @since 1.0
*/
-@Component( role = Parser.class, hint = "fml" )
+@Named( "fml" )
public class FmlParser
extends AbstractXmlParser
implements FmlMarkup
diff --git a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParserModule.java b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParserModule.java
index 30e39f5..0801804 100644
--- a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParserModule.java
+++ b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParserModule.java
@@ -19,16 +19,16 @@ package org.apache.maven.doxia.module.fml;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* <p>FmlParserModule class.</p>
*
* @since 1.6
*/
-@Component( role = ParserModule.class, hint = "fml" )
+@Named( "fml" )
public class FmlParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java b/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
index c5a47db..bebb5bd 100644
--- a/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
+++ b/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.module.fml;
* under the License.
*/
+import javax.inject.Inject;
+
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
@@ -35,6 +37,14 @@ import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
import org.codehaus.plexus.util.IOUtil;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
@@ -42,16 +52,13 @@ import org.codehaus.plexus.util.IOUtil;
public class FmlParserTest
extends AbstractParserTest
{
+ @Inject
private FmlParser parser;
- @Override
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
-
- parser = (FmlParser) lookup( Parser.class, "fml" );
-
// AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files in ${java.io.tmpdir}
// Be sure to delete them
String tmpDir = System.getProperty( "java.io.tmpdir" );
@@ -59,7 +66,7 @@ public class FmlParserTest
// Using FileFilter, because is it is much faster then FileUtils.listFiles
File[] tmpFiles = new File( tmpDir ).listFiles( new FileFilter()
{
- Pattern xsdPatterns = Pattern.compile( "(xml|fml\\-.+)\\.xsd" );
+ final Pattern xsdPatterns = Pattern.compile( "(xml|fml\\-.+)\\.xsd" );
@Override
public boolean accept( File pathname )
@@ -87,6 +94,7 @@ public class FmlParserTest
}
/** @throws Exception */
+ @Test
public void testFaqEventsList()
throws Exception
{
@@ -152,6 +160,7 @@ public class FmlParserTest
}
/** @throws Exception */
+ @Test
public void testEntities()
throws Exception
{
@@ -255,6 +264,7 @@ public class FmlParserTest
* @throws Exception if any
* @since 1.1.1
*/
+ @Test
public void testFaqMacro()
throws Exception
{
@@ -267,7 +277,7 @@ public class FmlParserTest
}
File f = getTestFile( getBasedir(), outputBaseDir() + getOutputDir() + "macro.fml" );
- assertTrue( "The file " + f.getAbsolutePath() + " was not created", f.exists() );
+ assertTrue( f.exists(), "The file " + f.getAbsolutePath() + " was not created" );
String content;
try ( Reader reader = new FileReader( f ) )
diff --git a/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java b/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
index b301524..d1e3176 100644
--- a/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
+++ b/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
@@ -26,6 +26,9 @@ import java.util.regex.Pattern;
import org.apache.maven.doxia.markup.XmlMarkup;
import org.apache.maven.doxia.xsd.AbstractXmlValidatorTest;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
/**
* Test FML files with namespace.
@@ -69,6 +72,7 @@ public class FmlValidatorTest
return content;
}
+ @Test
public void testValidateFiles()
{
// TODO: super.testValidateFiles() only validates files from doxia-test-docs, what's the point?
diff --git a/doxia-modules/doxia-module-markdown/pom.xml b/doxia-modules/doxia-module-markdown/pom.xml
index 92cff9a..a221802 100644
--- a/doxia-modules/doxia-module-markdown/pom.xml
+++ b/doxia-modules/doxia-module-markdown/pom.xml
@@ -57,6 +57,10 @@ under the License.
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.42.14</version>
@@ -87,6 +91,11 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
index 1ac7508..bba74f4 100644
--- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
+++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
@@ -19,6 +19,9 @@ package org.apache.maven.doxia.module.markdown;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import com.vladsch.flexmark.ast.Heading;
import com.vladsch.flexmark.ast.HtmlCommentBlock;
import com.vladsch.flexmark.util.ast.Node;
@@ -38,11 +41,8 @@ import org.apache.maven.doxia.markup.HtmlMarkup;
import org.apache.maven.doxia.module.xhtml.XhtmlParser;
import org.apache.maven.doxia.parser.AbstractParser;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.util.HtmlTools;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -66,7 +66,7 @@ import java.util.regex.Pattern;
* @author Julien Nicoulaud
* @since 1.3
*/
-@Component( role = Parser.class, hint = MarkdownParser.ROLE_HINT )
+@Named( MarkdownParser.ROLE_HINT )
public class MarkdownParser
extends AbstractParser
{
@@ -112,7 +112,7 @@ public class MarkdownParser
* The parser of the HTML produced by Flexmark, that we will
* use to convert this HTML to Sink events
*/
- @Requirement
+ @Inject
private MarkdownHtmlParser parser;
/**
@@ -279,7 +279,7 @@ public class MarkdownParser
* which is how most Maven Skin (incl. Fluido) recognize a block of code, which
* needs to be highlighted accordingly.
*/
- @Component( role = MarkdownHtmlParser.class )
+ @Named
public static class MarkdownHtmlParser
extends XhtmlParser
{
diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParserModule.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParserModule.java
index 0e1e9a1..465a6d5 100644
--- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParserModule.java
+++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParserModule.java
@@ -19,16 +19,16 @@ package org.apache.maven.doxia.module.markdown;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* {@link org.apache.maven.doxia.parser.module.ParserModule} for Markdown.
*
* @since 1.6
*/
-@Component( role = ParserModule.class, hint = "markdown" )
+@Named( "markdown" )
public class MarkdownParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaLinkResolverTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaLinkResolverTest.java
index c02d5cf..079fdf6 100644
--- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaLinkResolverTest.java
+++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/FlexmarkDoxiaLinkResolverTest.java
@@ -22,9 +22,10 @@ package org.apache.maven.doxia.module.markdown;
import com.vladsch.flexmark.html.renderer.LinkStatus;
import com.vladsch.flexmark.html.renderer.LinkType;
import com.vladsch.flexmark.html.renderer.ResolvedLink;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.Assert.assertEquals;
public class FlexmarkDoxiaLinkResolverTest
{
diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
index 4895969..11dde47 100644
--- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
+++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserModuleTest.java
@@ -19,31 +19,26 @@ package org.apache.maven.doxia.module.markdown;
* under the License.
*/
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.PlexusTestCase;
+import javax.inject.Inject;
+
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test MarkdownParserModule.
*/
+@PlexusTest
public class MarkdownParserModuleTest
- extends PlexusTestCase
{
/**
* The {@link MarkdownParser} used for the tests.
*/
+ @Inject
protected MarkdownParserModule parserModule;
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- parserModule = (MarkdownParserModule) lookup( ParserModule.class, MarkdownParser.ROLE_HINT );
- }
-
+ @Test
public void testExtensions()
{
assertEquals( 2, parserModule.getExtensions().length );
diff --git a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java
index 11e4da5..eef74ad 100644
--- a/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java
+++ b/doxia-modules/doxia-module-markdown/src/test/java/org/apache/maven/doxia/module/markdown/MarkdownParserTest.java
@@ -1,10 +1,5 @@
package org.apache.maven.doxia.module.markdown;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Iterator;
-import java.util.List;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -24,6 +19,13 @@ import java.util.List;
* under the License.
*/
+import javax.inject.Inject;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.maven.doxia.parser.AbstractParserTest;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
@@ -31,6 +33,12 @@ import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for {@link MarkdownParser}.
@@ -45,23 +53,13 @@ public class MarkdownParserTest
/**
* The {@link MarkdownParser} used for the tests.
*/
+ @Inject
protected MarkdownParser parser;
/**
* {@inheritDoc}
*/
@Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- parser = (MarkdownParser) lookup( Parser.class, MarkdownParser.ROLE_HINT );
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected Parser createParser()
{
return parser;
@@ -81,12 +79,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testParagraphSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "paragraph" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "body_" );
assertFalse( it.hasNext() );
}
@@ -96,6 +95,7 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testFontBoldSinkEvent()
throws Exception
{
@@ -103,7 +103,7 @@ public class MarkdownParserTest
List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-bold" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
assertFalse( it.hasNext() );
@@ -118,6 +118,7 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testFontItalicSinkEvent()
throws Exception
{
@@ -125,7 +126,7 @@ public class MarkdownParserTest
List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-italic" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
assertFalse( it.hasNext() );
SinkEventElement inline = eventList.get( 4 );
@@ -139,6 +140,7 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testFontMonospacedSinkEvent()
throws Exception
{
@@ -146,7 +148,7 @@ public class MarkdownParserTest
List<SinkEventElement> eventList = parseFileToEventTestingSink( "font-monospaced" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "inline", "text", "inline_", "paragraph_", "body_" );
assertFalse( it.hasNext() );
SinkEventElement inline = eventList.get( 4 );
@@ -160,12 +162,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testCodeSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "code" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
assertFalse( it.hasNext() );
}
@@ -175,13 +178,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testFencedCodeBlockSinkEvent()
throws Exception
{
List<SinkEventElement> eventList = parseFileToEventTestingSink( "fenced-code-block" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "paragraph_", "text", "verbatim", "inline", "text", "inline_", "verbatim_", "body_" );
assertFalse( it.hasNext() );
@@ -206,12 +210,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testImageSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "image" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "figureGraphics", "text", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "figureGraphics", "text", "paragraph_", "body_" );
assertFalse( it.hasNext() );
}
@@ -221,12 +226,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testLinkSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "link" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
assertFalse( it.hasNext() );
}
@@ -236,13 +242,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testLinkRewriteSinkEvent()
throws Exception
{
List<SinkEventElement> eventList = parseFileToEventTestingSink( "link_rewrite" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "link", "text",
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "text", "link", "text", "link_", "text", "link", "text",
"link_", "text", "paragraph_", "body_" );
assertFalse( it.hasNext() );
@@ -251,11 +258,12 @@ public class MarkdownParserTest
assertEquals( "ftp://doc.md", eventList.get( 9 ).getArgs()[0] );
}
+ @Test
public void testLinkWithAnchorAndQuery() throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "link_anchor_query" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "paragraph", "link", "text", "link_", "paragraph_", "body_" );
+ assertSinkEquals( it, "head", "head_", "body", "paragraph", "link", "text", "link_", "paragraph_", "body_" );
assertFalse( it.hasNext() );
}
@@ -265,12 +273,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testListSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "list" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "list", "text", "listItem", "text", "listItem_", "listItem", "text",
+ assertSinkEquals( it, "head", "head_", "body", "list", "text", "listItem", "text", "listItem_", "listItem", "text",
"listItem_", "text", "list_", "body_" );
assertFalse( it.hasNext() );
@@ -281,12 +290,13 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testNumberedListSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "numbered-list" ).getEventList().iterator();
- assertEquals( it, "head", "head_", "body", "numberedList", "text", "numberedListItem", "text", "numberedListItem_",
+ assertSinkEquals( it, "head", "head_", "body", "numberedList", "text", "numberedListItem", "text", "numberedListItem_",
"numberedListItem", "text", "numberedListItem_", "text", "numberedList_", "body_" );
assertFalse( it.hasNext() );
@@ -297,13 +307,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testMetadataSinkEvent()
throws Exception
{
List<SinkEventElement> eventList = parseFileToEventTestingSink( "metadata" ).getEventList();
Iterator<SinkEventElement> it = eventList.iterator();
- assertEquals( it, "head", "title", "text", "text", "text", "title_", "author", "text", "author_", "date", "text", "date_",
+ assertSinkEquals( it, "head", "title", "text", "text", "text", "title_", "author", "text", "author_", "date", "text", "date_",
"unknown", "head_", "body", "unknown", "text", "unknown", "paragraph", "text", "paragraph_", "section1",
"sectionTitle1", "text", "sectionTitle1_", "paragraph", "text", "paragraph_", "section1_",
"body_" );
@@ -337,13 +348,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testFirstHeadingSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "first-heading" ).getEventList().iterator();
// NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
- assertEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text",
+ assertSinkEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text",
"section1", "sectionTitle1", "text", "sectionTitle1_", "paragraph", "text",
"paragraph_", "section1_", "body_" );
@@ -355,13 +367,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testCommentBeforeHeadingSinkEvent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "comment-before-heading" ).getEventList().iterator();
// NOTE: H1 is rendered as "unknown" and H2 is "section1" (see DOXIA-203)
- assertEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "text",
+ assertSinkEquals( it, "head", "title", "text", "title_", "head_", "body", "comment", "text", "unknown", "text",
"unknown", "paragraph", "text", "link", "text", "link_", "text", "paragraph_", "body_" );
assertFalse( it.hasNext() );
@@ -372,13 +385,14 @@ public class MarkdownParserTest
*
* @throws Exception if the event list is not correct when parsing the document
*/
+ @Test
public void testHtmlContent()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "html-content" ).getEventList().iterator();
// NOTE: H1 and DIV are rendered as "unknown" and H2 is "section1" (see DOXIA-203)
- assertEquals( it, "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text",
+ assertSinkEquals( it, "head", "head_", "body", "unknown", "text", "paragraph", "inline", "text",
"inline_", "text", "inline", "text", "inline_", "text", "paragraph_", "text", "unknown", "text", "horizontalRule", "unknown",
"text", "unknown", "paragraph", "text", "paragraph_", "text", "table", "tableRows", "text", "tableRow",
"tableHeaderCell", "text", "tableHeaderCell_", "tableRow_", "text", "tableRow",
@@ -416,12 +430,13 @@ public class MarkdownParserTest
}
}
+ @Test
public void testTocMacro()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "macro-toc" ).getEventList().iterator();
- assertEquals( it, "head", "title", "text", "title_", "head_",
+ assertSinkEquals( it, "head", "title", "text", "title_", "head_",
"body",
"list", // TOC start
"listItem", "link", "text", "link_", // emtpy section 2 TOC entry
@@ -440,12 +455,13 @@ public class MarkdownParserTest
}
// TOC macro fails with EmptyStackException when title 2 followed by title 4 then title 2
+ @Test
public void testTocMacroDoxia559()
throws Exception
{
Iterator<SinkEventElement> it = parseFileToEventTestingSink( "macro-toc-DOXIA-559" ).getEventList().iterator();
- assertEquals( it, "head", "title", "text", "title_", "head_",
+ assertSinkEquals( it, "head", "title", "text", "title_", "head_",
"body",
"list", // TOC start
"listItem", "link", "text", "link_", // first section 2 TOC entry
diff --git a/doxia-modules/doxia-module-xdoc/pom.xml b/doxia-modules/doxia-module-xdoc/pom.xml
index a7535f4..cc53efa 100644
--- a/doxia-modules/doxia-module-xdoc/pom.xml
+++ b/doxia-modules/doxia-module-xdoc/pom.xml
@@ -46,6 +46,10 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
<!-- test -->
<dependency>
@@ -74,6 +78,11 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
index 7eb2918..82edd20 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
@@ -26,18 +26,17 @@ import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
+import javax.inject.Named;
import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.XhtmlBaseParser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.util.HtmlTools;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -51,7 +50,7 @@ import org.slf4j.LoggerFactory;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @since 1.0
*/
-@Component( role = Parser.class, hint = "xdoc" )
+@Named( "xdoc" )
public class XdocParser
extends XhtmlBaseParser
implements XdocMarkup
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParserModule.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParserModule.java
index 0e48c08..32eacc8 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParserModule.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParserModule.java
@@ -19,16 +19,16 @@ package org.apache.maven.doxia.module.xdoc;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* <p>XdocParserModule class.</p>
*
* @since 1.6
*/
-@Component( role = ParserModule.class, hint = "xdoc" )
+@Named( "xdoc" )
public class XdocParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
index b9ffce7..bcbe7a8 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSinkFactory.java
@@ -19,12 +19,12 @@ package org.apache.maven.doxia.module.xdoc;
* under the License.
*/
+import javax.inject.Named;
+
import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
import org.apache.maven.doxia.sink.impl.AbstractXmlSinkFactory;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Xdoc implementation of the Sink factory.
@@ -32,7 +32,7 @@ import org.codehaus.plexus.component.annotations.Component;
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @since 1.0
*/
-@Component( role = SinkFactory.class, hint = "xdoc" )
+@Named( "xdoc" )
public class XdocSinkFactory
extends AbstractXmlSinkFactory
{
diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java
index b216b7a..abd4406 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java
+++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocIdentityTest.java
@@ -25,6 +25,7 @@ import org.apache.maven.doxia.module.AbstractIdentityTest;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Check that piping a full model through an XdocParser and an XdocSink
@@ -34,10 +35,10 @@ public class XdocIdentityTest
extends AbstractIdentityTest
{
/** {@inheritDoc} */
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
assertIdentity( true );
}
diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
index a7fd9b8..c1cbc57 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
+++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.module.xdoc;
* under the License.
*/
+import javax.inject.Inject;
+
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
@@ -36,6 +38,16 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
import org.codehaus.plexus.util.IOUtil;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -45,16 +57,13 @@ import org.codehaus.plexus.util.IOUtil;
public class XdocParserTest
extends AbstractParserTest
{
+ @Inject
private XdocParser parser;
- @Override
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
-
- parser = (XdocParser) lookup( Parser.class, "xdoc" );
-
// AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files in ${java.io.tmpdir}
// Be sure to delete them
String tmpDir = System.getProperty( "java.io.tmpdir" );
@@ -97,6 +106,7 @@ public class XdocParserTest
}
/** @throws Exception */
+ @Test
public void testSnippetMacro()
throws Exception
{
@@ -109,7 +119,7 @@ public class XdocParserTest
}
File f = getTestFile( getBasedir(), outputBaseDir() + getOutputDir() + "macro.xml" );
- assertTrue( "The file " + f.getAbsolutePath() + " was not created", f.exists() );
+ assertTrue( f.exists(), "The file " + f.getAbsolutePath() + " was not created" );
String content;
try( Reader reader = new FileReader( f ) )
@@ -120,6 +130,7 @@ public class XdocParserTest
assertTrue( content.contains( "<modelVersion>4.0.0</modelVersion>" ) );
}
+ @Test
public void testTocMacro()
throws Exception
{
@@ -132,7 +143,7 @@ public class XdocParserTest
}
File f = getTestFile( getBasedir(), outputBaseDir() + getOutputDir() + "toc.xml" );
- assertTrue( "The file " + f.getAbsolutePath() + " was not created", f.exists() );
+ assertTrue( f.exists(), "The file " + f.getAbsolutePath() + " was not created" );
String content;
try ( Reader reader = new FileReader( f ) )
@@ -155,6 +166,7 @@ public class XdocParserTest
return sink.getEventList().iterator();
}
+ @Test
public void testHeadEventsList()
throws Exception
{
@@ -170,7 +182,7 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertStartsWith( it, "head", "title", "text", "title_", "comment", "author", "text", "author_" );
+ assertSinkStartsWith( it, "head", "title", "text", "title_", "comment", "author", "text", "author_" );
SinkEventElement unknown = it.next();
assertEquals( "unknown", unknown.getName() );
@@ -180,7 +192,7 @@ public class XdocParserTest
assertEquals( "unknown", unknown.getName() );
assertEquals( "base", unknown.getArgs()[0] );
- assertEquals( it, "head_", "body", "body_" );
+ assertSinkEquals( it, "head_", "body", "body_" );
// DOXIA-359
text = "<document>"
@@ -190,15 +202,16 @@ public class XdocParserTest
it = parseText( text );
- assertStartsWith( it, "head", "title" );
+ assertSinkStartsWith( it, "head", "title" );
SinkEventElement title = it.next();
assertEquals( "text", title.getName() );
assertEquals( "properties title", title.getArgs()[0] );
- assertEquals( it, "title_", "head_", "body", "body_" );
+ assertSinkEquals( it, "title_", "head_", "body", "body_" );
}
+ @Test
public void testDocumentBodyEventsList()
throws Exception
{
@@ -206,9 +219,10 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "body", "body_" );
+ assertSinkEquals( it, "body", "body_" );
}
+ @Test
public void testSectionEventsList()
throws Exception
{
@@ -216,10 +230,11 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "section1", "sectionTitle1", "text", "sectionTitle1_", "section2", "sectionTitle2", "text",
+ assertSinkEquals( it, "section1", "sectionTitle1", "text", "sectionTitle1_", "section2", "sectionTitle2", "text",
"sectionTitle2_", "section2_", "section1_" );
}
+ @Test
public void testSectionAttributes()
throws Exception
{
@@ -228,7 +243,7 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertStartsWith( it, "anchor", "anchor_" );
+ assertSinkStartsWith( it, "anchor", "anchor_" );
SinkEventElement next = it.next();
assertEquals( "section1", next.getName() );
@@ -242,9 +257,10 @@ public class XdocParserTest
assertEquals( "sectionTitle1", next.getName() );
assertNull( next.getArgs()[0] );
- assertEquals( it, "text", "sectionTitle1_", "section1_" );
+ assertSinkEquals( it, "text", "sectionTitle1_", "section1_" );
}
+ @Test
public void testNestedSectionsEventsList()
throws Exception
{
@@ -253,11 +269,12 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "section1", "sectionTitle1", "text", "sectionTitle1_", "section2", "section3", "section4",
+ assertSinkEquals( it, "section1", "sectionTitle1", "text", "sectionTitle1_", "section2", "section3", "section4",
"section5", "sectionTitle5", "text", "sectionTitle5_", "section5_", "section4_", "section3_",
"section2_", "section2", "sectionTitle2", "text", "sectionTitle2_", "section2_", "section1_" );
}
+ @Test
public void testSourceEventsList()
throws Exception
{
@@ -265,19 +282,20 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "verbatim", "link", "text", "link_", "verbatim_" );
+ assertSinkEquals( it, "verbatim", "link", "text", "link_", "verbatim_" );
text = "<source><![CDATA[<a href=\"what.html\">what</a>]]></source>";
it = parseText( text );
- assertEquals( it, "verbatim", "text", "verbatim_" );
+ assertSinkEquals( it, "verbatim", "text", "verbatim_" );
text = "<source><![CDATA[<source>what</source>]]></source>";
it = parseText( text );
- assertEquals( it, "verbatim", "text", "verbatim_" );
+ assertSinkEquals( it, "verbatim", "text", "verbatim_" );
}
+ @Test
public void testSourceContainingDTD()
throws Exception
{
@@ -289,9 +307,10 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "verbatim", "text", "verbatim_" );
+ assertSinkEquals( it, "verbatim", "text", "verbatim_" );
}
+ @Test
public void testPreEOL()
throws Exception
{
@@ -301,12 +320,13 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "verbatim", "link", "text", "link_", "text", "link", "text", "link_", "verbatim_" );
+ assertSinkEquals( it, "verbatim", "link", "text", "link_", "text", "link", "text", "link_", "verbatim_" );
}
/**
* Test section with ids.
*/
+ @Test
public void testSectionIdAnchor()
throws Exception
{
@@ -315,43 +335,46 @@ public class XdocParserTest
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it.next(), "anchor", "test-id" );
+ assertSinkEquals( it.next(), "anchor", "test-id" );
- assertStartsWith( it, "anchor_", "section1", "sectionTitle1", "text", "sectionTitle1_", "text" );
+ assertSinkStartsWith( it, "anchor_", "section1", "sectionTitle1", "text", "sectionTitle1_", "text" );
- assertEquals( it.next(), "anchor", "sub-id" );
+ assertSinkEquals( it.next(), "anchor", "sub-id" );
- assertEquals( it, "anchor_", "section2", "sectionTitle2", "text", "sectionTitle2_", "text", "section2_",
+ assertSinkEquals( it, "anchor_", "section2", "sectionTitle2", "text", "sectionTitle2_", "text", "section2_",
"section1_" );
}
/**
* Test script block.
*/
+ @Test
public void testJavaScript()
throws Exception
{
String text = "<script type=\"text/javascript\"><![CDATA[alert(\"Hello!\");]]></script>";
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "unknown", "unknown", "unknown" );
+ assertSinkEquals( it, "unknown", "unknown", "unknown" );
}
/**
* Test unknown tags.
*/
+ @Test
public void testUnknown()
throws Exception
{
String text = "<applet><param name=\"name\" value=\"value\"/><unknown/></applet>";
Iterator<SinkEventElement> it = parseText( text );
- assertEquals( it, "unknown", "unknown", "unknown", "unknown", "unknown" );
+ assertSinkEquals( it, "unknown", "unknown", "unknown", "unknown", "unknown" );
}
/**
* Test invalid macro tags.
*/
+ @Test
public void testMacroExceptions()
{
SinkEventTestingSink sink = new SinkEventTestingSink();
@@ -366,18 +389,11 @@ public class XdocParserTest
private void assertParseException( Sink sink, String text )
{
- try
- {
- parser.parse( text, sink );
-
- fail( "Should not be parseable: '" + text + "'" );
- }
- catch ( ParseException ex )
- {
- assertNotNull( ex );
- }
+ assertThrows( ParseException.class, () -> parser.parse( text, sink ),
+ "Should not be parseable: '" + text + "'" );
}
+ @Test
public void testEntities()
throws Exception
{
@@ -391,21 +407,22 @@ public class XdocParserTest
Iterator<SinkEventElement> it = sink.getEventList().iterator();
- assertStartsWith( it, "section1", "sectionTitle1" );
+ assertSinkStartsWith( it, "section1", "sectionTitle1" );
- assertEquals( it.next(), "text", "&\u0159\uD835\uDFED" );
+ assertSinkEquals( it.next(), "text", "&\u0159\uD835\uDFED" );
- assertStartsWith( it, "sectionTitle1_", "paragraph" );
+ assertSinkStartsWith( it, "sectionTitle1_", "paragraph" );
- assertEquals( it.next(), "text", "&" );
+ assertSinkEquals( it.next(), "text", "&" );
- assertEquals( it.next(), "text", "\u0159" );
+ assertSinkEquals( it.next(), "text", "\u0159" );
- assertEquals( it.next(), "text", "\uD835\uDFED" );
+ assertSinkEquals( it.next(), "text", "\uD835\uDFED" );
- assertEquals( it, "paragraph_", "section1_" );
+ assertSinkEquals( it, "paragraph_", "section1_" );
}
+ @Test
public void testStyleWithCData() throws Exception
{
// DOXIA-449
diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
index f1d21b7..f925995 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
+++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
@@ -22,11 +22,13 @@ package org.apache.maven.doxia.module.xdoc;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
+import org.junit.jupiter.api.Test;
import java.io.StringWriter;
import java.io.Writer;
import static org.apache.maven.doxia.util.HtmlTools.escapeHTML;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -342,6 +344,7 @@ public class XdocSinkTest
/**
* Test verbatim.
*/
+ @Test
public void testBoxedVerbatim()
{
Writer writer = new StringWriter();
@@ -369,6 +372,7 @@ public class XdocSinkTest
/**
* Test link.
*/
+ @Test
public void testLinkWithTarget()
{
Writer writer = new StringWriter();
diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
index b534ba4..ec3b634 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
+++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
@@ -27,6 +27,8 @@ import org.apache.maven.doxia.markup.XmlMarkup;
import org.apache.maven.doxia.xsd.AbstractXmlValidatorTest;
import org.codehaus.plexus.util.StringUtils;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+
/**
* Test XDOC files with namespace.
*
diff --git a/doxia-modules/doxia-module-xhtml/pom.xml b/doxia-modules/doxia-module-xhtml/pom.xml
index 8ca927b..43adc7e 100644
--- a/doxia-modules/doxia-module-xhtml/pom.xml
+++ b/doxia-modules/doxia-module-xhtml/pom.xml
@@ -47,6 +47,10 @@ under the License.
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<classifier>no_aop</classifier>
@@ -67,5 +71,10 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
index d337a26..1d19043 100644
--- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
+++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
@@ -25,17 +25,17 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
+
+import javax.inject.Named;
import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.XhtmlBaseParser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @since 1.0
*/
-@Component( role = Parser.class, hint = "xhtml" )
+@Named( "xhtml" )
public class XhtmlParser
extends XhtmlBaseParser
implements XhtmlMarkup
diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParserModule.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParserModule.java
index 1e4bddd..4b78d93 100644
--- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParserModule.java
+++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParserModule.java
@@ -19,16 +19,16 @@ package org.apache.maven.doxia.module.xhtml;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* <p>XhtmlParserModule class.</p>
*
* @since 1.6
*/
-@Component( role = ParserModule.class, hint = "xhtml" )
+@Named( "xhtml" )
public class XhtmlParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
index e947092..18c4c29 100644
--- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
+++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkFactory.java
@@ -19,12 +19,12 @@ package org.apache.maven.doxia.module.xhtml;
* under the License.
*/
+import javax.inject.Named;
+
import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
import org.apache.maven.doxia.sink.impl.AbstractXmlSinkFactory;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Xhtml implementation of the Sink factory.
@@ -32,7 +32,7 @@ import org.codehaus.plexus.component.annotations.Component;
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @since 1.0
*/
-@Component( role = SinkFactory.class, hint = "xhtml" )
+@Named( "xhtml" )
public class XhtmlSinkFactory
extends AbstractXmlSinkFactory
{
diff --git a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlIdentityTest.java b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlIdentityTest.java
index f7a28b9..fb3abeb 100644
--- a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlIdentityTest.java
+++ b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlIdentityTest.java
@@ -25,6 +25,7 @@ import org.apache.maven.doxia.module.AbstractIdentityTest;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Check that piping a full model through an XhtmlParser and an XhtmlSink
@@ -34,10 +35,10 @@ public class XhtmlIdentityTest
extends AbstractIdentityTest
{
/** {@inheritDoc} */
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
assertIdentity( true );
}
diff --git a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
index 9d90db1..fa7df51 100644
--- a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
+++ b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
@@ -19,6 +19,9 @@ package org.apache.maven.doxia.module.xhtml;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import java.io.File;
import java.io.FileFilter;
import java.util.Iterator;
@@ -28,6 +31,11 @@ import org.apache.maven.doxia.parser.AbstractParserTest;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* @author <a href="mailto:lars@trieloff.net">Lars Trieloff</a>
@@ -35,16 +43,14 @@ import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
public class XhtmlParserTest
extends AbstractParserTest
{
+ @Inject
private XhtmlParser parser;
/** {@inheritDoc} */
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
-
- parser = (XhtmlParser) lookup( Parser.class, "xhtml" );
-
// AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files in ${java.io.tmpdir}
// Be sure to delete them
String tmpDir = System.getProperty( "java.io.tmpdir" );
@@ -81,6 +87,7 @@ public class XhtmlParserTest
}
/** @throws Exception */
+ @Test
public void testDocumentBodyEventsList()
throws Exception
{
@@ -98,6 +105,7 @@ public class XhtmlParserTest
}
/** @throws Exception */
+ @Test
public void testHeadEventsList()
throws Exception
{
@@ -126,6 +134,7 @@ public class XhtmlParserTest
}
/** @throws Exception */
+ @Test
public void testPreEventsList()
throws Exception
{
@@ -147,6 +156,7 @@ public class XhtmlParserTest
*
* @throws java.lang.Exception if any.
*/
+ @Test
public void testUnknown()
throws Exception
{
@@ -165,6 +175,7 @@ public class XhtmlParserTest
}
/** @throws Exception */
+ @Test
public void testTocMacro()
throws Exception
{
diff --git a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
index 2ed78ff..c63aed6 100644
--- a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
+++ b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
@@ -26,8 +26,11 @@ import org.apache.maven.doxia.markup.HtmlMarkup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
+import org.junit.jupiter.api.Test;
import static org.apache.maven.doxia.util.HtmlTools.escapeHTML;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Jason van Zyl
@@ -58,6 +61,7 @@ public class XhtmlSinkTest
* Test link generation.
*
*/
+ @Test
public void testLinks()
{
XhtmlSink sink = null;
@@ -237,9 +241,10 @@ public class XhtmlSinkTest
// Disable testTable until the order of attributes issue is clarified
// TODO: remove
/** {@inheritDoc} */
+ @Test
public void testTable()
{
- assertEquals( "Dummy!", "", "" );
+ assertEquals( "", "", "Dummy!" );
}
/** {@inheritDoc} */
@@ -384,6 +389,7 @@ public class XhtmlSinkTest
/**
* Test entities is section titles and paragraphs.
*/
+ @Test
public void testEntities()
{
XhtmlSink sink = null;
@@ -412,6 +418,7 @@ public class XhtmlSinkTest
/**
* Test head events.
*/
+ @Test
public void testHead()
{
XhtmlSink sink = null;
@@ -443,7 +450,7 @@ public class XhtmlSinkTest
"<head>\n<title>Title</title><!--A comment--><meta name=\"author\" content=\"ģ&\" />"
+ "<base href=\"http://maven.apache.org/\" /></head>";
String actual = writer.toString();
- assertTrue( actual, actual.contains( expected ) );
+ assertTrue( actual.contains( expected ), actual );
}
/** {@inheritDoc} */
diff --git a/doxia-modules/doxia-module-xhtml5/pom.xml b/doxia-modules/doxia-module-xhtml5/pom.xml
index 5c63115..7e1c7c9 100644
--- a/doxia-modules/doxia-module-xhtml5/pom.xml
+++ b/doxia-modules/doxia-module-xhtml5/pom.xml
@@ -47,6 +47,10 @@ under the License.
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<classifier>no_aop</classifier>
@@ -67,5 +71,10 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
index be887a7..46887af 100644
--- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
+++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
@@ -25,17 +25,17 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
+
+import javax.inject.Named;
import javax.swing.text.html.HTML.Attribute;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.parser.ParseException;
-import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.Xhtml5BaseParser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
/**
* Parse an xhtml model and emit events into a Doxia Sink.
*/
-@Component( role = Parser.class, hint = Xhtml5Parser.ROLE_HINT )
+@Named( Xhtml5Parser.ROLE_HINT )
public class Xhtml5Parser
extends Xhtml5BaseParser
implements Xhtml5Markup
diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserModule.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserModule.java
index e52cfba..14a06ca 100644
--- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserModule.java
+++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserModule.java
@@ -19,14 +19,14 @@ package org.apache.maven.doxia.module.xhtml5;
* under the License.
*/
+import javax.inject.Named;
+
import org.apache.maven.doxia.parser.module.AbstractParserModule;
-import org.apache.maven.doxia.parser.module.ParserModule;
-import org.codehaus.plexus.component.annotations.Component;
/**
* <p>Xhtml5ParserModule class.</p>
*/
-@Component( role = ParserModule.class, hint = "xhtml5" )
+@Named( "xhtml5" )
public class Xhtml5ParserModule
extends AbstractParserModule
{
diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkFactory.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkFactory.java
index 7421c9a..227dd07 100644
--- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkFactory.java
+++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkFactory.java
@@ -19,17 +19,17 @@ package org.apache.maven.doxia.module.xhtml5;
* under the License.
*/
+import javax.inject.Named;
+
import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkFactory;
import org.apache.maven.doxia.sink.impl.AbstractXmlSinkFactory;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Xhtml implementation of the Sink factory.
*/
-@Component( role = SinkFactory.class, hint = "xhtml5" )
+@Named( "xhtml5" )
public class Xhtml5SinkFactory
extends AbstractXmlSinkFactory
{
diff --git a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5IdentityTest.java b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5IdentityTest.java
index 9ea44c9..d6a0738 100644
--- a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5IdentityTest.java
+++ b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5IdentityTest.java
@@ -27,6 +27,7 @@ import org.apache.maven.doxia.module.xhtml5.Xhtml5Sink;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.BeforeEach;
/**
* Check that piping a full model through an Xhtml5Parser and an Xhtml5Sink
@@ -36,10 +37,9 @@ public class Xhtml5IdentityTest
extends AbstractIdentityTest
{
/** {@inheritDoc} */
+ @BeforeEach
protected void setUp()
- throws Exception
{
- super.setUp();
assertIdentity( true );
}
diff --git a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserTest.java b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserTest.java
index f5e4164..4ab6c63 100644
--- a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserTest.java
+++ b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5ParserTest.java
@@ -19,30 +19,34 @@ package org.apache.maven.doxia.module.xhtml5;
* under the License.
*/
+import javax.inject.Inject;
+
import java.io.File;
import java.io.FileFilter;
import java.util.Iterator;
import java.util.regex.Pattern;
-import org.apache.maven.doxia.module.xhtml5.Xhtml5Parser;
import org.apache.maven.doxia.parser.AbstractParserTest;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class Xhtml5ParserTest
extends AbstractParserTest
{
+ @Inject
private Xhtml5Parser parser;
/** {@inheritDoc} */
+ @BeforeEach
protected void setUp()
throws Exception
{
- super.setUp();
-
- parser = (Xhtml5Parser) lookup( Parser.class, Xhtml5Parser.ROLE_HINT );
-
// AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files in ${java.io.tmpdir}
// Be sure to delete them
String tmpDir = System.getProperty( "java.io.tmpdir" );
@@ -79,6 +83,7 @@ public class Xhtml5ParserTest
}
/** @throws Exception */
+ @Test
public void testDocumentBodyEventsList()
throws Exception
{
@@ -96,6 +101,7 @@ public class Xhtml5ParserTest
}
/** @throws Exception */
+ @Test
public void testHeadEventsList()
throws Exception
{
@@ -124,6 +130,7 @@ public class Xhtml5ParserTest
}
/** @throws Exception */
+ @Test
public void testPreEventsList()
throws Exception
{
@@ -145,6 +152,7 @@ public class Xhtml5ParserTest
*
* @throws java.lang.Exception if any.
*/
+ @Test
public void testUnknown()
throws Exception
{
@@ -163,6 +171,7 @@ public class Xhtml5ParserTest
}
/** @throws Exception */
+ @Test
public void testTocMacro()
throws Exception
{
diff --git a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkTest.java b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkTest.java
index 36e0271..59cc67c 100644
--- a/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkTest.java
+++ b/doxia-modules/doxia-module-xhtml5/src/test/java/org/apache/maven/doxia/module/xhtml5/Xhtml5SinkTest.java
@@ -27,8 +27,11 @@ import org.apache.maven.doxia.module.xhtml5.Xhtml5Sink;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
+import org.junit.jupiter.api.Test;
import static org.apache.maven.doxia.util.HtmlTools.escapeHTML;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class Xhtml5SinkTest
extends AbstractSinkTest
@@ -55,6 +58,7 @@ public class Xhtml5SinkTest
* Test link generation.
*
*/
+ @Test
public void testLinks()
{
Xhtml5Sink sink = null;
@@ -230,9 +234,10 @@ public class Xhtml5SinkTest
// Disable testTable until the order of attributes issue is clarified
// TODO: remove
/** {@inheritDoc} */
+ @Test
public void testTable()
{
- assertEquals( "Dummy!", "", "" );
+ assertEquals( "", "", "Dummy!" );
}
/** {@inheritDoc} */
@@ -377,6 +382,7 @@ public class Xhtml5SinkTest
/**
* Test entities is section titles and paragraphs.
*/
+ @Test
public void testEntities()
{
Xhtml5Sink sink = null;
@@ -407,6 +413,7 @@ public class Xhtml5SinkTest
/**
* Test head events.
*/
+ @Test
public void testHead()
{
Xhtml5Sink sink = null;
@@ -438,7 +445,7 @@ public class Xhtml5SinkTest
"<head>\n<title>Title</title><!--A comment--><meta name=\"author\" content=\"ģ&\" />"
+ "<base href=\"http://maven.apache.org/\" /></head>";
String actual = writer.toString();
- assertTrue( actual, actual.contains( expected ) );
+ assertTrue( actual.contains( expected ), actual );
}
/** {@inheritDoc} */
diff --git a/doxia-modules/pom.xml b/doxia-modules/pom.xml
index 7fb0ebc..a1ff538 100644
--- a/doxia-modules/pom.xml
+++ b/doxia-modules/pom.xml
@@ -52,10 +52,6 @@ under the License.
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- </dependency>
<!-- test -->
<dependency>
diff --git a/pom.xml b/pom.xml
index 104c60f..3377367 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,7 @@ under the License.
<checkstyle.violation.ignore>RedundantThrows,NewlineAtEndOfFile,ParameterNumber,MethodLength,FileLength,MethodName,InnerAssignment,MagicNumber</checkstyle.violation.ignore>
<project.build.outputTimestamp>2022-01-17T09:10:13Z</project.build.outputTimestamp>
<slf4jVersion>1.7.32</slf4jVersion>
+ <junitVersion>5.8.2</junitVersion>
</properties>
<dependencyManagement>
@@ -171,6 +172,12 @@ under the License.
<version>2.8.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <version>1.1.0</version>
+ <scope>test</scope>
+ </dependency>
<!-- Plexus -->
<dependency>
@@ -186,14 +193,14 @@ under the License.
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <version>2.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.1</version>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
<!-- SLF4J -->
<dependency>
@@ -206,15 +213,19 @@ under the License.
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junitVersion}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -441,6 +452,9 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
+ <doclint>none</doclint>
+ <failOnWarnings>false</failOnWarnings>
+ <failOnError>false</failOnError>
<linksource>true</linksource>
<groups>
<group>