summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/Sandbox.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
index 0e1fe9737..2af724585 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
@@ -13,7 +13,10 @@
package org.aspectj.testing.harness.bridge;
import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
import java.util.ArrayList;
+import java.util.Arrays;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
@@ -327,6 +330,25 @@ public class Sandbox {
return testBaseSrcDir;
}
+ /**
+ * Get the files with names (case-sensitive)
+ * under the staging or test base directories.
+ * @param names
+ * @return
+ */
+ File[] findFiles(final String[] names) {
+ ArrayList result = new ArrayList();
+ NamesFilter filter = new NamesFilter(names);
+ File[] bases = { testBaseDir, sandboxDir };
+ for (int i = 0; i < bases.length; i++) {
+ File base = bases[i];
+ if ((null == base) || !base.canRead()) {
+ continue;
+ }
+ result.addAll(Arrays.asList(FileUtil.listFiles(base, filter)));
+ }
+ return (File[]) result.toArray(new File[0]);
+ }
File getTestBaseSrcDir(JavaRun caller) {
LangUtil.throwIaxIfNull(caller, "caller");
return testBaseSrcDir;
@@ -491,4 +513,23 @@ public class Sandbox {
LangUtil.throwIaxIfNull(caller, "caller");
return bootClasspath;
}
+ private static class NamesFilter implements FileFilter {
+ private final String[] names;
+ private NamesFilter(String[] names) {
+ this.names = names;
+ }
+ public boolean accept(File file) {
+ if (null != file) {
+ String name = file.getName();
+ if (null != name) {
+ for (int i = 0; i < names.length; i++) {
+ if (name.equals(names[i])) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ }
}