You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Saha, Sanjeev" <SS...@asce.org> on 2004/05/20 17:23:06 UTC

Using JUnit for testing

Are there any known issues related to testing the schema validation
mechanism, say for e.g the InstanceValidator.java through JUnit?

The concerned problem I am facing is if I write a main() in a different
class and pass an xml for validation, everything works out fine.
However, if I pass the same xml through the Junit test case, it returns
a null for sLoader.findDocumentType(xc.getName()), where 

SchemaTypeLoader sLoader = XmlBeans.typeLoaderForClassLoader(
           threadContextClassLoader);

easypo.jar is certainly available in the classpath. I've tried switching
the classpath to InstanceValidator.class.getClassLoader() but the
stacktrace comes back with 'Invalid Type' and nothing else. Please note
that the InstanceValidator has been trimmed down to load the schemas
from the easypo.jar file and not as an inline xsd file. However, the
test seems to work outside of the JUnit test case.

-Sanjeev

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Using JUnit for testing

Posted by Sanjeev Saha <ss...@asce.org>.
Not sure why such a thing would happen, but I just wanted to submit my
findings:

with regards to the problem I had encountered as mentioned below, on a
thorough debug of the testcase, I noticed that
XmlObject.Factory.parse(xmlString) was returning a "anyType" instead of the
impl.PurchaseOrderDocument which lead me to assume that the easypo.jar was
probably not getting loaded.

However, the problem seemed to go away if I switched from
"junit.swingui.TestRunner.run(XbeanTest.class)" to
"junit.textui.TestRunner.run(XbeanTest.class)" which furhter lead me to
assume that the classpath wasn't getting set properly on executing the swing
interface of JUnit.

I am using JBuilderX for development and am not sure whether that has
anything to do with this. I've also made sure that there is only one copy of
junit.jar in the classpath.

Any insight into this matter would be helpful. As of now, executing the
swingui of junit from within the IDE seems to be a no-no for me :o(

-Sanjeev

----- Original Message ----- 
From: "Saha, Sanjeev" <SS...@asce.org>
To: <xm...@xml.apache.org>
Sent: Thursday, May 20, 2004 11:23 AM
Subject: Using JUnit for testing


Are there any known issues related to testing the schema validation
mechanism, say for e.g the InstanceValidator.java through JUnit?

The concerned problem I am facing is if I write a main() in a different
class and pass an xml for validation, everything works out fine.
However, if I pass the same xml through the Junit test case, it returns
a null for sLoader.findDocumentType(xc.getName()), where

SchemaTypeLoader sLoader = XmlBeans.typeLoaderForClassLoader(
           threadContextClassLoader);

easypo.jar is certainly available in the classpath. I've tried switching
the classpath to InstanceValidator.class.getClassLoader() but the
stacktrace comes back with 'Invalid Type' and nothing else. Please note
that the InstanceValidator has been trimmed down to load the schemas
from the easypo.jar file and not as an inline xsd file. However, the
test seems to work outside of the JUnit test case.

-Sanjeev

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Using JUnit for testing

Posted by Sanjeev Saha <ss...@asce.org>.
Not sure why such a thing would happen, but I just wanted to submit my
findings:

with regards to the problem I had encountered as mentioned below, on a
thorough debug of the testcase, I noticed that
XmlObject.Factory.parse(xmlString) was returning a "anyType" instead of the
impl.PurchaseOrderDocument which lead me to assume that the easypo.jar was
probably not getting loaded.

However, the problem seemed to go away if I switched from
"junit.swingui.TestRunner.run(XbeanTest.class)" to
"junit.textui.TestRunner.run(XbeanTest.class)" which furhter lead me to
assume that the classpath wasn't getting set properly on executing the swing
interface of JUnit.

I am using JBuilderX for development and am not sure whether that has
anything to do with this. I've also made sure that there is only one copy of
junit.jar in the classpath.

Any insight into this matter would be helpful. As of now, executing the
swingui of junit from within the IDE seems to be a no-no for me :o(

-Sanjeev

----- Original Message ----- 
From: "Saha, Sanjeev" <SS...@asce.org>
To: <xm...@xml.apache.org>
Sent: Thursday, May 20, 2004 11:23 AM
Subject: Using JUnit for testing


Are there any known issues related to testing the schema validation
mechanism, say for e.g the InstanceValidator.java through JUnit?

The concerned problem I am facing is if I write a main() in a different
class and pass an xml for validation, everything works out fine.
However, if I pass the same xml through the Junit test case, it returns
a null for sLoader.findDocumentType(xc.getName()), where

SchemaTypeLoader sLoader = XmlBeans.typeLoaderForClassLoader(
           threadContextClassLoader);

easypo.jar is certainly available in the classpath. I've tried switching
the classpath to InstanceValidator.class.getClassLoader() but the
stacktrace comes back with 'Invalid Type' and nothing else. Please note
that the InstanceValidator has been trimmed down to load the schemas
from the easypo.jar file and not as an inline xsd file. However, the
test seems to work outside of the JUnit test case.

-Sanjeev

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/