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 vs...@apache.org on 2007/01/13 15:37:06 UTC
svn commit: r495902 - in /maven/doxia/trunk/doxia-core/src:
main/java/org/apache/maven/doxia/module/xdoc/
test/java/org/apache/maven/doxia/module/apt/
test/java/org/apache/maven/doxia/module/xdoc/ test/site/apt/ test/site/xdoc/
Author: vsiveton
Date: Sat Jan 13 06:37:06 2007
New Revision: 495902
URL: http://svn.apache.org/viewvc?view=rev&rev=495902
Log:
DOXIA-77: Snippets do not work in xdoc
o Replaced id parameter by name in the XdocParser (to have <macro name="snippet" id="superpom" .../>)
o added test cases
Added:
maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt (with props)
maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml (with props)
Modified:
maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?view=diff&rev=495902&r1=495901&r2=495902
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java (original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java Sat Jan 13 06:37:06 2007
@@ -161,7 +161,7 @@
}
else if ( parser.getName().equals( "macro" ) )
{
- String macroId = parser.getAttributeValue( null, "id" );
+ String macroName = parser.getAttributeValue( null, "name" );
int count = parser.getAttributeCount();
@@ -174,7 +174,7 @@
MacroRequest request = new MacroRequest( parameters, getBasedir() );
- executeMacro( macroId, request, sink );
+ executeMacro( macroName, request, sink );
}
// ----------------------------------------------------------------------
Modified: maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java?view=diff&rev=495902&r1=495901&r2=495902
==============================================================================
--- maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java (original)
+++ maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java Sat Jan 13 06:37:06 2007
@@ -36,12 +36,25 @@
{
private static final String EOL = System.getProperty( "line.separator" );
+ private AptParser parser;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ parser = (AptParser) lookup( Parser.ROLE, "apt" );
+ }
+
/**
* @see org.apache.maven.doxia.parser.AbstractParserTestCase#getParser()
*/
protected Parser getParser()
{
- return new AptParser();
+ return parser;
}
/**
@@ -70,6 +83,32 @@
getParser().parse( reader, sink );
assertTrue( output.toString().indexOf( "Line\\" + EOL + "break." ) != -1 );
+ }
+ finally
+ {
+ output.close();
+ reader.close();
+ }
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testSnippetMacro()
+ throws Exception
+ {
+ StringWriter output = null;
+ Reader reader = null;
+
+ try
+ {
+ output = new StringWriter();
+ reader = new FileReader( getTestFile( getBasedir(), "src/test/site/apt/macro.apt" ) );
+
+ Sink sink = new AptSink( output );
+ getParser().parse( reader, sink );
+
+ assertTrue( output.toString().indexOf( "<modelVersion\\>4.0.0\\</modelVersion\\>" ) != -1 );
}
finally
{
Modified: maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java?view=diff&rev=495902&r1=495901&r2=495902
==============================================================================
--- maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java (original)
+++ maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java Sat Jan 13 06:37:06 2007
@@ -1,24 +1,31 @@
package org.apache.maven.doxia.module.xdoc;
/*
- * Copyright 2004-2005 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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 org.apache.maven.doxia.module.xdoc.XdocParser;
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.StringWriter;
+
import org.apache.maven.doxia.parser.AbstractParserTestCase;
import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -28,13 +35,58 @@
public class XdocParserTest
extends AbstractParserTestCase
{
+ private XdocParser parser;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ parser = (XdocParser) lookup( Parser.ROLE, "xdoc" );
+ }
+
+ /**
+ * @see org.apache.maven.doxia.parser.AbstractParserTestCase#getParser()
+ */
protected Parser getParser()
{
- return new XdocParser();
+ return parser;
}
+ /**
+ * @see org.apache.maven.doxia.parser.AbstractParserTestCase#getDocument()
+ */
protected String getDocument()
{
return "src/test/site/xdoc/report.xml";
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testSnippetMacro()
+ throws Exception
+ {
+ StringWriter output = null;
+ Reader reader = null;
+
+ try
+ {
+ output = new StringWriter();
+ reader = new FileReader( getTestFile( getBasedir(), "src/test/site/xdoc/macro.xml" ) );
+
+ Sink sink = new XdocSink( output );
+ getParser().parse( reader, sink );
+
+ assertTrue( output.toString().indexOf( "<modelVersion>4.0.0</modelVersion>" ) != -1 );
+ }
+ finally
+ {
+ output.close();
+ reader.close();
+ }
}
}
Added: maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt?view=auto&rev=495902
==============================================================================
--- maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt (added)
+++ maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt Sat Jan 13 06:37:06 2007
@@ -0,0 +1,9 @@
+ -----
+ Test DOXIA-77
+ -----
+ Vincent Siveton
+ -----
+
+Test DOXIA-77
+
+%{snippet|id=superpom|url=http://svn.apache.org/repos/asf/maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml}
Propchange: maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/trunk/doxia-core/src/test/site/apt/macro.apt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml?view=auto&rev=495902
==============================================================================
--- maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml (added)
+++ maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml Sat Jan 13 06:37:06 2007
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+ <title>Test DOXIA-77</title>
+ <author email="vsiveton@apache.org">Vincent Siveton</author>
+ </properties>
+ <body>
+ <p>
+ Test DOXIA-77
+ </p>
+ <macro name="snippet" id="superpom" url="http://svn.apache.org/repos/asf/maven/components/trunk/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml"/>
+ </body>
+</document>
Propchange: maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/trunk/doxia-core/src/test/site/xdoc/macro.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"