blob: 001ad64e2da3954a2e68d2e6c84ff98735579e84 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2017 Yahoo Holdings. 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 bratseth
*/
public class StructTestCase extends SearchDefinitionTestCase {
@Test
public void testStruct() throws IOException {
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 expected) {
// success
}
}
@Test
public void testStructAndDocumentWithSameNames() {
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.
*/
@Test(expected = IllegalArgumentException.class)
public void testStructOutsideDocumentIllegal() throws IOException, ParseException {
SearchBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd");
}
}
|