Browse Source

Add a getResource method. I would rather prefer to

load resource this way than assuming the JVM is the
root directory.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271133 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
390132ed55
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      src/testcases/org/apache/tools/ant/BuildFileTest.java

+ 14
- 2
src/testcases/org/apache/tools/ant/BuildFileTest.java View File

@@ -57,6 +57,7 @@ package org.apache.tools.ant;
import junit.framework.*;
import org.apache.tools.ant.*;
import java.io.*;
import java.net.URL;

/**
* A BuildFileTest is a TestCase which executes targets from an Ant buildfile
@@ -256,9 +257,20 @@ public abstract class BuildFileTest extends TestCase {
expectPropertySet(target, property, null);
}

/**
* Retrieve a resource from the caller classloader to avoid
* assuming a vm working directory. The resource path must be
* relative to the package name or absolute from the root path.
* @param resource the resource to retrieve its url.
* @throws AssertionFailureException if resource is not found.
*/
protected URL getResource(String resource){
URL url = getClass().getResource(resource);
assertNotNull("Could not find resource :" + resource, url);
return url;
}

private class AntOutputStream extends java.io.OutputStream {
private class AntOutputStream extends java.io.OutputStream {
public void write(int b) {
outBuffer.append((char)b);
}


Loading…
Cancel
Save