You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2020/03/22 17:20:58 UTC

[karaf] branch master updated: [KARAF-6650] fix NullPointerException

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 5965290  [KARAF-6650] fix NullPointerException
     new f4c88eb  Merge pull request #1079 from oklimberg/KARAF-6650
5965290 is described below

commit 5965290b9e7d6ae83045051f9325dace891390a1
Author: Oliver Limberg <o....@portrix.net>
AuthorDate: Sat Mar 21 17:17:14 2020 +0100

    [KARAF-6650] fix NullPointerException
    
    I also enhanced the test data, to include a comment, an enumeration containing a dash,
    bold text and a test line for this issue.
    
    additionally, removed not needed calls to EasyMock.expectLastCall() because
    the returned IExpectationSetters was never used to configure axpectations.
---
 .../console/commands/help/wikidoc/WikiParser.java  |  4 ++
 .../commands/help/wikidoc/WikiParserTest.java      | 50 ++++++++++------------
 2 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParser.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParser.java
index 783331e..7ac02c4 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParser.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParser.java
@@ -100,6 +100,10 @@ public class WikiParser {
 
 	private void parseHeading(Tokenizer tokenizer) {
 		String level = tokenizer.nextToken("123456789");
+		if (level == null) {
+			visitor.text("h");
+			return;
+		}
 		if (!level.matches("[123456789]")) {
 			visitor.text("h" + level);
 			return;
diff --git a/shell/core/src/test/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParserTest.java b/shell/core/src/test/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParserTest.java
index 62cc6ca..25836c0 100644
--- a/shell/core/src/test/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParserTest.java
+++ b/shell/core/src/test/java/org/apache/karaf/shell/impl/console/commands/help/wikidoc/WikiParserTest.java
@@ -24,13 +24,17 @@ import org.junit.Test;
 
 public class WikiParserTest {
 
-	private static final String TESTDOC = 
+	private static final String TESTDOC =
 		"h1. myTestdoc\n" +
 		"\n" +
 		"Some text\n" +
 		"* enumeration\n" +
+		"* enumeration - with additional text\n" +
 		" some text [a link] some more text\n" +
-		"h1 is no heading";
+		"# a comment in between\n" +
+		"h1 is no heading\n" +
+		"some **bold** text\n" +
+		"and a line for KARAF-6650 h\n";
 	
 	private static final String HEADINGCASES = 
 		"h1.\n" +
@@ -40,43 +44,40 @@ public class WikiParserTest {
 	public void parseTestDoc() throws IOException {
 		WikiVisitor visitor = EasyMock.createStrictMock(WikiVisitor.class);
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.heading(1, "myTestdoc");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.text("Some text");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.enumeration("enumeration");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
+		visitor.startPara(0);
+		visitor.enumeration("enumeration");
+		visitor.text("- wit");
+		visitor.text("h additional text");
+		visitor.endPara();
 		visitor.startPara(1);
-		EasyMock.expectLastCall();
 		visitor.text("some text ");
-		EasyMock.expectLastCall();
 		visitor.link("a link", "");
-		EasyMock.expectLastCall();
 		visitor.text(" some more text");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.text("h1 is no heading");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
+		visitor.startPara(0);
+		visitor.text("some ");
+		visitor.bold(true);
+		visitor.text("bold");
+		visitor.bold(false);
+		visitor.text(" text");
+		visitor.endPara();
+		visitor.startPara(0);
+		visitor.text("and a line for KARAF-6650 ");
+		visitor.text("h");
+		visitor.endPara();
 
 		EasyMock.replay(visitor);
 		WikiParser parser = new WikiParser(visitor);
@@ -87,20 +88,13 @@ public class WikiParserTest {
 	@Test
 	public void parseHeadingSpecialCases() throws IOException {
 		WikiVisitor visitor = EasyMock.createStrictMock(WikiVisitor.class);
-
 		visitor.startPara(0);
 		EasyMock.expectLastCall();
 		visitor.heading(1, "");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
-
 		visitor.startPara(0);
-		EasyMock.expectLastCall();
 		visitor.text("hf.");
-		EasyMock.expectLastCall();
 		visitor.endPara();
-		EasyMock.expectLastCall();
 		
 		EasyMock.replay(visitor);
 		WikiParser parser = new WikiParser(visitor);