Search in sources :

Example 96 with Project

use of org.apache.tools.ant.Project in project exist by eXist-db.

the class XmldbTaskTest method copy.

@Test
public void copy() {
    final Project project = buildFileRule.getProject();
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION, TEST_COLLECTION_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_RESOURCE, TEST_RESOURCE_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_RESOURCE2, TEST_RESOURCE2_NAME);
    buildFileRule.executeTarget("copy");
    final String result = project.getProperty(PROP_ANT_TEST_DATA_RESULT);
    assertThat(result, allOf(containsString(TEST_RESOURCE_NAME), containsString(TEST_RESOURCE2_NAME)));
}
Also used : Project(org.apache.tools.ant.Project) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 97 with Project

use of org.apache.tools.ant.Project in project exist by eXist-db.

the class XmldbTaskTest method extractCreateDirectories.

@Test
public void extractCreateDirectories() throws IOException {
    final Path tmpDir = temporaryFolder.newFolder().toPath();
    Files.createDirectories(tmpDir);
    final Project project = buildFileRule.getProject();
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION, TEST_COLLECTION_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_RESOURCE, TEST_RESOURCE_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TMP_DIR, tmpDir.toAbsolutePath().toString());
    buildFileRule.executeTarget("extractCreateDirectories");
    assertTrue(Files.exists(tmpDir));
    assertTrue(Files.exists(tmpDir.resolve(TEST_RESOURCE_NAME)));
    assertTrue(Files.exists(tmpDir.resolve(OTHER_TEST_COLLECTION_NAME)));
    assertTrue(Files.exists(tmpDir.resolve(OTHER_TEST_COLLECTION_NAME).resolve(OTHER_TEST_RESOURCE_NAME)));
}
Also used : Path(java.nio.file.Path) Project(org.apache.tools.ant.Project) Test(org.junit.Test)

Example 98 with Project

use of org.apache.tools.ant.Project in project exist by eXist-db.

the class XmldbTaskTest method storeEmptyFile.

@Test
public void storeEmptyFile() throws IOException {
    final Path tmpFile = temporaryFolder.newFile().toPath();
    final Project project = buildFileRule.getProject();
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION, TEST_COLLECTION_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TMP_FILE, tmpFile.toAbsolutePath().toString());
    project.setProperty(PROP_ANT_TEST_DATA_TMP_FILE_NAME, FileUtils.fileName(tmpFile));
    buildFileRule.executeTarget("store");
    final String result = project.getProperty(PROP_ANT_TEST_DATA_RESULT);
    assertFalse(Boolean.parseBoolean(result));
}
Also used : Path(java.nio.file.Path) Project(org.apache.tools.ant.Project) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 99 with Project

use of org.apache.tools.ant.Project in project exist by eXist-db.

the class XmldbTaskTest method create.

@Test
public void create() {
    final Project project = buildFileRule.getProject();
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION, TEST_COLLECTION_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION2, TEST_COLLECTION2_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_RESOURCE, TEST_RESOURCE_NAME);
    buildFileRule.executeTarget("create");
    final String result = project.getProperty(PROP_ANT_TEST_DATA_RESULT);
    assertThat(result, containsString(TEST_COLLECTION2_NAME));
}
Also used : Project(org.apache.tools.ant.Project) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 100 with Project

use of org.apache.tools.ant.Project in project exist by eXist-db.

the class FileTaskTest method chmod.

@Test
public void chmod() throws XMLDBException {
    final Project project = buildFileRule.getProject();
    project.setProperty(PROP_ANT_TEST_DATA_TEST_COLLECTION, TEST_COLLECTION_NAME);
    project.setProperty(PROP_ANT_TEST_DATA_TEST_RESOURCE, TEST_RESOURCE_NAME);
    buildFileRule.executeTarget("chmod");
    final String result = project.getProperty(PROP_ANT_TEST_DATA_RESULT);
    assertThat(result, containsString(TEST_RESOURCE_NAME));
    final Collection col = existEmbeddedServer.getRoot().getChildCollection(TEST_COLLECTION_NAME);
    final EXistResource res = (EXistResource) col.getResource(TEST_RESOURCE_NAME);
    assertEquals("---rwxrwx", res.getPermissions().toString());
}
Also used : EXistResource(org.exist.xmldb.EXistResource) Project(org.apache.tools.ant.Project) Collection(org.xmldb.api.base.Collection) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

Project (org.apache.tools.ant.Project)331 File (java.io.File)125 Test (org.junit.Test)107 BuildException (org.apache.tools.ant.BuildException)66 Path (org.apache.tools.ant.types.Path)44 IOException (java.io.IOException)38 Before (org.junit.Before)36 FileSet (org.apache.tools.ant.types.FileSet)24 Commandline (org.apache.tools.ant.types.Commandline)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)16 Path (java.nio.file.Path)14 DefaultLogger (org.apache.tools.ant.DefaultLogger)14 Test (org.junit.jupiter.api.Test)14 Matchers.containsString (org.hamcrest.Matchers.containsString)13 ZipFile (java.util.zip.ZipFile)12 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)12 Delete (org.apache.tools.ant.taskdefs.Delete)12 Properties (java.util.Properties)9 ProjectHelper (org.apache.tools.ant.ProjectHelper)9 ArrayList (java.util.ArrayList)8