aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java71
1 files changed, 63 insertions, 8 deletions
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 6fa716d9b76..7e6eaa0683a 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java
@@ -19,28 +19,83 @@ import static org.junit.Assert.assertTrue;
public class SummaryTestCase {
@Test
- public void testMemorySummary() throws IOException, ParseException {
+ public void testMemorySummary() throws ParseException {
+ String sd =
+ "search memorysummary {\n" +
+ "\n" +
+ " document memorysummary {\n" +
+ "\n" +
+ " field inmemory type string {\n" +
+ " indexing: attribute | summary\n" +
+ " }\n" +
+ " field ondisk type string {\n" +
+ " indexing: index # no summary, so ignored\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ "\n" +
+ "}";
DeployLoggerStub logger = new DeployLoggerStub();
- SearchBuilder.createFromFile("src/test/examples/memorysummary.sd", logger);
+ SearchBuilder.createFromString(sd, logger);
assertTrue(logger.entries.isEmpty());
}
@Test
- public void testDiskSummary() throws IOException, ParseException {
+ public void testDiskSummary() throws ParseException {
+ String sd =
+ "search disksummary {\n" +
+ "\n" +
+ " document-summary foobar {\n" +
+ " summary foo1 type string { source: inmemory }\n" +
+ " summary foo2 type string { source: ondisk }\n" +
+ " }\n" +
+ " document disksummary {\n" +
+ "\n" +
+ " field inmemory type string {\n" +
+ " indexing: attribute | summary\n" +
+ " }\n" +
+ " field ondisk type string {\n" +
+ " indexing: index | summary\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ "\n" +
+ "}";
DeployLoggerStub logger = new DeployLoggerStub();
- SearchBuilder.createFromFile("src/test/examples/disksummary.sd", logger);
+ SearchBuilder.createFromString(sd, logger);
assertEquals(1, logger.entries.size());
- assertEquals(Level.FINE, logger.entries.get(0).level);
- assertEquals("summary field 'ondisk' in document summary 'default' references source field 'ondisk', " +
+ assertEquals(Level.WARNING, logger.entries.get(0).level);
+ assertEquals("summary field 'foo2' in document summary 'foobar' references source field 'ondisk', " +
"which is not an attribute: Using this summary will cause disk accesses. " +
"Set 'from-disk' on this summary class to silence this warning.",
logger.entries.get(0).message);
}
@Test
- public void testDiskSummaryExplicit() throws IOException, ParseException {
+ public void testDiskSummaryExplicit() throws ParseException {
+ String sd =
+ "search disksummary {\n" +
+ "\n" +
+ " document disksummary {\n" +
+ "\n" +
+ " field inmemory type string {\n" +
+ " indexing: attribute | summary\n" +
+ " }\n" +
+ " field ondisk type string {\n" +
+ " indexing: index | summary\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ "\n" +
+ " document-summary foobar {\n" +
+ " summary foo1 type string { source: inmemory }\n" +
+ " summary foo2 type string { source: ondisk }\n" +
+ " from-disk\n" +
+ " }\n" +
+ "\n" +
+ "}";
DeployLoggerStub logger = new DeployLoggerStub();
- SearchBuilder.createFromFile("src/test/examples/disksummaryexplicit.sd", logger);
+ SearchBuilder.createFromString(sd, logger);
assertTrue(logger.entries.isEmpty());
}