UTF-X, Unit Testing Framework - Xslt

utfx.framework
Class XMLValidationTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by utfx.framework.XMLValidationTestCase
All Implemented Interfaces:
junit.framework.Test, org.xml.sax.ErrorHandler

public class XMLValidationTestCase
extends junit.framework.TestCase
implements org.xml.sax.ErrorHandler

Validation Test Case. This test case uses a DOM validating parser to parse the document and reports any warnings, errors and fatal error using the weblogic logging facility. Please see the Extensible Markup Language (XML) 1.0 (Second Edition) W3C recommendation for a full definition of error and fatal error.

Copyright © 2004 - University of Southern Queensland.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

$Source: /cvs/utf-x/framework/src/java/utfx/framework/XMLValidationTestCase.java,v $

Version:
$Revidion:$ $Date: 2006/08/08 05:06:20 $ $Name: release_0_0_8_alpha $
Author:
Jacek Radajewski, Oliver Lucido (Lulu)

Field Summary
private  javax.xml.parsers.DocumentBuilder db
          document builder
private  javax.xml.parsers.DocumentBuilderFactory dbf
          document builder factory
private  java.lang.StringBuffer errors
          this is where we log validation errors
private  boolean isValid
          true iff the xml content is valid
private  org.apache.log4j.Logger log
          logging facility
private  java.lang.String testName
          name of this test
private  java.lang.String xml
          the XML content we are to validate
 
Constructor Summary
XMLValidationTestCase(java.lang.String testName, java.lang.String xml)
          Construct a new XML Validator from a URI pointing to an XML doc.
 
Method Summary
 void error(org.xml.sax.SAXParseException e)
          Handle parse error.
 void fatalError(org.xml.sax.SAXParseException e)
          Handle fatal error.
 java.lang.String toString()
           
 void validate()
          Perform validation.
 void warning(org.xml.sax.SAXParseException e)
          Handle warning but take no further action.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbf

private javax.xml.parsers.DocumentBuilderFactory dbf
document builder factory


db

private javax.xml.parsers.DocumentBuilder db
document builder


log

private org.apache.log4j.Logger log
logging facility


testName

private java.lang.String testName
name of this test


errors

private java.lang.StringBuffer errors
this is where we log validation errors


xml

private java.lang.String xml
the XML content we are to validate


isValid

private boolean isValid
true iff the xml content is valid

Constructor Detail

XMLValidationTestCase

public XMLValidationTestCase(java.lang.String testName,
                             java.lang.String xml)
Construct a new XML Validator from a URI pointing to an XML doc.

Parameters:
is - the XML document to be validated, as an input stream
Method Detail

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Handle parse error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
e - instance of SAXParserException containing the details of the error.
Throws:
SAXException.
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
Handle warning but take no further action.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
e - instance of SAXParserException containing the details of the warning.
Throws:
SAXException.
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Handle fatal error.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
e - instance of SAXParserException containing the details of the error.
Throws:
SAXException.
org.xml.sax.SAXException

validate

public void validate()
              throws java.lang.Exception
Perform validation.

Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class junit.framework.TestCase

UTF-X, Unit Testing Framework - Xslt