aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2020-03-17 11:41:59 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2020-03-17 11:41:59 +0100
commit79f4cb5be4a6719d0b11cd39c3f44af2849903b8 (patch)
tree58d830381f0e6f05309d49d4b8f5c88aa2545db9 /config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java
parentca1eae82829cd9f2d270b2b788432a4461c1dc3e (diff)
Revert "Merge pull request #12565 from vespa-engine/revert-12563-bratseth/search-to-schema"
This reverts commit ea5fe1bf8c0d389a3964d2e5c490994920d21a4e, reversing changes made to 7e92c3852e893d09f0aa821e04e4e9dbe83b4ab2.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java')
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java44
1 files changed, 25 insertions, 19 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java
index cb1577417b4..fe82f2406f2 100644
--- a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java
@@ -20,7 +20,7 @@ import com.yahoo.searchdefinition.DocumentOnlySearch;
import com.yahoo.vespa.config.ConfigDefinition;
import com.yahoo.vespa.config.ConfigDefinitionKey;
import com.yahoo.vespa.model.VespaModel;
-import com.yahoo.vespa.model.search.SearchDefinition;
+import com.yahoo.vespa.model.search.NamedSchema;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -31,7 +31,6 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -60,9 +59,9 @@ public class ApplicationDeployTest {
public void testVespaModel() throws SAXException, IOException {
ApplicationPackageTester tester = ApplicationPackageTester.create(TESTDIR + "app1");
VespaModel model = new VespaModel(tester.app());
- List<SearchDefinition> searchDefinitions = tester.getSearchDefinitions();
- assertEquals(searchDefinitions.size(), 5);
- for (SearchDefinition searchDefinition : searchDefinitions) {
+ List<NamedSchema> schemas = tester.getSchemas();
+ assertEquals(schemas.size(), 5);
+ for (NamedSchema searchDefinition : schemas) {
Search s = searchDefinition.getSearch();
switch (s.getName()) {
case "music":
@@ -72,21 +71,18 @@ public class ApplicationDeployTest {
break;
case "product":
assertTrue(s instanceof DocumentOnlySearch);
- assertEquals(s.getDocument().getField("title").getDataType(), DataType.STRING);
+ assertEquals(DataType.STRING, s.getDocument().getField("title").getDataType());
break;
default:
fail();
}
}
- File[] truth = new File[]{new File(TESTSDDIR + "laptop.sd"),
- new File(TESTSDDIR + "music.sd"),
- new File(TESTSDDIR + "pc.sd"),
- new File(TESTSDDIR + "product.sd"),
- new File(TESTSDDIR + "sock.sd")};
- Arrays.sort(truth);
- List<File> appSdFiles = tester.app().getSearchDefinitionFiles();
- Collections.sort(appSdFiles);
- assertEquals(appSdFiles, Arrays.asList(truth));
+ assertEquals(Set.of(new File(TESTSDDIR + "laptop.sd"),
+ new File(TESTSDDIR + "music.sd"),
+ new File(TESTSDDIR + "pc.sd"),
+ new File(TESTSDDIR + "product.sd"),
+ new File(TESTSDDIR + "sock.sd")),
+ new HashSet<>(tester.app().getSearchDefinitionFiles()));
List<FilesApplicationPackage.Component> components = tester.app().getComponents();
assertEquals(1, components.size());
@@ -103,7 +99,7 @@ public class ApplicationDeployTest {
// Check that getFilename works
ArrayList<String> sdFileNames = new ArrayList<>();
- for (SearchDefinition sd : searchDefinitions)
+ for (NamedSchema sd : schemas)
sdFileNames.add(sd.getFilename());
Collections.sort(sdFileNames);
assertEquals("laptop.sd", sdFileNames.get(0));
@@ -190,11 +186,11 @@ public class ApplicationDeployTest {
File tmpDir = tmpFolder.getRoot();
IOUtils.copyDirectory(new File(TESTDIR, "app1"), tmpDir);
ApplicationPackageTester tester = ApplicationPackageTester.create(tmpDir.getAbsolutePath());
- assertEquals(5, tester.getSearchDefinitions().size());
- File sdDir = new File(tmpDir, "searchdefinitions");
+ assertEquals(5, tester.getSchemas().size());
+ File sdDir = new File(tmpDir, "schemas");
File sd = new File(sdDir, "testfoo.sd");
IOUtils.writeFile(sd, "search testfoo { document testfoo { field bar type string { } } }", false);
- assertEquals(6, tester.getSearchDefinitions().size());
+ assertEquals(6, tester.getSchemas().size());
}
@Test
@@ -300,6 +296,16 @@ public class ApplicationDeployTest {
@Test
public void testGetJarEntryName() {
+ JarEntry e = new JarEntry("/schemas/foo.sd");
+ assertEquals(ApplicationPackage.getFileName(e), "foo.sd");
+ e = new JarEntry("bar");
+ assertEquals(ApplicationPackage.getFileName(e), "bar");
+ e = new JarEntry("");
+ assertEquals(ApplicationPackage.getFileName(e), "");
+ }
+
+ @Test
+ public void testGetJarEntryNameForLegacyPath() {
JarEntry e = new JarEntry("/searchdefinitions/foo.sd");
assertEquals(ApplicationPackage.getFileName(e), "foo.sd");
e = new JarEntry("bar");