You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2009/03/28 21:59:08 UTC
svn commit: r759585 - in /maven/doxia/doxia/trunk/doxia-core/src/test:
java/org/apache/maven/doxia/macro/ java/org/apache/maven/doxia/macro/snippet/
java/org/apache/maven/doxia/macro/toc/ java/org/apache/maven/doxia/parser/
java/org/apache/maven/doxia/...
Author: ltheussl
Date: Sat Mar 28 20:59:07 2009
New Revision: 759585
URL: http://svn.apache.org/viewvc?rev=759585&view=rev
Log:
Improve our test coverage
Added:
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java (with props)
maven/doxia/doxia/trunk/doxia-core/src/test/resources/
maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/
maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/
maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt (with props)
Modified:
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/XhtmlBaseSinkTest.java
maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,81 @@
+package org.apache.maven.doxia.macro;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.doxia.sink.SinkEventElement;
+import org.apache.maven.doxia.sink.SinkEventTestingSink;
+
+/**
+ * Test echo macro.
+ *
+ * @author ltheussl
+ */
+public class EchoMacroTest
+ extends TestCase
+{
+
+ /**
+ * Test of execute method, of class EchoMacro.
+ */
+ public void testExecute()
+ {
+ Map macroParameters = new HashMap();
+ macroParameters.put( "paramName", "paramValue" );
+ macroParameters.put( "parser", "parserValue" );
+ macroParameters.put( "sourceContent", "sourceContentValue" );
+
+ SinkEventTestingSink sink = new SinkEventTestingSink();
+ MacroRequest request = new MacroRequest( macroParameters, new File( "." ) );
+
+ new EchoMacro().execute( sink, request );
+
+ Iterator it = sink.getEventList().iterator();
+ SinkEventElement event = (SinkEventElement) it.next();
+ assertEquals( "verbatim", event.getName() );
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "echo" + Macro.EOL, (String) event.getArgs()[0] );
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "paramName ---> paramValue" + Macro.EOL, (String) event.getArgs()[0] );
+ event = (SinkEventElement) it.next();
+ assertEquals( "verbatim_", event.getName() );
+ assertFalse( it.hasNext() );
+ }
+
+ /**
+ * Test log.
+ */
+ public void testLog()
+ {
+ EchoMacro macro = new EchoMacro();
+ macro.enableLogging( null );
+ assertNotNull ( macro.getLog() );
+ assertNotNull ( macro.getLog() );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/EchoMacroTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,109 @@
+package org.apache.maven.doxia.macro;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.doxia.sink.SinkEventElement;
+import org.apache.maven.doxia.sink.SinkEventTestingSink;
+
+/**
+ * Test swf macro.
+ *
+ * @author ltheussl
+ */
+public class SwfMacroTest
+ extends TestCase
+{
+
+ /**
+ * Test of execute method, of class SwfMacro.
+ *
+ * @throws MacroExecutionException if a macro fails during testing.
+ */
+ public void testExecute()
+ throws MacroExecutionException
+ {
+
+ Map macroParameters = new HashMap();
+ macroParameters.put( "src", "src.swf" );
+ macroParameters.put( "id", "Movie" );
+ macroParameters.put( "width", "50" );
+ macroParameters.put( "height", "60" );
+ macroParameters.put( "quality", "best" );
+ macroParameters.put( "menu", "true" );
+ macroParameters.put( "loop", "3" );
+ macroParameters.put( "play", "false" );
+ macroParameters.put( "version", "6" );
+ macroParameters.put( "allowScript", "always" );
+
+
+ SinkEventTestingSink sink = new SinkEventTestingSink();
+ MacroRequest request = new MacroRequest( macroParameters, new File( "." ) );
+ SwfMacro macro = new SwfMacro();
+ macro.required( "src", "value" );
+
+ try
+ {
+ macro.required( "src", "" );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertNotNull( e );
+ }
+
+ try
+ {
+ macro.required( "src", null );
+ fail();
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertNotNull( e );
+ }
+
+ macro.execute( sink, request );
+
+ Iterator it = sink.getEventList().iterator();
+ SinkEventElement event = (SinkEventElement) it.next();
+
+ assertEquals( "rawText", event.getName() );
+ assertFalse( it.hasNext() );
+
+ request = new MacroRequest( new HashMap(), new File( "." ) );
+ sink.reset();
+
+ macro.execute( sink, request );
+
+ it = sink.getEventList().iterator();
+ event = (SinkEventElement) it.next();
+
+ assertEquals( "rawText", event.getName() );
+ assertFalse( it.hasNext() );
+ }
+
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/SwfMacroTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,117 @@
+package org.apache.maven.doxia.macro.snippet;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.maven.doxia.macro.MacroExecutionException;
+import org.apache.maven.doxia.macro.MacroRequest;
+import org.apache.maven.doxia.sink.SinkEventElement;
+import org.apache.maven.doxia.sink.SinkEventTestingSink;
+
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Test snippet macro.
+ *
+ * @author ltheussl
+ */
+public class SnippetMacroTest
+ extends PlexusTestCase
+{
+ /**
+ * Test of execute method, of class SnippetMacro.
+ *
+ * @throws MacroExecutionException if a macro fails during testing.
+ */
+ public void testExecute()
+ throws MacroExecutionException
+ {
+ File basedir = new File( getBasedir() );
+ Map macroParameters = new HashMap();
+ macroParameters.put( "file", "src/test/resources/macro/snippet/testSnippet.txt" );
+
+ SinkEventTestingSink sink = new SinkEventTestingSink();
+
+ MacroRequest request = new MacroRequest( macroParameters, basedir );
+ SnippetMacro macro = new SnippetMacro();
+ macro.execute( sink, request );
+
+ Iterator it = sink.getEventList().iterator();
+ assertEquals( "verbatim", ( (SinkEventElement) it.next() ).getName() );
+ SinkEventElement event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ String snippet = (String) event.getArgs()[0];
+ assertEquals( "verbatim_", ( (SinkEventElement) it.next() ).getName() );
+ assertFalse( it.hasNext() );
+
+ assertTrue( snippet.indexOf( "preamble" ) != -1 );
+ assertTrue( snippet.indexOf( "first snippet" ) != -1 );
+ assertTrue( snippet.indexOf( "interlude" ) != -1 );
+ assertTrue( snippet.indexOf( "second snippet" ) != -1 );
+ assertTrue( snippet.indexOf( "conclusion" ) != -1 );
+
+ // again
+
+ macroParameters.put( "id", "firstId" );
+ macroParameters.put( "verbatim", "" );
+ sink.reset();
+ request = new MacroRequest( macroParameters, basedir );
+ macro.execute( sink, request );
+
+ it = sink.getEventList().iterator();
+ assertEquals( "verbatim", ( (SinkEventElement) it.next() ).getName() );
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ snippet = (String) event.getArgs()[0];
+ assertEquals( "verbatim_", ( (SinkEventElement) it.next() ).getName() );
+ assertFalse( it.hasNext() );
+
+ assertTrue( snippet.indexOf( "preamble" ) == -1 );
+ assertTrue( snippet.indexOf( "first snippet" ) != -1 );
+ assertTrue( snippet.indexOf( "interlude" ) == -1 );
+ assertTrue( snippet.indexOf( "second snippet" ) == -1 );
+ assertTrue( snippet.indexOf( "conclusion" ) == -1 );
+
+ // again
+
+ macroParameters.put( "id", "secondId" );
+ macroParameters.put( "verbatim", "false" );
+ sink.reset();
+ request = new MacroRequest( macroParameters, basedir );
+ macro.execute( sink, request );
+
+ it = sink.getEventList().iterator();
+ event = (SinkEventElement) it.next();
+ assertEquals( "rawText", event.getName() );
+ snippet = (String) event.getArgs()[0];
+ assertFalse( it.hasNext() );
+
+ assertTrue( snippet.indexOf( "preamble" ) == -1 );
+ assertTrue( snippet.indexOf( "first snippet" ) == -1 );
+ assertTrue( snippet.indexOf( "interlude" ) == -1 );
+ assertTrue( snippet.indexOf( "second snippet" ) != -1 );
+ assertTrue( snippet.indexOf( "conclusion" ) == -1 );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/snippet/SnippetMacroTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,138 @@
+package org.apache.maven.doxia.macro.toc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+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;
+import org.apache.maven.doxia.sink.SinkEventElement;
+import org.apache.maven.doxia.sink.SinkEventTestingSink;
+
+/**
+ * Test toc macro.
+ *
+ * @author ltheussl
+ */
+public class TocMacroTest
+ extends TestCase
+{
+
+ /**
+ * Test of execute method, of class TocMacro.
+ *
+ * @throws MacroExecutionException if a macro fails during testing.
+ */
+ public void testExecute()
+ throws MacroExecutionException
+ {
+ String sourceContent = "<div><h2>h21</h2><h2>h22</h2><h3>h3</h3><h4>h4</h4><h2>h23</h2></div>";
+
+ XhtmlBaseParser parser = new XhtmlBaseParser();
+ parser.setSecondParsing( true );
+
+ Map macroParameters = new HashMap();
+ macroParameters.put( "parser", parser );
+ macroParameters.put( "sourceContent", sourceContent );
+ macroParameters.put( "section", "sec1" );
+
+ File basedir = new File( "" );
+
+ SinkEventTestingSink sink = new SinkEventTestingSink();
+ MacroRequest request = new MacroRequest( macroParameters, basedir );
+ TocMacro macro = new TocMacro();
+ macro.execute( sink, request );
+
+ Iterator it = sink.getEventList().iterator();
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "text", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "text", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "text", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "text", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "text", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+ assertFalse( it.hasNext() );
+
+ // test parameters
+
+ parser = new XhtmlBaseParser();
+ parser.setSecondParsing( true );
+ macroParameters.put( "parser", parser );
+ macroParameters.put( "section", "2" );
+ macroParameters.put( "fromDepth", "1" );
+ macroParameters.put( "toDepth", "2" );
+
+ sink.reset();
+ request = new MacroRequest( macroParameters, basedir );
+ macro.execute( sink, request );
+
+ it = sink.getEventList().iterator();
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ SinkEventElement event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "h22", (String) event.getArgs()[0] );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "h3", (String) event.getArgs()[0] );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+ assertFalse( it.hasNext() );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/macro/toc/TocMacroTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java?rev=759585&r1=759584&r2=759585&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/parser/XhtmlBaseParserTest.java Sat Mar 28 20:59:07 2009
@@ -21,6 +21,7 @@
import java.util.Iterator;
+import org.apache.maven.doxia.logging.Log;
import org.apache.maven.doxia.sink.SinkEventElement;
import org.apache.maven.doxia.sink.SinkEventTestingSink;
@@ -45,6 +46,7 @@
super.setUp();
parser = new XhtmlBaseParser();
+ parser.getLog().setLogLevel( Log.LEVEL_ERROR );
sink.reset();
}
@@ -347,4 +349,178 @@
event = (SinkEventElement) it.next();
assertEquals( "bold_", event.getName() );
}
+
+ /** @throws Exception */
+ public void testDecoration()
+ throws Exception
+ {
+ String text = "<div><u>u</u><s>s</s><del>del</del><strike>strike</strike><sub>sub</sub><sup>sup</sup></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ SinkEventElement event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "u", (String) event.getArgs()[0] );
+
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "s", (String) event.getArgs()[0] );
+
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "del", (String) event.getArgs()[0] );
+
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "strike", (String) event.getArgs()[0] );
+
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "sub", (String) event.getArgs()[0] );
+
+ event = (SinkEventElement) it.next();
+ assertEquals( "text", event.getName() );
+ assertEquals( "sup", (String) event.getArgs()[0] );
+// assertTrue( ( (SinkEventAttributeSet) event.getArgs()[1] )
+// .containsAttribute( SinkEventAttributeSet.VALIGN, "sup" ) ); // TODO
+ }
+
+ /** @throws Exception */
+ public void testLists()
+ throws Exception
+ {
+ String text = "<div><ul><li></li></ul><ol><li></li></ol><dl><dt></dt><dd></dd></dl></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "list", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "listItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "list_", ( (SinkEventElement) it.next() ).getName() );
+
+ assertEquals( "numberedList", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "numberedListItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "numberedListItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "numberedList_", ( (SinkEventElement) it.next() ).getName() );
+
+ assertEquals( "definitionList", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definitionListItem", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definedTerm", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definedTerm_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definition", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definition_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definitionListItem_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "definitionList_", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testStyles()
+ throws Exception
+ {
+ String text = "<div><b></b><strong></strong><i></i><em></em><code></code><samp></samp><tt></tt></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "bold", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "bold_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "bold", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "bold_", ( (SinkEventElement) it.next() ).getName() );
+
+ assertEquals( "italic", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "italic_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "italic", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "italic_", ( (SinkEventElement) it.next() ).getName() );
+
+ assertEquals( "monospaced", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "monospaced_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "monospaced", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "monospaced_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "monospaced", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "monospaced_", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testSimpleTags()
+ throws Exception
+ {
+ String text = "<div><br/><hr/><img src=\"img.src\"/></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "lineBreak", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "horizontalRule", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "figureGraphics", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testSpecial()
+ throws Exception
+ {
+ String text = "<p><!-- a pagebreak: --><!-- PB -->  <unknown /></p>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "paragraph", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "comment", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "pageBreak", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "nonBreakingSpace", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "nonBreakingSpace", ( (SinkEventElement) it.next() ).getName() );
+ // unknown events are not reported by the base parser
+ assertEquals( "paragraph_", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testTable()
+ throws Exception
+ {
+ String text = "<table><caption></caption><tr><th></th></tr><tr><td></td></tr></table>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "table", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRows", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableCaption", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableCaption_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRow", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableHeaderCell", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableHeaderCell_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRow_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRow", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableCell", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableCell_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRow_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "tableRows_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "table_", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testFigure()
+ throws Exception
+ {
+ String text = "<div class=\"figure\"><p><img src=\"src.jpg\"/></p><p><i></i></p></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "figure", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "figureGraphics", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "figureCaption", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "figureCaption_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "figure_", ( (SinkEventElement) it.next() ).getName() );
+ }
+
+ /** @throws Exception */
+ public void testAnchorLink()
+ throws Exception
+ {
+ String text = "<div><a href=\"\"></a><a name=\"valid\"></a><a id=\"1invalid\"></a></div>";
+ parser.parse( text, sink );
+ Iterator it = sink.getEventList().iterator();
+
+ assertEquals( "link", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "link_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "anchor", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "anchor_", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "anchor", ( (SinkEventElement) it.next() ).getName() );
+ assertEquals( "anchor_", ( (SinkEventElement) it.next() ).getName() );
+ }
}
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,133 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.swing.text.html.HTML.Tag;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author ltheussl
+ */
+public class AbstractXmlSinkTest
+ extends TestCase
+{
+ /**
+ * Test of set/getNameSpace method, of class AbstractXmlSink.
+ */
+ public void testNameSpace()
+ {
+ final Tag t = Tag.A;
+ final String ns = "ns";
+ final XmlTestSink instance = new XmlTestSink();
+
+ instance.writeStartTag( t );
+ instance.writeEndTag( t );
+ assertEquals( "<a></a>", instance.getText() );
+
+ instance.writeSimpleTag( t );
+ assertEquals( "<a />", instance.getText() );
+
+ instance.setNameSpace( ns );
+
+ instance.writeStartTag( t );
+ instance.writeEndTag( t );
+ assertEquals( "<ns:a></ns:a>", instance.getText() );
+
+ instance.writeSimpleTag( t );
+ assertEquals( "<ns:a />", instance.getText() );
+ }
+
+ /**
+ * Test of writeStartTag method, of class AbstractXmlSink.
+ */
+ public void testWriteStartTag()
+ {
+ final Tag t = Tag.A;
+ final SinkEventAttributes att = new SinkEventAttributeSet( SinkEventAttributeSet.BOLD );
+ final XmlTestSink instance = new XmlTestSink();
+
+ instance.writeStartTag( t );
+ assertEquals( "<a>", instance.getText() );
+
+ instance.writeStartTag( t, att );
+ assertEquals( "<a style=\"bold\">", instance.getText() );
+
+ instance.writeStartTag( t, att, false );
+ assertEquals( "<a style=\"bold\">", instance.getText() );
+
+ instance.writeStartTag( t, att, true );
+ assertEquals( "<a style=\"bold\" />", instance.getText() );
+ }
+
+ /**
+ * Test of writeEOL method, of class AbstractXmlSink.
+ */
+ public void testWriteEOL()
+ {
+ final XmlTestSink instance = new XmlTestSink();
+
+ instance.writeEOL();
+ assertEquals( System.getProperty( "line.separator" ), instance.getText() );
+ }
+
+ /**
+ * Test of writeSimpleTag method, of class AbstractXmlSink.
+ */
+ public void testWriteSimpleTag()
+ {
+ final Tag t = Tag.A;
+ final SinkEventAttributes att = new SinkEventAttributeSet( SinkEventAttributeSet.BOLD );
+ final XmlTestSink instance = new XmlTestSink();
+
+ instance.writeSimpleTag( t );
+ assertEquals( "<a />", instance.getText() );
+
+ instance.writeSimpleTag( t, att );
+ assertEquals( "<a style=\"bold\" />", instance.getText() );
+ }
+
+ /** Test sink. */
+ private class XmlTestSink
+ extends AbstractXmlSink
+ {
+ private final StringBuffer buffer = new StringBuffer( 0 );
+
+ public void reset()
+ {
+ buffer.setLength( 0 );
+ }
+
+ public String getText()
+ {
+ String text = buffer.toString();
+ reset();
+
+ return text;
+ }
+
+ protected void write( String text )
+ {
+ buffer.append( text );
+ }
+
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/AbstractXmlSinkTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,554 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author ltheussl
+ */
+public class SinkAdapterTest
+ extends TestCase
+{
+ private final SinkAdapter instance = new SinkAdapter();
+
+ /**
+ * Test of head method, of class SinkAdapter.
+ */
+ public void testHead()
+ {
+ instance.head();
+ instance.head( null );
+ instance.head_();
+ }
+
+ /**
+ * Test of body method, of class SinkAdapter.
+ */
+ public void testBody()
+ {
+ instance.body();
+ instance.body( null );
+ instance.body_();
+ }
+
+ /**
+ * Test of section1 method, of class SinkAdapter.
+ */
+ public void testSection1()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_1;
+ instance.section1();
+ instance.section1_();
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of section2 method, of class SinkAdapter.
+ */
+ public void testSection2()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_2;
+ instance.section2();
+ instance.section2_();
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of section3 method, of class SinkAdapter.
+ */
+ public void testSection3()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_3;
+ instance.section3();
+ instance.section3_();
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of section4 method, of class SinkAdapter.
+ */
+ public void testSection4()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_4;
+ instance.section4();
+ instance.section4_();
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of section5 method, of class SinkAdapter.
+ */
+ public void testSection5()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_5;
+ instance.section5();
+ instance.section5_();
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of list method, of class SinkAdapter.
+ */
+ public void testList()
+ {
+ instance.list();
+ instance.list( null );
+ instance.list_();
+ }
+
+ /**
+ * Test of listItem method, of class SinkAdapter.
+ */
+ public void testListItem()
+ {
+ instance.listItem();
+ instance.listItem( null );
+ instance.listItem_();
+ }
+
+ /**
+ * Test of numberedList method, of class SinkAdapter.
+ */
+ public void testNumberedList()
+ {
+ final int numbering = SinkAdapter.NUMBERING_DECIMAL;
+ instance.numberedList( numbering );
+ instance.numberedList( numbering, null );
+ instance.numberedList_();
+ }
+
+ /**
+ * Test of numberedListItem method, of class SinkAdapter.
+ */
+ public void testNumberedListItem()
+ {
+ instance.numberedListItem();
+ instance.numberedListItem( null );
+ instance.numberedListItem_();
+ }
+
+ /**
+ * Test of definitionList method, of class SinkAdapter.
+ */
+ public void testDefinitionList()
+ {
+ instance.definitionList();
+ instance.definitionList( null );
+ instance.definitionList_();
+ }
+
+ /**
+ * Test of definitionListItem method, of class SinkAdapter.
+ */
+ public void testDefinitionListItem()
+ {
+ instance.definitionListItem();
+ instance.definitionListItem( null );
+ instance.definitionListItem_();
+ }
+
+ /**
+ * Test of definition method, of class SinkAdapter.
+ */
+ public void testDefinition()
+ {
+ instance.definition();
+ instance.definition( null );
+ instance.definition_();
+ }
+
+ /**
+ * Test of figure method, of class SinkAdapter.
+ */
+ public void testFigure()
+ {
+ instance.figure();
+ instance.figure( null );
+ instance.figure_();
+ }
+
+ /**
+ * Test of table method, of class SinkAdapter.
+ */
+ public void testTable()
+ {
+ instance.table();
+ instance.table( null );
+ instance.table_();
+ }
+
+ /**
+ * Test of tableRows method, of class SinkAdapter.
+ */
+ public void testTableRows()
+ {
+ final int[] justification = null;
+ final boolean grid = false;
+ instance.tableRows( justification, grid );
+ instance.tableRows_();
+ }
+
+ /**
+ * Test of tableRow method, of class SinkAdapter.
+ */
+ public void testTableRow()
+ {
+ instance.tableRow();
+ instance.tableRow( null );
+ instance.tableRow_();
+ }
+
+ /**
+ * Test of title method, of class SinkAdapter.
+ */
+ public void testTitle()
+ {
+ instance.title();
+ instance.title( null );
+ instance.title_();
+ }
+
+ /**
+ * Test of author method, of class SinkAdapter.
+ */
+ public void testAuthor()
+ {
+ instance.author();
+ instance.author( null );
+ instance.author_();
+ }
+
+ /**
+ * Test of date method, of class SinkAdapter.
+ */
+ public void testDate()
+ {
+ instance.date();
+ instance.date( null );
+ instance.date_();
+ }
+
+ /**
+ * Test of sectionTitle method, of class SinkAdapter.
+ */
+ public void testSectionTitle()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_1;
+ instance.sectionTitle();
+ instance.sectionTitle_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of sectionTitle1 method, of class SinkAdapter.
+ */
+ public void testSectionTitle1()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_1;
+ instance.sectionTitle1();
+ instance.sectionTitle1_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of sectionTitle2 method, of class SinkAdapter.
+ */
+ public void testSectionTitle2()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_2;
+ instance.sectionTitle2();
+ instance.sectionTitle2_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of sectionTitle3 method, of class SinkAdapter.
+ */
+ public void testSectionTitle3()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_3;
+ instance.sectionTitle3();
+ instance.sectionTitle3_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of sectionTitle4 method, of class SinkAdapter.
+ */
+ public void testSectionTitle4()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_4;
+ instance.sectionTitle4();
+ instance.sectionTitle4_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of sectionTitle5 method, of class SinkAdapter.
+ */
+ public void testSectionTitle5()
+ {
+ final int level = SinkAdapter.SECTION_LEVEL_5;
+ instance.sectionTitle5();
+ instance.sectionTitle5_();
+ instance.sectionTitle( level, null );
+ instance.sectionTitle_( level );
+ }
+
+ /**
+ * Test of paragraph method, of class SinkAdapter.
+ */
+ public void testParagraph()
+ {
+ instance.paragraph();
+ instance.paragraph( null );
+ instance.paragraph_();
+ }
+
+ /**
+ * Test of verbatim method, of class SinkAdapter.
+ */
+ public void testVerbatim()
+ {
+ instance.verbatim( null );
+ instance.verbatim( false );
+ instance.verbatim_();
+ }
+
+ /**
+ * Test of definedTerm method, of class SinkAdapter.
+ */
+ public void testDefinedTerm()
+ {
+ instance.definedTerm();
+ instance.definedTerm( null );
+ instance.definedTerm_();
+ }
+
+ /**
+ * Test of figureCaption method, of class SinkAdapter.
+ */
+ public void testFigureCaption()
+ {
+ instance.figureCaption();
+ instance.figureCaption( null );
+ instance.figureCaption_();
+ }
+
+ /**
+ * Test of tableCell method, of class SinkAdapter.
+ */
+ public void testTableCell()
+ {
+ instance.tableCell();
+ instance.tableCell( (SinkEventAttributes) null );
+ instance.tableCell( (String) null );
+ instance.tableCell_();
+ }
+
+ /**
+ * Test of tableHeaderCell method, of class SinkAdapter.
+ */
+ public void testTableHeaderCell()
+ {
+ instance.tableHeaderCell();
+ instance.tableHeaderCell( (SinkEventAttributes) null );
+ instance.tableHeaderCell( (String) null );
+ instance.tableHeaderCell_();
+ }
+
+ /**
+ * Test of tableCaption method, of class SinkAdapter.
+ */
+ public void testTableCaption()
+ {
+ instance.tableCaption();
+ instance.tableCaption( null );
+ instance.tableCaption_();
+ }
+
+ /**
+ * Test of figureGraphics method, of class SinkAdapter.
+ */
+ public void testFigureGraphics()
+ {
+ String name = "";
+ instance.figureGraphics( name );
+ instance.figureGraphics( name, null );
+ }
+
+ /**
+ * Test of horizontalRule method, of class SinkAdapter.
+ */
+ public void testHorizontalRule()
+ {
+ instance.horizontalRule();
+ instance.horizontalRule( null );
+ }
+
+ /**
+ * Test of pageBreak method, of class SinkAdapter.
+ */
+ public void testPageBreak()
+ {
+ instance.pageBreak();
+ }
+
+ /**
+ * Test of anchor method, of class SinkAdapter.
+ */
+ public void testAnchor()
+ {
+ String name = "";
+ instance.anchor( name );
+ instance.anchor( name, null );
+ instance.anchor_();
+ }
+
+ /**
+ * Test of link method, of class SinkAdapter.
+ */
+ public void testLink()
+ {
+ String name = "";
+ instance.link( name );
+ instance.link( name, null );
+ instance.link_();
+ }
+
+ /**
+ * Test of italic method, of class SinkAdapter.
+ */
+ public void testItalic()
+ {
+ instance.italic();
+ instance.italic_();
+ }
+
+ /**
+ * Test of bold method, of class SinkAdapter.
+ */
+ public void testBold()
+ {
+ instance.bold();
+ instance.bold_();
+ }
+
+ /**
+ * Test of monospaced method, of class SinkAdapter.
+ */
+ public void testMonospaced()
+ {
+ instance.monospaced();
+ instance.monospaced_();
+ }
+
+ /**
+ * Test of lineBreak method, of class SinkAdapter.
+ */
+ public void testLineBreaks()
+ {
+ instance.lineBreak();
+ instance.lineBreak( null );
+ }
+
+ /**
+ * Test of nonBreakingSpace method, of class SinkAdapter.
+ */
+ public void testNonBreakingSpace()
+ {
+ instance.nonBreakingSpace();
+ }
+
+ /**
+ * Test of text method, of class SinkAdapter.
+ */
+ public void testText()
+ {
+ String text = "";
+ instance.text( text );
+ instance.text( text, null );
+ }
+
+ /**
+ * Test of rawText method, of class SinkAdapter.
+ */
+ public void testRawText()
+ {
+ String text = "";
+ instance.rawText( text );
+ }
+
+ /**
+ * Test of comment method, of class SinkAdapter.
+ */
+ public void testComment()
+ {
+ instance.comment( "" );
+ }
+
+ /**
+ * Test of flush method, of class SinkAdapter.
+ */
+ public void testFlush()
+ {
+ instance.flush();
+ }
+
+ /**
+ * Test of close method, of class SinkAdapter.
+ */
+ public void testClose()
+ {
+ instance.close();
+ }
+
+ /**
+ * Test of section method, of class SinkAdapter.
+ */
+ public void testSection()
+ {
+ int level = 0;
+ instance.section( level, null );
+ instance.section_( level );
+ }
+
+ /**
+ * Test of unknown method, of class SinkAdapter.
+ */
+ public void testUnknown()
+ {
+ String name = "";
+ Object[] requiredParams = null;
+ instance.unknown( name, requiredParams, null );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkAdapterTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java Sat Mar 28 20:59:07 2009
@@ -0,0 +1,85 @@
+package org.apache.maven.doxia.sink;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.MutableAttributeSet;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author ltheussl
+ */
+public class SinkUtilsTest
+ extends TestCase
+{
+
+ /**
+ * Test of getAttributeString method, of class SinkUtils.
+ */
+ public void testGetAttributeString()
+ {
+ assertEquals( "", SinkUtils.getAttributeString( null ) );
+
+ AttributeSet att = new SinkEventAttributeSet( SinkEventAttributeSet.BOXED );
+ String expResult = " decoration=\"boxed\"";
+ String result = SinkUtils.getAttributeString( att );
+ assertEquals( expResult, result );
+
+ SinkEventAttributes at = new SinkEventAttributeSet( SinkEventAttributeSet.BOLD );
+ at.addAttributes( att );
+ expResult = " style=\"bold\" decoration=\"boxed\"";
+ result = SinkUtils.getAttributeString( at );
+ assertEquals( expResult, result );
+
+ att = new SinkEventAttributeSet( new String[] {"color", "red", "margin-left", "20px"} );
+
+ at = new SinkEventAttributeSet();
+ at.addAttribute( SinkEventAttributeSet.STYLE, att );
+ expResult = " style=\"color: red; margin-left: 20px\"";
+ result = SinkUtils.getAttributeString( at );
+ assertEquals( expResult, result );
+ }
+
+ /**
+ * Test of filterAttributes method, of class SinkUtils.
+ */
+ public void testFilterAttributes()
+ {
+ assertNull( SinkUtils.filterAttributes( null, null ) );
+
+ AttributeSet attributes = new SinkEventAttributeSet( 1 );
+ String[] valids = null;
+
+ MutableAttributeSet result = SinkUtils.filterAttributes( attributes, valids );
+ assertEquals( 0, result.getAttributeCount() );
+
+ valids = new String[] {};
+ result = SinkUtils.filterAttributes( attributes, valids );
+ assertEquals( 0, result.getAttributeCount() );
+
+ result = SinkUtils.filterAttributes( SinkEventAttributeSet.BOLD, SinkUtils.SINK_BASE_ATTRIBUTES );
+ assertEquals( 1, result.getAttributeCount() );
+
+ result = SinkUtils.filterAttributes( SinkEventAttributeSet.CENTER, SinkUtils.SINK_BASE_ATTRIBUTES );
+ assertEquals( 0, result.getAttributeCount() );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkUtilsTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/XhtmlBaseSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/XhtmlBaseSinkTest.java?rev=759585&r1=759584&r2=759585&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/XhtmlBaseSinkTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/XhtmlBaseSinkTest.java Sat Mar 28 20:59:07 2009
@@ -34,14 +34,28 @@
public class XhtmlBaseSinkTest
extends PlexusTestCase
{
+ private final SinkEventAttributes attributes =
+ new SinkEventAttributeSet( new String[] {SinkEventAttributes.STYLE, "bold"} );
+ private XhtmlBaseSink sink;
+ private Writer writer;
+
+ /**
+ * Set up the writer.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ writer = new StringWriter();
+ }
+
/** @throws Exception */
public void testSpaceAfterClosingTag()
throws Exception
{
// DOXIA-189
- XhtmlBaseSink sink = null;
-
- Writer writer = new StringWriter();
try
{
sink = new XhtmlBaseSink( writer );
@@ -73,8 +87,6 @@
throws Exception
{
// DOXIA-177
- XhtmlBaseSink sink = null;
- Writer writer = new StringWriter();
try
{
@@ -114,4 +126,709 @@
assertTrue( actual.indexOf( "class=\"bodyTable\"><caption>caption1</caption><tr" ) != 1 );
assertTrue( actual.indexOf( "class=\"bodyTable\"><caption>caption2</caption><tr" ) != 1 );
}
+
+ /**
+ * Test of section method, of class XhtmlBaseSink.
+ */
+ public void testSection()
+ {
+ final int level = XhtmlBaseSink.SECTION_LEVEL_1;
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section( level, attributes );
+ sink.sectionTitle( level, attributes );
+ sink.sectionTitle_( level );
+ sink.section_( level );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\" style=\"bold\"><h2 style=\"bold\"></h2></div>", writer.toString() );
+ }
+
+ /**
+ * Test of section1 method, of class XhtmlBaseSink.
+ */
+ public void testSection1()
+ {
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section1();
+ sink.sectionTitle1();
+ sink.sectionTitle1_();
+ sink.section1_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\"><h2></h2></div>", writer.toString() );
+ }
+
+ /**
+ * Test of section2 method, of class XhtmlBaseSink.
+ */
+ public void testSection2()
+ {
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section2();
+ sink.sectionTitle2();
+ sink.sectionTitle2_();
+ sink.section2_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\"><h3></h3></div>", writer.toString() );
+ }
+
+ /**
+ * Test of section3 method, of class XhtmlBaseSink.
+ */
+ public void testSection3()
+ {
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section3();
+ sink.sectionTitle3();
+ sink.sectionTitle3_();
+ sink.section3_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\"><h4></h4></div>", writer.toString() );
+ }
+
+ /**
+ * Test of section4 method, of class XhtmlBaseSink.
+ */
+ public void testSection4()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section4();
+ sink.sectionTitle4();
+ sink.sectionTitle4_();
+ sink.section4_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\"><h5></h5></div>", writer.toString() );
+ }
+
+ /**
+ * Test of section5 method, of class XhtmlBaseSink.
+ */
+ public void testSection5()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.section5();
+ sink.sectionTitle5();
+ sink.sectionTitle5_();
+ sink.section5_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"section\"><h6></h6></div>", writer.toString() );
+ }
+
+ /**
+ * Test of list method, of class XhtmlBaseSink.
+ * @throws java.lang.Exception if any.
+ */
+ public void testList()
+ throws Exception
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.list();
+ sink.listItem();
+ sink.listItem_();
+ sink.list_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<ul><li></li></ul>", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.list( attributes );
+ sink.listItem( attributes );
+ sink.listItem_();
+ sink.list_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<ul style=\"bold\"><li style=\"bold\"></li></ul>", writer.toString() );
+ }
+
+ /**
+ * Test of numberedList method, of class XhtmlBaseSink.
+ */
+ public void testNumberedList()
+ {
+ final int numbering = XhtmlBaseSink.NUMBERING_DECIMAL;
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.numberedList( numbering );
+ sink.numberedListItem();
+ sink.numberedListItem_();
+ sink.numberedList_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<ol style=\"list-style-type: decimal\"><li></li></ol>", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.numberedList( numbering, attributes );
+ sink.numberedListItem( attributes );
+ sink.numberedListItem_();
+ sink.numberedList_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<ol style=\"list-style-type: decimal\"><li style=\"bold\"></li></ol>", writer.toString() );
+ }
+
+ /**
+ * Test of definitionList method, of class XhtmlBaseSink.
+ */
+ public void testDefinitionList()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.definitionList();
+ sink.definedTerm();
+ sink.definedTerm_();
+ sink.definition();
+ sink.definition_();
+ sink.definitionList_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<dl><dt></dt><dd></dd></dl>", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.definitionList( attributes );
+ sink.definedTerm( attributes );
+ sink.definedTerm_();
+ sink.definition( attributes );
+ sink.definition_();
+ sink.definitionList_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<dl style=\"bold\"><dt style=\"bold\"></dt><dd style=\"bold\"></dd></dl>", writer.toString() );
+ }
+
+ /**
+ * Test of figure method, of class XhtmlBaseSink.
+ */
+ public void testFigure()
+ {
+ final String src = "src.jpg";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.figure( attributes );
+ sink.figureGraphics( src, attributes );
+ sink.figureCaption( attributes );
+ sink.figureCaption_();
+ sink.figure_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div style=\"bold\" class=\"figure\">"
+ + "<p align=\"center\"><img src=\"src.jpg\" style=\"bold\" alt=\"\" /></p>"
+ + "<p align=\"center\" style=\"bold\"><i></i></p></div>", writer.toString() );
+ }
+
+ /**
+ * Test of figureGraphics method, of class XhtmlBaseSink.
+ */
+ public void testFigureGraphics()
+ {
+ String src = "source.png";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.figureGraphics( src, attributes );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<img src=\"source.png\" style=\"bold\" alt=\"\" />", writer.toString() );
+ }
+
+ /**
+ * Test of paragraph method, of class XhtmlBaseSink.
+ */
+ public void testParagraph()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.paragraph();
+ sink.paragraph_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<p></p>", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.paragraph( attributes );
+ sink.paragraph_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<p style=\"bold\"></p>", writer.toString() );
+ }
+
+ /**
+ * Test of verbatim method, of class XhtmlBaseSink.
+ */
+ public void testVerbatim()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.verbatim( true );
+ sink.verbatim_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div class=\"source\"><pre></pre></div>", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.verbatim( attributes );
+ sink.verbatim_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<div style=\"bold\"><pre style=\"bold\"></pre></div>", writer.toString() );
+ }
+
+ /**
+ * Test of horizontalRule method, of class XhtmlBaseSink.
+ */
+ public void testHorizontalRule()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.horizontalRule();
+ sink.horizontalRule( attributes );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<hr /><hr style=\"bold\" />", writer.toString() );
+ }
+
+ /**
+ * Test of table method, of class XhtmlBaseSink.
+ */
+ public void testTable()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.table( attributes );
+ sink.table_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "</table>", writer.toString() );
+ }
+
+ /**
+ * Test of tableRows method, of class XhtmlBaseSink.
+ */
+ public void testTableRows()
+ {
+ final int[] justification = null;
+ final boolean grid = false;
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.tableRows( justification, grid );
+ sink.tableRows_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<table align=\"center\" border=\"0\" class=\"bodyTable\">", writer.toString() );
+ }
+
+ /**
+ * Test of tableRow method, of class XhtmlBaseSink.
+ */
+ public void testTableRow()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.tableRow( attributes );
+ sink.tableRow_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<tr class=\"a\" style=\"bold\"></tr>", writer.toString() );
+ }
+
+ /**
+ * Test of tableCell method, of class XhtmlBaseSink.
+ */
+ public void testTableCell()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.tableCell( attributes );
+ sink.tableCell_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<td style=\"bold\"></td>", writer.toString() );
+ }
+
+ /**
+ * Test of tableHeaderCell method, of class XhtmlBaseSink.
+ */
+ public void testTableHeaderCell()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.tableHeaderCell( attributes );
+ sink.tableHeaderCell_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<th style=\"bold\"></th>", writer.toString() );
+ }
+
+ /**
+ * Test of tableCaption method, of class XhtmlBaseSink.
+ */
+ public void testTableCaption()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+
+ sink.tableCaption( attributes );
+ sink.tableCaption_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<caption style=\"bold\"></caption>", writer.toString() );
+ }
+
+ /**
+ * Test of anchor method, of class XhtmlBaseSink.
+ */
+ public void testAnchor()
+ {
+ String name = "anchor";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.anchor( name, attributes );
+ sink.anchor_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<a name=\"anchor\" style=\"bold\"></a>", writer.toString() );
+ }
+
+ /**
+ * Test of link method, of class XhtmlBaseSink.
+ */
+ public void testLink()
+ {
+ final String name = "link.html";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.link( name, attributes );
+ sink.link_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<a href=\"link.html\" style=\"bold\"></a>", writer.toString() );
+ }
+
+ /**
+ * Test of italic/bold/monospaced method, of class XhtmlBaseSink.
+ */
+ public void testItalic()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.italic();
+ sink.italic_();
+ sink.bold();
+ sink.bold_();
+ sink.monospaced();
+ sink.monospaced_();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<i></i><b></b><tt></tt>", writer.toString() );
+ }
+
+ /**
+ * Test of lineBreak/pageBreak/nonBreakingSpace method, of class XhtmlBaseSink.
+ */
+ public void testLineBreak()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.lineBreak( attributes );
+ sink.pageBreak();
+ sink.nonBreakingSpace();
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<br style=\"bold\" /><!-- PB --> ", writer.toString() );
+ }
+
+ /**
+ * Test of text method, of class XhtmlBaseSink.
+ */
+ public void testText()
+ {
+ String text = "a text";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.text( text );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "a text", writer.toString() );
+
+ writer = new StringWriter();
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.text( text, attributes );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "a text", writer.toString() );
+ }
+
+ /**
+ * Test of rawText method, of class XhtmlBaseSink.
+ */
+ public void testRawText()
+ {
+ String text = "raw text";
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.rawText( text );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "raw text", writer.toString() );
+ }
+
+ /**
+ * Test of comment method, of class XhtmlBaseSink.
+ */
+ public void testComment()
+ {
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.comment( "a comment" );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "<!-- a comment -->", writer.toString() );
+ }
+
+ /**
+ * Test of unknown method, of class XhtmlBaseSink.
+ */
+ public void testUnknown()
+ {
+ final String name = "unknown";
+ final Object[] requiredParams = null;
+
+ try
+ {
+ sink = new XhtmlBaseSink( writer );
+ sink.unknown( name, requiredParams, attributes );
+ }
+ finally
+ {
+ sink.close();
+ }
+
+ assertEquals( "", writer.toString() );
+ }
}
Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java?rev=759585&r1=759584&r2=759585&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/util/DoxiaUtilsTest.java Sat Mar 28 20:59:07 2009
@@ -77,6 +77,10 @@
assertTrue( "Should be an external link: " + link,
DoxiaUtils.isExternalLink( link ) );
+ link = "resource_type://domain:port/filepathname?query_string#anchor";
+ assertTrue( "Should be an external link: " + link,
+ DoxiaUtils.isExternalLink( link ) );
+
link = "index.html";
assertFalse( "Should NOT be an external link: " + link,
DoxiaUtils.isExternalLink( link ) );
@@ -129,6 +133,50 @@
assertFalse( "Should NOT be a local link: " + link,
DoxiaUtils.isLocalLink( link ) );
+ link = "http://maven.apache.org/";
+ assertFalse( "Should NOT be a local link: " + link,
+ DoxiaUtils.isLocalLink( link ) );
+
}
+ /**
+ * Verify the expected results.
+ */
+ public void testEncodeId()
+ {
+ assertEquals( DoxiaUtils.encodeId( null ), null );
+ assertEquals( DoxiaUtils.encodeId( "" ), "" );
+ assertEquals( DoxiaUtils.encodeId( " " ), "" );
+ assertEquals( DoxiaUtils.encodeId( " _ " ), "a_" );
+ assertEquals( DoxiaUtils.encodeId( "1" ), "a1" );
+ assertEquals( DoxiaUtils.encodeId( "1anchor" ), "a1anchor" );
+ assertEquals( DoxiaUtils.encodeId( "_anchor" ), "a_anchor" );
+ assertEquals( DoxiaUtils.encodeId( "a b-c123 " ), "a_b-c123" );
+ assertEquals( DoxiaUtils.encodeId( " anchor" ), "anchor" );
+ assertEquals( DoxiaUtils.encodeId( "myAnchor" ), "myAnchor" );
+ assertEquals( DoxiaUtils.encodeId( "my&Anchor" ), "my%26Anchor" );
+ }
+
+ /**
+ * Verify the expected results.
+ */
+ public void testIsValidId()
+ {
+ assertFalse( DoxiaUtils.isValidId( null ) );
+ assertFalse( DoxiaUtils.isValidId( "" ) );
+ assertFalse( DoxiaUtils.isValidId( " " ) );
+ assertFalse( DoxiaUtils.isValidId( " _ " ) );
+ assertFalse( DoxiaUtils.isValidId( "1" ) );
+ assertFalse( DoxiaUtils.isValidId( "1anchor" ) );
+ assertFalse( DoxiaUtils.isValidId( "_anchor" ) );
+ assertFalse( DoxiaUtils.isValidId( "a b-c123 " ) );
+ assertFalse( DoxiaUtils.isValidId( " anchor" ) );
+ assertFalse( DoxiaUtils.isValidId( "my&Anchor" ) );
+ assertTrue( DoxiaUtils.isValidId( "myAnchor" ) );
+ assertTrue( DoxiaUtils.isValidId( "a_" ) );
+ assertTrue( DoxiaUtils.isValidId( "a-" ) );
+ assertTrue( DoxiaUtils.isValidId( "a:" ) );
+ assertTrue( DoxiaUtils.isValidId( "a." ) );
+ assertTrue( DoxiaUtils.isValidId( "index.html" ) );
+ }
}
Added: maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt?rev=759585&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt Sat Mar 28 20:59:07 2009
@@ -0,0 +1,14 @@
+
+preamble
+
+SNIPPET START firstId
+first snippet
+SNIPPET END firstId
+
+interlude
+
+another snippet to start: secondId
+second snippet
+another snippet to end: secondId
+
+conclusion
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-core/src/test/resources/macro/snippet/testSnippet.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"