You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/02/07 16:35:06 UTC
[maven-doxia] 03/04: [DOXIA-602] Code improvements for Junit
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch DOXIA-602
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 31beadfbbe874e521ecc5f884596b4bc17d43ea2
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Thu Feb 6 14:56:55 2020 +0100
[DOXIA-602] Code improvements for Junit
- convert to Junit4 notation (remove TestCase)
- remove deprecated method calls
- simplify assertions
---
.gitignore | 1 -
.../maven/doxia/document/DocumentModelTest.java | 4 +-
.../apache/maven/doxia/index/IndexEntryTest.java | 7 +-
.../apache/maven/doxia/macro/EchoMacroTest.java | 16 +--
.../org/apache/maven/doxia/macro/SsiMacroTest.java | 7 +-
.../org/apache/maven/doxia/macro/SwfMacroTest.java | 10 +-
.../doxia/macro/snippet/SnippetMacroTest.java | 6 +-
.../apache/maven/doxia/macro/toc/TocMacroTest.java | 12 ++-
.../maven/doxia/parser/Xhtml5BaseParserTest.java | 4 +-
.../maven/doxia/parser/XhtmlBaseParserTest.java | 4 +-
.../maven/doxia/sink/impl/AbstractSinkTest.java | 8 +-
.../doxia/sink/impl/AbstractSinkTestCase.java | 5 +-
.../maven/doxia/sink/impl/AbstractXmlSinkTest.java | 14 +--
.../doxia/sink/impl/RandomAccessSinkTest.java | 9 +-
.../maven/doxia/sink/impl/SinkAdapterTest.java | 67 +++++++++++-
.../doxia/sink/impl/SinkEventAttributeSetTest.java | 50 ++++++---
.../maven/doxia/sink/impl/SinkUtilsTest.java | 13 +--
.../maven/doxia/sink/impl/TestAbstractSink.java | 10 +-
.../maven/doxia/sink/impl/Xhtml5BaseSinkTest.java | 110 ++++++++++++++------
.../maven/doxia/sink/impl/XhtmlBaseSinkTest.java | 91 ++++++++++------
.../maven/doxia/util/ByLineReaderSourceTest.java | 11 +-
.../apache/maven/doxia/util/DoxiaUtilsTest.java | 2 +-
.../org/apache/maven/doxia/util/HtmlToolsTest.java | 2 +-
.../maven/doxia/module/apt/AptParserTest.java | 2 +-
.../maven/doxia/module/apt/AptUtilsTest.java | 55 +++++-----
.../doxia/module/docbook/DocbookUtilsTest.java | 10 +-
.../maven/doxia/module/fml/FmlValidatorTest.java | 1 -
.../maven/doxia/module/fo/FoAggregateSinkTest.java | 44 ++++----
.../maven/doxia/module/fo/FoConfigurationTest.java | 14 +--
.../maven/doxia/module/itext/ITextUtilTest.java | 42 ++++----
.../markdown/FlexmarkDoxiaLinkResolverTest.java | 7 +-
.../apache/maven/doxia/module/rtf/RtfSinkTest.java | 1 -
.../twiki/parser/GenericListBlockParser.java | 2 +-
.../module/twiki/parser/AbstractBlockTestCase.java | 3 -
.../maven/doxia/module/twiki/parser/BlockTest.java | 82 +++++----------
.../module/twiki/parser/FormatedTextTest.java | 85 ++++++++-------
.../maven/doxia/module/twiki/parser/ListTest.java | 14 +--
.../doxia/module/twiki/parser/ParagraphTest.java | 24 ++---
.../doxia/module/twiki/parser/SectionTest.java | 24 ++---
.../maven/doxia/module/twiki/parser/TableTest.java | 12 +--
.../maven/doxia/module/twiki/parser/TitleTest.java | 115 ++++++++++-----------
.../doxia/module/twiki/parser/VerbatimTest.java | 15 ++-
.../maven/doxia/module/twiki/parser/WordsTest.java | 43 +++-----
.../maven/doxia/module/xdoc/XdocParserTest.java | 2 +-
.../maven/doxia/module/xdoc/XdocSinkTest.java | 1 -
.../maven/doxia/module/xdoc/XdocValidatorTest.java | 1 -
.../maven/doxia/module/xhtml/XhtmlSinkTest.java | 2 -
.../maven/doxia/module/xhtml5/Xhtml5SinkTest.java | 2 -
48 files changed, 595 insertions(+), 471 deletions(-)
diff --git a/.gitignore b/.gitignore
index 19e9e0b..8092565 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,6 @@ target
.classpath
dependency-reduced-pom.xml
build
-.classpath
.project
.settings
.idea
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/document/DocumentModelTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/document/DocumentModelTest.java
index 120a879..dd1f5cd 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/document/DocumentModelTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/document/DocumentModelTest.java
@@ -60,7 +60,7 @@ public class DocumentModelTest
DocumentModel copy = writeAndRecover( model );
verifyModel( copy );
- assertTrue( copy.equals( model ) );
+ assertEquals( copy, model );
}
private DocumentModel getModel()
@@ -80,7 +80,7 @@ public class DocumentModelTest
{
assertNotNull( model );
//noinspection EqualsWithItself
- assertTrue( model.equals( model ) );
+ assertEquals( model, model );
assertTrue ( model.hashCode() != 0 );
assertTrue( model.toString().length() > 0 );
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 c7e7eae..5ae1815 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,18 +19,21 @@ package org.apache.maven.doxia.index;
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:trygve.laugstol@objectware.no">Trygve Laugstøl</a>
* @version $Id$
*/
public class IndexEntryTest
- extends TestCase
{
/**
* Test IndexEntry.
*/
+ @Test
public void testIndexEntry()
{
IndexEntry root = new IndexEntry( null );
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 0825af5..12b2594 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
@@ -28,7 +28,9 @@ import java.util.Map;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Test echo macro.
@@ -36,12 +38,11 @@ import junit.framework.TestCase;
* @author ltheussl
*/
public class EchoMacroTest
- extends TestCase
{
-
/**
* Test of execute method, of class EchoMacro.
*/
+ @Test
public void testExecute()
{
final Map<String,Object> macroParameters = new HashMap<>();
@@ -59,10 +60,10 @@ public class EchoMacroTest
assertEquals( "verbatim", event.getName() );
event = it.next();
assertEquals( "text", event.getName() );
- assertEquals( "echo" + Macro.EOL, (String) event.getArgs()[0] );
+ assertEquals( "echo" + Macro.EOL, event.getArgs()[0] );
event = it.next();
assertEquals( "text", event.getName() );
- assertEquals( "paramName ---> paramValue" + Macro.EOL, (String) event.getArgs()[0] );
+ assertEquals( "paramName ---> paramValue" + Macro.EOL, event.getArgs()[0] );
event = it.next();
assertEquals( "verbatim_", event.getName() );
assertFalse( it.hasNext() );
@@ -71,11 +72,12 @@ public class EchoMacroTest
/**
* Test log.
*/
+ @Test
public void testLog()
{
EchoMacro macro = new EchoMacro();
macro.enableLogging( null );
- assertNotNull ( macro.getLog() );
- assertNotNull ( macro.getLog() );
+ assertNotNull( macro.getLog() );
+ assertNotNull( macro.getLog() );
}
}
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java
index b5c157e..7ef3f97 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SsiMacroTest.java
@@ -29,10 +29,12 @@ import org.apache.maven.doxia.parser.XhtmlBaseParser;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
public class SsiMacroTest
- extends TestCase
{
/**
@@ -40,6 +42,7 @@ public class SsiMacroTest
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testExecute()
throws MacroExecutionException
{
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
index 2580cec..e827f84 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
@@ -28,7 +28,9 @@ import java.util.Map;
import org.apache.maven.doxia.sink.impl.SinkEventElement;
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Test swf macro.
@@ -36,14 +38,13 @@ import junit.framework.TestCase;
* @author ltheussl
*/
public class SwfMacroTest
- extends TestCase
{
-
/**
* Test of execute method, of class SwfMacro.
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testExecute()
throws MacroExecutionException
{
@@ -111,6 +112,7 @@ public class SwfMacroTest
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testOthersThenStringParameters()
throws MacroExecutionException
{
@@ -153,6 +155,4 @@ public class SwfMacroTest
assertEquals( "rawText", event.getName() );
assertFalse( it.hasNext() );
}
-
-
}
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 b4cb0c2..121e573 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
@@ -32,6 +32,8 @@ import org.codehaus.plexus.PlexusTestCase;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
+import static org.hamcrest.MatcherAssert.assertThat;
+
/**
* Test snippet macro.
*
@@ -119,7 +121,7 @@ public class SnippetMacroTest
assertFalse( it.hasNext() );
// no need to verify the absence of the first and second snippets if tests above were successful
- Assert.assertThat( snippet, CoreMatchers.containsString( "Этот сниппет в формате Unicode (UTF-8)" ) );
+ assertThat( snippet, CoreMatchers.containsString( "Этот сниппет в формате Unicode (UTF-8)" ) );
// again
// Shouldn't work because no snippet called "first" exists, only "firstId"
@@ -152,7 +154,7 @@ public class SnippetMacroTest
SinkEventElement event = it.next();
assertEquals( "text", event.getName() );
String snippet = (String) event.getArgs()[0];
- Assert.assertThat( snippet, CoreMatchers.containsString( "Error during retrieving content" ) );
+ assertThat( snippet, CoreMatchers.containsString( "Error during retrieving content" ) );
}
private SinkEventTestingSink executeSnippetMacro( Map<String, Object> macroParameters )
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 3a59a66..e9a2696 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
@@ -26,8 +26,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.parser.XhtmlBaseParser;
@@ -35,6 +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 static org.junit.Assert.*;
/**
* Test toc macro.
@@ -43,13 +44,13 @@ import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
* @version $Id$
*/
public class TocMacroTest
- extends TestCase
{
/**
* Test of execute method, of class TocMacro.
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testExecute()
throws MacroExecutionException
{
@@ -129,14 +130,14 @@ public class TocMacroTest
assertEquals( "link", ( it.next() ).getName() );
event = it.next();
assertEquals( "text", event.getName() );
- assertEquals( "h22", (String) event.getArgs()[0] );
+ assertEquals( "h22", event.getArgs()[0] );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "list", ( it.next() ).getName() );
assertEquals( "listItem", ( it.next() ).getName() );
assertEquals( "link", ( it.next() ).getName() );
event = it.next();
assertEquals( "text", event.getName() );
- assertEquals( "h3", (String) event.getArgs()[0] );
+ assertEquals( "h3", event.getArgs()[0] );
assertEquals( "link_", ( it.next() ).getName() );
assertEquals( "listItem_", ( it.next() ).getName() );
assertEquals( "list_", ( it.next() ).getName() );
@@ -150,6 +151,7 @@ public class TocMacroTest
*
* @throws MacroExecutionException if a macro fails during testing.
*/
+ @Test
public void testTocStyle()
throws MacroExecutionException
{
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 853d37c..2776045 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
@@ -26,6 +26,8 @@ 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 static org.junit.Assert.assertNotEquals;
+
/**
* Test for XhtmlBaseParser.
*/
@@ -64,7 +66,7 @@ public class Xhtml5BaseParserTest
public void testDoxiaVersion()
{
assertNotNull( XhtmlBaseParser.doxiaVersion() );
- assertFalse( "unknown".equals( XhtmlBaseParser.doxiaVersion() ) );
+ assertNotEquals( "unknown", XhtmlBaseParser.doxiaVersion() );
}
/** @throws Exception */
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 e4d4b1c..70f2085 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
@@ -26,6 +26,8 @@ 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 static org.junit.Assert.assertNotEquals;
+
/**
* Test for XhtmlBaseParser.
*
@@ -68,7 +70,7 @@ public class XhtmlBaseParserTest
public void testDoxiaVersion()
{
assertNotNull( XhtmlBaseParser.doxiaVersion() );
- assertFalse( "unknown".equals( XhtmlBaseParser.doxiaVersion() ) );
+ assertNotEquals( "unknown", XhtmlBaseParser.doxiaVersion() );
}
/** @throws Exception */
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 ff5cb2c..208785a 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
@@ -31,7 +31,7 @@ import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.util.IOUtil;
import org.xmlunit.matchers.CompareMatcher;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* Abstract base class to test sinks.
@@ -570,7 +570,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getFigureBlock getFigureBlock}( source, caption ).
*/
- public void testFigure() throws Exception
+ public void testFigure()
{
String source = "figure.jpg";
String caption = "Figure_caption";
@@ -597,7 +597,7 @@ public abstract class AbstractSinkTest
}
- public void testFigureWithoutCaption() throws Exception
+ public void testFigureWithoutCaption()
{
String source = "figure.jpg";
sink.figure();
@@ -648,7 +648,7 @@ public abstract class AbstractSinkTest
* invoked on the current sink, produces the same result as
* {@link #getTableBlock getTableBlock}( cell, caption ).
*/
- public void testTable() throws Exception
+ public void testTable()
{
String cell = "cell";
String caption = "Table_caption";
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 5dce1a5..e2d4521 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
@@ -25,6 +25,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
+import java.util.Objects;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
@@ -120,14 +121,12 @@ public abstract class AbstractSinkTestCase
* Returns a Reader that gives access to a common test apt file.
*
* @return a Reader to access the test apt resource file.
- * @throws java.lang.Exception if the Reader cannot be constructed.
*/
protected Reader getTestReader()
- throws Exception
{
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "test.apt" );
- return new InputStreamReader( is );
+ return new InputStreamReader( Objects.requireNonNull( is ) );
}
// ----------------------------------------------------------------------
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 56fe78c..07c6cc9 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
@@ -23,21 +23,21 @@ import javax.swing.text.html.HTML.Tag;
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.apache.maven.doxia.sink.impl.AbstractXmlSink;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
* @author ltheussl
*/
public class AbstractXmlSinkTest
- extends TestCase
{
/**
* Test of set/getNameSpace method, of class AbstractXmlSink.
*/
+ @Test
public void testNameSpace()
{
final Tag t = Tag.A;
@@ -86,6 +86,7 @@ public class AbstractXmlSinkTest
/**
* Test of writeStartTag method, of class AbstractXmlSink.
*/
+ @Test
public void testWriteStartTag()
{
final Tag t = Tag.A;
@@ -108,6 +109,7 @@ public class AbstractXmlSinkTest
/**
* Test of writeEOL method, of class AbstractXmlSink.
*/
+ @Test
public void testWriteEOL()
{
final XmlTestSink instance = new XmlTestSink();
@@ -119,6 +121,7 @@ public class AbstractXmlSinkTest
/**
* Test of writeSimpleTag method, of class AbstractXmlSink.
*/
+ @Test
public void testWriteSimpleTag()
{
final Tag t = Tag.A;
@@ -133,8 +136,7 @@ public class AbstractXmlSinkTest
}
/** Test sink. */
- private class XmlTestSink
- extends AbstractXmlSink
+ private static class XmlTestSink extends AbstractXmlSink
{
private final StringBuilder buffer = new StringBuilder( 0 );
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 84624d5..dce1f54 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,14 +28,14 @@ import java.io.Writer;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkFactory;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
public class RandomAccessSinkTest
- extends TestCase
{
private SinkFactory factory = new AbstractXmlSinkFactory()
{
-
protected Sink createSink( Writer writer, String encoding, String languageId )
{
return new TextSink( writer );
@@ -48,13 +48,13 @@ public class RandomAccessSinkTest
};
private void buildSimple( Sink sink, String text )
- throws Exception
{
sink.anchor( "foobar" );
sink.text( text );
sink.anchor_();
}
+ @Test
public void testSimple()
throws Exception
{
@@ -75,6 +75,7 @@ public class RandomAccessSinkTest
assertEquals( outFlatSink.toString( encoding ), outRandomAccessSink.toString( encoding ) );
}
+ @Test
public void testComplex()
throws Exception
{
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 e2b870e..24f4ca9 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,20 +22,20 @@ import org.apache.maven.doxia.sink.impl.SinkAdapter;
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Test;
/**
*
* @author ltheussl
*/
public class SinkAdapterTest
- extends TestCase
{
private final SinkAdapter instance = new SinkAdapter();
/**
* Test of head method, of class SinkAdapter.
*/
+ @Test
public void testHead()
{
instance.head();
@@ -46,6 +46,7 @@ public class SinkAdapterTest
/**
* Test of body method, of class SinkAdapter.
*/
+ @Test
public void testBody()
{
instance.body();
@@ -56,6 +57,7 @@ public class SinkAdapterTest
/**
* Test of article method, of class SinkAdapter.
*/
+ @Test
public void testArticle()
{
instance.article();
@@ -66,6 +68,7 @@ public class SinkAdapterTest
/**
* Test of navigation method, of class SinkAdapter.
*/
+ @Test
public void testNavigation()
{
instance.navigation();
@@ -76,6 +79,7 @@ public class SinkAdapterTest
/**
* Test of sidebar method, of class SinkAdapter.
*/
+ @Test
public void testSidebar()
{
instance.sidebar();
@@ -86,6 +90,7 @@ public class SinkAdapterTest
/**
* Test of section1 method, of class SinkAdapter.
*/
+ @Test
public void testSection1()
{
final int level = SinkAdapter.SECTION_LEVEL_1;
@@ -98,6 +103,7 @@ public class SinkAdapterTest
/**
* Test of section2 method, of class SinkAdapter.
*/
+ @Test
public void testSection2()
{
final int level = SinkAdapter.SECTION_LEVEL_2;
@@ -110,6 +116,7 @@ public class SinkAdapterTest
/**
* Test of section3 method, of class SinkAdapter.
*/
+ @Test
public void testSection3()
{
final int level = SinkAdapter.SECTION_LEVEL_3;
@@ -122,6 +129,7 @@ public class SinkAdapterTest
/**
* Test of section4 method, of class SinkAdapter.
*/
+ @Test
public void testSection4()
{
final int level = SinkAdapter.SECTION_LEVEL_4;
@@ -134,6 +142,7 @@ public class SinkAdapterTest
/**
* Test of section5 method, of class SinkAdapter.
*/
+ @Test
public void testSection5()
{
final int level = SinkAdapter.SECTION_LEVEL_5;
@@ -146,6 +155,7 @@ public class SinkAdapterTest
/**
* Test of list method, of class SinkAdapter.
*/
+ @Test
public void testList()
{
instance.list();
@@ -156,6 +166,7 @@ public class SinkAdapterTest
/**
* Test of listItem method, of class SinkAdapter.
*/
+ @Test
public void testListItem()
{
instance.listItem();
@@ -166,6 +177,7 @@ public class SinkAdapterTest
/**
* Test of numberedList method, of class SinkAdapter.
*/
+ @Test
public void testNumberedList()
{
final int numbering = SinkAdapter.NUMBERING_DECIMAL;
@@ -177,6 +189,7 @@ public class SinkAdapterTest
/**
* Test of numberedListItem method, of class SinkAdapter.
*/
+ @Test
public void testNumberedListItem()
{
instance.numberedListItem();
@@ -187,6 +200,7 @@ public class SinkAdapterTest
/**
* Test of definitionList method, of class SinkAdapter.
*/
+ @Test
public void testDefinitionList()
{
instance.definitionList();
@@ -197,6 +211,7 @@ public class SinkAdapterTest
/**
* Test of definitionListItem method, of class SinkAdapter.
*/
+ @Test
public void testDefinitionListItem()
{
instance.definitionListItem();
@@ -207,6 +222,7 @@ public class SinkAdapterTest
/**
* Test of definition method, of class SinkAdapter.
*/
+ @Test
public void testDefinition()
{
instance.definition();
@@ -217,6 +233,7 @@ public class SinkAdapterTest
/**
* Test of figure method, of class SinkAdapter.
*/
+ @Test
public void testFigure()
{
instance.figure();
@@ -227,6 +244,7 @@ public class SinkAdapterTest
/**
* Test of table method, of class SinkAdapter.
*/
+ @Test
public void testTable()
{
instance.table();
@@ -237,6 +255,7 @@ public class SinkAdapterTest
/**
* Test of tableRows method, of class SinkAdapter.
*/
+ @Test
public void testTableRows()
{
final int[] justification = null;
@@ -248,6 +267,7 @@ public class SinkAdapterTest
/**
* Test of tableRow method, of class SinkAdapter.
*/
+ @Test
public void testTableRow()
{
instance.tableRow();
@@ -258,6 +278,7 @@ public class SinkAdapterTest
/**
* Test of title method, of class SinkAdapter.
*/
+ @Test
public void testTitle()
{
instance.title();
@@ -268,6 +289,7 @@ public class SinkAdapterTest
/**
* Test of author method, of class SinkAdapter.
*/
+ @Test
public void testAuthor()
{
instance.author();
@@ -278,6 +300,7 @@ public class SinkAdapterTest
/**
* Test of date method, of class SinkAdapter.
*/
+ @Test
public void testDate()
{
instance.date();
@@ -288,6 +311,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle()
{
final int level = SinkAdapter.SECTION_LEVEL_1;
@@ -300,6 +324,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle1 method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle1()
{
final int level = SinkAdapter.SECTION_LEVEL_1;
@@ -312,6 +337,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle2 method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle2()
{
final int level = SinkAdapter.SECTION_LEVEL_2;
@@ -324,6 +350,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle3 method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle3()
{
final int level = SinkAdapter.SECTION_LEVEL_3;
@@ -336,6 +363,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle4 method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle4()
{
final int level = SinkAdapter.SECTION_LEVEL_4;
@@ -348,6 +376,7 @@ public class SinkAdapterTest
/**
* Test of sectionTitle5 method, of class SinkAdapter.
*/
+ @Test
public void testSectionTitle5()
{
final int level = SinkAdapter.SECTION_LEVEL_5;
@@ -360,6 +389,7 @@ public class SinkAdapterTest
/**
* Test of header method, of class SinkAdapter.
*/
+ @Test
public void testHeader()
{
instance.header();
@@ -370,6 +400,7 @@ public class SinkAdapterTest
/**
* Test of content method, of class SinkAdapter.
*/
+ @Test
public void testContent()
{
instance.content();
@@ -380,6 +411,7 @@ public class SinkAdapterTest
/**
* Test of footer method, of class SinkAdapter.
*/
+ @Test
public void testFooter()
{
instance.footer();
@@ -390,6 +422,7 @@ public class SinkAdapterTest
/**
* Test of paragraph method, of class SinkAdapter.
*/
+ @Test
public void testParagraph()
{
instance.paragraph();
@@ -400,6 +433,7 @@ public class SinkAdapterTest
/**
* Test of data method, of class SinkAdapter.
*/
+ @Test
public void testData()
{
String value = "";
@@ -411,6 +445,7 @@ public class SinkAdapterTest
/**
* Test of time method, of class SinkAdapter.
*/
+ @Test
public void testTime()
{
String datetime = "";
@@ -422,6 +457,7 @@ public class SinkAdapterTest
/**
* Test of address method, of class SinkAdapter.
*/
+ @Test
public void testAddress()
{
instance.address();
@@ -432,6 +468,7 @@ public class SinkAdapterTest
/**
* Test of blockquote method, of class SinkAdapter.
*/
+ @Test
public void testBlockquote()
{
instance.blockquote();
@@ -442,6 +479,7 @@ public class SinkAdapterTest
/**
* Test of division method, of class SinkAdapter.
*/
+ @Test
public void testDivision()
{
instance.division();
@@ -452,6 +490,7 @@ public class SinkAdapterTest
/**
* Test of verbatim method, of class SinkAdapter.
*/
+ @Test
public void testVerbatim()
{
instance.verbatim( null );
@@ -462,6 +501,7 @@ public class SinkAdapterTest
/**
* Test of definedTerm method, of class SinkAdapter.
*/
+ @Test
public void testDefinedTerm()
{
instance.definedTerm();
@@ -472,6 +512,7 @@ public class SinkAdapterTest
/**
* Test of figureCaption method, of class SinkAdapter.
*/
+ @Test
public void testFigureCaption()
{
instance.figureCaption();
@@ -482,6 +523,7 @@ public class SinkAdapterTest
/**
* Test of tableCell method, of class SinkAdapter.
*/
+ @Test
public void testTableCell()
{
instance.tableCell();
@@ -493,6 +535,7 @@ public class SinkAdapterTest
/**
* Test of tableHeaderCell method, of class SinkAdapter.
*/
+ @Test
public void testTableHeaderCell()
{
instance.tableHeaderCell();
@@ -504,6 +547,7 @@ public class SinkAdapterTest
/**
* Test of tableCaption method, of class SinkAdapter.
*/
+ @Test
public void testTableCaption()
{
instance.tableCaption();
@@ -514,6 +558,7 @@ public class SinkAdapterTest
/**
* Test of figureGraphics method, of class SinkAdapter.
*/
+ @Test
public void testFigureGraphics()
{
String name = "";
@@ -524,6 +569,7 @@ public class SinkAdapterTest
/**
* Test of horizontalRule method, of class SinkAdapter.
*/
+ @Test
public void testHorizontalRule()
{
instance.horizontalRule();
@@ -533,6 +579,7 @@ public class SinkAdapterTest
/**
* Test of pageBreak method, of class SinkAdapter.
*/
+ @Test
public void testPageBreak()
{
instance.pageBreak();
@@ -541,6 +588,7 @@ public class SinkAdapterTest
/**
* Test of anchor method, of class SinkAdapter.
*/
+ @Test
public void testAnchor()
{
String name = "";
@@ -552,6 +600,7 @@ public class SinkAdapterTest
/**
* Test of link method, of class SinkAdapter.
*/
+ @Test
public void testLink()
{
String name = "";
@@ -563,6 +612,7 @@ public class SinkAdapterTest
/**
* Test of inline method, of class SinkAdapter.
*/
+ @Test
public void testInline()
{
instance.inline();
@@ -573,6 +623,7 @@ public class SinkAdapterTest
/**
* Test of italic method, of class SinkAdapter.
*/
+ @Test
public void testItalic()
{
instance.inline( SinkEventAttributeSet.Semantics.ITALIC );
@@ -582,6 +633,7 @@ public class SinkAdapterTest
/**
* Test of bold method, of class SinkAdapter.
*/
+ @Test
public void testBold()
{
instance.inline( SinkEventAttributeSet.Semantics.BOLD );
@@ -591,6 +643,7 @@ public class SinkAdapterTest
/**
* Test of monospaced method, of class SinkAdapter.
*/
+ @Test
public void testMonospaced()
{
instance.inline( SinkEventAttributeSet.Semantics.MONOSPACED );
@@ -600,6 +653,7 @@ public class SinkAdapterTest
/**
* Test of lineBreak method, of class SinkAdapter.
*/
+ @Test
public void testLineBreaks()
{
instance.lineBreak();
@@ -609,6 +663,7 @@ public class SinkAdapterTest
/**
* Test of lineBreakOpportunity method, of class SinkAdapter.
*/
+ @Test
public void testLineBreakOpportunities()
{
instance.lineBreakOpportunity();
@@ -618,6 +673,7 @@ public class SinkAdapterTest
/**
* Test of nonBreakingSpace method, of class SinkAdapter.
*/
+ @Test
public void testNonBreakingSpace()
{
instance.nonBreakingSpace();
@@ -626,6 +682,7 @@ public class SinkAdapterTest
/**
* Test of text method, of class SinkAdapter.
*/
+ @Test
public void testText()
{
String text = "";
@@ -636,6 +693,7 @@ public class SinkAdapterTest
/**
* Test of rawText method, of class SinkAdapter.
*/
+ @Test
public void testRawText()
{
String text = "";
@@ -645,6 +703,7 @@ public class SinkAdapterTest
/**
* Test of comment method, of class SinkAdapter.
*/
+ @Test
public void testComment()
{
instance.comment( "" );
@@ -653,6 +712,7 @@ public class SinkAdapterTest
/**
* Test of flush method, of class SinkAdapter.
*/
+ @Test
public void testFlush()
{
instance.flush();
@@ -661,6 +721,7 @@ public class SinkAdapterTest
/**
* Test of close method, of class SinkAdapter.
*/
+ @Test
public void testClose()
{
instance.close();
@@ -669,6 +730,7 @@ public class SinkAdapterTest
/**
* Test of section method, of class SinkAdapter.
*/
+ @Test
public void testSection()
{
int level = 0;
@@ -679,6 +741,7 @@ public class SinkAdapterTest
/**
* Test of unknown method, of class SinkAdapter.
*/
+ @Test
public void testUnknown()
{
String name = "";
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 0199d2e..e628d5f 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,32 +25,30 @@ import javax.swing.text.AttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Test SinkEventAttributeSet.
*
* @author ltheussl
*/
-public class SinkEventAttributeSetTest extends TestCase
+public class SinkEventAttributeSetTest
{
-
private SinkEventAttributeSet sinkEventAttributeSet;
- /**
- * @throws java.lang.Exception if any.
- */
- @Override
- protected void setUp()
- throws Exception
+ @Before
+ public void setUp()
{
- super.setUp();
this.sinkEventAttributeSet = new SinkEventAttributeSet();
}
/**
* Test of constructors, of class SinkEventAttributeSet.
*/
+ @Test
public void testConstructor()
{
try
@@ -67,6 +65,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of isEmpty method, of class SinkEventAttributeSet.
*/
+ @Test
public void testIsEmpty()
{
assertTrue( sinkEventAttributeSet.isEmpty() );
@@ -77,6 +76,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of getAttributeCount method, of class SinkEventAttributeSet.
*/
+ @Test
public void testGetAttributeCount()
{
assertEquals( 0, sinkEventAttributeSet.getAttributeCount() );
@@ -98,6 +98,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of isDefined method, of class SinkEventAttributeSet.
*/
+ @Test
public void testIsDefined()
{
assertFalse( sinkEventAttributeSet.isDefined( SinkEventAttributes.DECORATION ) );
@@ -108,6 +109,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of isEqual method, of class SinkEventAttributeSet.
*/
+ @Test
public void testIsEqual()
{
SinkEventAttributes instance = new SinkEventAttributeSet( SinkEventAttributeSet.BOLD );
@@ -120,9 +122,12 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of equals method, of class SinkEventAttributeSet.
*/
+ @Test
+ @SuppressWarnings( "SimplifiableJUnitAssertion" )
public void testEquals()
{
assertFalse( sinkEventAttributeSet.equals( null ) );
+ //noinspection EqualsWithItself
assertTrue( sinkEventAttributeSet.equals( sinkEventAttributeSet ) );
SinkEventAttributes instance = new SinkEventAttributeSet( SinkEventAttributeSet.BOLD );
@@ -135,6 +140,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of copyAttributes method, of class SinkEventAttributeSet.
*/
+ @Test
public void testCopyAttributes()
{
sinkEventAttributeSet.addAttributes( SinkEventAttributeSet.ITALIC );
@@ -145,6 +151,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of getAttributeNames method, of class SinkEventAttributeSet.
*/
+ @Test
public void testGetAttributeNames()
{
sinkEventAttributeSet.addAttributes( SinkEventAttributeSet.UNDERLINE );
@@ -156,16 +163,18 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of getAttribute method, of class SinkEventAttributeSet.
*/
+ @Test
public void testGetAttribute()
{
sinkEventAttributeSet.addAttribute( "key", "value" );
- assertTrue( sinkEventAttributeSet.getAttribute( "key" ).equals( "value" ) );
+ assertEquals( "value", sinkEventAttributeSet.getAttribute( "key" ) );
assertNull( sinkEventAttributeSet.getAttribute( "bla" ) );
}
/**
* Test of containsAttribute method, of class SinkEventAttributeSet.
*/
+ @Test
public void testContainsAttribute()
{
sinkEventAttributeSet.addAttribute( "key", "value" );
@@ -176,6 +185,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of containsAttributes method, of class SinkEventAttributeSet.
*/
+ @Test
public void testContainsAttributes()
{
sinkEventAttributeSet.addAttributes( SinkEventAttributeSet.JUSTIFY );
@@ -186,6 +196,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of addAttribute method, of class SinkEventAttributeSet.
*/
+ @Test
public void testAddAttribute()
{
assertFalse( sinkEventAttributeSet.containsAttribute( "key", "value" ) );
@@ -198,6 +209,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of add/removeAttributes methods, of class SinkEventAttributeSet.
*/
+ @Test
public void testAddAttributes()
{
assertFalse( sinkEventAttributeSet.containsAttributes( SinkEventAttributeSet.JUSTIFY ) );
@@ -220,6 +232,7 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of getResolveParent method, of class SinkEventAttributeSet.
*/
+ @Test
public void testGetResolveParent()
{
assertNull( sinkEventAttributeSet.getResolveParent() );
@@ -230,21 +243,22 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of clone method, of class SinkEventAttributeSet.
*/
+ @Test
public void testClone()
{
Object result = sinkEventAttributeSet.clone();
- assertTrue( sinkEventAttributeSet.equals( result ) );
+ assertEquals( sinkEventAttributeSet, result );
sinkEventAttributeSet.addAttributes( SinkEventAttributeSet.MONOSPACED );
- assertFalse( sinkEventAttributeSet.equals( result ) );
+ assertNotEquals( sinkEventAttributeSet, result );
result = sinkEventAttributeSet.clone();
- assertTrue( sinkEventAttributeSet.equals( result ) );
+ assertEquals( sinkEventAttributeSet, result );
sinkEventAttributeSet.setResolveParent( SinkEventAttributeSet.CENTER );
//assertFalse( sinkEventAttributeSet.equals( result ) );
result = sinkEventAttributeSet.clone();
- assertTrue( sinkEventAttributeSet.equals( result ) );
+ assertEquals( sinkEventAttributeSet, result );
sinkEventAttributeSet.setResolveParent( SinkEventAttributeSet.BOXED );
//assertFalse( sinkEventAttributeSet.equals( result ) );
}
@@ -252,22 +266,24 @@ public class SinkEventAttributeSetTest extends TestCase
/**
* Test of hashCode method, of class SinkEventAttributeSet.
*/
+ @Test
public void testHashCode()
{
int oldValue = sinkEventAttributeSet.hashCode();
sinkEventAttributeSet.addAttributes( SinkEventAttributeSet.BOLD );
int newValue = sinkEventAttributeSet.hashCode();
- assertFalse( oldValue == newValue );
+ assertNotEquals( oldValue, newValue );
oldValue = newValue;
sinkEventAttributeSet.setResolveParent( SinkEventAttributeSet.CENTER );
newValue = sinkEventAttributeSet.hashCode();
- assertFalse( oldValue == newValue );
+ assertNotEquals( oldValue, newValue );
}
/**
* Test of toString method, of class SinkEventAttributeSet.
*/
+ @Test
public void testToString()
{
String expected = "";
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 964610b..e990c27 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
@@ -23,22 +23,22 @@ import javax.swing.text.AttributeSet;
import javax.swing.text.MutableAttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.apache.maven.doxia.sink.impl.SinkUtils;
-import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
*
* @author ltheussl
*/
public class SinkUtilsTest
- extends TestCase
{
-
/**
* Test of getAttributeString method, of class SinkUtils.
*/
+ @Test
public void testGetAttributeString()
{
assertEquals( "", SinkUtils.getAttributeString( null ) );
@@ -66,9 +66,10 @@ public class SinkUtilsTest
/**
* Test of filterAttributes method, of class SinkUtils.
*/
+ @Test
public void testFilterAttributes()
{
- assertNull( SinkUtils.filterAttributes( null, null ) );
+ Assert.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 a7744f4..cec63b0 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
@@ -1,7 +1,4 @@
package org.apache.maven.doxia.sink.impl;
-
-import org.apache.maven.doxia.sink.impl.AbstractSink;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,12 +18,13 @@ import org.apache.maven.doxia.sink.impl.AbstractSink;
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
public class TestAbstractSink
- extends TestCase
{
-
+ @Test
public void testUnifiedEOL()
{
String EOL = AbstractSink.EOL;
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 949761c..029da65 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
@@ -24,19 +24,19 @@ import java.io.Writer;
import javax.swing.text.html.HTML.Attribute;
-import junit.framework.TestCase;
-
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.apache.maven.doxia.sink.impl.Xhtml5BaseSink;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test for Xhtml5BaseSink.
*/
public class Xhtml5BaseSinkTest
- extends TestCase
{
protected static final String LS = Markup.EOL;
private final SinkEventAttributes attributes = SinkEventAttributeSet.BOLD;
@@ -45,16 +45,14 @@ public class Xhtml5BaseSinkTest
String EOL = System.lineSeparator();
- @Override
- protected void setUp()
- throws Exception
+ @Before
+ public void setUp()
{
- super.setUp();
writer = new StringWriter();
}
+ @Test
public void testSpaceAfterClosingTag()
- throws Exception
{
// DOXIA-189
try
@@ -84,10 +82,9 @@ public class Xhtml5BaseSinkTest
}
/**
- * @throws Exception if any
*/
+ @Test
public void testNestedTables()
- throws Exception
{
// DOXIA-177
try
@@ -172,12 +169,12 @@ public class Xhtml5BaseSinkTest
}
String actual = writer.toString();
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\">"
- + "<caption>caption&1</caption>" ) );
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\" align=\"left\">"
- + "<caption>caption2</caption>" ) );
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\" align=\"right\">"
- + "<caption>caption3</caption>" ) );
+ assertTrue(
+ actual.contains( "<table border=\"0\" class=\"bodyTable\">" + "<caption>caption&1</caption>" ) );
+ assertTrue( actual.contains(
+ "<table border=\"0\" class=\"bodyTable\" align=\"left\">" + "<caption>caption2</caption>" ) );
+ assertTrue( actual.contains(
+ "<table border=\"0\" class=\"bodyTable\" align=\"right\">" + "<caption>caption3</caption>" ) );
assertTrue( actual.contains( "<td>cell11</td>" ) );
assertTrue( actual.contains( "<td>nestedTable1Cell11</td>" ) );
@@ -189,6 +186,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of article method, of class Xhtml5BaseSink.
*/
+ @Test
public void testArticle()
{
try
@@ -225,6 +223,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of navigation method, of class Xhtml5BaseSink.
*/
+ @Test
public void testNavigation()
{
try
@@ -261,6 +260,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of sidebar method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSidebar()
{
try
@@ -297,6 +297,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection()
{
final int level = Xhtml5BaseSink.SECTION_LEVEL_1;
@@ -315,12 +316,14 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<section style=\"bold\">" + LS + "<h2 style=\"bold\"></h2></section>", writer.toString() );
+ assertEquals( "<section style=\"bold\">" + LS + "<h2 style=\"bold\"></h2></section>",
+ writer.toString() );
}
/**
* Test of section method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSectionAttributes()
{
final int level = Xhtml5BaseSink.SECTION_LEVEL_1;
@@ -347,6 +350,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section1 method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection1()
{
@@ -370,6 +374,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section2 method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection2()
{
@@ -393,6 +398,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section3 method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection3()
{
@@ -416,6 +422,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section4 method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection4()
{
try
@@ -438,6 +445,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of section5 method, of class Xhtml5BaseSink.
*/
+ @Test
public void testSection5()
{
try
@@ -460,6 +468,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of header method, of class Xhtml5BaseSink.
*/
+ @Test
public void testHeader()
{
try
@@ -496,6 +505,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of content method, of class Xhtml5BaseSink.
*/
+ @Test
public void testContent()
{
try
@@ -530,12 +540,14 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<main style=\"bold\">" + EOL + "<div style=\"bold\" class=\"content\"></div></main>", writer.toString() );
+ assertEquals( "<main style=\"bold\">" + EOL + "<div style=\"bold\" class=\"content\"></div></main>",
+ writer.toString() );
}
/**
* Test of footer method, of class Xhtml5BaseSink.
*/
+ @Test
public void testFooter()
{
try
@@ -571,10 +583,9 @@ public class Xhtml5BaseSinkTest
/**
* Test of list method, of class Xhtml5BaseSink.
- * @throws java.lang.Exception if any.
*/
+ @Test
public void testList()
- throws Exception
{
try
{
@@ -614,6 +625,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of numberedList method, of class Xhtml5BaseSink.
*/
+ @Test
public void testNumberedList()
{
final int numbering = Xhtml5BaseSink.NUMBERING_DECIMAL;
@@ -650,12 +662,14 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<ol style=\"list-style-type: decimal\">" + LS + "<li style=\"bold\"></li></ol>", writer.toString() );
+ assertEquals( "<ol style=\"list-style-type: decimal\">" + LS + "<li style=\"bold\"></li></ol>",
+ writer.toString() );
}
/**
* Test of definitionList method, of class Xhtml5BaseSink.
*/
+ @Test
public void testDefinitionList()
{
try
@@ -694,12 +708,15 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<dl style=\"bold\">" + LS + "<dt style=\"bold\"></dt>" + LS + "<dd style=\"bold\"></dd></dl>", writer.toString() );
+ assertEquals(
+ "<dl style=\"bold\">" + LS + "<dt style=\"bold\"></dt>" + LS + "<dd style=\"bold\"></dd></dl>",
+ writer.toString() );
}
/**
* Test of figure method, of class Xhtml5BaseSink.
*/
+ @Test
public void testFigure()
{
final String src = "src.jpg";
@@ -719,14 +736,15 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<figure style=\"bold\">"
- + "<img src=\"src.jpg\" style=\"bold\" alt=\"\" />"
- + "<figcaption style=\"bold\"></figcaption></figure>", writer.toString() );
+ assertEquals(
+ "<figure style=\"bold\">" + "<img src=\"src.jpg\" style=\"bold\" alt=\"\" />" + "<figcaption style=\"bold\"></figcaption></figure>",
+ writer.toString() );
}
/**
* Test of figureGraphics method, of class Xhtml5BaseSink.
*/
+ @Test
public void testFigureGraphics()
{
String src = "source.png";
@@ -747,6 +765,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of paragraph method, of class Xhtml5BaseSink.
*/
+ @Test
public void testParagraph()
{
try
@@ -783,6 +802,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of data method, of class Xhtml5BaseSink.
*/
+ @Test
public void testData()
{
String value = "value";
@@ -804,6 +824,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of time method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTime()
{
String datetime = "datetime";
@@ -825,6 +846,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of address method, of class Xhtml5BaseSink.
*/
+ @Test
public void testAddress()
{
try
@@ -861,6 +883,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of blockquote method, of class Xhtml5BaseSink.
*/
+ @Test
public void testBlockquote()
{
try
@@ -897,6 +920,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of division method, of class Xhtml5BaseSink.
*/
+ @Test
public void testDivision()
{
try
@@ -933,6 +957,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of verbatim method, of class Xhtml5BaseSink.
*/
+ @Test
public void testVerbatim()
{
try
@@ -988,6 +1013,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of horizontalRule method, of class Xhtml5BaseSink.
*/
+ @Test
public void testHorizontalRule()
{
try
@@ -1008,6 +1034,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of table method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTable()
{
try
@@ -1028,6 +1055,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of tableRows method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTableRows()
{
final int[] justification = null;
@@ -1051,6 +1079,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of tableRow method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTableRow()
{
try
@@ -1071,6 +1100,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of tableCell method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTableCell()
{
try
@@ -1091,6 +1121,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of tableHeaderCell method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTableHeaderCell()
{
try
@@ -1111,6 +1142,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of tableCaption method, of class Xhtml5BaseSink.
*/
+ @Test
public void testTableCaption()
{
try
@@ -1130,13 +1162,15 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<table border=\"0\" class=\"bodyTable\">" +
- "<caption style=\"bold\">caption</caption></table>", writer.toString() );
+ assertEquals(
+ "<table border=\"0\" class=\"bodyTable\">" + "<caption style=\"bold\">caption</caption></table>",
+ writer.toString() );
}
/**
* Test of anchor method, of class Xhtml5BaseSink.
*/
+ @Test
public void testAnchor()
{
String name = "anchor";
@@ -1158,6 +1192,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of link method, of class Xhtml5BaseSink.
*/
+ @Test
public void testLink()
{
final String name = "link.html";
@@ -1179,6 +1214,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of inline method, of class Xhtml5BaseSink.
*/
+ @Test
public void testInline()
{
String text = "a text & \u00c6";
@@ -1251,12 +1287,15 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<em><strong><small><s><cite><q><dfn><abbr><i><b><code><var><samp><kbd><sup><sub><u><mark><ruby><rb><rt><rtc><rp><bdi><bdo><span><ins><del>a text & Æ</del></ins></span></bdo></bdi></rp></rtc></rt></rb></ruby></mark></u></sub></sup></kbd></samp></var></code></b></i></abbr></dfn></q></cite></s></small></strong></em>", writer.toString() );
+ assertEquals(
+ "<em><strong><small><s><cite><q><dfn><abbr><i><b><code><var><samp><kbd><sup><sub><u><mark><ruby><rb><rt><rtc><rp><bdi><bdo><span><ins><del>a text & Æ</del></ins></span></bdo></bdi></rp></rtc></rt></rb></ruby></mark></u></sub></sup></kbd></samp></var></code></b></i></abbr></dfn></q></cite></s></small></strong></em>",
+ writer.toString() );
}
/**
* Test of italic/bold/code method, of class Xhtml5BaseSink.
*/
+ @Test
public void testItalic()
{
try
@@ -1280,6 +1319,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of lineBreak/lineBreakOpportunity/pageBreak/nonBreakingSpace method, of class Xhtml5BaseSink.
*/
+ @Test
public void testLineBreak()
{
try
@@ -1301,6 +1341,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of text method, of class Xhtml5BaseSink.
*/
+ @Test
public void testText()
{
String text = "a text & \u00c6";
@@ -1335,6 +1376,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of rawText method, of class Xhtml5BaseSink.
*/
+ @Test
public void testRawText()
{
String text = "raw text";
@@ -1355,6 +1397,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of comment method, of class Xhtml5BaseSink.
*/
+ @Test
public void testComment()
{
try
@@ -1370,12 +1413,14 @@ public class Xhtml5BaseSinkTest
sink.close();
}
- assertEquals( "<!--a comment--><!-- a comment--><!--a comment --><!-- a comment -->", writer.toString() );
+ assertEquals( "<!--a comment--><!-- a comment--><!--a comment --><!-- a comment -->",
+ writer.toString() );
}
/**
* Test of unknown method, of class Xhtml5BaseSink.
*/
+ @Test
public void testUnknown()
{
final String name = "unknown";
@@ -1397,6 +1442,7 @@ public class Xhtml5BaseSinkTest
/**
* Test entities in attribute values.
*/
+ @Test
public void testAttributeEntities()
{
final Object[] startTag = new Object[] { Xhtml5BaseSink.TAG_TYPE_START };
@@ -1428,6 +1474,7 @@ public class Xhtml5BaseSinkTest
/**
* Test of entity.
*/
+ @Test
public void testEntity()
{
// DOXIA-314
@@ -1449,6 +1496,7 @@ public class Xhtml5BaseSinkTest
/**
* Test unicode chracters in tables. DOXIA-433.
*/
+ @Test
public void testSpecialCharacters()
{
try
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 b94f253..a06b763 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
@@ -24,13 +24,14 @@ import java.io.Writer;
import javax.swing.text.html.HTML.Attribute;
-import junit.framework.TestCase;
-
import org.apache.maven.doxia.markup.Markup;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
-import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test for XhtmlBaseSink.
@@ -40,23 +41,20 @@ import org.apache.maven.doxia.sink.impl.XhtmlBaseSink;
* @since 1.1
*/
public class XhtmlBaseSinkTest
- extends TestCase
{
protected static final String LS = Markup.EOL;
private final SinkEventAttributes attributes = SinkEventAttributeSet.BOLD;
private XhtmlBaseSink sink;
private Writer writer;
- @Override
- protected void setUp()
- throws Exception
+ @Before
+ public void setUp()
{
- super.setUp();
writer = new StringWriter();
}
+ @Test
public void testSpaceAfterClosingTag()
- throws Exception
{
// DOXIA-189
try
@@ -86,10 +84,9 @@ public class XhtmlBaseSinkTest
}
/**
- * @throws Exception if any
*/
+ @Test
public void testNestedTables()
- throws Exception
{
// DOXIA-177
try
@@ -174,12 +171,12 @@ public class XhtmlBaseSinkTest
}
String actual = writer.toString();
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\">"
- + "<caption>caption&1</caption>" ) );
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\" align=\"left\">"
- + "<caption>caption2</caption>" ) );
- assertTrue( actual.contains( "<table border=\"0\" class=\"bodyTable\" align=\"right\">"
- + "<caption>caption3</caption>" ) );
+ assertTrue(
+ actual.contains( "<table border=\"0\" class=\"bodyTable\">" + "<caption>caption&1</caption>" ) );
+ assertTrue( actual.contains(
+ "<table border=\"0\" class=\"bodyTable\" align=\"left\">" + "<caption>caption2</caption>" ) );
+ assertTrue( actual.contains(
+ "<table border=\"0\" class=\"bodyTable\" align=\"right\">" + "<caption>caption3</caption>" ) );
assertTrue( actual.contains( "<td>cell11</td>" ) );
assertTrue( actual.contains( "<td>nestedTable1Cell11</td>" ) );
@@ -191,6 +188,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection()
{
final int level = XhtmlBaseSink.SECTION_LEVEL_1;
@@ -209,12 +207,14 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<div class=\"section\" style=\"bold\">" + LS + "<h2 style=\"bold\"></h2></div>", writer.toString() );
+ assertEquals( "<div class=\"section\" style=\"bold\">" + LS + "<h2 style=\"bold\"></h2></div>",
+ writer.toString() );
}
/**
* Test of section method, of class XhtmlBaseSink.
*/
+ @Test
public void testSectionAttributes()
{
final int level = XhtmlBaseSink.SECTION_LEVEL_1;
@@ -241,6 +241,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section1 method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection1()
{
@@ -264,6 +265,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section2 method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection2()
{
@@ -287,6 +289,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section3 method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection3()
{
@@ -310,6 +313,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section4 method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection4()
{
try
@@ -332,6 +336,7 @@ public class XhtmlBaseSinkTest
/**
* Test of section5 method, of class XhtmlBaseSink.
*/
+ @Test
public void testSection5()
{
try
@@ -353,10 +358,9 @@ public class XhtmlBaseSinkTest
/**
* Test of list method, of class XhtmlBaseSink.
- * @throws java.lang.Exception if any.
*/
+ @Test
public void testList()
- throws Exception
{
try
{
@@ -396,6 +400,7 @@ public class XhtmlBaseSinkTest
/**
* Test of numberedList method, of class XhtmlBaseSink.
*/
+ @Test
public void testNumberedList()
{
final int numbering = XhtmlBaseSink.NUMBERING_DECIMAL;
@@ -432,12 +437,14 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<ol style=\"list-style-type: decimal\">" + LS + "<li style=\"bold\"></li></ol>", writer.toString() );
+ assertEquals( "<ol style=\"list-style-type: decimal\">" + LS + "<li style=\"bold\"></li></ol>",
+ writer.toString() );
}
/**
* Test of definitionList method, of class XhtmlBaseSink.
*/
+ @Test
public void testDefinitionList()
{
try
@@ -476,12 +483,15 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<dl style=\"bold\">" + LS + "<dt style=\"bold\"></dt>" + LS + "<dd style=\"bold\"></dd></dl>", writer.toString() );
+ assertEquals(
+ "<dl style=\"bold\">" + LS + "<dt style=\"bold\"></dt>" + LS + "<dd style=\"bold\"></dd></dl>",
+ writer.toString() );
}
/**
* Test of figure method, of class XhtmlBaseSink.
*/
+ @Test
public void testFigure()
{
final String src = "src.jpg";
@@ -501,14 +511,15 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<div style=\"bold\" class=\"figure\">"
- + "" + LS + "<p align=\"center\"><img src=\"src.jpg\" style=\"bold\" alt=\"\" /></p>"
- + "" + LS + "<p align=\"center\" style=\"bold\"><i></i></p></div>", writer.toString() );
+ assertEquals(
+ "<div style=\"bold\" class=\"figure\">" + "" + LS + "<p align=\"center\"><img src=\"src.jpg\" style=\"bold\" alt=\"\" /></p>" + "" + LS + "<p align=\"center\" style=\"bold\"><i></i></p></div>",
+ writer.toString() );
}
/**
* Test of figureGraphics method, of class XhtmlBaseSink.
*/
+ @Test
public void testFigureGraphics()
{
String src = "source.png";
@@ -529,6 +540,7 @@ public class XhtmlBaseSinkTest
/**
* Test of paragraph method, of class XhtmlBaseSink.
*/
+ @Test
public void testParagraph()
{
try
@@ -565,6 +577,7 @@ public class XhtmlBaseSinkTest
/**
* Test of verbatim method, of class XhtmlBaseSink.
*/
+ @Test
public void testVerbatim()
{
try
@@ -620,6 +633,7 @@ public class XhtmlBaseSinkTest
/**
* Test of horizontalRule method, of class XhtmlBaseSink.
*/
+ @Test
public void testHorizontalRule()
{
try
@@ -640,6 +654,7 @@ public class XhtmlBaseSinkTest
/**
* Test of table method, of class XhtmlBaseSink.
*/
+ @Test
public void testTable()
{
try
@@ -660,6 +675,7 @@ public class XhtmlBaseSinkTest
/**
* Test of tableRows method, of class XhtmlBaseSink.
*/
+ @Test
public void testTableRows()
{
final int[] justification = null;
@@ -683,6 +699,7 @@ public class XhtmlBaseSinkTest
/**
* Test of tableRow method, of class XhtmlBaseSink.
*/
+ @Test
public void testTableRow()
{
try
@@ -703,6 +720,7 @@ public class XhtmlBaseSinkTest
/**
* Test of tableCell method, of class XhtmlBaseSink.
*/
+ @Test
public void testTableCell()
{
try
@@ -723,6 +741,7 @@ public class XhtmlBaseSinkTest
/**
* Test of tableHeaderCell method, of class XhtmlBaseSink.
*/
+ @Test
public void testTableHeaderCell()
{
try
@@ -743,6 +762,7 @@ public class XhtmlBaseSinkTest
/**
* Test of tableCaption method, of class XhtmlBaseSink.
*/
+ @Test
public void testTableCaption()
{
try
@@ -762,13 +782,15 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<table border=\"0\" class=\"bodyTable\">" +
- "<caption style=\"bold\">caption</caption></table>", writer.toString() );
+ assertEquals(
+ "<table border=\"0\" class=\"bodyTable\">" + "<caption style=\"bold\">caption</caption></table>",
+ writer.toString() );
}
/**
* Test of anchor method, of class XhtmlBaseSink.
*/
+ @Test
public void testAnchor()
{
String name = "anchor";
@@ -790,6 +812,7 @@ public class XhtmlBaseSinkTest
/**
* Test of link method, of class XhtmlBaseSink.
*/
+ @Test
public void testLink()
{
final String name = "link.html";
@@ -811,6 +834,7 @@ public class XhtmlBaseSinkTest
/**
* Test of italic/bold/monospaced method, of class XhtmlBaseSink.
*/
+ @Test
public void testItalic()
{
try
@@ -834,6 +858,7 @@ public class XhtmlBaseSinkTest
/**
* Test of lineBreak/pageBreak/nonBreakingSpace method, of class XhtmlBaseSink.
*/
+ @Test
public void testLineBreak()
{
try
@@ -854,6 +879,7 @@ public class XhtmlBaseSinkTest
/**
* Test of text method, of class XhtmlBaseSink.
*/
+ @Test
public void testText()
{
String text = "a text & \u00c6";
@@ -888,6 +914,7 @@ public class XhtmlBaseSinkTest
/**
* Test of rawText method, of class XhtmlBaseSink.
*/
+ @Test
public void testRawText()
{
String text = "raw text";
@@ -908,6 +935,7 @@ public class XhtmlBaseSinkTest
/**
* Test of comment method, of class XhtmlBaseSink.
*/
+ @Test
public void testComment()
{
try
@@ -923,12 +951,14 @@ public class XhtmlBaseSinkTest
sink.close();
}
- assertEquals( "<!--a comment--><!-- a comment--><!--a comment --><!-- a comment -->", writer.toString() );
+ assertEquals( "<!--a comment--><!-- a comment--><!--a comment --><!-- a comment -->",
+ writer.toString() );
}
/**
* Test of unknown method, of class XhtmlBaseSink.
*/
+ @Test
public void testUnknown()
{
final String name = "unknown";
@@ -950,6 +980,7 @@ public class XhtmlBaseSinkTest
/**
* Test entities in attribute values.
*/
+ @Test
public void testAttributeEntities()
{
final Object[] startTag = new Object[] { XhtmlBaseSink.TAG_TYPE_START };
@@ -981,6 +1012,7 @@ public class XhtmlBaseSinkTest
/**
* Test of entity.
*/
+ @Test
public void testEntity()
{
// DOXIA-314
@@ -1002,6 +1034,7 @@ public class XhtmlBaseSinkTest
/**
* Test unicode chracters in tables. DOXIA-433.
*/
+ @Test
public void testSpecialCharacters()
{
try
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 85f00b0..ca4b8df 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,8 +23,9 @@ import java.io.StringReader;
import org.apache.maven.doxia.parser.ParseException;
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* Unit test for {@link org.apache.maven.doxia.util.ByLineReaderSource}.
@@ -32,16 +33,16 @@ import junit.framework.TestCase;
* @author Juan F. Codagnone
* @since Nov 1, 2005
*/
-public class ByLineReaderSourceTest extends TestCase
+public class ByLineReaderSourceTest
{
/**
* @throws ParseException on error
*/
+ @Test
public final void testUse() throws ParseException
{
- ByLineReaderSource r = new ByLineReaderSource(
- new StringReader( "1 \n2\n3" ) );
+ ByLineReaderSource r = new ByLineReaderSource( new StringReader( "1 \n2\n3" ) );
assertEquals( -1, r.getLineNumber() );
assertEquals( "", r.getName() );
@@ -61,6 +62,6 @@ public class ByLineReaderSourceTest extends TestCase
}
assertEquals( "2", r.getNextLine() );
assertEquals( "3", r.getNextLine() );
- assertEquals( null, r.getNextLine() );
+ assertNull( r.getNextLine() );
}
}
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 b7a6fda..3093701 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
@@ -150,7 +150,7 @@ public class DoxiaUtilsTest
*/
public void testEncodeId()
{
- assertEquals( DoxiaUtils.encodeId( null ), null );
+ assertNull( DoxiaUtils.encodeId( null ) );
assertEquals( DoxiaUtils.encodeId( "" ), "a" );
assertEquals( DoxiaUtils.encodeId( " " ), "a" );
assertEquals( DoxiaUtils.encodeId( " _ " ), "a_" );
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 b9c92fc..1afa281 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
@@ -92,7 +92,7 @@ public class HtmlToolsTest
*/
public void testEncodeId()
{
- assertEquals( HtmlTools.encodeId( null ), null );
+ assertNull( HtmlTools.encodeId( null ) );
assertEquals( HtmlTools.encodeId( "" ), "a" );
assertEquals( HtmlTools.encodeId( " " ), "a" );
assertEquals( HtmlTools.encodeId( " _ " ), "a_" );
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 d9aa56f..e9018d7 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
@@ -154,7 +154,7 @@ public class AptParserTest
// No section, only subsection 1 and 2
assertTrue( toc.contains( "* {{{SubSection_1.1}SubSection 1.1}}" ) );
- assertTrue( !toc.contains( "* {{{SubSection_1.1.2.1.1}SubSection 1.1.2.1.1}}" ) );
+ assertFalse( toc.contains( "* {{{SubSection_1.1.2.1.1}SubSection 1.1.2.1.1}}" ) );
}
/**
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 9533272..eb253eb 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,7 +19,9 @@ package org.apache.maven.doxia.module.apt;
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Test AptUtils.
@@ -28,75 +30,62 @@ import junit.framework.TestCase;
* @version $Id$
*/
public class AptUtilsTest
- extends TestCase
{
/**
* Test of isExternalLink method, of class AptUtils.
*/
+ @Test
public void testIsExternalLink()
{
String link = "http://maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "https://maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "HTTPS://MAVEN.APACHE.ORG/";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "ftp:/maven.apache.org/";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "mailto:maven@apache.org";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "file:/index.html";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "resource_type://domain:port/filepathname?query_string#anchor";
- assertTrue( "Should be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertTrue( "Should be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "example.pdf";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "./index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "../index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
// Windows style separators "\" are not allowed
link = "file:\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
link = ".\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
link = "..\\index.html";
- assertFalse( "Should NOT be an external link: " + link,
- AptUtils.isExternalLink( link ) );
+ assertFalse( "Should NOT be an external link: " + link, AptUtils.isExternalLink( link ) );
}
/**
* Test of isInternalLink method, of class AptUtils.
*/
+ @Test
public void testIsInternalLink()
{
String link = "index.html";
@@ -110,6 +99,7 @@ public class AptUtilsTest
/**
* Test of isLocalLink method, of class AptUtils.
*/
+ @Test
public void testIsLocalLink()
{
String link = "/index.html";
@@ -137,6 +127,7 @@ public class AptUtilsTest
/**
* Test of encodeAnchor method, of class AptUtils.
*/
+ @Test
public void testEncodeAnchor()
{
assertNull( AptUtils.encodeAnchor( null ) );
@@ -146,6 +137,8 @@ public class AptUtilsTest
/**
* Test of encodeFragment method, of class AptUtils.
*/
+ @SuppressWarnings( "deprecation" )
+ @Test
public void testEncodeFragment()
{
assertNull( AptUtils.encodeFragment( null ) );
@@ -155,6 +148,8 @@ public class AptUtilsTest
/**
* Test of linkToKey method, of class AptUtils.
*/
+ @SuppressWarnings( "deprecation" )
+ @Test
public void testLinkToKey()
{
assertEquals( "abc56au", AptUtils.linkToKey( "aB$%C56 a&\\/'U" ) );
diff --git a/doxia-modules/doxia-module-docbook-simple/src/test/java/org/apache/maven/doxia/module/docbook/DocbookUtilsTest.java b/doxia-modules/doxia-module-docbook-simple/src/test/java/org/apache/maven/doxia/module/docbook/DocbookUtilsTest.java
index 23a506a..98a2533 100644
--- a/doxia-modules/doxia-module-docbook-simple/src/test/java/org/apache/maven/doxia/module/docbook/DocbookUtilsTest.java
+++ b/doxia-modules/doxia-module-docbook-simple/src/test/java/org/apache/maven/doxia/module/docbook/DocbookUtilsTest.java
@@ -19,9 +19,10 @@ package org.apache.maven.doxia.module.docbook;
* under the License.
*/
-import junit.framework.TestCase;
-
import org.apache.maven.doxia.sink.Sink;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Test DocbookUtils.
@@ -30,11 +31,11 @@ import org.apache.maven.doxia.sink.Sink;
* @version $Id$
*/
public class DocbookUtilsTest
- extends TestCase
{
/**
* Test of doxiaTableFrameAttribute method, of class DocbookUtils.
*/
+ @Test
public void testDoxiaTableFrameAttribute()
{
assertEquals( "box", DocbookUtils.doxiaTableFrameAttribute( "all" ) );
@@ -58,6 +59,7 @@ public class DocbookUtilsTest
/**
* Test of doxiaListNumbering method, of class DocbookUtils.
*/
+ @Test
public void testDoxiaListNumbering()
{
assertEquals( Sink.NUMBERING_LOWER_ALPHA,
@@ -85,6 +87,7 @@ public class DocbookUtilsTest
/**
* Test of docbookListNumbering method, of class DocbookUtils.
*/
+ @Test
public void testDocbookListNumbering()
{
assertEquals( SimplifiedDocbookMarkup.UPPERALPHA_STYLE,
@@ -112,6 +115,7 @@ public class DocbookUtilsTest
/**
* Test of trademarkFromClass method, of class DocbookUtils.
*/
+ @Test
public void testTrademarkFromClass()
{
assertEquals( '\u00AE', DocbookUtils.trademarkFromClass( "registered" ) );
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 d783e70..7a51235 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
@@ -71,7 +71,6 @@ public class FmlValidatorTest
}
public void testValidateFiles()
- throws Exception
{
// TODO: super.testValidateFiles() only validates files from doxia-test-docs, what's the point?
}
diff --git a/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java b/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
index b7ef2b6..e309a70 100644
--- a/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
+++ b/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
@@ -19,23 +19,23 @@ package org.apache.maven.doxia.module.fo;
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import javax.xml.transform.TransformerException;
-
import org.apache.maven.doxia.document.DocumentCover;
import org.apache.maven.doxia.document.DocumentModel;
import org.apache.maven.doxia.markup.Markup;
import org.codehaus.plexus.util.WriterFactory;
+import org.junit.Before;
+import org.junit.Test;
import org.xml.sax.SAXParseException;
-
-import junit.framework.TestCase;
import org.xmlunit.matchers.CompareMatcher;
-import static org.junit.Assert.assertThat;
+import javax.xml.transform.TransformerException;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Test FoAggregateSink.
@@ -44,17 +44,14 @@ import static org.junit.Assert.assertThat;
* @version $Id$
*/
public class FoAggregateSinkTest
- extends TestCase
{
private FoAggregateSink sink;
private Writer writer;
- @Override
- protected void setUp()
- throws Exception
+ @Before
+ public void setUp()
{
- super.setUp();
writer = new StringWriter();
}
@@ -67,6 +64,7 @@ public class FoAggregateSinkTest
/**
* Test of body method, of class FoAggregateSink.
*/
+ @Test
public void testBody()
{
try
@@ -89,6 +87,7 @@ public class FoAggregateSinkTest
/**
* Test of setDocumentName method, of class FoAggregateSink.
*/
+ @Test
public void testSetDocumentName()
{
try
@@ -109,6 +108,7 @@ public class FoAggregateSinkTest
/**
* Test the FO PDF generation with some special characters in company name.
*/
+ @Test
public void testSpecialCharacters()
throws IOException, TransformerException
{
@@ -150,12 +150,9 @@ public class FoAggregateSinkTest
if ( ( e.getCause() != null ) && ( e.getCause() instanceof SAXParseException ) )
{
SAXParseException sax = (SAXParseException) e.getCause();
-
- StringBuilder sb = new StringBuilder();
- sb.append( "Error creating PDF from " ).append( foFile.getAbsolutePath() ).append( ":" ).append( sax.getLineNumber() ).append( ":" ).append( sax.getColumnNumber() ).append( "\n" );
- sb.append( e.getMessage() );
-
- throw new RuntimeException( sb.toString() );
+ String sb = "Error creating PDF from " + foFile.getAbsolutePath() + ":" + sax.getLineNumber() + ":"
+ + sax.getColumnNumber() + "\n" + e.getMessage();
+ throw new RuntimeException( sb );
}
throw new TransformerException( "Error creating PDF from " + foFile + ": " + e.getMessage() );
@@ -165,7 +162,8 @@ public class FoAggregateSinkTest
/**
* Test of figureGraphics method, of class FoAggregateSink.
*/
- public void testFigureGraphics() throws Exception
+ @Test
+ public void testFigureGraphics()
{
try
{
@@ -191,6 +189,7 @@ public class FoAggregateSinkTest
/**
* Test of anchor method, of class FoAggregateSink.
*/
+ @Test
public void testAnchor()
{
try
@@ -212,6 +211,7 @@ public class FoAggregateSinkTest
/**
* Test of link method, of class FoAggregateSink.
*/
+ @Test
public void testLink()
{
try
diff --git a/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoConfigurationTest.java b/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoConfigurationTest.java
index 6877f75..cc8b689 100644
--- a/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoConfigurationTest.java
+++ b/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoConfigurationTest.java
@@ -22,7 +22,9 @@ package org.apache.maven.doxia.module.fo;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* FoConfiguration tests.
@@ -30,10 +32,9 @@ import junit.framework.TestCase;
* @version $Id$
*/
public class FoConfigurationTest
- extends TestCase
{
-
/** Tests the getAttributeString( String ) method. */
+ @Test
public void testGetAttributeString()
{
FoConfiguration config = new FoConfiguration();
@@ -41,13 +42,14 @@ public class FoConfigurationTest
assertEquals( "Null attribute ID should return empty string!", "", config.getAttributeString( null ) );
assertEquals( "Non existent attribute ID should return empty string!", "",
- config.getAttributeString( "a.dummy.attribute" ) );
+ config.getAttributeString( "a.dummy.attribute" ) );
assertEquals( "Wrong attributes returned for italic!", " font-style=\"italic\"",
- config.getAttributeString( "italic" ) );
+ config.getAttributeString( "italic" ) );
}
/** Tests the getAttributeSet( String ) method. */
+ @Test
public void testGetAttributeSet()
{
FoConfiguration config = new FoConfiguration();
@@ -57,7 +59,7 @@ public class FoConfigurationTest
assertNull( "Empty attribute ID should return null AttributeSet!", config.getAttributeSet( "" ) );
assertNull( "Non existent attribute ID should return null AttributeSet!",
- config.getAttributeSet( "a.dummy.attribute" ) );
+ config.getAttributeSet( "a.dummy.attribute" ) );
MutableAttributeSet expected = new SimpleAttributeSet();
expected.addAttribute( "font-style", "italic" );
diff --git a/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/ITextUtilTest.java b/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/ITextUtilTest.java
index b7abfb1..83013b9 100644
--- a/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/ITextUtilTest.java
+++ b/doxia-modules/doxia-module-itext/src/test/java/org/apache/maven/doxia/module/itext/ITextUtilTest.java
@@ -21,19 +21,20 @@ package org.apache.maven.doxia.module.itext;
import java.util.Locale;
-import junit.framework.TestCase;
-
import com.lowagie.text.PageSize;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
*/
public class ITextUtilTest
- extends TestCase
{
+ @Test
public void testGetDefaultPageSize()
- throws Exception
{
Locale oldLocale = Locale.getDefault();
@@ -54,6 +55,7 @@ public class ITextUtilTest
}
}
+ @Test
public void testGetPageSize()
throws Exception
{
@@ -72,23 +74,23 @@ public class ITextUtilTest
assertEquals( "LEGAL", ITextUtil.getPageSize( PageSize.LEGAL ) );
}
+ @Test
public void testIsPageSupported()
- throws Exception
{
- assertEquals( true, ITextUtil.isPageSizeSupported( "A0" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A1" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A2" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A3" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A4" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A5" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A6" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A7" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A8" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A9" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "A10" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "LETTER" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "letter" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "LEGAL" ) );
- assertEquals( true, ITextUtil.isPageSizeSupported( "legal" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A0" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A1" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A2" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A3" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A4" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A5" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A6" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A7" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A8" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A9" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "A10" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "LETTER" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "letter" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "LEGAL" ) );
+ assertTrue( ITextUtil.isPageSizeSupported( "legal" ) );
}
}
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 126151a..50e1108 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,12 +22,13 @@ 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 junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
public class FlexmarkDoxiaLinkResolverTest
- extends TestCase
{
-
+ @Test
public void testResolveLink()
{
FlexmarkDoxiaLinkResolver flexmarkDoxiaLinkResolver = new FlexmarkDoxiaLinkResolver( null );
diff --git a/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java b/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
index 1297b61..75cbbf9 100644
--- a/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
+++ b/doxia-modules/doxia-module-rtf/src/test/java/org/apache/maven/doxia/module/rtf/RtfSinkTest.java
@@ -63,7 +63,6 @@ public class RtfSinkTest
/** {@inheritDoc} */
protected Reader getTestReader()
- throws Exception
{
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "test.apt" );
diff --git a/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/GenericListBlockParser.java b/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/GenericListBlockParser.java
index c9ea1f6..6731115 100644
--- a/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/GenericListBlockParser.java
+++ b/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/GenericListBlockParser.java
@@ -406,7 +406,7 @@ class TreeListBuilder
* @author Juan F. Codagnone
* @version $Id$
*/
- class TreeComponent
+ static class TreeComponent
{
/**
* childrens
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/AbstractBlockTestCase.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/AbstractBlockTestCase.java
index 122f01e..481d0e7 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/AbstractBlockTestCase.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/AbstractBlockTestCase.java
@@ -19,8 +19,6 @@ package org.apache.maven.doxia.module.twiki.parser;
* under the License.
*/
-import junit.framework.TestCase;
-
import org.apache.maven.doxia.module.twiki.TWikiParser;
/**
@@ -30,7 +28,6 @@ import org.apache.maven.doxia.module.twiki.TWikiParser;
* @since Nov 1, 2005
*/
public abstract class AbstractBlockTestCase
- extends TestCase
{
/**
* sectionParser to use in all the tests
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/BlockTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/BlockTest.java
index ecf9887..7711a8c 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/BlockTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/BlockTest.java
@@ -21,111 +21,82 @@ package org.apache.maven.doxia.module.twiki.parser;
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
- * Generic unit tests for
- * {@link Block}s
+ * Generic unit tests for {@link Block}s
*
* @author Juan F. Codagnone
* @since Nov 2, 2005
*/
public class BlockTest
- extends TestCase
{
-
- /**
- * @see TextBlock#equals(Object)
- */
+ @Test
public final void testTextBlockEquals()
{
- testEquals( new TextBlock( "bar" ), new TextBlock( "bar" ), new TextBlock( "foo" ) );
+ internaTestEquals( new TextBlock( "bar" ), new TextBlock( "bar" ), new TextBlock( "foo" ) );
}
- /**
- * @see WikiWordBlock#equals(Object)
- */
+ @Test
public final void testWikiWordBlockEquals()
{
final WikiWordLinkResolver resolver = new XHTMLWikiWordLinkResolver();
- testEquals( new WikiWordBlock( "bar", resolver ), new WikiWordBlock( "bar", resolver ),
+ internaTestEquals( new WikiWordBlock( "bar", resolver ), new WikiWordBlock( "bar", resolver ),
new WikiWordBlock( "foo", resolver ) );
- testEquals( new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ),
+ internaTestEquals( new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ),
new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ), new WikiWordBlock( "bar",
resolver ) );
- testEquals( new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ),
+ internaTestEquals( new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ),
new WikiWordBlock( "bar", new TextBlock( "text" ), resolver ),
new WikiWordBlock( "text", new TextBlock( "bar" ), resolver ) );
-
}
- /**
- * @see LinkBlock#equals(Object)
- */
+ @Test
public final void testLinkBlockEquals()
{
- testEquals( new LinkBlock( "foo", new TextBlock( "bar" ) ),
+ internaTestEquals( new LinkBlock( "foo", new TextBlock( "bar" ) ),
new LinkBlock( "foo", new TextBlock( "bar" ) ), new LinkBlock( "bar", new TextBlock( "foo" ) ) );
}
- /**
- * @see ListItemBlock#equals(Object)
- */
+ @Test
public final void testListBlockEquals()
{
final Block[] blocks = new Block[] { new TextBlock( "hello" ) };
- testEquals( new ListItemBlock( blocks ), new ListItemBlock( blocks ), new ListItemBlock( new Block[] {} ) );
+ internaTestEquals( new ListItemBlock( blocks ), new ListItemBlock( blocks ), new ListItemBlock( new Block[] {} ) );
}
- /**
- * @see ListItemBlock#equals(Object)
- */
+ @Test
public final void testNestedBlockEquals()
{
-
- testEquals( new ParagraphBlock( new Block[] { new BoldBlock( new Block[] { new TextBlock( "foo" ) } ) } ),
+ internaTestEquals( new ParagraphBlock( new Block[] { new BoldBlock( new Block[] { new TextBlock( "foo" ) } ) } ),
new ParagraphBlock( new Block[] { new BoldBlock( new Block[] { new TextBlock( "foo" ) } ) } ),
new ParagraphBlock( new Block[] { new BoldBlock( new Block[] { new TextBlock( "bar" ) } ) } ) );
}
- /**
- * @see AbstractFatherBlock#equals(Object)
- */
+ @Test
public final void testAbstractFatherBlockEquals()
{
- assertFalse( Arrays
- .equals(
- new Block[] {
- new TextBlock( "mary " ),
- new ItalicBlock(
- new Block[] { new MonospaceBlock(
- new Block[] { new TextBlock(
- "has" ) } ) } ) },
- new Block[] {
- new TextBlock( "mary " ),
- new BoldBlock(
- new Block[] { new MonospaceBlock(
- new Block[] { new TextBlock(
- "has" ) } ) } ) } ) );
+ assertFalse( Arrays.equals( new Block[] {new TextBlock( "mary " ), new ItalicBlock(
+ new Block[] {new MonospaceBlock( new Block[] {new TextBlock( "has" )} )} )},
+ new Block[] {new TextBlock( "mary " ), new BoldBlock(
+ new Block[] {new MonospaceBlock( new Block[] {new TextBlock( "has" )} )} )} ) );
}
- /**
- * @see AnchorBlock#equals(Object)
- */
+ @Test
public final void testAnchorBlockEquals()
{
- testEquals( new AnchorBlock( "anchor" ), new AnchorBlock( "anchor" ), new AnchorBlock( "anch" ) );
+ internaTestEquals( new AnchorBlock( "anchor" ), new AnchorBlock( "anchor" ), new AnchorBlock( "anch" ) );
}
- /**
- * @see HorizontalRuleBlock#equals(Object)
- */
+ @Test
public final void testHorizontalEquals()
{
- testEquals( new HorizontalRuleBlock(), new HorizontalRuleBlock(), "foo" );
+ internaTestEquals( new HorizontalRuleBlock(), new HorizontalRuleBlock(), "foo" );
}
/**
@@ -133,7 +104,8 @@ public class BlockTest
* @param b an object that is equals to a
* @param c a diferent object
*/
- public final void testEquals( final Object a, final Object b, final Object c )
+ @SuppressWarnings( "SimplifiableJUnitAssertion" )
+ private void internaTestEquals( final Object a, final Object b, final Object c )
{
assertFalse( a.equals( null ) );
assertFalse( b.equals( null ) );
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
index 0995a5c..207647f 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/FormatedTextTest.java
@@ -19,7 +19,10 @@ package org.apache.maven.doxia.module.twiki.parser;
* under the License.
*/
-import java.util.Arrays;
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
/**
* Tests the {@link org.apache.maven.doxia.module.twiki.parser.FormatedTextParser}
@@ -34,6 +37,7 @@ public class FormatedTextTest
/**
* test bold text
*/
+ @Test
public final void testBold()
{
String text;
@@ -46,24 +50,24 @@ public class FormatedTextTest
text = "foo *bold* bar";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new TextBlock( "foo " ),
- new BoldBlock( new Block[] { new TextBlock( "bold" ) } ), new TextBlock( " bar" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new TextBlock( "foo " ), new BoldBlock(
+ new Block[] {new TextBlock( "bold" )} ), new TextBlock( " bar" )}, blocks );
text = "\t*bold* bar";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new TextBlock( "\t" ),
- new BoldBlock( new Block[] { new TextBlock( "bold" ) } ), new TextBlock( " bar" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new TextBlock( "\t" ), new BoldBlock(
+ new Block[] {new TextBlock( "bold" )} ), new TextBlock( " bar" )}, blocks );
text = "*nice* foo *bold* bar";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new BoldBlock( new Block[] { new TextBlock( "nice" ) } ),
- new TextBlock( " foo " ), new BoldBlock( new Block[] { new TextBlock( "bold" ) } ),
- new TextBlock( " bar" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new BoldBlock( new Block[] {new TextBlock( "nice" )} ), new TextBlock(
+ " foo " ), new BoldBlock( new Block[] {new TextBlock( "bold" )} ), new TextBlock( " bar" )}, blocks );
}
/**
* test italic text
*/
+ @Test
public final void testItalic()
{
String text;
@@ -76,19 +80,20 @@ public class FormatedTextTest
text = "foo _italic_ bar";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new TextBlock( "foo " ),
- new ItalicBlock( new Block[] { new TextBlock( "italic" ) } ), new TextBlock( " bar" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new TextBlock( "foo " ), new ItalicBlock(
+ new Block[] {new TextBlock( "italic" )} ), new TextBlock( " bar" )}, blocks );
text = "_nice_ foo _italic_ bar";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new ItalicBlock( new Block[] { new TextBlock( "nice" ) } ),
- new TextBlock( " foo " ), new ItalicBlock( new Block[] { new TextBlock( "italic" ) } ),
- new TextBlock( " bar" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new ItalicBlock( new Block[] {new TextBlock( "nice" )} ), new TextBlock(
+ " foo " ), new ItalicBlock( new Block[] {new TextBlock( "italic" )} ), new TextBlock( " bar" )},
+ blocks );
}
/**
* test monospaced text
*/
+ @Test
public final void testMonospaced()
{
String text;
@@ -96,17 +101,17 @@ public class FormatedTextTest
text = "mary =has= a =little= lamb He followed her (=to school one day=)";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new TextBlock( "mary " ),
- new MonospaceBlock( new Block[] { new TextBlock( "has" ) } ), new TextBlock( " a " ),
- new MonospaceBlock( new Block[] { new TextBlock( "little" ) } ),
- new TextBlock( " lamb He followed her (" ),
- new MonospaceBlock( new Block[] { new TextBlock( "to school one day" ) } ), new TextBlock( ")" ) },
- blocks ) );
+ assertArrayEquals( new Block[] {new TextBlock( "mary " ), new MonospaceBlock(
+ new Block[] {new TextBlock( "has" )} ), new TextBlock( " a " ), new MonospaceBlock(
+ new Block[] {new TextBlock( "little" )} ), new TextBlock(
+ " lamb He followed her (" ), new MonospaceBlock(
+ new Block[] {new TextBlock( "to school one day" )} ), new TextBlock( ")" )}, blocks );
}
/**
* test monospaced text
*/
+ @Test
public final void testBoldMonospaced()
{
String text;
@@ -121,12 +126,13 @@ public class FormatedTextTest
new BoldBlock( new Block[] { new MonospaceBlock( new Block[] { new TextBlock( "little" ) } ) } ),
new TextBlock( " lamb" ) };
- assertTrue( Arrays.equals( expected, blocks ) );
+ assertArrayEquals( expected, blocks );
}
/**
* test monospaced text
*/
+ @Test
public final void testBoldItalic()
{
String text;
@@ -134,16 +140,17 @@ public class FormatedTextTest
text = "mary __has__ a __little__ lamb";
blocks = formatTextParser.parse( text );
- assertTrue( Arrays.equals( new Block[] { new TextBlock( "mary " ),
- new BoldBlock( new Block[] { new ItalicBlock( new Block[] { new TextBlock( "has" ) } ) } ),
- new TextBlock( " a " ),
- new BoldBlock( new Block[] { new ItalicBlock( new Block[] { new TextBlock( "little" ) } ) } ),
- new TextBlock( " lamb" ) }, blocks ) );
+ assertArrayEquals( new Block[] {new TextBlock( "mary " ), new BoldBlock(
+ new Block[] {new ItalicBlock( new Block[] {new TextBlock( "has" )} )} ), new TextBlock(
+ " a " ), new BoldBlock(
+ new Block[] {new ItalicBlock( new Block[] {new TextBlock( "little" )} )} ), new TextBlock( " lamb" )},
+ blocks );
}
/**
* test mixed formats side by side
*/
+ @Test
public final void testMultiFormatSideBySide()
{
String text;
@@ -158,13 +165,14 @@ public class FormatedTextTest
new TextBlock( " " ), new MonospaceBlock( new Block[] { new TextBlock( "no play" ) } ),
new TextBlock( " " ), new ItalicBlock( new Block[] { new TextBlock( "makes" ) } ),
new TextBlock( " Juan a dull " ), new BoldBlock( new Block[] { new TextBlock( "boy" ) } ) };
- assertTrue( Arrays.equals( expected, blocks ) );
+ assertArrayEquals( expected, blocks );
}
/**
* test mixed formats recursevily
*/
+ @Test
public final void testMultiFormatInside()
{
String text;
@@ -184,30 +192,31 @@ public class FormatedTextTest
new ItalicBlock( new Block[] { new TextBlock( "makes" ) } ),
new TextBlock( " Juan" ) } ), new TextBlock( " a dull" ) } ),
new TextBlock( " boy" ) };
- assertTrue( Arrays.equals( expected, blocks ) );
+ assertArrayEquals( expected, blocks );
}
/**
* test unbonded formats
*/
+ @Test
public final void testUnboundedFormat()
{
- testHanging( "All *work and no play makes Juan a dull boy" );
- testHanging( "All __work and no play makes Juan a dull boy" );
- testHanging( "All __work and *no play makes _Juan a = dull boy" );
- testHanging( "*" );
- testHanging( "==" );
- testHanging( "**" ); // hehe
- testHanging( "* hello *" );
- testHanging( "* hello =*" );
- testHanging( "*=_ hello _=*" );
+ internalTestHanging( "All *work and no play makes Juan a dull boy" );
+ internalTestHanging( "All __work and no play makes Juan a dull boy" );
+ internalTestHanging( "All __work and *no play makes _Juan a = dull boy" );
+ internalTestHanging( "*" );
+ internalTestHanging( "==" );
+ internalTestHanging( "**" ); // hehe
+ internalTestHanging( "* hello *" );
+ internalTestHanging( "* hello =*" );
+ internalTestHanging( "*=_ hello _=*" );
}
/**
* @param text unbonded text
*/
- public final void testHanging( final String text )
+ private void internalTestHanging( final String text )
{
- assertTrue( Arrays.equals( new Block[] { new TextBlock( text ) }, formatTextParser.parse( text ) ) );
+ assertArrayEquals( new Block[] {new TextBlock( text )}, formatTextParser.parse( text ) );
}
}
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ListTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ListTest.java
index 71fdfba..e369bd2 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ListTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ListTest.java
@@ -25,6 +25,10 @@ import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.util.ByLineSource;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.sink.Sink;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
/**
* Units tests for Lists
@@ -35,12 +39,12 @@ import org.apache.maven.doxia.sink.Sink;
public class ListTest
extends AbstractBlockTestCase
{
-
/**
* unit test for recurrent enumeration
*
* @throws ParseException on error
*/
+ @Test
public final void testList()
throws ParseException
{
@@ -78,9 +82,7 @@ public class ListTest
assertEquals( "item2.1", ( (TextBlock) item.getBlocks()[0] ).getText() );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testNumeringDecimal()
throws ParseException
{
@@ -97,9 +99,7 @@ public class ListTest
assertEquals( expected, blocks );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testHetero()
throws ParseException
{
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
index f9d7cec..0281865 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/ParagraphTest.java
@@ -20,10 +20,13 @@ package org.apache.maven.doxia.module.twiki.parser;
*/
import java.io.StringReader;
-import java.util.Arrays;
import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.parser.ParseException;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.*;
/**
* Tests the {@link org.apache.maven.doxia.module.twiki.parser.ParagraphBlockParser}
@@ -34,10 +37,7 @@ import org.apache.maven.doxia.parser.ParseException;
public class ParagraphTest
extends AbstractBlockTestCase
{
-
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testMultiLines()
throws ParseException
{
@@ -61,9 +61,7 @@ public class ParagraphTest
assertEquals( "para2 -> text1 para2 -> text2", ( (TextBlock) block.getBlocks()[0] ).getText() );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testParagraphWithList()
throws ParseException
{
@@ -121,9 +119,7 @@ public class ParagraphTest
assertEquals( "item2", ( (TextBlock) ( (ListItemBlock) listChilds[1] ).getBlocks()[0] ).getText() );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testHorizontalRule()
throws ParseException
{
@@ -148,9 +144,7 @@ public class ParagraphTest
assertEquals( expected, block );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testHorizontalRuleAndParagraph()
throws ParseException
{
@@ -162,6 +156,6 @@ public class ParagraphTest
new Block[] { new ParagraphBlock( new Block[] { new TextBlock( "Some text" ) } ),
new HorizontalRuleBlock(), new ParagraphBlock( new Block[] { new TextBlock( "More text" ) } ) };
blocks = twikiParser.parse( source ).toArray( new Block[] {} );
- assertTrue( Arrays.equals( expected, blocks ) );
+ assertArrayEquals( expected, blocks );
}
}
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
index 09a07de..fdcdbb2 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/SectionTest.java
@@ -20,10 +20,12 @@ package org.apache.maven.doxia.module.twiki.parser;
*/
import java.io.StringReader;
-import java.util.Arrays;
import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.parser.ParseException;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Tests the {@link org.apache.maven.doxia.module.twiki.parser.SectionBlockParser}
@@ -35,9 +37,7 @@ public class SectionTest
extends AbstractBlockTestCase
{
- /**
- * @see SectionBlock#SectionBlock(String, int, Block[])
- */
+ @Test
public final void testSectionBlockWrongArgs()
{
final int maxLevel = 5;
@@ -77,9 +77,7 @@ public class SectionTest
new SectionBlock( "", 1, new Block[] {} );
}
- /**
- * @see SectionBlockParser#getLevel(String)
- */
+ @Test
public final void testSectionParserGetLevel()
{
assertEquals( 2, SectionBlockParser.getLevel( "++" ) );
@@ -94,10 +92,7 @@ public class SectionTest
}
}
- /**
- * @throws java.lang.Exception
- * @see SectionBlockParser
- */
+ @Test
public final void testSectionParser()
throws Exception
{
@@ -137,6 +132,7 @@ public class SectionTest
*
* @throws Exception on error
*/
+ @Test
public final void testSectionWithParagraphs()
throws Exception
{
@@ -154,9 +150,7 @@ public class SectionTest
( (TextBlock) ( (ParagraphBlock) block.getBlocks()[1] ).getBlocks()[0] ).getText() );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testSectionAndParaAndHrule()
throws ParseException
{
@@ -171,6 +165,6 @@ public class SectionTest
new ParagraphBlock( new Block[] { new TextBlock( "Some text" ) } ), new HorizontalRuleBlock(),
new ParagraphBlock( new Block[] { new TextBlock( "More text" ) } ) } ) };
blocks = twikiParser.parse( source ).toArray( new Block[] {} );
- assertTrue( Arrays.equals( expected, blocks ) );
+ assertArrayEquals( expected, blocks );
}
}
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
index 3091a46..02f6fde 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TableTest.java
@@ -24,6 +24,9 @@ import java.io.StringReader;
import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.util.ByLineSource;
import org.apache.maven.doxia.parser.ParseException;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* Tests the {@link org.apache.maven.doxia.module.twiki.parser.TableBlockParser}
@@ -38,15 +41,14 @@ public class TableTest
/**
* unit test the regex
*/
+ @Test
public final void testRegex()
{
assertTrue( tableParser.accept( " | cell1 | cell2| " ) );
assertFalse( tableParser.accept( " | cell1 | cell" ) );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testTable()
throws ParseException
{
@@ -66,9 +68,7 @@ public class TableTest
assertEquals( block, expected );
}
- /**
- * @throws ParseException on error
- */
+ @Test
public final void testTableHeader()
throws ParseException
{
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TitleTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TitleTest.java
index 9ab9a98..1d5faf2 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TitleTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/TitleTest.java
@@ -24,6 +24,9 @@ import org.apache.maven.doxia.module.twiki.TWikiParser;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.util.ByLineSource;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
* Tests for {@link TWikiParser#getTitle(java.util.List)}
@@ -35,9 +38,8 @@ import org.apache.maven.doxia.util.ByLineSource;
public class TitleTest
extends AbstractBlockTestCase
{
-
- public void testSectionTitle()
- throws Exception
+ @Test
+ public void testSectionTitle() throws Exception
{
final ByLineSource source = new ByLineReaderSource( new StringReader( "---++ Test\n hello world" ) );
@@ -46,86 +48,79 @@ public class TitleTest
assertEquals( "Test", parser.getTitle( parser.parse( source ), source ) );
}
- public void testNoSectionTitle()
- throws Exception
+ @Test
+ public void testNoSectionTitle() throws Exception
{
- final ByLineSource source =
- new NamedByLineSource( new ByLineReaderSource( new StringReader( "hello world" ) ), "testpage" );
+ final ByLineSource source = new NamedByLineSource( new ByLineReaderSource( new StringReader( "hello world" ) ),
+ "testpage" );
final TWikiParser parser = new TWikiParser();
assertEquals( "testpage", parser.getTitle( parser.parse( source ), source ) );
}
- public void testNoSectionTwikiExtensionTitle()
- throws Exception
+ @Test
+ public void testNoSectionTwikiExtensionTitle() throws Exception
{
- final ByLineSource source =
- new NamedByLineSource( new ByLineReaderSource( new StringReader( "hello world" ) ), "testpage.twiki" );
+ final ByLineSource source = new NamedByLineSource( new ByLineReaderSource( new StringReader( "hello world" ) ),
+ "testpage.twiki" );
final TWikiParser parser = new TWikiParser();
assertEquals( "testpage", parser.getTitle( parser.parse( source ), source ) );
}
-}
-
-class NamedByLineSource
- implements ByLineSource
-{
- /** reader */
- private final ByLineReaderSource reader;
+ static class NamedByLineSource implements ByLineSource
+ {
+ /**
+ * reader
+ */
+ private final ByLineReaderSource reader;
- /** reader's name */
- private final String name;
+ /**
+ * reader's name
+ */
+ private final String name;
- public NamedByLineSource( final ByLineReaderSource reader, final String name )
- {
- if ( reader == null || name == null )
+ public NamedByLineSource( final ByLineReaderSource reader, final String name )
{
- throw new IllegalArgumentException( "null arguments are not allowed" );
- }
+ if ( reader == null || name == null )
+ {
+ throw new IllegalArgumentException( "null arguments are not allowed" );
+ }
- this.reader = reader;
- this.name = name;
- }
+ this.reader = reader;
+ this.name = name;
+ }
- /** @see ByLineReaderSource#close() */
- public final void close()
- {
- reader.close();
- }
+ public final void close()
+ {
+ reader.close();
+ }
- /** @see ByLineReaderSource#getLineNumber() */
- public final int getLineNumber()
- {
- return reader.getLineNumber();
- }
+ public final int getLineNumber()
+ {
+ return reader.getLineNumber();
+ }
- /** @see ByLineReaderSource#getName() */
- public final String getName()
- {
- return name;
- }
+ public final String getName()
+ {
+ return name;
+ }
- /** @see ByLineReaderSource#getNextLine() */
- public final String getNextLine()
- throws ParseException
- {
- return reader.getNextLine();
- }
+ public final String getNextLine() throws ParseException
+ {
+ return reader.getNextLine();
+ }
- /** @see ByLineReaderSource#unget(java.lang.String) */
- public final void unget( final String s )
- throws IllegalStateException
- {
- reader.unget( s );
- }
+ public final void unget( final String s ) throws IllegalStateException
+ {
+ reader.unget( s );
+ }
- /** @see ByLineReaderSource#ungetLine() */
- public final void ungetLine()
- throws IllegalStateException
- {
- reader.ungetLine();
+ public final void ungetLine() throws IllegalStateException
+ {
+ reader.ungetLine();
+ }
}
}
\ No newline at end of file
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/VerbatimTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/VerbatimTest.java
index 3f99927..829b0dd 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/VerbatimTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/VerbatimTest.java
@@ -1,13 +1,14 @@
package org.apache.maven.doxia.module.twiki.parser;
-import static org.junit.Assert.assertArrayEquals;
-
import java.io.StringReader;
import java.util.List;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.util.ByLineReaderSource;
import org.apache.maven.doxia.util.ByLineSource;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -41,6 +42,7 @@ public class VerbatimTest
/**
* unit test the regex
*/
+ @Test
public final void testRegex()
{
assertTrue( getVerbatimParser().accept( "<verbatim>" ) );
@@ -53,6 +55,7 @@ public class VerbatimTest
* @throws ParseException if the parser does not accept the line
*
*/
+ @Test
public void testVerbatim()
throws ParseException
{
@@ -72,9 +75,7 @@ public class VerbatimTest
assertEquals( block, expected );
}
- /**
- * @throws Exception .
- */
+ @Test
public void testTwiki()
throws Exception
{
@@ -96,9 +97,7 @@ public class VerbatimTest
}
- /** test
- * @throws org.apache.maven.doxia.parser.ParseException
- */
+ @Test
public void testVerbatimAfterSection()
throws ParseException
{
diff --git a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
index a8ba000..2f69ba1 100644
--- a/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
+++ b/doxia-modules/doxia-module-twiki/src/test/java/org/apache/maven/doxia/module/twiki/parser/WordsTest.java
@@ -19,6 +19,8 @@ package org.apache.maven.doxia.module.twiki.parser;
* under the License.
*/
+import org.junit.Test;
+
import static org.junit.Assert.assertArrayEquals;
/**
@@ -40,9 +42,7 @@ public class WordsTest
*/
private final WikiWordLinkResolver resolver = new XHTMLWikiWordLinkResolver();
- /**
- * ...
- */
+ @Test
public final void testText()
{
Block[] blocks, expected;
@@ -52,9 +52,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testWikiWords()
{
Block[] blocks, expected;
@@ -81,9 +79,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testWebWikiWords()
{
Block[] blocks, expected;
@@ -97,9 +93,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testWebAnchorWikiWords()
{
Block[] blocks, expected;
@@ -117,6 +111,7 @@ public class WordsTest
/**
* test Specific Links
*/
+ @Test
public final void testURLSpecificLinks()
{
Block[] blocks, expected;
@@ -154,6 +149,7 @@ public class WordsTest
/**
* test Specific Links with wikiWords
*/
+ @Test
public final void testWikiSpecificLinks()
{
Block[] blocks, expected;
@@ -178,6 +174,7 @@ public class WordsTest
/**
* test Specific Links
*/
+ @Test
public final void testSpecificLinkPrevention()
{
Block[] blocks, expected;
@@ -187,9 +184,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testPreventLinkingWikiWord()
{
Block[] blocks, expected;
@@ -206,6 +201,7 @@ public class WordsTest
/**
* ej [[Main.TWiki rules]] would be wikiword Main.TWikiRules
*/
+ @Test
public final void testForcedLinks()
{
Block[] blocks, expected;
@@ -232,9 +228,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testMailtoForcedLinks()
{
Block[] blocks, expected;
@@ -244,9 +238,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * ...
- */
+ @Test
public final void testAnchors()
{
Block[] blocks, expected;
@@ -266,9 +258,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /**
- * unit test
- */
+ @Test
public final void testAutomaticLink()
{
Block[] blocks, expected;
@@ -281,7 +271,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /** unit test */
+ @Test
public final void testAutomaticImage()
{
Block[] blocks, expected;
@@ -292,7 +282,7 @@ public class WordsTest
assertArrayEquals( expected, blocks );
}
- /** unit test */
+ @Test
public final void testLinkImage()
{
Block[] blocks, expected;
@@ -308,6 +298,7 @@ public class WordsTest
/**
* Test image inserted with a html img tag
*/
+ @Test
public final void testRelativeImage()
{
Block[] blocks, expected;
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 c31367c..c24ad4d 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
@@ -174,7 +174,7 @@ public class XdocParserTest
// No section, only subsection 1 and 2
assertTrue( content.contains( "<a href=\"#Section_11\">Section 11</a>" ) );
- assertTrue( !content.contains( "<a href=\"#Section_1211\">Section 1211</a>" ) );
+ assertFalse( content.contains( "<a href=\"#Section_1211\">Section 1211</a>" ) );
}
private Iterator<SinkEventElement> parseText( String text )
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 3b392b0..e873fa4 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,7 +22,6 @@ 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.apache.maven.doxia.util.HtmlTools;
import java.io.StringWriter;
import java.io.Writer;
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 4a7ea38..124e8ac 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
@@ -72,7 +72,6 @@ public class XdocValidatorTest
@Override
public void testValidateFiles()
- throws Exception
{
// TODO: super.testValidateFiles() only validates files from doxia-test-docs, what's the point?
}
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 27f7d93..f9a5510 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
@@ -58,10 +58,8 @@ public class XhtmlSinkTest
/**
* Test link generation.
*
- * @throws java.lang.Exception if any.
*/
public void testLinks()
- throws Exception
{
XhtmlSink sink = null;
Writer writer = new StringWriter();
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 ea42b53..36e0271 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
@@ -54,10 +54,8 @@ public class Xhtml5SinkTest
/**
* Test link generation.
*
- * @throws java.lang.Exception if any.
*/
public void testLinks()
- throws Exception
{
Xhtml5Sink sink = null;
Writer writer = new StringWriter();