Methods Summary |
---|
JUnitTaskMirror.JUnitResultFormatterMirror | createFormatter()
return createFormatter(null);
|
JUnitTaskMirror.JUnitResultFormatterMirror | createFormatter(java.lang.ClassLoader loader)
if (classname == null) {
throw new BuildException("you must specify type or classname");
}
//although this code appears to duplicate that of ClasspathUtils.newInstance,
//we cannot use that because this formatter may run in a forked process,
//without that class.
Class f = null;
try {
if (loader == null) {
f = Class.forName(classname);
} else {
f = Class.forName(classname, true, loader);
}
} catch (ClassNotFoundException e) {
throw new BuildException(
"Using loader " + loader + " on class " + classname
+ ": " + e, e);
} catch (NoClassDefFoundError e) {
throw new BuildException(
"Using loader " + loader + " on class " + classname
+ ": " + e, e);
}
Object o = null;
try {
o = f.newInstance();
} catch (InstantiationException e) {
throw new BuildException(e);
} catch (IllegalAccessException e) {
throw new BuildException(e);
}
if (!(o instanceof JUnitTaskMirror.JUnitResultFormatterMirror)) {
throw new BuildException(classname
+ " is not a JUnitResultFormatter");
}
JUnitTaskMirror.JUnitResultFormatterMirror r =
(JUnitTaskMirror.JUnitResultFormatterMirror) o;
if (useFile && outFile != null) {
try {
out = new BufferedOutputStream(new FileOutputStream(outFile));
} catch (java.io.IOException e) {
throw new BuildException("Unable to open file " + outFile, e);
}
}
r.setOutput(out);
return r;
|
public java.lang.String | getClassname()Get name of class to be used as the formatter.
return classname;
|
public java.lang.String | getExtension()Get the extension used for the report file.
return extension;
|
boolean | getUseFile()Get whether the formatter should log to file.
return useFile;
|
public void | setClassname(java.lang.String classname) Set name of class to be used as the formatter.
This class must implement JUnitResultFormatter
this.classname = classname;
if (XML_FORMATTER_CLASS_NAME.equals(classname)) {
setExtension(".xml");
} else if (PLAIN_FORMATTER_CLASS_NAME.equals(classname)) {
setExtension(".txt");
} else if (BRIEF_FORMATTER_CLASS_NAME.equals(classname)) {
setExtension(".txt");
}
|
public void | setExtension(java.lang.String ext)Set the extension to use for the report file.
this.extension = ext;
|
public void | setIf(java.lang.String ifProperty)Set whether this formatter should be used. It will be
used if the property has been set, otherwise it won't.
this.ifProperty = ifProperty;
|
void | setOutfile(java.io.File out) Set the file which the formatte should log to.
Note that logging to file must be enabled .
this.outFile = out;
|
public void | setOutput(java.io.OutputStream out) Set output stream for formatter to use.
Defaults to standard out.
this.out = out;
|
public void | setType(org.apache.tools.ant.taskdefs.optional.junit.FormatterElement$TypeAttribute type) Quick way to use a standard formatter.
At the moment, there are three supported standard formatters.
- The
xml type uses a XMLJUnitResultFormatter .
- The
brief type uses a BriefJUnitResultFormatter .
- The
plain type (the default) uses a PlainJUnitResultFormatter .
Sets classname attribute - so you can't use that
attribute if you use this one.
if ("xml".equals(type.getValue())) {
setClassname(XML_FORMATTER_CLASS_NAME);
} else {
if ("brief".equals(type.getValue())) {
setClassname(BRIEF_FORMATTER_CLASS_NAME);
} else { // must be plain, ensured by TypeAttribute
setClassname(PLAIN_FORMATTER_CLASS_NAME);
}
}
|
public void | setUnless(java.lang.String unlessProperty)Set whether this formatter should NOT be used. It
will not be used if the property has been set, orthwise it
will be used.
this.unlessProperty = unlessProperty;
|
public void | setUseFile(boolean useFile)Set whether the formatter should log to file.
this.useFile = useFile;
|
public boolean | shouldUse(org.apache.tools.ant.Task t)Ensures that the selector passes the conditions placed
on it with if and unless properties.
if (ifProperty != null && t.getProject().getProperty(ifProperty) == null) {
return false;
} else if (unlessProperty != null
&& t.getProject().getProperty(unlessProperty) != null) {
return false;
}
return true;
|