| java.lang.Object org.netbeans.spi.project.support.ant.AntBasedTestUtil
AntBasedTestUtil | public class AntBasedTestUtil (Code) | | Test-related utilities for use in ant/project.
author: Jesse Glick |
Inner Class :public static class TestAntArtifact extends AntArtifact | |
Inner Class :final public static class TestMutablePropertyProvider implements PropertyProvider | |
countTextDiffs | public static int[] countTextDiffs(Reader r1, Reader r2) throws IOException(Code) | | Count the number of (line-based) differences between two text files.
The returned count has, in this order:
- Lines modified between the first and second files.
- Lines added in the second file that were not in the first.
- Lines removed in the second file that were in the first.
It thus serves as a summary of the number of diff lines you would expect
to get from e.g. a version control system doing a normal text checkin.
Parameters: r1 - the first file (the reader will not be closed for you) Parameters: r2 - the second file (the reader will not be closed for you) a count of lines modified, added, and removed (resp.) throws: IOException - in case reading from the files failed |
replaceInFile | public static int replaceInFile(File f, String from, String to) throws IOException(Code) | | Replace all occurrences of a given string in a file with a new string.
UTF-8 encoding is assumed.
Parameters: f - the file to modify Parameters: from - the search string Parameters: to - the replacement string a count of how many occurrences were replaced throws: IOException - in case reading or writing the file failed |
slurpProperties | public static Properties slurpProperties(AntProjectHelper h, String path) throws IOException(Code) | | Load a properties file from disk.
Parameters: h - a project reference Parameters: path - the relative file path properties available at that location, or null if no such file throws: IOException - if there is any problem loading it |
slurpText | public static String slurpText(AntProjectHelper h, String path) throws IOException(Code) | | Load a text file from disk.
Assumes UTF-8 encoding.
Parameters: h - a project reference Parameters: path - the relative file path the raw contents of the text file at that point, or null if no such file throws: IOException - if there is any problem loading it |
testAntBasedProjectType | public static AntBasedProjectType testAntBasedProjectType()(Code) | | Create an AntBasedProjectType instance suitable for testing.
It has the type code test.
It uses <data> as the configuration data element,
with namespaces urn:test:shared and urn:test:private.
Loading the project succeeds unless there is a file in it nbproject/broken.
The project's methods mostly delegate to the helper; its lookup uses the helper's
supports for AuxiliaryConfiguration, CacheDirectoryProvider, and SubprojectProvider,
and also adds an instance of String, namely "hello".
It also puts the AntProjectHelper into its lookup to assist in testing.
build-impl.xml is generated from data/build-impl.xsl
by a ProjectXmlSavedHook using GeneratedFilesHelper.refreshBuildScript.
A ReferenceHelper is also added to its lookup for testing purposes.
An
AntArtifactProviderMutable is added which initially publishes two artifacts:
one of target 'dojar' type 'jar' with artifact ${build.jar};
one of target 'dojavadoc' type 'javadoc' with artifact ${build.javadoc};
both using clean target 'clean'.
A GeneratedFilesHelper is added to its lookup for testing purposes.
a project type object for testing purposes |
testBuildXmlStylesheet | public static URL testBuildXmlStylesheet()(Code) | | Get a sample build.xsl .
a URL to a stylesheet |
testCollocationQueryImplementation | public static CollocationQueryImplementation testCollocationQueryImplementation(File root)(Code) | | Get a sample file collocation query provider.
Files under the supplied root are normally considered to be collocated.
However the subdirectory separate (if it exists) forms its own root.
And the subdirectory transient (if it exists) does not form a root,
but any files in there are not considered collocated with anything.
|
|
|