dcsimg
Problems using SAXParser (Xerces 2.0.1) and JUnit 3.7
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sven_Jankus
Posted On:   Monday, June 24, 2002 06:49 AM

I wrote a Java-program which generates a XML-String. Therefore I wrote a small TestCase-class so that I can check the validity of the generated XML-String using JUnit. public void test1() { //get a wrapper for the data.. BB3KontoAuszug auszug = new BB3KontoAuszug(getAuszugBlatt()); org.apache.xerces.parsers.SAXParser parser = new org.apache.xerces.parsers.SAXParser(); // get the XML-data out of the wrapper and put them into an InputStream... ByteArrayInputStream in = new ByteArrayInputStream(auszug.getFiduciaXML().toByteArray()); InputSource is = new InputSource(in); try { parser.setFeature("http://xml.org/sax/features/validation", true);    More>>


I wrote a Java-program which generates a XML-String. Therefore I wrote a small TestCase-class
so that I can check the validity of the generated XML-String using JUnit.


			
public void test1()
{
//get a wrapper for the data..
BB3KontoAuszug auszug = new BB3KontoAuszug(getAuszugBlatt());
org.apache.xerces.parsers.SAXParser parser = new org.apache.xerces.parsers.SAXParser();
// get the XML-data out of the wrapper and put them into an InputStream...
ByteArrayInputStream in = new ByteArrayInputStream(auszug.getFiduciaXML().toByteArray());
InputSource is = new InputSource(in);
try
{
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.parse(is);
}
catch (Exception e)
{
e.printStackTrace();
}
}


If I try to run this method using JBuilder it works very well :o) But if I try to run this
TestCase-Method using JUnit I get the following ClassCastException :o(


			
java.lang.ClassCastException: org.apache.xerces.parsers.StandardParserConfiguration

at org.apache.xerces.parsers.SAXParser. (SAXParser.java:95)

at test.TestPDF.test1(TestPDF.java:33)



Line 33 is
org.apache.xerces.parsers.SAXParser parser = new org.apache.xerces.parsers.SAXParser();

Is there anybody who can tell me why? I'm using JUnit 3.7 and Apache Xerces 2.0.1


Sven Jankus

   <<Less
About | Sitemap | Contact