summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-05-17 09:27:38 +0200
committerGitHub <noreply@github.com>2022-05-17 09:27:38 +0200
commit16de8d32fd0394335ffa065b61f4943c4fd49542 (patch)
tree37b502cbc7957f25eebf2a58cf9b085509966a9d
parente2f707a511fd320d41d6ab33fb75ebbc4b4c54fe (diff)
parent48cd2507f132fdc376a721d05fdf6f55b4358fdd (diff)
Merge pull request #22626 from vespa-engine/bratseth/schema-parser
Rename to SchemaParser
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/IntermediateCollection.java4
-rw-r--r--config-model/src/main/javacc/SchemaParser.jj (renamed from config-model/src/main/javacc/IntermediateParser.jj)8
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/parser/SchemaParserTestCase.java (renamed from config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java)15
3 files changed, 14 insertions, 13 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/IntermediateCollection.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/IntermediateCollection.java
index cdcd13619e8..8dd69085efb 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/IntermediateCollection.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/IntermediateCollection.java
@@ -46,7 +46,7 @@ public class IntermediateCollection {
public ParsedSchema addSchemaFromString(String input) throws ParseException {
var stream = new SimpleCharStream(input);
- var parser = new IntermediateParser(stream, deployLogger, modelProperties);
+ var parser = new SchemaParser(stream, deployLogger, modelProperties);
try {
var schema = parser.schema();
if (parsedSchemas.containsKey(schema.name())) {
@@ -132,7 +132,7 @@ public class IntermediateCollection {
throw new IllegalArgumentException("No schema named: " + schemaName);
}
var stream = new SimpleCharStream(IOUtils.readAll(reader.getReader()));
- var parser = new IntermediateParser(stream, deployLogger, modelProperties);
+ var parser = new SchemaParser(stream, deployLogger, modelProperties);
try {
parser.rankProfile(schema);
} catch (ParseException pe) {
diff --git a/config-model/src/main/javacc/IntermediateParser.jj b/config-model/src/main/javacc/SchemaParser.jj
index 01f111df284..421894e51cd 100644
--- a/config-model/src/main/javacc/IntermediateParser.jj
+++ b/config-model/src/main/javacc/SchemaParser.jj
@@ -9,7 +9,7 @@ options {
USER_CHAR_STREAM = true;
}
-PARSER_BEGIN(IntermediateParser)
+PARSER_BEGIN(SchemaParser)
package com.yahoo.searchdefinition.parser;
@@ -58,13 +58,13 @@ import java.util.logging.Level;
*
* @author bratseth
*/
-public class IntermediateParser {
+public class SchemaParser {
private DeployLogger deployLogger;
private ModelContext.Properties properties;
/** Creates a parser. */
- public IntermediateParser(SimpleCharStream stream,
+ public SchemaParser(SimpleCharStream stream,
DeployLogger deployLogger,
ModelContext.Properties properties)
{
@@ -122,7 +122,7 @@ public class IntermediateParser {
}
}
-PARSER_END(IntermediateParser)
+PARSER_END(SchemaParser)
// --------------------------------------------------------------------------------
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/SchemaParserTestCase.java
index 1e0c554af81..17d94639d87 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/SchemaParserTestCase.java
@@ -10,20 +10,22 @@ import java.io.File;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertThrows;
/**
* @author arnej
*/
-public class IntermediateParserTestCase {
+public class SchemaParserTestCase {
ParsedSchema parseString(String input) throws Exception {
var deployLogger = new BaseDeployLogger();
var modelProperties = new TestProperties();
var stream = new SimpleCharStream(input);
try {
- var parser = new IntermediateParser(stream, deployLogger, modelProperties);
+ var parser = new SchemaParser(stream, deployLogger, modelProperties);
return parser.schema();
} catch (ParseException pe) {
throw new ParseException(stream.formatException(pe.getMessage()));
@@ -60,7 +62,7 @@ public class IntermediateParserTestCase {
}
@Test
- public void multiple_documents_disallowed() throws Exception {
+ public void multiple_documents_disallowed() {
String input = joinLines
("schema foo {",
" document foo {",
@@ -85,11 +87,10 @@ public class IntermediateParserTestCase {
}
void checkFileParses(String fileName) throws Exception {
- System.err.println("TRY parsing: "+fileName);
var schema = parseFile(fileName);
- assertTrue(schema != null);
- assertTrue(schema.name() != null);
- assertTrue(! schema.name().equals(""));
+ assertNotNull(schema);
+ assertNotNull(schema.name());
+ assertNotEquals("", schema.name());
}
@Test