use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFileCreateDirectory.
@Test
public void testApplicationFileCreateDirectory() throws Exception {
ApplicationFile file = getApplicationFile(Path.fromString("/notyet/exists/here"));
assertFalse(file.exists());
file.createDirectory();
assertTrue(file.exists());
assertTrue(file.isDirectory());
file = getApplicationFile(Path.fromString("myDir")).createDirectory();
assertTrue(file.isDirectory());
file = getApplicationFile(Path.fromString("myDir/sub")).createDirectory();
file = getApplicationFile(Path.fromString("myDir/sub")).createDirectory();
assertTrue(file.isDirectory());
file = getApplicationFile(Path.fromString("searchdefinitions/myDir2/")).createDirectory();
assertTrue(file.isDirectory());
file = getApplicationFile(Path.fromString("myDir3/myDir4/myDir5")).createDirectory();
assertTrue(file.exists());
assertTrue(file.isDirectory());
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method assertFileContent.
private void assertFileContent(String expected, String path) throws Exception {
ApplicationFile file = getApplicationFile(Path.fromString(path));
String actual = com.yahoo.io.IOUtils.readAll(file.createReader());
assertThat(actual, is(expected));
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFileListFiles.
@Test
public void testApplicationFileListFiles() throws Exception {
ApplicationFile file = getApplicationFile(Path.createRoot());
assertTrue(file.exists());
assertTrue(file.isDirectory());
List<ApplicationFile> list = file.listFiles();
assertThat(list.size(), is(6));
assertTrue(listContains(list, "vespa-services.xml"));
assertTrue(listContains(list, "vespa-hosts.xml"));
assertTrue(listContains(list, "components/"));
assertTrue(listContains(list, "searchdefinitions/"));
assertTrue(listContains(list, "templates/"));
assertTrue(listContains(list, "files/"));
list = getApplicationFile(Path.fromString("templates")).listFiles(false);
assertTrue(listContains(list, "templates/basic/"));
assertTrue(listContains(list, "templates/simple_html/"));
assertTrue(listContains(list, "templates/text/"));
list = getApplicationFile(Path.fromString("components")).listFiles(false);
assertTrue(listContains(list, "components/defs-only.jar"));
assertTrue(listContains(list, "components/file.txt"));
list = getApplicationFile(Path.fromString("components")).listFiles(true);
assertTrue(listContains(list, "components/defs-only.jar"));
assertTrue(listContains(list, "components/file.txt"));
list = getApplicationFile(Path.fromString("templates")).listFiles(true);
assertThat(list.size(), is(14));
assertTrue(listContains(list, "templates/basic/"));
assertTrue(listContains(list, "templates/basic/error.templ"));
assertTrue(listContains(list, "templates/basic/header.templ"));
assertTrue(listContains(list, "templates/basic/hit.templ"));
assertTrue(listContains(list, "templates/simple_html/"));
assertTrue(listContains(list, "templates/simple_html/footer.templ"));
assertTrue(listContains(list, "templates/simple_html/header.templ"));
assertTrue(listContains(list, "templates/simple_html/hit.templ"));
assertTrue(listContains(list, "templates/text/"));
assertTrue(listContains(list, "templates/text/error.templ"));
assertTrue(listContains(list, "templates/text/footer.templ"));
assertTrue(listContains(list, "templates/text/header.templ"));
assertTrue(listContains(list, "templates/text/hit.templ"));
assertTrue(listContains(list, "templates/text/nohits.templ"));
list = getApplicationFile(Path.createRoot()).listFiles(true);
assertTrue(listContains(list, "components/"));
assertTrue(listContains(list, "files/"));
assertTrue(listContains(list, "searchdefinitions/"));
assertTrue(listContains(list, "templates/"));
assertTrue(listContains(list, "vespa-hosts.xml"));
assertTrue(listContains(list, "vespa-services.xml"));
assertTrue(listContains(list, "templates/text/"));
assertTrue(listContains(list, "templates/text/error.templ"));
assertTrue(listContains(list, "templates/text/footer.templ"));
assertTrue(listContains(list, "templates/text/header.templ"));
assertTrue(listContains(list, "templates/text/hit.templ"));
assertTrue(listContains(list, "templates/text/nohits.templ"));
list = getApplicationFile(Path.createRoot()).listFiles(new ApplicationFile.PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().endsWith(".xml");
}
});
assertThat(list.size(), is(2));
assertFalse(listContains(list, "components/"));
assertFalse(listContains(list, "files/"));
assertFalse(listContains(list, "searchdefinitions/"));
assertFalse(listContains(list, "templates/"));
assertTrue(listContains(list, "vespa-hosts.xml"));
assertTrue(listContains(list, "vespa-services.xml"));
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFileCreateFileWithPath.
@Test
public void testApplicationFileCreateFileWithPath() throws Exception {
ApplicationFile file = getApplicationFile(Path.fromString("subdir/newfile.txt"));
assertFalse(file.exists());
file.writeFile(new StringReader("foobar"));
assertTrue(file.exists());
assertFalse(file.isDirectory());
assertThat(com.yahoo.io.IOUtils.readAll(file.createReader()), is("foobar"));
}
use of com.yahoo.config.application.api.ApplicationFile in project vespa by vespa-engine.
the class SessionFactoryTest method require_that_application_name_is_set_in_application_package.
@Test
public void require_that_application_name_is_set_in_application_package() throws IOException, JSONException {
LocalSession session = getLocalSession("book");
assertNotNull(session);
ApplicationFile meta = session.getApplicationFile(Path.createRoot().append(".applicationMetaData"), LocalSession.Mode.READ);
assertTrue(meta.exists());
JSONObject json = new JSONObject(IOUtils.readAll(meta.createReader()));
assertThat(json.getJSONObject("application").getString("name"), is("book"));
}
Aggregations