Main Page Packages Class Hierarchy Compound List File List Compound Members

# DOMTestCase.java

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (c) 2001 World Wide Web Consortium,
    00003  * (Massachusetts Institute of Technology, Institut National de
    00004  * Recherche en Informatique et en Automatique, Keio University). All
    00005  * Rights Reserved. This program is distributed under the W3C's Software
    00006  * Intellectual Property License. This program is distributed in the
    00007  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
    00008  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00009  * PURPOSE.
    00010  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
    00011  */
    00012
    00013  /*
    00014  $Log: DOMTestCase.java,v $
    00015  Revision 1.11  2002/02/03 04:22:35  dom-ts-4
    00016  DOM4J and Batik support added.
    00017  Rework of parser settings
    00018
    00019  Revision 1.10  2002/01/30 07:08:44  dom-ts-4
    00020  Update for GNUJAXP
    00021
    00022  Revision 1.9  2001/12/10 05:37:21  dom-ts-4
    00023  Added xml_alltests, svg_alltests, and html_alltests suites to run all tests
    00024  using a particular content type.
    00025
    00026  Revision 1.8  2001/11/01 15:02:50  dom-ts-4
    00027  Doxygen and Avalon support
    00028
    00029  Revision 1.7  2001/10/18 07:58:17  dom-ts-4
    00030  assertURIEquals added
    00031  Can now run from dom1-core.jar
    00032
    00033  Revision 1.6  2001/08/30 08:30:18  dom-ts-4
    00034  Added metadata and Software licence (dropped in earlier processing) to test
    00035  Enhanced test-matrix.xsl
    00036
    00037  Revision 1.5  2001/08/22 22:12:49  dom-ts-4
    00038  Now passing all tests with default settings
    00039
    00040  Revision 1.4  2001/08/22 06:22:46  dom-ts-4
    00041  Updated resource path for IDE debugging
    00042
    00043  Revision 1.3  2001/08/20 06:56:35  dom-ts-4
    00044  Full compile (-2 files that lock up Xalan 2.1)
    00045
    00046  Revision 1.2  2001/07/23 04:52:20  dom-ts-4
    00047  Initial test running using JUnit.
    00048
    00049  */
    00050
    00051 package org.w3c.domts;
    00052
    00053 import org.w3c.dom.*;
    00054 import org.w3c.domts.*;
    00055 import java.util.*;
    00056 import java.net.*;
    00057 import java.lang.reflect.*;
    00058
    00062 public abstract class DOMTestCase extends DOMTest  {
    00063   private DOMTestFramework framework;
    00064
    00071   public DOMTestCase() {
    00072     framework = null;
    00073   }
    00074
    00079   public DOMTestCase(DOMTestDocumentBuilderFactory factory) {
    00080     super(factory);
    00081     framework = null;
    00082   }
    00083
    00084
    00089   public static void doMain(Class testClass,String[] args) {
    00090     //
    00091     //   Attempt to load JUnitRunner
    00092     //
    00093     Class runnerClass = null;
    00094     ClassLoader loader = ClassLoader.getSystemClassLoader();
    00095     Exception classException = null;
    00096     Constructor runnerFactory = null;
    00097     try {
    00098         runnerClass = loader.loadClass("org.w3c.domts.JUnitRunner");
    00099         runnerFactory = runnerClass.getConstructor(new Class[] { Class.class });
    00100     }
    00101     catch(Exception ex) {
    00102         classException = ex;
    00103         try {
    00104             runnerClass = loader.loadClass("org.w3c.domts.AvalonRunner");
    00105             runnerFactory = runnerClass.getConstructor(new Class[] { Class.class });
    00106         }
    00107         catch(Exception ex2) {
    00108             classException = ex2;
    00109         }
    00110     }
    00111     if(runnerClass == null || runnerFactory == null) {
    00112         System.out.println("junit-run.jar amd junit.jar or avalon-run.jar and testlet.jar\n must be in same directory or on classpath.");
    00113         if(classException != null) {
    00114             classException.printStackTrace();
    00115         }
    00116     }
    00117     else {
    00118         try
    00119         {
    00120             //
    00121             //   create the JUnitRunner
    00122             //
    00123             Object junitRun = runnerFactory.newInstance(new Object[] { testClass });
    00124             //
    00125             //   find and call its execute method
    00126             //
    00127             Class argsClass = loader.loadClass("[Ljava.lang.String;");
    00128             Method execMethod = runnerClass.getMethod("execute", new Class[] { argsClass });
    00129             execMethod.invoke(junitRun, new Object[] { args });
    00130         }
    00131         catch(InvocationTargetException ex) {
    00132             ex.getTargetException().printStackTrace();
    00133         }
    00134         catch(Exception ex) {
    00135             ex.printStackTrace();
    00136         }
    00137     }
    00138   }
    00139
    00140   abstract public void runTest() throws Throwable;
    00141
    00142
    00143   public void setFramework(DOMTestFramework framework) {
    00144     this.framework = framework;
    00145   }
    00146
    00147
    00148
    00149   public void wait(int millisecond) {
    00150     framework.wait(millisecond);
    00151   }
    00152
    00153
    00154   public void assertTrue(String assertID, boolean actual) {
    00155     framework.assertTrue(this,assertID,actual);
    00156   }
    00157
    00158   public void assertFalse(String assertID, boolean actual) {
    00159     framework.assertFalse(this,assertID,actual);
    00160   }
    00161
    00162   public void assertNull(String assertID, Object actual) {
    00163     framework.assertNull(this,assertID,actual);
    00164   }
    00165
    00166   public void assertNotNull(String assertID, Object actual) {
    00167     framework.assertNotNull(this,assertID,actual);
    00168   }
    00169
    00170   public void assertSame(String assertID, Object expected, Object actual) {
    00171     framework.assertSame(this,assertID, expected, actual);
    00172   }
    00173
    00174   public void assertInstanceOf(String assertID, Class cls, Object obj) {
    00175     framework.assertInstanceOf(this,assertID, obj,cls);
    00176   }
    00177
    00178
    00179   public void assertSize(String assertID, int expectedSize, NodeList collection) {
    00180     framework.assertSize(this,assertID, expectedSize, collection);
    00181   }
    00182
    00183   public void assertSize(String assertID, int expectedSize, NamedNodeMap collection) {
    00184     framework.assertSize(this, assertID, expectedSize, collection);
    00185   }
    00186
    00187   public void assertSize(String assertID, int expectedSize, Collection collection) {
    00188     framework.assertSize(this, assertID, expectedSize, collection);
    00189   }
    00190
    00191   public void assertEqualsIgnoreCase(String assertID, String expected, String actual) {
    00192     framework.assertEqualsIgnoreCase(this, assertID, expected, actual);
    00193   }
    00194
    00195   public void assertEqualsIgnoreCase(String assertID, Collection expected, Collection actual) {
    00196     framework.assertEqualsIgnoreCase(this, assertID, expected,actual);
    00197   }
    00198
    00199   public void assertEqualsIgnoreCase(String assertID, List expected, List actual) {
    00200     framework.assertEqualsIgnoreCase(this, assertID, expected,actual);
    00201   }
    00202
    00203   public void assertEquals(String assertID, String expected, String actual) {
    00204     framework.assertEquals(this, assertID, expected,actual);
    00205   }
    00206
    00207   public void assertEquals(String assertID, int expected, int actual) {
    00208     framework.assertEquals(this, assertID, expected, actual);
    00209   }
    00210
    00211   public void assertEquals(String assertID, double expected, double actual) {
    00212     framework.assertEquals(this, assertID, expected,actual);
    00213   }
    00214
    00215   public void assertEquals(String assertID, Collection expected, NodeList actual) {
    00216     Collection actualList = new ArrayList();
    00217     int actualLen = actual.getLength();
    00218     for(int i = 0; i < actualLen; i++) {
    00219       actualList.add(actual.item(i));
    00220     }
    00221     framework.assertEquals(this, assertID, expected,actualList);
    00222   }
    00223
    00224   public void assertEquals(String assertID, Collection expected, Collection actual) {
    00225     framework.assertEquals(this, assertID,expected,actual);
    00226   }
    00227
    00228   public void assertNotEqualsIgnoreCase(String assertID, String expected, String actual) {
    00229     framework.assertNotEqualsIgnoreCase(this, assertID,expected,actual);
    00230   }
    00231
    00232   public void assertNotEquals(String assertID, String expected, String actual) {
    00233     framework.assertNotEquals(this, assertID,expected,actual);
    00234   }
    00235
    00236   public void assertNotEquals(String assertID, int expected, int actual) {
    00237     framework.assertNotEquals(this, assertID, expected,actual);
    00238   }
    00239
    00240   public void assertNotEquals(String assertID, double expected, double actual) {
    00241     framework.assertNotEquals(this, assertID,expected,actual);
    00242   }
    00243
    00244   public void assertURIEquals(String assertID, String scheme, String path, String host, String file, String query, String fragment, Boolean isAbsolute, String actual) throws java.net.MalformedURLException {
    00245     framework.assertURIEquals(this, assertID, scheme, path, host, file, query, fragment, isAbsolute, actual);
    00246   }
    00247
    00248
    00249   public boolean same(Object expected, Object actual) {
    00250     return framework.same(expected,actual);
    00251   }
    00252
    00253   public boolean equalsIgnoreCase(String expected, String actual) {
    00254     return framework.equalsIgnoreCase(expected,actual);
    00255   }
    00256
    00257   public boolean equalsIgnoreCase(Collection expected, Collection actual) {
    00258     return framework.equalsIgnoreCase(expected,actual);
    00259   }
    00260
    00261   public boolean equalsIgnoreCase(List expected, List actual) {
    00262     return framework.equalsIgnoreCase(expected,actual);
    00263   }
    00264
    00265   public boolean equals(String expected, String actual) {
    00266     return framework.equals(expected,actual);
    00267   }
    00268
    00269   public boolean equals(int expected, int actual) {
    00270     return framework.equals(expected,actual);
    00271   }
    00272
    00273   public boolean equals(double expected, double actual) {
    00274     return framework.equals(expected,actual);
    00275   }
    00276
    00277   public boolean equals(Collection expected, Collection actual) {
    00278     return framework.equals(expected,actual);
    00279   }
    00280
    00281   public boolean equals(List expected, List actual) {
    00282     return framework.equals(expected,actual);
    00283   }
    00284
    00285   public int size(Collection collection) {
    00286     return framework.size(collection);
    00287   }
    00288
    00289   public int size(NamedNodeMap collection) {
    00290     return framework.size(collection);
    00291   }
    00292
    00293   public int size(NodeList collection) {
    00294     return framework.size(collection);
    00295   }
    00296
    00297
    00298 }
    00299