DOMTestCasepublic abstract class DOMTestCase extends DOMTest This is an abstract base class for generated DOM tests |
Fields Summary |
---|
private DOMTestFramework | framework |
Constructors Summary |
---|
public DOMTestCase()This constructor is for DOMTestCase's that make specific demands for
parser configuration. setFactory should be called before the end of the
tests constructor to set the factory.
framework = null;
| public DOMTestCase(DOMTestDocumentBuilderFactory factory)This constructor is for DOMTestCase's that do not add any requirements
for parser configuration.
super(factory);
framework = null;
|
Methods Summary |
---|
public void | assertEqualAutoCase(java.lang.String context, java.lang.String assertID, java.util.Collection expected, java.util.Collection actual)Asserts that each entry in actual is matched with an entry in expected
that only differs by case. Order is not significant.
String contentType = getContentType();
if ("text/html".equals(contentType)) {
if ("attribute".equals(context)) {
assertEqualsIgnoreCase(assertID, expected, actual);
}
else {
framework.assertEquals(this, assertID, toUpperCase(expected), actual);
}
}
else {
framework.assertEquals(this, assertID, expected, actual);
}
| public void | assertEquals(java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that expected.equals(actual) is true
framework.assertEquals(this, assertID, expected, actual);
| public void | assertEquals(java.lang.String assertID, int expected, int actual)Asserts that values of expected and actual are equal.
framework.assertEquals(this, assertID, expected, actual);
| public void | assertEquals(java.lang.String assertID, double expected, double actual)Asserts that values of expected and actual are equal.
framework.assertEquals(this, assertID, expected, actual);
| public void | assertEquals(java.lang.String assertID, boolean expected, boolean actual)Asserts that values of expected and actual are equal.
framework.assertEquals(this, assertID, expected, actual);
| public void | assertEquals(java.lang.String assertID, java.util.Collection expected, org.w3c.dom.NodeList actual)Asserts that each entry in actual exactly matches with an entry in
expected. Order is not significant.
Collection actualList = new ArrayList();
int actualLen = actual.getLength();
for (int i = 0; i < actualLen; i++) {
actualList.add(actual.item(i));
}
framework.assertEquals(this, assertID, expected, actualList);
| public void | assertEquals(java.lang.String assertID, java.util.Collection expected, java.util.Collection actual)Asserts that each entry in actual exactly matches with an entry in
expected. Order is not significant.
framework.assertEquals(this, assertID, expected, actual);
| public void | assertEqualsAutoCase(java.lang.String context, java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that expected.equalsIgnoreCase(actual) is true
String contentType = getContentType();
//
// if the content type is HTML (not XHTML)
//
if ("text/html".equals(contentType)) {
//
// if the context is attribute, then use case-insentive comparison
//
if ("attribute".equals(context)) {
framework.assertEqualsIgnoreCase(this, assertID, expected, actual);
}
else {
//
// otherwise should be compared against uppercased expectation
framework.assertEquals(this, assertID, expected.toUpperCase(), actual);
}
}
else {
framework.assertEquals(this, assertID, expected, actual);
}
| public void | assertEqualsAutoCase(java.lang.String context, java.lang.String assertID, java.util.List expected, java.util.List actual)Asserts that each entry in actual is matched with an entry in expected
that only differs by case. Order is significant.
String contentType = getContentType();
if ("text/html".equals(contentType)) {
if ("attribute".equals(context)) {
assertEqualsIgnoreCase(assertID, expected, actual);
}
else {
framework.assertEquals(this, assertID, toUpperCase(expected), actual);
}
}
else {
framework.assertEquals(this, assertID, expected, actual);
}
| public void | assertEqualsIgnoreCase(java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that expected.equalsIgnoreCase(actual) is true
framework.assertEqualsIgnoreCase(this, assertID, expected, actual);
| public void | assertEqualsIgnoreCase(java.lang.String assertID, java.util.Collection expected, java.util.Collection actual)Asserts that each entry in actual is matched with an entry in expected
that only differs by case. Order is not significant.
framework.assertEqualsIgnoreCase(this, assertID, expected, actual);
| public void | assertEqualsIgnoreCase(java.lang.String assertID, java.util.List expected, java.util.List actual)Asserts that each entry in actual is matched with an entry in expected
that only differs by case. Order is significant.
framework.assertEqualsIgnoreCase(this, assertID, expected, actual);
| public void | assertFalse(java.lang.String assertID, boolean actual)Asserts that actual==false
framework.assertFalse(this, assertID, actual);
| public void | assertFalse(java.lang.String assertID, java.lang.Object actual)Asserts that actual==false
framework.assertFalse(
this,
assertID,
( (Boolean) actual).booleanValue());
| public void | assertInstanceOf(java.lang.String assertID, java.lang.Class cls, java.lang.Object obj)Asserts that obj is an instance of cls
framework.assertInstanceOf(this, assertID, obj, cls);
| public void | assertNotEquals(java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that values of expected and actual are not equal.
framework.assertNotEquals(this, assertID, expected, actual);
| public void | assertNotEquals(java.lang.String assertID, int expected, int actual)Asserts that values of expected and actual are not equal.
framework.assertNotEquals(this, assertID, expected, actual);
| public void | assertNotEquals(java.lang.String assertID, double expected, double actual)Asserts that values of expected and actual are not equal.
framework.assertNotEquals(this, assertID, expected, actual);
| public void | assertNotEqualsAutoCase(java.lang.String context, java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that expected.equalsIgnoreCase(actual) is false
String contentType = getContentType();
if ("text/html".equals(contentType)) {
if ("attribute".equals(context)) {
framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual);
}
else {
framework.assertNotEquals(this, assertID, expected.toUpperCase(),
actual);
}
}
framework.assertNotEquals(this, assertID, expected, actual);
| public void | assertNotEqualsIgnoreCase(java.lang.String assertID, java.lang.String expected, java.lang.String actual)Asserts that expected.equalsIgnoreCase(actual) is false
framework.assertNotEqualsIgnoreCase(this, assertID, expected, actual);
| public void | assertNotNull(java.lang.String assertID, java.lang.Object actual)Asserts that actual != null
framework.assertNotNull(this, assertID, actual);
| public void | assertNull(java.lang.String assertID, java.lang.Object actual)Asserts that actual == null
framework.assertNull(this, assertID, actual);
| public void | assertSame(java.lang.String assertID, java.lang.Object expected, java.lang.Object actual)Asserts that actual and expected are the same object
framework.assertSame(this, assertID, expected, actual);
| public void | assertSize(java.lang.String assertID, int expectedSize, org.w3c.dom.NodeList collection)Asserts that the length of the collection is the expected size.
framework.assertSize(this, assertID, expectedSize, collection);
| public void | assertSize(java.lang.String assertID, int expectedSize, org.w3c.dom.NamedNodeMap collection)Asserts that the length of the collection is the expected size.
framework.assertSize(this, assertID, expectedSize, collection);
| public void | assertSize(java.lang.String assertID, int expectedSize, java.util.Collection collection)Asserts that the length of the collection is the expected size.
framework.assertSize(this, assertID, expectedSize, collection);
| public void | assertTrue(java.lang.String assertID, boolean actual)Asserts that actual==true
framework.assertTrue(this, assertID, actual);
| public void | assertTrue(java.lang.String assertID, java.lang.Object actual)Asserts that actual==true
framework.assertTrue(this, assertID, ( (Boolean) actual).booleanValue());
| public void | assertURIEquals(java.lang.String assertID, java.lang.String scheme, java.lang.String path, java.lang.String host, java.lang.String file, java.lang.String name, java.lang.String query, java.lang.String fragment, java.lang.Boolean isAbsolute, java.lang.String actual)Asserts aspects of a URI
//
// URI must be non-null
assertNotNull(assertID, actual);
String uri = actual;
int lastPound = actual.lastIndexOf("#");
String actualFragment = "";
if (lastPound != -1) {
//
// substring before pound
//
uri = actual.substring(0, lastPound);
actualFragment = actual.substring(lastPound + 1);
}
if (fragment != null) {
assertEquals(assertID, fragment, actualFragment);
}
int lastQuestion = uri.lastIndexOf("?");
String actualQuery = "";
if (lastQuestion != -1) {
//
// substring before pound
//
uri = actual.substring(0, lastQuestion);
actualQuery = actual.substring(lastQuestion + 1);
}
if (query != null) {
assertEquals(assertID, query, actualQuery);
}
int firstColon = uri.indexOf(":");
int firstSlash = uri.indexOf("/");
String actualPath = uri;
String actualScheme = "";
if (firstColon != -1 && firstColon < firstSlash) {
actualScheme = uri.substring(0, firstColon);
actualPath = uri.substring(firstColon + 1);
}
if (scheme != null) {
assertEquals(assertID, scheme, actualScheme);
}
if (path != null) {
assertEquals(assertID, path, actualPath);
}
if (host != null) {
String actualHost = "";
if (actualPath.startsWith("//")) {
int termSlash = actualPath.indexOf("/", 2);
actualHost = actualPath.substring(0, termSlash);
}
assertEquals(assertID, host, actualHost);
}
String actualFile = actualPath;
if (file != null || name != null) {
int finalSlash = actualPath.lastIndexOf("/");
if (finalSlash != -1) {
actualFile = actualPath.substring(finalSlash + 1);
}
if (file != null) {
assertEquals(assertID, file, actualFile);
}
}
if (name != null) {
String actualName = actualFile;
int finalPeriod = actualFile.lastIndexOf(".");
if (finalPeriod != -1) {
actualName = actualFile.substring(0, finalPeriod);
}
assertEquals(assertID, name, actualName);
}
if (isAbsolute != null) {
//
// Jar URL's will have any actual path like file:/c:/somedrive...
assertEquals(
assertID,
isAbsolute.booleanValue(),
actualPath.startsWith("/") || actualPath.startsWith("file:/"));
}
| public static void | doMain(java.lang.Class testClass, java.lang.String[] args)This method is called by the main() for each test and locates the
appropriate test framework and runs the specified test
//
// Attempt to load JUnitRunner
//
ClassLoader loader = ClassLoader.getSystemClassLoader();
try {
Class runnerClass = loader.loadClass("org.w3c.domts.JUnitRunner");
Constructor runnerFactory =
runnerClass.getConstructor(new Class[] {Class.class});
//
// create the JUnitRunner
//
Object junitRun =
runnerFactory.newInstance(new Object[] {testClass});
//
// find and call its execute method method
//
Class argsClass = loader.loadClass("[Ljava.lang.String;");
Method execMethod =
runnerClass.getMethod("execute", new Class[] {argsClass});
execMethod.invoke(junitRun, new Object[] {args});
}
catch (InvocationTargetException ex) {
ex.getTargetException().printStackTrace();
}
catch (Exception ex) {
System.out.println(
"junit-run.jar and junit.jar \n must be in same directory or on classpath.");
ex.printStackTrace();
}
| public boolean | equals(java.lang.String expected, java.lang.String actual)Compares the values of actual and expected.
return framework.equals(expected, actual);
| public boolean | equals(int expected, int actual)Compares the values of actual and expected.
return framework.equals(expected, actual);
| public boolean | equals(double expected, double actual)Compares the values of actual and expected.
return framework.equals(expected, actual);
| public boolean | equals(java.util.Collection expected, java.util.Collection actual)Compares the values in actual and expected ignoring order.
return framework.equals(expected, actual);
| public boolean | equals(java.util.List expected, java.util.List actual)Compares the values in actual and expected.
return framework.equals(expected, actual);
| public boolean | equalsAutoCase(java.lang.String context, java.lang.String expected, java.lang.String actual)Compares the value of actual and expected ignoring case.
if ("text/html".equals(getContentType())) {
if ("attribute".equals(context)) {
return framework.equalsIgnoreCase(expected, actual);
}
else {
return framework.equals(expected.toUpperCase(), actual);
}
}
return framework.equals(expected, actual);
| public boolean | equalsAutoCase(java.lang.String context, java.util.Collection expected, java.util.Collection actual)Compares the values in actual and expected ignoring case and order.
if ("text/html".equals(getContentType())) {
if ("attribute".equals(context)) {
return framework.equalsIgnoreCase(expected, actual);
}
else {
return framework.equals(toUpperCase(expected), actual);
}
}
return framework.equals(expected, actual);
| public boolean | equalsAutoCase(java.lang.String context, java.util.List expected, java.util.List actual)Compares the values in actual and expected ignoring case.
if ("text/html".equals(getContentType())) {
if ("attribute".equals(context)) {
return framework.equalsIgnoreCase(expected, actual);
}
else {
return framework.equals(toUpperCase(expected), actual);
}
}
return framework.equals(expected, actual);
| public boolean | equalsIgnoreCase(java.lang.String expected, java.lang.String actual)Compares the value of actual and expected ignoring case.
return framework.equalsIgnoreCase(expected, actual);
| public boolean | equalsIgnoreCase(java.util.Collection expected, java.util.Collection actual)Compares the values in actual and expected ignoring case and order.
return framework.equalsIgnoreCase(expected, actual);
| public boolean | equalsIgnoreCase(java.util.List expected, java.util.List actual)Compares the values in actual and expected ignoring case.
return framework.equalsIgnoreCase(expected, actual);
| public void | fail(java.lang.String assertID)Fail test
framework.fail(this, assertID);
| public abstract void | runTest()Body of test
| public boolean | same(java.lang.Object expected, java.lang.Object actual)Compares the identity of actual and expected.
return framework.same(expected, actual);
| public void | setFramework(DOMTestFramework framework)Sets test framework to be used by test.
this.framework = framework;
| public int | size(java.util.Collection collection)Gets the size of the collection
return framework.size(collection);
| public int | size(org.w3c.dom.NamedNodeMap collection)Gets the size of the collection
return framework.size(collection);
| public int | size(org.w3c.dom.NodeList collection)Gets the size of the collection
return framework.size(collection);
| private java.util.List | toUpperCase(java.util.Collection expected)Creates an equivalent list where every member has
been uppercased
List upperd = new ArrayList(expected.size());
Iterator iter = expected.iterator();
while (iter.hasNext()) {
upperd.add(iter.next().toString().toUpperCase());
}
return upperd;
| public void | wait(int millisecond)Wait
framework.wait(millisecond);
|
|