aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
Publish
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java')
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java53
1 files changed, 53 insertions, 0 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
new file mode 100755
index 00000000000..0b119ccbf0d
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
@@ -0,0 +1,53 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.searchdefinition;
+
+import com.yahoo.document.DocumenttypesConfig;
+import com.yahoo.document.config.DocumentmanagerConfig;
+import com.yahoo.searchdefinition.derived.Deriver;
+import com.yahoo.searchdefinition.parser.ParseException;
+import org.junit.Test;
+import java.io.IOException;
+import static org.junit.Assert.fail;
+
+/**
+ * tests importing of document containing array type fields
+ *
+ * @author <a href="bratseth@yahoo-inc.com">Jon Bratseth</a>
+ */
+public class StructTestCase extends SearchDefinitionTestCase {
+ @Test
+ public void testStruct() throws IOException, ParseException {
+ assertConfigFile("src/test/examples/structresult.cfg",
+ new DocumentmanagerConfig(Deriver.getDocumentManagerConfig("src/test/examples/struct.sd")).toString() + "\n");
+ }
+ @Test
+ public void testBadStruct() throws IOException {
+ try {
+ SearchBuilder.buildFromFile("src/test/examples/badstruct.sd");
+ fail("Should throw exception.");
+ } catch (ParseException e) {
+ //ok!
+ //e.printStackTrace();
+ }
+ }
+ @Test
+ public void testStructAndDocumentWithSameNames() throws IOException, ParseException {
+ try {
+ DocumenttypesConfig.Builder dt = Deriver.getDocumentTypesConfig("src/test/examples/structanddocumentwithsamenames.sd");
+ } catch (Exception e) {
+ fail("Should not have thrown exception " + e.toString());
+ }
+ }
+
+ /**
+ * Declaring a struct before a document will fail, no doc type to add it to.
+ * @throws IOException
+ * @throws ParseException
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testStructOutsideDocumentIllegal() throws IOException, ParseException {
+ SearchBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd");
+ }
+
+}
+