summaryrefslogtreecommitdiffstats
path: root/taskdefs
diff options
context:
space:
mode:
Diffstat (limited to 'taskdefs')
-rw-r--r--taskdefs/testdata/inpathDirs/InpathAspect.java7
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirOne/pack/Pack.classbin0 -> 235 bytes
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirOne/pack/includeme1
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirOne/pack/something.txt1
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirTwo/Default.classbin0 -> 300 bytes
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirTwo/copyMe.htm1
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirTwo/doNotCopy0
-rw-r--r--taskdefs/testdata/inpathDirs/inpathDirTwo/skipTxtFiles.txt1
-rw-r--r--taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java91
9 files changed, 101 insertions, 1 deletions
diff --git a/taskdefs/testdata/inpathDirs/InpathAspect.java b/taskdefs/testdata/inpathDirs/InpathAspect.java
new file mode 100644
index 000000000..5929fab56
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/InpathAspect.java
@@ -0,0 +1,7 @@
+
+public aspect InpathAspect {
+ after() returning : staticinitialization(Default)
+ || staticinitialization(pack.Pack) {
+ System.out.println("initialized " + thisJoinPoint);
+ }
+} \ No newline at end of file
diff --git a/taskdefs/testdata/inpathDirs/inpathDirOne/pack/Pack.class b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/Pack.class
new file mode 100644
index 000000000..6821e2017
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/Pack.class
Binary files differ
diff --git a/taskdefs/testdata/inpathDirs/inpathDirOne/pack/includeme b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/includeme
new file mode 100644
index 000000000..5e40c0877
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/includeme
@@ -0,0 +1 @@
+asdf \ No newline at end of file
diff --git a/taskdefs/testdata/inpathDirs/inpathDirOne/pack/something.txt b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/something.txt
new file mode 100644
index 000000000..d6d9d34ca
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirOne/pack/something.txt
@@ -0,0 +1 @@
+blah \ No newline at end of file
diff --git a/taskdefs/testdata/inpathDirs/inpathDirTwo/Default.class b/taskdefs/testdata/inpathDirs/inpathDirTwo/Default.class
new file mode 100644
index 000000000..84cb19122
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirTwo/Default.class
Binary files differ
diff --git a/taskdefs/testdata/inpathDirs/inpathDirTwo/copyMe.htm b/taskdefs/testdata/inpathDirs/inpathDirTwo/copyMe.htm
new file mode 100644
index 000000000..124ceef98
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirTwo/copyMe.htm
@@ -0,0 +1 @@
+<html><head><title>copyMe</title></head><body>copyMe</body></html> \ No newline at end of file
diff --git a/taskdefs/testdata/inpathDirs/inpathDirTwo/doNotCopy b/taskdefs/testdata/inpathDirs/inpathDirTwo/doNotCopy
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirTwo/doNotCopy
diff --git a/taskdefs/testdata/inpathDirs/inpathDirTwo/skipTxtFiles.txt b/taskdefs/testdata/inpathDirs/inpathDirTwo/skipTxtFiles.txt
new file mode 100644
index 000000000..5e40c0877
--- /dev/null
+++ b/taskdefs/testdata/inpathDirs/inpathDirTwo/skipTxtFiles.txt
@@ -0,0 +1 @@
+asdf \ No newline at end of file
diff --git a/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
index ee5be7103..b8ebf9655 100644
--- a/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
+++ b/taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
@@ -23,6 +23,8 @@ import org.aspectj.util.*;
import java.io.*;
import java.io.File;
import java.util.Arrays;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import junit.framework.TestCase;
@@ -197,7 +199,94 @@ public class AjcTaskTest extends TestCase {
assertTrue(file + ".canRead() passed", !file.canRead());
}
- private void checkRun(AjcTask task, String exceptionString) {
+ public void testInpathDirCopyFilter() {
+ // inpathDirCopyFilter works with output directory
+ File destDir = getTempDir();
+ assertTrue(
+ "unable to create " + destDir,
+ destDir.canRead() || destDir.mkdirs());
+ AjcTask task = getTask(NOFILE, destDir);
+ Project p = task.getProject();
+ Path indirs = new Path(p);
+ File dir = new File(testdataDir, "inpathDirs").getAbsoluteFile();
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirOne").getAbsolutePath()));
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirTwo").getAbsolutePath()));
+ task.setInpath(indirs);
+ task.setInpathDirCopyFilter("doNotCopy,**/*.txt");
+
+ File file = new File(destDir, "Default.java").getAbsoluteFile();
+ assertTrue(file + ".canRead() prematurely", !file.canRead());
+ checkRun(task, null);
+
+ // got expected resources
+ File pack = new File(destDir, "pack");
+ file = new File(pack, "includeme").getAbsoluteFile();
+ assertTrue(file + ".canRead() failed", file.canRead());
+ file = new File(pack, "Pack.class").getAbsoluteFile();
+ assertTrue(file + ".canRead() failed", file.canRead());
+ file = new File(destDir, "copyMe.htm").getAbsoluteFile();
+ assertTrue(file + ".canRead() failed", file.canRead());
+ file = new File(destDir, "Default.class").getAbsoluteFile();
+ assertTrue(file + ".canRead() failed", file.canRead());
+
+ // didn't get unexpected resources
+ file = new File(pack, "something.txt");
+ assertTrue(file + ".canRead() passed", !file.canRead());
+ file = new File(destDir, "doNotCopy");
+ assertTrue(file + ".canRead() passed", !file.canRead());
+ file = new File(destDir, "skipTxtFiles.txt");
+ assertTrue(file + ".canRead() passed", !file.canRead());
+ }
+
+ public void testInpathDirCopyFilterWithJar() throws IOException {
+ // inpathDirCopyFilter works with output jar
+ File destDir = getTempDir();
+ assertTrue(
+ "unable to create " + destDir,
+ destDir.canRead() || destDir.mkdirs());
+ AjcTask task = getTask(NOFILE, null);
+ File destJar = new File(destDir, "testInpathDirCopyFilterWithJar-out.jar");
+ task.setOutjar(destJar);
+ Project p = task.getProject();
+ Path indirs = new Path(p);
+ File dir = new File(testdataDir, "inpathDirs").getAbsoluteFile();
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirOne").getAbsolutePath()));
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirTwo").getAbsolutePath()));
+ task.setInpath(indirs);
+ task.setInpathDirCopyFilter("doNotCopy,**/*.txt,**/*.class");
+
+ checkRun(task, null);
+
+ JarFile jarFile = new JarFile(destJar);
+ String[] expected = {"copyMe.htm", "pack/includeme",
+ "pack/Pack.class", "Default.class"};
+ String[] unexpected = {"doNotCopy", "skipTxtFiles.txt", "pack/something.txt"};
+ for (int i = 0; i < expected.length; i++) {
+ JarEntry entry = jarFile.getJarEntry(expected[i]);
+ assertTrue(expected[i] + " not found", null != entry);
+ }
+ for (int i = 0; i < unexpected.length; i++) {
+ JarEntry entry = jarFile.getJarEntry(unexpected[i]);
+ assertTrue(unexpected[i] + " found", null == entry);
+ }
+ }
+
+ public void testInpathDirCopyFilterError() {
+ // inpathDirCopyFilter fails with no output directory or jar iff specified
+ AjcTask task = getTask(NOFILE, null);
+ Project p = task.getProject();
+ Path indirs = new Path(p);
+ File dir = new File(testdataDir, "inpathDirs").getAbsoluteFile();
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirOne").getAbsolutePath()));
+ indirs.addExisting(new Path(p, new File(dir, "inpathDirTwo").getAbsolutePath()));
+ task.setInpath(indirs);
+ task.setInpathDirCopyFilter("doNotCopy,**/*.txt,**/*.class");
+
+ // expecting error
+ checkRun(task, "inpathDirCopyFilter");
+ }
+
+ private void checkRun(AjcTask task, String exceptionString) {
try {
task.execute();
assertTrue(null == exceptionString);