maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1726441 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src: main/java/org/apache/maven/doxia/module/confluence/parser/table/ test/java/org/apache/maven/doxia/module/confluence/ test/resources/
Date Sat, 23 Jan 2016 19:37:22 GMT
Author: rfscholte
Date: Sat Jan 23 19:37:22 2016
New Revision: 1726441

URL: http://svn.apache.org/viewvc?rev=1726441&view=rev
Log:
[DOXIA-537] NullPointerException parsing table cell with single space

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/table/TableBlockParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/table.confluence

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/table/TableBlockParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/table/TableBlockParser.java?rev=1726441&r1=1726440&r2=1726441&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/table/TableBlockParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/table/TableBlockParser.java
Sat Jan 23 19:37:22 2016
@@ -133,12 +133,11 @@ public class TableBlockParser
                     it++;
                 }
 
-                String[] pText = texts.toArray( new String[0] );
-                for ( int i = 0; i < pText.length; i++ )
+                for ( String pText : texts )
                 {
                     List<Block> blocks = new ArrayList<Block>();
 
-                    blocks.add( parseLine( pText[i], new ByLineReaderSource( new StringReader(
EMPTY_STRING ) ) ) );
+                    blocks.add( parseLine( pText, new ByLineReaderSource( new StringReader(
EMPTY_STRING ) ) ) );
 
                     cells.add( new TableCellBlock( blocks ) );
                 }
@@ -146,7 +145,6 @@ public class TableBlockParser
 
             rows.add( new TableRowBlock( cells ) );
         }
-
         while ( ( l = source.getNextLine() ) != null && accept( l, source ) );
 
         assert rows.size() >= 1;
@@ -157,7 +155,7 @@ public class TableBlockParser
     private Block parseLine( String text, ByLineSource source )
         throws ParseException
     {
-        if ( text.trim().length() > 0 )
+        if ( text.length() > 0 )
         {
             for ( BlockParser parser : parsers )
             {

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java?rev=1726441&r1=1726440&r2=1726441&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
Sat Jan 23 19:37:22 2016
@@ -300,6 +300,21 @@ public class ConfluenceParserTest
         assertEquals( 9, result.split( "end:link\n" ).length );
     }
 
+    public void testTable()
+        throws Exception
+    {
+        String result = locateAndParseTestSourceFile( "table" );
+        
+        // DOXIA-537
+        // |1|2|3|
+        assertContainsLines( result, "begin:tableRow\nbegin:tableCell\ntext: 1\nend:tableCell\n\n\nbegin:tableCell\ntext:
2\nend:tableCell\n\n\nbegin:tableCell\ntext: 3\nend:tableCell\n" );
+        // |1||3|
+        assertContainsLines( result, "begin:tableRow\nbegin:tableCell\ntext: 1\nend:tableCell\n\n\nbegin:tableCell\ntext:
3\nend:tableCell\n" );
+        // |1| |3|
+        assertContainsLines( result, "begin:tableRow\nbegin:tableCell\ntext: 1\nend:tableCell\n\n\nbegin:tableCell\ntext:
 \nend:tableCell\n\n\nbegin:tableCell\ntext: 3\nend:tableCell\n" );
+        
+    }
+
     /** @throws Exception */
     public void testTableWithLinks()
         throws Exception

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/table.confluence
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/table.confluence?rev=1726441&r1=1726440&r2=1726441&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/table.confluence
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/table.confluence
Sat Jan 23 19:37:22 2016
@@ -10,4 +10,19 @@ Table with links (DOXIA-301):
 || Version || Download || Date || Format || 
 |0.1.1 | [Download|http://example.com/release.0.1.1/ex-win32-win32.x86.zip] | 12-12-2008
| zip |
 |0.1.2 | [Download|http://example.com/release.0.1.2/ex-win32-win32.x86.zip] | 04-12-2008
| zip |
-|0.1.3 | [Download|http://example.com/release.0.1.3/ex-win32-win32.x86.zip] | 03-11-2008
| zip |
\ No newline at end of file
+|0.1.3 | [Download|http://example.com/release.0.1.3/ex-win32-win32.x86.zip] | 03-11-2008
| zip |
+
+Here is a 3 column table with headers, one row, and data in every column:
+ 
+||One||Two||Three||
+|1|2|3|
+ 
+Now there is no data in column Two
+ 
+||One||Two||Three||
+|1||3|
+ 
+Now there is a space in column Two
+ 
+||One||Two||Three||
+|1| |3|
\ No newline at end of file



Mime
View raw message