diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-10-16 17:54:27 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-10-16 17:54:27 +0200 |
commit | 891cf8a8a1178afa459a1c1d771bd1b8b920fb73 (patch) | |
tree | e890dd2e182a62361cec1eb4cca06067b80b0063 /config-model | |
parent | cf7c0cb612a2cbc1cd63e7043eae28e5a5ecba06 (diff) |
Validate schema inheritance
Diffstat (limited to 'config-model')
56 files changed, 236 insertions, 149 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java index ea69b829e85..11ee03d5dfb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java @@ -7,6 +7,7 @@ import com.yahoo.config.application.api.FileRegistry; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.model.deploy.TestProperties; +import com.yahoo.document.DataTypeName; import com.yahoo.document.Field; import com.yahoo.searchdefinition.derived.SummaryClass; import com.yahoo.searchdefinition.document.Attribute; @@ -95,7 +96,7 @@ public class Schema implements ImmutableSearch { private Optional<TemporaryImportedFields> temporaryImportedFields = Optional.of(new TemporaryImportedFields()); private Optional<ImportedFields> importedFields = Optional.empty(); - private final Application application; + private final Application owner; private final DeployLogger deployLogger; private final ModelContext.Properties properties; @@ -140,7 +141,7 @@ public class Schema implements ImmutableSearch { ModelContext.Properties properties, boolean documentsOnly) { this.inherited = inherited; - this.application = application; + this.owner = application; this.deployLogger = deployLogger; this.properties = properties; this.documentsOnly = documentsOnly; @@ -321,15 +322,15 @@ public class Schema implements ImmutableSearch { */ @Override public Reader getRankingExpression(String fileName) { - return application.applicationPackage().getRankingExpression(fileName); + return owner.applicationPackage().getRankingExpression(fileName); } - public Application application() { return application; } + public Application application() { return owner; } @Override public ApplicationPackage applicationPackage() { - if (application == null) return null; - return application.applicationPackage(); + if (owner == null) return null; + return owner.applicationPackage(); } @Override @@ -698,6 +699,18 @@ public class Schema implements ImmutableSearch { } public void validate(DeployLogger logger) { + if (inherited.isPresent()) { + if (! owner.schemas().containsKey(inherited.get())) + throw new IllegalArgumentException(this + " inherits '" + inherited.get() + + "', but this schema does not exist"); + + // Require schema and document type inheritance to be consistent to keep things simple + // And require it to be explicit so we have the option to support other possibilities later + var parentDocument = owner.schemas().get(inherited.get()).getDocument(); + if ( ! getDocument().inheritedTypes().containsKey(new DataTypeName(parentDocument.getName()))) + throw new IllegalArgumentException(this + " inherits '" + inherited.get() + + "', but its document type does not inherit the parent's document type"); + } for (var summary : summaries.values()) summary.validate(logger); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java index cef9cf3dede..752eb856afa 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java @@ -196,6 +196,8 @@ public class SDDocumentType implements Cloneable, Serializable { public Collection<SDDocumentType> getInheritedTypes() { return inheritedTypes.values(); } + public Map<DataTypeName, SDDocumentType> inheritedTypes() { return inheritedTypes; } + protected void validateId(Schema schema) { if (schema == null) return; if (schema.getDocument(getName()) == null) return; @@ -298,6 +300,8 @@ public class SDDocumentType implements Cloneable, Serializable { return docType.getFieldCount(); } + + @Override public String toString() { return "SD document type '" + docType.getName() + "'"; diff --git a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java index c878ea9951a..4714f4396dd 100644 --- a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.document.test; import com.yahoo.document.DataType; import com.yahoo.document.DataTypeName; import com.yahoo.documentmodel.VespaDocumentType; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import org.junit.Test; @@ -17,7 +17,7 @@ import static org.junit.Assert.*; * @author Thomas Gundersen * @author bratseth */ -public class SDDocumentTypeTestCase extends SchemaTestCase { +public class SDDocumentTypeTestCase extends AbstractSchemaTestCase { // Verify that we can register and retrieve fields. @Test diff --git a/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java b/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java index 223cd6a6e85..36a4c7bdafc 100644 --- a/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.document.test; import com.yahoo.document.DataType; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import org.junit.Test; @@ -11,7 +11,7 @@ import static org.junit.Assert.fail; /** * @author Thomas Gundersen */ -public class SDFieldTestCase extends SchemaTestCase { +public class SDFieldTestCase extends AbstractSchemaTestCase { @Test public void testIdSettingConflict() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AbstractSchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AbstractSchemaTestCase.java new file mode 100644 index 00000000000..a08ec110219 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AbstractSchemaTestCase.java @@ -0,0 +1,78 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition; + +import com.yahoo.io.IOUtils; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; + +import static helpers.CompareConfigTestHelper.assertSerializedConfigEquals; +import static helpers.CompareConfigTestHelper.assertSerializedConfigFileEquals; + +public abstract class AbstractSchemaTestCase { + + protected static void assertConfigFile(String filename, String cfg) throws IOException { + assertSerializedConfigFileEquals(filename, cfg); + } + + protected static void assertConfigFiles(String expectedFile, + String cfgFile, + boolean orderMatters, + boolean updateOnAssert) throws IOException { + try { + assertSerializedConfigEquals(readAndCensorIndexes(expectedFile), readAndCensorIndexes(cfgFile), orderMatters); + } catch (AssertionError e) { + if (updateOnAssert) { + BufferedWriter writer = IOUtils.createWriter(expectedFile, false); + writer.write(readAndCensorIndexes(cfgFile)); + writer.newLine(); + writer.flush(); + writer.close(); + System.err.println(e.getMessage() + " [not equal files: >>>"+expectedFile+"<<< and >>>"+cfgFile+"<<< in assertConfigFiles]"); + return; + } + throw new AssertionError(e.getMessage() + " [not equal files: >>>"+expectedFile+"<<< and >>>"+cfgFile+"<<< in assertConfigFiles]", e); + } + } + /** + * This is to avoid having to keep those pesky array index numbers in the config format up to date + * as new entries are added and removed. + */ + private static String readAndCensorIndexes(String file) throws IOException { + StringBuilder b = new StringBuilder(); + try (BufferedReader r = IOUtils.createReader(file)) { + int character; + boolean lastWasNewline = false; + boolean inBrackets = false; + while (-1 != (character = r.read())) { + // skip empty lines + if (character == '\n') { + if (lastWasNewline) continue; + lastWasNewline = true; + } + else { + lastWasNewline = false; + } + + // skip quoted strings + if (character == '"') { + b.appendCodePoint(character); + while (-1 != (character = r.read()) && character != '"') { + b.appendCodePoint(character); + } + } + + // skip bracket content + if (character == ']') + inBrackets = false; + if (! inBrackets) + b.appendCodePoint(character); + if (character == '[') + inBrackets = true; + } + } + return b.toString(); + } + +} diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java index bcd9d462528..131c6e19c68 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue; * * @author bratseth */ -public class ArraysTestCase extends SchemaTestCase { +public class ArraysTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java index d824460a36a..0d5a4b357b1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue; * * @author Einar M R Rosenvinge */ -public class ArraysWeightedSetsTestCase extends SchemaTestCase { +public class ArraysWeightedSetsTestCase extends AbstractSchemaTestCase { @Test public void testArrayWeightedSetsImporting() throws java.io.IOException, com.yahoo.searchdefinition.parser.ParseException { Schema schema = SearchBuilder.buildFromFile("src/test/examples/arraysweightedsets.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index 0b5bb8fe486..22ae06d929a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -25,7 +25,7 @@ import static org.junit.Assert.*; * * @author bratseth */ -public class AttributeSettingsTestCase extends SchemaTestCase { +public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Rule public final ExpectedException exceptionRule = ExpectedException.none(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java index faeb033a427..35eccb19151 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java @@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals; * * @author bratseth */ -public class CommentTestCase extends SchemaTestCase { +public class CommentTestCase extends AbstractSchemaTestCase { @Test public void testComments() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java index d4557549b14..fdd7fe95c45 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertSame; /** * @author Einar M R Rosenvinge */ -public class FieldOfTypeDocumentTestCase extends SchemaTestCase { +public class FieldOfTypeDocumentTestCase extends AbstractSchemaTestCase { @Test public void testDocument() throws IOException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java index f7687640202..aab8c9939d2 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java @@ -15,7 +15,7 @@ import static org.junit.Assert.fail; /** * @author bratseth */ -public class IncorrectRankingExpressionFileRefTestCase extends SchemaTestCase { +public class IncorrectRankingExpressionFileRefTestCase extends AbstractSchemaTestCase { @Test public void testIncorrectRef() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java index 4e579fa62aa..76f8c05c1c8 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java @@ -11,7 +11,7 @@ import static org.junit.Assert.fail; * * @author bratseth */ -public class IncorrectSummaryTypesTestCase extends SchemaTestCase { +public class IncorrectSummaryTypesTestCase extends AbstractSchemaTestCase { @Test public void testImportingIncorrect() throws ParseException { try { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java index 7dec8df6e8c..0e25798fbe2 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertTrue; * * @author bratseth */ -public class IndexSettingsTestCase extends SchemaTestCase { +public class IndexSettingsTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java index 8deaddf9749..428114f47e5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java @@ -11,7 +11,7 @@ import static org.junit.Assert.assertNotNull; * * @author frodelu */ -public class IndexingParsingTestCase extends SchemaTestCase { +public class IndexingParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java index cbdb11f49fd..181f12083c4 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java @@ -11,7 +11,7 @@ import java.io.IOException; * * @author bratseth */ -public class MultipleSummariesTestCase extends SchemaTestCase { +public class MultipleSummariesTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { SearchBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java index 67fd54142f7..557df74e700 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java @@ -14,7 +14,7 @@ import static org.junit.Assert.fail; * * @author Lars Christian Jensen */ -public class NameFieldCheckTestCase extends SchemaTestCase { +public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testNameField() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java index c5e593c706f..fda1f184a62 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue; * * @author bratseth */ -public class OutsideTestCase extends SchemaTestCase { +public class OutsideTestCase extends AbstractSchemaTestCase { @Test public void testOutsideIndex() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java index 25581d2173c..857da3068cd 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -39,7 +39,7 @@ import static org.junit.Assert.fail; * * @author bratseth */ -public class RankProfileTestCase extends SchemaTestCase { +public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void testRankProfileInheritance() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java index 5bc4aa9c386..e2ca8ac4f65 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; /** * @author bratseth */ -public class RankPropertiesTestCase extends SchemaTestCase { +public class RankPropertiesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropertyInheritance() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java index 2904f9ed299..19a50817f75 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java @@ -19,7 +19,7 @@ import static org.junit.Assert.*; /** * @author bratseth */ -public class RankingExpressionConstantsTestCase extends SchemaTestCase { +public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testConstants() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index 52b8481f330..238e71a6340 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue; /** * @author bratseth */ -public class RankingExpressionInliningTestCase extends SchemaTestCase { +public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testFunctionInliningPreserveArithmeticOrdering() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java index 192ac38a854..231fa531770 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; /** * @author lesters */ -public class RankingExpressionShadowingTestCase extends SchemaTestCase { +public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testBasicFunctionShadowing() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java index 0f42e7c5211..a66a4cd8648 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java @@ -11,7 +11,7 @@ import static org.junit.Assert.fail; /** * @author bratseth */ -public class RankingExpressionValidationTestCase extends SchemaTestCase { +public class RankingExpressionValidationTestCase extends AbstractSchemaTestCase { @Test public void testInvalidExpressionProducesException() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java index 9a1fe665e9b..f893f532f09 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java @@ -11,7 +11,7 @@ import static org.junit.Assert.assertNotNull; /** * @author bratseth */ -public class ReservedWordsAsFieldNamesTestCase extends SchemaTestCase { +public class ReservedWordsAsFieldNamesTestCase extends AbstractSchemaTestCase { @Test public void testIt() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java index d382dc9f34a..1ae44e30c32 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java @@ -30,7 +30,7 @@ import static org.junit.Assert.fail; * * @author bratseth */ -public class SchemaImporterTestCase extends SchemaTestCase { +public class SchemaImporterTestCase extends AbstractSchemaTestCase { @Test @SuppressWarnings("deprecation") diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java index 3a6dd00bc0e..984140be12c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java @@ -15,7 +15,7 @@ import static org.junit.Assert.*; * * @author hmusum */ -public class SchemaParsingTestCase extends SchemaTestCase { +public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java index c9371160ea5..106f28b42e4 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java @@ -1,78 +1,70 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; -import com.yahoo.io.IOUtils; +import com.yahoo.searchdefinition.parser.ParseException; +import com.yahoo.vespa.model.test.utils.DeployLoggerStub; +import org.junit.Test; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; +import static com.yahoo.config.model.test.TestUtil.joinLines; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import static helpers.CompareConfigTestHelper.assertSerializedConfigEquals; -import static helpers.CompareConfigTestHelper.assertSerializedConfigFileEquals; +/** + * Schema tests that don't depend on files. + * + * @author bratseth + */ +public class SchemaTestCase { -public abstract class SchemaTestCase { - - protected static void assertConfigFile(String filename, String cfg) throws IOException { - assertSerializedConfigFileEquals(filename, cfg); - } - - protected static void assertConfigFiles(String expectedFile, - String cfgFile, - boolean orderMatters, - boolean updateOnAssert) throws IOException { + @Test + public void testValidationOfInheritedSchema() throws ParseException { try { - assertSerializedConfigEquals(readAndCensorIndexes(expectedFile), readAndCensorIndexes(cfgFile), orderMatters); - } catch (AssertionError e) { - if (updateOnAssert) { - BufferedWriter writer = IOUtils.createWriter(expectedFile, false); - writer.write(readAndCensorIndexes(cfgFile)); - writer.newLine(); - writer.flush(); - writer.close(); - System.err.println(e.getMessage() + " [not equal files: >>>"+expectedFile+"<<< and >>>"+cfgFile+"<<< in assertConfigFiles]"); - return; - } - throw new AssertionError(e.getMessage() + " [not equal files: >>>"+expectedFile+"<<< and >>>"+cfgFile+"<<< in assertConfigFiles]", e); + String schema = joinLines( + "schema test inherits nonesuch {" + + " document test inherits nonesuch {" + + " }" + + "}"); + DeployLoggerStub logger = new DeployLoggerStub(); + SearchBuilder.createFromStrings(logger, schema); + assertEquals("schema 'test' inherits 'nonesuch', but this schema does not exist", + logger.entries.get(0).message); + fail("Expected failure"); + } + catch (IllegalArgumentException e) { + assertEquals("schema 'test' inherits 'nonesuch', but this schema does not exist", e.getMessage()); } } - /** - * This is to avoid having to keep those pesky array index numbers in the config format up to date - * as new entries are added and removed. - */ - private static String readAndCensorIndexes(String file) throws IOException { - StringBuilder b = new StringBuilder(); - try (BufferedReader r = IOUtils.createReader(file)) { - int character; - boolean lastWasNewline = false; - boolean inBrackets = false; - while (-1 != (character = r.read())) { - // skip empty lines - if (character == '\n') { - if (lastWasNewline) continue; - lastWasNewline = true; - } - else { - lastWasNewline = false; - } - // skip quoted strings - if (character == '"') { - b.appendCodePoint(character); - while (-1 != (character = r.read()) && character != '"') { - b.appendCodePoint(character); - } - } - - // skip bracket content - if (character == ']') - inBrackets = false; - if (! inBrackets) - b.appendCodePoint(character); - if (character == '[') - inBrackets = true; - } + @Test + public void testValidationOfSchemaAndDocumentInheritanceConsistency() throws ParseException { + try { + String parent = joinLines( + "schema parent {" + + " document parent {" + + " field pf1 type string {" + + " indexing: summary" + + " }" + + " }" + + "}"); + String child = joinLines( + "schema child inherits parent {" + + " document child {" + + " field cf1 type string {" + + " indexing: summary" + + " }" + + " }" + + "}"); + DeployLoggerStub logger = new DeployLoggerStub(); + SearchBuilder.createFromStrings(logger, parent, child); + logger.entries.forEach(e -> System.out.println(e)); + assertTrue(logger.entries.isEmpty()); + } + catch (IllegalArgumentException e) { + assertEquals("schema 'child' inherits 'parent', " + + "but its document type does not inherit the parent's document type" + , e.getMessage()); } - return b.toString(); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java index 6155b1521b0..d382e29ca4d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNull; * * @author bratseth */ -public class StemmingSettingTestCase extends SchemaTestCase { +public class StemmingSettingTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java index 9fd5df5e028..73c8915b5a0 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java @@ -14,7 +14,7 @@ import static org.junit.Assert.fail; * * @author bratseth */ -public class StructTestCase extends SchemaTestCase { +public class StructTestCase extends AbstractSchemaTestCase { @Test public void testStruct() throws IOException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java index a3adfc8dd9f..52e155fc9a5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java @@ -265,7 +265,7 @@ public class SummaryTestCase { DeployLoggerStub logger = new DeployLoggerStub(); SearchBuilder.createFromStrings(logger, parent, child); logger.entries.forEach(e -> System.out.println(e)); - // assertTrue(logger.entries.isEmpty()); + //assertTrue(logger.entries.isEmpty()); } private static class TestValue { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java index a517f2544a6..3394db6869e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java @@ -9,7 +9,7 @@ import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import com.yahoo.vespa.configmodel.producers.DocumentManager; @@ -23,7 +23,7 @@ import java.io.IOException; * * @author bratseth */ -public abstract class AbstractExportingTestCase extends SchemaTestCase { +public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { private static final String tempDir = "temp/"; private static final String searchDefRoot = "src/test/derived/"; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index 43dfb9f3bc5..f8316c831f1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -20,7 +20,7 @@ import static org.junit.Assert.assertFalse; * * @author bratseth */ -public class AttributeListTestCase extends SchemaTestCase { +public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java index ad4ca1ebb46..080752d260f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals; * * @author vegardh */ -public class CasingTestCase extends SchemaTestCase { +public class CasingTestCase extends AbstractSchemaTestCase { @Test public void testCasing() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java index 5638aeb92c0..b1fb1962fc8 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.DataType; import com.yahoo.document.DocumentTypeManager; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import org.junit.Test; import java.util.List; @@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals; * * @author bratseth */ -public class DeriverTestCase extends SchemaTestCase { +public class DeriverTestCase extends AbstractSchemaTestCase { @Test public void testDeriveDocManager() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java index 41ad7cd3bd1..2633f7881bd 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import org.junit.Test; @@ -16,7 +16,7 @@ import org.junit.Test; * * @author bratseth */ -public class EmptyRankProfileTestCase extends SchemaTestCase { +public class EmptyRankProfileTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java index 3b16ff0221e..8c6bc40ece0 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.RankType; import org.junit.Test; @@ -14,7 +14,7 @@ import static org.junit.Assert.*; * * @author geirst */ -public class NativeRankTypeDefinitionsTestCase extends SchemaTestCase { +public class NativeRankTypeDefinitionsTestCase extends AbstractSchemaTestCase { @Test public void testTables() { assertEquals(NativeTable.Type.FIRST_OCCURRENCE.getName(), "firstOccurrenceTable"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java index ef939aa5093..c6f254df798 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.DocumentReference; import com.yahoo.searchdefinition.DocumentReferences; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.TemporarySDField; @@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; * @author bratseth * @author bjorncs */ -public class SchemaOrdererTestCase extends SchemaTestCase { +public class SchemaOrdererTestCase extends AbstractSchemaTestCase { private static Map<String, Schema> createSchemas() { Map<String, Schema> schemas = new HashMap<>(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java index 6ed03f7b237..8bb9d8c923d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; * * @author bratseth */ -public class SummaryMapTestCase extends SchemaTestCase { +public class SummaryMapTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { Schema schema = SearchBuilder.buildFromFile("src/test/examples/simple.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java index 67403cdd25a..ea801b54b5c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.search.SummaryConfig; import org.junit.Test; @@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue; * * @author bratseth */ -public class SummaryTestCase extends SchemaTestCase { +public class SummaryTestCase extends AbstractSchemaTestCase { @Test public void deriveRawAsBase64() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java index bfed1efe398..6967c86944c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TypeConversionTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.processing.Processing; @@ -18,7 +18,7 @@ import static org.junit.Assert.assertFalse; * * @author bratseth */ -public class TypeConversionTestCase extends SchemaTestCase { +public class TypeConversionTestCase extends AbstractSchemaTestCase { /** Tests that exact-string stuff is not spilled over to the default index */ @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java index c2d1023826c..57e01cb9dfc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,7 +17,7 @@ import static org.junit.Assert.assertFalse; * @author vegardh * */ -public class AttributesExactMatchTestCase extends SchemaTestCase { +public class AttributesExactMatchTestCase extends AbstractSchemaTestCase { @Test public void testAttributesExactMatch() throws IOException, ParseException { Schema schema = SearchBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java index 288987e0f2f..d9d8e47338b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -12,7 +12,7 @@ import static org.junit.Assert.fail; /** * @author bratseth */ -public class BoldingTestCase extends SchemaTestCase { +public class BoldingTestCase extends AbstractSchemaTestCase { private final String boldonnonstring = "search boldnonstring {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java index f3d188abf82..dffc0d968df 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.parser.ParseException; @@ -14,7 +14,7 @@ import java.io.IOException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -public class ImplicitSchemaFieldsTestCase extends SchemaTestCase { +public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatExtraFieldsAreIncluded() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java index ec132bd2450..b069f62ee92 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.document.*; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; @@ -13,7 +13,7 @@ import org.junit.Test; import java.io.IOException; import static org.junit.Assert.*; -public class ImplicitStructTypesTestCase extends SchemaTestCase { +public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException { Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java index 78dabe9301a..c9f941087ef 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.DocumentSummary; import org.junit.Test; @@ -13,7 +13,7 @@ import java.io.IOException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -public class ImplicitSummaryFieldsTestCase extends SchemaTestCase { +public class ImplicitSummaryFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java index aad7a725b9e..e0b8f4b89a5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -28,7 +28,7 @@ import static org.junit.Assert.assertEquals; /** * @author Simon Thoresen Hult */ -public class IndexingScriptRewriterTestCase extends SchemaTestCase { +public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { @Test public void testSetLanguageRewriting() { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java index 5df8f20b5c7..cd5dd451026 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue; /** * @author baldersheim */ -public class IntegerIndex2AttributeTestCase extends SchemaTestCase { +public class IntegerIndex2AttributeTestCase extends AbstractSchemaTestCase { @Test public void testIntegerIndex2Attribute() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java index 73b4b9a7e53..0e13aacb76f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -21,7 +21,7 @@ import static org.junit.Assert.fail; /** * @author bratseth */ -public class NGramTestCase extends SchemaTestCase { +public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testNGram() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java index 0aa4c3917d2..97eed506c85 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -14,7 +14,7 @@ import java.io.IOException; * @author vegardh * */ -public class RankModifierTestCase extends SchemaTestCase { +public class RankModifierTestCase extends AbstractSchemaTestCase { @Test public void testLiteral() throws IOException, ParseException { Schema schema = SearchBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java index 3f77741aa2a..5c53dbf0c57 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.searchdefinition.RankProfile.RankProperty; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -16,7 +16,7 @@ import java.util.List; import static org.junit.Assert.fail; -public class RankPropertyVariablesTestCase extends SchemaTestCase { +public class RankPropertyVariablesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropVariables() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java index a76379d185f..fc5a2b6a39a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java @@ -10,7 +10,7 @@ import com.yahoo.searchdefinition.LargeRankExpressions; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.derived.AttributeFields; @@ -28,7 +28,7 @@ import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class RankingExpressionsTestCase extends SchemaTestCase { +public class RankingExpressionsTestCase extends AbstractSchemaTestCase { private static Schema createSearch(String dir, ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { return SearchBuilder.createFromDirectory(dir, new MockFileRegistry(), new TestableDeployLogger(), deployProperties, rankProfileRegistry).getSearch(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java index da1037b6fd7..ec6a7e7acf9 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.model.container.search.QueryProfiles; import org.junit.Test; @@ -16,7 +16,7 @@ import java.io.IOException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -public class SummaryFieldsMustHaveValidSourceTestCase extends SchemaTestCase { +public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTestCase { @Test public void requireThatInvalidSourceIsCaught() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java index 19ae565ed07..888cd22c1c3 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java @@ -15,7 +15,7 @@ import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; import com.yahoo.searchdefinition.parser.ParseException; @@ -27,7 +27,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -public class TensorTransformTestCase extends SchemaTestCase { +public class TensorTransformTestCase extends AbstractSchemaTestCase { @Test public void requireThatNormalMaxAndMinAreNotReplaced() throws ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java index eec382a115c..e9aec9b7293 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -12,7 +12,7 @@ import java.io.IOException; import static org.junit.Assert.assertNotNull; /** @author bratseth */ -public class WeightedSetSummaryToTestCase extends SchemaTestCase { +public class WeightedSetSummaryToTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/AbstractReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/AbstractReferenceFieldTestCase.java index 9144ad411b2..e3f16711d73 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/AbstractReferenceFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/AbstractReferenceFieldTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; @@ -12,7 +12,7 @@ import java.io.IOException; /** * Utility functions for testing generated configs for reference/imported fields. */ -public abstract class AbstractReferenceFieldTestCase extends SchemaTestCase { +public abstract class AbstractReferenceFieldTestCase extends AbstractSchemaTestCase { private static String TEST_FOLDER = "src/test/configmodel/types/references/"; diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java index 04ac16eb999..15de4b8c02e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.SearchBuilder; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; @@ -13,7 +13,7 @@ import java.io.IOException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -public class DocumentModelBuilderTestCase extends SchemaTestCase { +public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { @Test public void testDocumentManagerSimple() throws IOException, ParseException { |