summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjoranv <gv@oath.com>2018-12-06 13:13:57 +0100
committergjoranv <gv@oath.com>2018-12-06 14:19:01 +0100
commit9820f82abab66b045f6ce65c03477903180f61b4 (patch)
treeefb0ce12a49e8eca52058196193b36ddf6d7373c
parent49de3f5478c4a44c8f5cebcb15062eb6289ddd35 (diff)
Update to latest ph-javacc-maven-plugin.
- Update FastCharStream method names to follow changes in generated CharStream class. - Update expected test output due to improvements in generated code. - Improve ability to debug tests by more clearly printing out the diff between expected and actual output.
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java33
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java50
-rw-r--r--document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java2
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptParserTestCase.java13
-rw-r--r--parent/pom.xml2
-rw-r--r--vespajlib/src/main/java/com/yahoo/javacc/FastCharStream.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/javacc/FastCharStreamTestCase.java8
8 files changed, 64 insertions, 56 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
index fd69e282fcb..4297b8697b4 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java
@@ -11,6 +11,7 @@ import java.util.Iterator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static com.yahoo.config.model.test.TestUtil.joinLines;
+import static org.junit.Assert.fail;
/**
* @author gjoranv
@@ -186,22 +187,26 @@ public class RankingConstantTest {
}
@Test
- public void constant_uri_only_supports_http_and_https() throws Exception {
+ public void constant_uri_only_supports_http_and_https() {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry);
- thrown.expect(ParseException.class);
- thrown.expectMessage("Encountered \" <IDENTIFIER> \"ftp \"\" at line 5, column 10.\n" +
- "Was expecting:\n" +
- " <URI_PATH> ...");
- searchBuilder.importString(joinLines(
- "search test {",
- " document test { }",
- " constant foo {",
- " type: tensor(x{})",
- " uri: ftp:somewhere.far.away/in/another-galaxy",
- " }",
- "}"
- ));
+ String expectedMessage = "Encountered \" <IDENTIFIER> \"ftp\"\" at line 5, column 10.\n\n" +
+ "Was expecting:\n\n" +
+ "<URI_PATH> ...";
+ try {
+ searchBuilder.importString(joinLines(
+ "search test {",
+ " document test { }",
+ " constant foo {",
+ " type: tensor(x{})",
+ " uri: ftp:somewhere.far.away/in/another-galaxy",
+ " }",
+ "}"
+ ));
+ } catch (ParseException e) {
+ if (! e.getMessage().startsWith(expectedMessage))
+ fail("Expected exception with message starting with:\n'" + expectedMessage + "\nBut got:\n'" + e.getMessage());
+ }
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
index 1851f59c824..2cffe195387 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/GroupingOperationTestCase.java
@@ -130,7 +130,7 @@ public class GroupingOperationTestCase {
GroupingOperation.fromString("all(foo)");
fail();
} catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().startsWith("Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 5.\n"));
+ assertTrue(e.getMessage().startsWith("Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 5.\n"));
assertTrue(e.getCause() instanceof ParseException);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
index afbad73f982..fcf1c3bcdd0 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/parser/GroupingParserTestCase.java
@@ -162,15 +162,15 @@ public class GroupingParserTestCase {
String expected = "all(group(foo) each(output(max(bar))))";
assertParse(" all(group(foo)each(output(max(bar))))", expected);
- assertIllegalArgument("all (group(foo)each(output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 4.");
+ assertIllegalArgument("all (group(foo)each(output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 4.");
assertParse("all( group(foo)each(output(max(bar))))", expected);
- assertIllegalArgument("all(group (foo)each(output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 10.");
+ assertIllegalArgument("all(group (foo)each(output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 10.");
assertParse("all(group( foo)each(output(max(bar))))", expected);
assertParse("all(group(foo )each(output(max(bar))))", expected);
assertParse("all(group(foo) each(output(max(bar))))", expected);
- assertIllegalArgument("all(group(foo)each (output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 19.");
+ assertIllegalArgument("all(group(foo)each (output(max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 19.");
assertParse("all(group(foo)each( output(max(bar))))", expected);
- assertIllegalArgument("all(group(foo)each(output (max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 26.");
+ assertIllegalArgument("all(group(foo)each(output (max(bar))))", "Encountered \" <SPACE> \" \"\" at line 1, column 26.");
assertParse("all(group(foo)each(output( max(bar))))", expected);
assertParse("all(group(foo)each(output(max(bar))))", expected);
assertParse("all(group(foo)each(output(max( bar))))", expected);
@@ -328,7 +328,7 @@ public class GroupingParserTestCase {
assertIllegalArgument("all(group(predefined(foo, bucket<-inf, inf>)))",
"Bucket type mismatch, cannot both be infinity");
assertIllegalArgument("all(group(predefined(foo, bucket<inf, -inf>)))",
- "Encountered \" \"inf\" \"inf \"\" at line 1, column 34.");
+ "Encountered \" \"inf\" \"inf\"\" at line 1, column 34.");
assertIllegalArgument("all(group(predefined(foo, bucket(2, 1))))",
"Bucket to-value can not be less than from-value.");
@@ -337,7 +337,7 @@ public class GroupingParserTestCase {
assertIllegalArgument("all(group(predefined(foo, bucket(b, a))))",
"Bucket to-value can not be less than from-value.");
assertIllegalArgument("all(group(predefined(foo, bucket(b, -inf))))",
- "Encountered \" \"-inf\" \"-inf \"\" at line 1, column 37.");
+ "Encountered \" \"-inf\" \"-inf\"\" at line 1, column 37.");
assertIllegalArgument("all(group(predefined(foo, bucket(c, d), bucket(a, b))))",
"Buckets must be monotonically increasing, got bucket[\"c\", \"d\"> before bucket[\"a\", \"b\">.");
assertIllegalArgument("all(group(predefined(foo, bucket(c, d), bucket(-inf, e))))",
@@ -381,19 +381,19 @@ public class GroupingParserTestCase {
" each() as(baz))",
"all(group(a) each(each() as(foo) each() as(bar)) each() as(baz))");
- assertIllegalArgument("all() as(foo)", "Encountered \" \"as\" \"as \"\" at line 1, column 7.");
- assertIllegalArgument("all(all() as(foo))", "Encountered \" \"as\" \"as \"\" at line 1, column 11.");
- assertIllegalArgument("each(all() as(foo))", "Encountered \" \"as\" \"as \"\" at line 1, column 12.");
+ assertIllegalArgument("all() as(foo)", "Encountered \" \"as\" \"as\"\" at line 1, column 7.");
+ assertIllegalArgument("all(all() as(foo))", "Encountered \" \"as\" \"as\"\" at line 1, column 11.");
+ assertIllegalArgument("each(all() as(foo))", "Encountered \" \"as\" \"as\"\" at line 1, column 12.");
}
@Test
public void testAttributeName() {
assertParse("all(group(foo))");
assertIllegalArgument("all(group(foo.))",
- "Encountered \" \")\" \") \"\" at line 1, column 15.");
+ "Encountered \" \")\" \")\"\" at line 1, column 15.");
assertParse("all(group(foo.bar))");
assertIllegalArgument("all(group(foo.bar.))",
- "Encountered \" \")\" \") \"\" at line 1, column 19.");
+ "Encountered \" \")\" \")\"\" at line 1, column 19.");
assertParse("all(group(foo.bar.baz))");
}
@@ -405,7 +405,7 @@ public class GroupingParserTestCase {
"all(output(min(a) as(foo), max(b) as(bar)))");
assertIllegalArgument("all(output(min(a)) as(foo))",
- "Encountered \" \"as\" \"as \"\" at line 1, column 20.");
+ "Encountered \" \"as\" \"as\"\" at line 1, column 20.");
}
@Test
@@ -418,11 +418,11 @@ public class GroupingParserTestCase {
@Test
public void testParseBadRequest() {
assertIllegalArgument("output(count())",
- "Encountered \" \"output\" \"output \"\" at line 1, column 1.");
+ "Encountered \" \"output\" \"output\"\" at line 1, column 1.");
assertIllegalArgument("each(output(count()))",
"Expression 'count()' not applicable for single hit.");
assertIllegalArgument("all(output(count())))",
- "Encountered \" \")\" \") \"\" at line 1, column 21.");
+ "Encountered \" \")\" \")\"\" at line 1, column 21.");
}
@Test
@@ -466,7 +466,7 @@ public class GroupingParserTestCase {
"my.map.key", "my.map.value", "", "my_attr.name");
assertIllegalArgument("all(group(my_map{attribute(\"my_attr\")}))",
- "Encountered \" <STRING> \"\\\"my_attr\\\" \"\" at line 1, column 28");
+ "Encountered \" <STRING> \"\\\"my_attr\\\"\"\" at line 1, column 28");
}
@@ -576,18 +576,18 @@ public class GroupingParserTestCase {
assertParse("all(group(debugwait(artist, 3.3, true)))");
assertParse("all(group(debugwait(artist, 3.3, false)))");
assertIllegalArgument("all(group(debugwait(artist, -3.3, true)))",
- "Encountered \" \"-\" \"- \"\" at line 1, column 29");
+ "Encountered \" \"-\" \"-\"\" at line 1, column 29");
assertIllegalArgument("all(group(debugwait(artist, 3.3, lol)))",
- "Encountered \" <IDENTIFIER> \"lol \"\" at line 1, column 34");
+ "Encountered \" <IDENTIFIER> \"lol\"\" at line 1, column 34");
assertParse("all(group(artist) each(output(stddev(simple))))");
}
@Test
public void requireThatParseExceptionMessagesContainErrorMarker() {
assertIllegalArgument("foo",
- "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.\n" +
- "Was expecting one of:\n" +
- " <SPACE> ...\n" +
+ "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.\n\n" +
+ "Was expecting one of:\n\n" +
+ "<SPACE> ...\n" +
" \"all\" ...\n" +
" \"each\" ...\n" +
" \n" +
@@ -595,9 +595,9 @@ public class GroupingParserTestCase {
"foo\n" +
"^");
assertIllegalArgument("\n foo",
- "Encountered \" <IDENTIFIER> \"foo \"\" at line 2, column 2.\n" +
- "Was expecting one of:\n" +
- " <SPACE> ...\n" +
+ "Encountered \" <IDENTIFIER> \"foo\"\" at line 2, column 2.\n\n" +
+ "Was expecting one of:\n\n" +
+ "<SPACE> ...\n" +
" \"all\" ...\n" +
" \"each\" ...\n" +
" \n" +
@@ -650,7 +650,9 @@ public class GroupingParserTestCase {
GroupingOperation.fromString(request).resolveLevel(1);
fail("Expected: " + expectedException);
} catch (IllegalArgumentException e) {
- assertTrue(e.getMessage(), e.getMessage().startsWith(expectedException));
+ if (! e.getMessage().startsWith(expectedException)) {
+ fail("Expected exception with message starting with:\n'" + expectedException + ", but got:\n'" + e.getMessage());
+ }
}
}
}
diff --git a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
index 10808f9b630..4c1d35244e4 100644
--- a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
+++ b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
@@ -166,7 +166,7 @@ public class DocumentSelectorTestCase {
assertParse("music.h == \"\\ttx48 \\n\"", "music.h == \"\\tt\\x48 \\n\"");
// Test illegal operator.
- assertParseError("music.hmm <> 12", "Exception parsing document selector 'music.hmm <> 12': Encountered \" \">\" \"> \"\" at line 1, column 12.");
+ assertParseError("music.hmm <> 12", "Exception parsing document selector 'music.hmm <> 12': Encountered \" \">\" \">\"\" at line 1, column 12.");
// Test comparison operators.
assertParse("music.hmm >= 123");
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptParserTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptParserTestCase.java
index cd6008d67d1..0df3073cd25 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptParserTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptParserTestCase.java
@@ -11,6 +11,7 @@ import com.yahoo.vespa.indexinglanguage.parser.ParseException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author Simon Thoresen Hult
@@ -22,7 +23,7 @@ public class ScriptParserTestCase {
try {
ScriptParser.parseExpression(newContext("foo"));
} catch (ParseException e) {
- assertException(e, "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.");
+ assertException(e, "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.");
}
assertEquals(new InputExpression("foo"),
ScriptParser.parseExpression(newContext("input foo")));
@@ -38,7 +39,7 @@ public class ScriptParserTestCase {
try {
ScriptParser.parseStatement(newContext("foo"));
} catch (ParseException e) {
- assertException(e, "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.");
+ assertException(e, "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.");
}
assertEquals(new StatementExpression(new InputExpression("foo")),
ScriptParser.parseStatement(newContext("input foo")));
@@ -54,17 +55,17 @@ public class ScriptParserTestCase {
try {
ScriptParser.parseScript(newContext("foo"));
} catch (ParseException e) {
- assertException(e, "Encountered \" <IDENTIFIER> \"foo \"\" at line 1, column 1.");
+ assertException(e, "Encountered \" <IDENTIFIER> \"foo\"\" at line 1, column 1.");
}
try {
ScriptParser.parseScript(newContext("input foo"));
} catch (ParseException e) {
- assertException(e, "Encountered \" \"input\" \"input \"\" at line 1, column 1.");
+ assertException(e, "Encountered \" \"input\" \"input\"\" at line 1, column 1.");
}
try {
ScriptParser.parseScript(newContext("input foo | echo"));
} catch (ParseException e) {
- assertException(e, "Encountered \" \"input\" \"input \"\" at line 1, column 1.");
+ assertException(e, "Encountered \" \"input\" \"input\"\" at line 1, column 1.");
}
assertEquals(new ScriptExpression(new StatementExpression(new InputExpression("foo")),
new StatementExpression(new EchoExpression())),
@@ -89,7 +90,7 @@ public class ScriptParserTestCase {
private static void assertException(ParseException e, String expectedMessage) throws ParseException {
if (!e.getMessage().startsWith(expectedMessage)) {
- throw e;
+ fail("Expected exception with message starting with:\n'" + expectedMessage + ", but got:\n'" + e.getMessage());
}
}
diff --git a/parent/pom.xml b/parent/pom.xml
index 43db7de964a..bb74e6a5f24 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -254,7 +254,7 @@
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>ph-javacc-maven-plugin</artifactId>
- <version>4.0.3</version>
+ <version>4.1.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
diff --git a/vespajlib/src/main/java/com/yahoo/javacc/FastCharStream.java b/vespajlib/src/main/java/com/yahoo/javacc/FastCharStream.java
index 57376734030..96dc03865e3 100644
--- a/vespajlib/src/main/java/com/yahoo/javacc/FastCharStream.java
+++ b/vespajlib/src/main/java/com/yahoo/javacc/FastCharStream.java
@@ -49,21 +49,21 @@ public class FastCharStream {
readPos -= amount;
}
- public char BeginToken() throws IOException {
+ public char beginToken() throws IOException {
tokenPos = readPos;
return readChar();
}
- public String GetImage() {
+ public String getImage() {
return inputStr.substring(tokenPos, readPos);
}
@SuppressWarnings("UnusedParameters")
- public char[] GetSuffix(int len) {
+ public char[] getSuffix(int len) {
throw new UnsupportedOperationException();
}
- public void Done() {
+ public void done() {
}
@@ -73,7 +73,7 @@ public class FastCharStream {
public void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; }
- public boolean getTrackLineColumn() { return trackLineColumn; }
+ public boolean isTrackLineColumn() { return trackLineColumn; }
public String formatException(String parseException) {
int errPos = findErrPos(parseException);
diff --git a/vespajlib/src/test/java/com/yahoo/javacc/FastCharStreamTestCase.java b/vespajlib/src/test/java/com/yahoo/javacc/FastCharStreamTestCase.java
index d8f7b6e9e7e..5d768ee3b93 100644
--- a/vespajlib/src/test/java/com/yahoo/javacc/FastCharStreamTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/javacc/FastCharStreamTestCase.java
@@ -79,7 +79,7 @@ public class FastCharStreamTestCase {
@Test
public void requireThatSuffixIsNotSupported() {
try {
- new FastCharStream("foo").GetSuffix(0);
+ new FastCharStream("foo").getSuffix(0);
fail();
} catch (UnsupportedOperationException e) {
@@ -89,7 +89,7 @@ public class FastCharStreamTestCase {
@Test
public void requireThatDoneDoesNotThrowException() {
FastCharStream input = new FastCharStream("foo");
- input.Done();
+ input.done();
}
@Test
@@ -99,7 +99,7 @@ public class FastCharStreamTestCase {
input.readChar();
input.readChar();
input.readChar();
- assertEquals('b', input.BeginToken());
+ assertEquals('b', input.beginToken());
assertEquals(5, input.getBeginColumn());
assertEquals(-1, input.getBeginLine());
assertEquals(6, input.getEndColumn());
@@ -108,7 +108,7 @@ public class FastCharStreamTestCase {
assertEquals('r', input.readChar());
assertEquals(8, input.getEndColumn());
assertEquals(-1, input.getEndLine());
- assertEquals("bar", input.GetImage());
+ assertEquals("bar", input.getImage());
}
@Test