Search in sources :

Example 1 with DOMTestSuite

use of org.w3c.domts.DOMTestSuite in project robovm by robovm.

the class AllTests_Level2 method suite.

/*public static void run() {
        TestRunner.main(new String[] {Main_AllTests.class.getName()});
    }*/
public static final Test suite() {
    // from http://www.w3.org/DOM/Test/
    // Level 2 Core tests
    DOMTestSuite domSuite;
    try {
        DOMTestDocumentBuilderFactory factory1 = new JAXPDOMTestDocumentBuilderFactory(null, JAXPDOMTestDocumentBuilderFactory.getConfiguration1());
        // android: coalescing, epand, ignorewhitespace, namespace, NOT validation
        domSuite = new org.w3c.domts.level2.core.alltests(factory1);
    } catch (Exception e) {
        throw new RuntimeException("problem creating dom test suite", e);
    }
    TestSuite suite = new JUnitTestSuiteAdapter(domSuite);
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite) DOMTestSuite(org.w3c.domts.DOMTestSuite) JUnitTestSuiteAdapter(org.w3c.domts.JUnitTestSuiteAdapter) DOMTestSuite(org.w3c.domts.DOMTestSuite) JAXPDOMTestDocumentBuilderFactory(org.w3c.domts.JAXPDOMTestDocumentBuilderFactory) DOMTestDocumentBuilderFactory(org.w3c.domts.DOMTestDocumentBuilderFactory) JAXPDOMTestDocumentBuilderFactory(org.w3c.domts.JAXPDOMTestDocumentBuilderFactory)

Example 2 with DOMTestSuite

use of org.w3c.domts.DOMTestSuite in project webservices-axiom by apache.

the class W3CDOMTestSuiteBuilder method addTests.

protected final void addTests() {
    final DOMTestDocumentBuilderFactory factory;
    try {
        factory = new DOMTestDocumentBuilderFactoryImpl(dbff, new DocumentBuilderSetting[] { DocumentBuilderSetting.notCoalescing, DocumentBuilderSetting.notExpandEntityReferences, DocumentBuilderSetting.notIgnoringElementContentWhitespace, DocumentBuilderSetting.namespaceAware, DocumentBuilderSetting.notValidating });
    } catch (DOMTestIncompatibleException ex) {
        // TODO
        throw new Error(ex);
    }
    DOMTestSuite suite;
    try {
        suite = createDOMTestSuite(factory);
    } catch (Exception ex) {
        // TODO
        throw new Error(ex);
    }
    suite.build(new DOMTestSink() {

        public void addTest(Class testClass) {
            try {
                if (!unsupportedFeatures.isEmpty()) {
                    Set<DOMFeature> usedFeatures = new HashSet<DOMFeature>();
                    DOMFeature.matchFeatures(testClass, usedFeatures);
                    ClassReader classReader = new ClassReader(testClass.getResourceAsStream(testClass.getSimpleName() + ".class"));
                    DOMTSClassVisitor cv = new DOMTSClassVisitor(usedFeatures);
                    classReader.accept(cv, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
                    usedFeatures.retainAll(unsupportedFeatures);
                    if (!usedFeatures.isEmpty()) {
                        return;
                    }
                }
                Constructor<? extends DOMTestCase> testConstructor = ((Class<?>) testClass).asSubclass(DOMTestCase.class).getConstructor(DOMTestDocumentBuilderFactory.class);
                DOMTestCase test;
                try {
                    test = testConstructor.newInstance(new Object[] { factory });
                } catch (InvocationTargetException ex) {
                    throw ex.getTargetException();
                }
                test.setFramework(JUnitTestFramework.INSTANCE);
                W3CDOMTestSuiteBuilder.this.addTest(new W3CTestCase(test));
            } catch (Throwable ex) {
                // TODO
                throw new Error(ex);
            }
        }
    });
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Constructor(java.lang.reflect.Constructor) DOMTestSuite(org.w3c.domts.DOMTestSuite) DOMTestIncompatibleException(org.w3c.domts.DOMTestIncompatibleException) DocumentBuilderSetting(org.w3c.domts.DocumentBuilderSetting) DOMTestDocumentBuilderFactory(org.w3c.domts.DOMTestDocumentBuilderFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException) DOMTestIncompatibleException(org.w3c.domts.DOMTestIncompatibleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DOMTestCase(org.w3c.domts.DOMTestCase) DOMTestSink(org.w3c.domts.DOMTestSink) ClassReader(org.objectweb.asm.ClassReader)

Example 3 with DOMTestSuite

use of org.w3c.domts.DOMTestSuite in project robovm by robovm.

the class AllTests_Level1 method suite.

/*public static void run() {
        TestRunner.main(new String[] {Main_AllTests.class.getName()});
    }*/
public static final Test suite() {
    // from http://www.w3.org/DOM/Test/
    // Level 1 Core tests
    DOMTestSuite domSuite;
    try {
        DOMTestDocumentBuilderFactory factory1 = new JAXPDOMTestDocumentBuilderFactory(null, JAXPDOMTestDocumentBuilderFactory.getConfiguration1());
        // android: coalescing, epand, ignorewhitespace, namespace, NOT validation
        domSuite = new org.w3c.domts.level1.core.alltests(factory1);
    } catch (Exception e) {
        throw new RuntimeException("problem creating dom test suite, " + e.getClass().getName() + ", " + e.getMessage(), e);
    }
    TestSuite suite = new JUnitTestSuiteAdapter(domSuite);
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite) DOMTestSuite(org.w3c.domts.DOMTestSuite) JUnitTestSuiteAdapter(org.w3c.domts.JUnitTestSuiteAdapter) DOMTestSuite(org.w3c.domts.DOMTestSuite) JAXPDOMTestDocumentBuilderFactory(org.w3c.domts.JAXPDOMTestDocumentBuilderFactory) DOMTestDocumentBuilderFactory(org.w3c.domts.DOMTestDocumentBuilderFactory) JAXPDOMTestDocumentBuilderFactory(org.w3c.domts.JAXPDOMTestDocumentBuilderFactory)

Aggregations

DOMTestDocumentBuilderFactory (org.w3c.domts.DOMTestDocumentBuilderFactory)3 DOMTestSuite (org.w3c.domts.DOMTestSuite)3 TestSuite (junit.framework.TestSuite)2 JAXPDOMTestDocumentBuilderFactory (org.w3c.domts.JAXPDOMTestDocumentBuilderFactory)2 JUnitTestSuiteAdapter (org.w3c.domts.JUnitTestSuiteAdapter)2 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ClassReader (org.objectweb.asm.ClassReader)1 DOMTestCase (org.w3c.domts.DOMTestCase)1 DOMTestIncompatibleException (org.w3c.domts.DOMTestIncompatibleException)1 DOMTestSink (org.w3c.domts.DOMTestSink)1 DocumentBuilderSetting (org.w3c.domts.DocumentBuilderSetting)1