/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: DOMTestSuite.java 512591 2007-02-28 03:35:44Z vgritsenko $
*/
package org.apache.xindice.xml.dom;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.w3c.dom.Document;
/**
* @version $Revision: 512591 $, $Date: 2007-02-27 22:35:44 -0500 (Tue, 27 Feb 2007) $
*/
public abstract class DOMTestSuite extends TestSuite {
public abstract static class DOMTestsSetup extends TestSetup {
public DOMTestsSetup(Test test) {
super(test);
}
public abstract Document getDocument(String xml) throws Exception;
protected void setUp() throws Exception {
super.setUp();
// now we set all tests with the doc & root
// we have an TestSuite of TestSuite of DOMTestCase
TestSuite suite = (TestSuite) getTest();
for (int i = 0; i < suite.testCount(); i++) {
TestSuite subSuite = (TestSuite) suite.testAt(i);
for (int j = 0; j < subSuite.testCount(); j++) {
DOMTestCase domTest = (DOMTestCase) subSuite.testAt(j);
domTest.doc = getDocument(domTest.getXml());
domTest.root = domTest.doc.getDocumentElement();
}
}
}
}
public DOMTestSuite() {
super();
addTestSuite(NodeListTest.class);
addTestSuite(NodeTest.class);
addTestSuite(DocumentTest.class);
}
}