aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java')
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java21
1 files changed, 19 insertions, 2 deletions
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 c27dd9dfdfb..32f82f44ad0 100755
--- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
@@ -1,10 +1,13 @@
+
// 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.config.model.deploy.TestProperties;
import com.yahoo.document.config.DocumenttypesConfig;
import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.searchdefinition.derived.Deriver;
import com.yahoo.searchdefinition.parser.ParseException;
+import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.fail;
@@ -27,15 +30,19 @@ public class StructTestCase extends AbstractSchemaTestCase {
try {
ApplicationBuilder.buildFromFile("src/test/examples/badstruct.sd");
fail("Should throw exception.");
- } catch (ParseException expected) {
+ } catch (IllegalArgumentException|ParseException expected) {
+ System.err.println("As expected, with message: "+expected.getMessage());
// success
}
}
@Test
+ @Ignore
public void testStructAndDocumentWithSameNames() {
try {
DocumenttypesConfig.Builder dt = Deriver.getDocumentTypesConfig("src/test/examples/structanddocumentwithsamenames.sd");
+ // while the above line may work, the config generated will fail.
+ // See also NameCollisionTestCase.
} catch (Exception e) {
fail("Should not have thrown exception " + e);
}
@@ -46,7 +53,17 @@ public class StructTestCase extends AbstractSchemaTestCase {
*/
@Test(expected = IllegalArgumentException.class)
public void testStructOutsideDocumentIllegal() throws IOException, ParseException {
- ApplicationBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd");
+ var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(false));
+ builder.addSchemaFile("src/test/examples/structoutsideofdocument.sd");
+ }
+
+ /**
+ * Declaring a struct before a document should work
+ */
+ @Test
+ public void testStructOutsideDocumentLegal() throws IOException, ParseException {
+ var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(true));
+ builder.addSchemaFile("src/test/examples/structoutsideofdocument.sd");
}
}