Hi,
We are using the PowerMock 1.2.5 jars, JUNIT 4.6, and JRE 1.6.0.12. I
am running on Windows XP, SP3.
We use JAXB and I am having a problem trying to create one of the JAXB
related classes (SchemaFactory) in my unit test class when using
@RunWith(PowerMockRunner.class). It gets an exception with the
following message:
java.lang.IllegalArgumentException: No SchemaFactory that implements
the schema language specified by:
http://www.w3.org/2001/XMLSchema
could be loaded
If I take the @RunWith(PowerMockRunner.class) line away, I do not get
the exception.
To troubleshoot, I thought I’d print my environment out in both
scenarios and compare. What I found was that when runing with
PowerMock, my PATH environment variable contains JRE 1.6.0 instead of
JRE 1.6.0.12 (hmmmm). I had the earlier version still installed on my
system, so I renamed the JRE directory of the earlier version. When I
ran again, I saw JRE 1.6.0.12 in my PATH which is correct. But I still
got the exception. Bummer.
Do you know what could be happening or how to resolve ? The unit test
code (thru the part that fails) is below. Any help would be greatly
appreciated. Thanks.
Tom Vicker
(303) 721-4655
package com.snp.ciq.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Map;
import java.util.Properties;
import javax.xml.XMLConstants;
import javax.xml.validation.SchemaFactory;
import org.junit.After;import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.snp.ciq.CiqHelper;
import com.snp.unildr.XFLApplication;
@RunWith(PowerMockRunner.class)
@PrepareForTest( { XFLApplication.class })
public class CiqHelperTest {
CiqHelper ciqHelper;
@Before
public void setUp() throws Exception {
try {
Map<String, String> env = System.getenv();
for (Map.Entry<String,String> entry : env.entrySet()) {
System.out.println(entry.getKey() + ", " +
entry.getValue());
}
SchemaFactory sf = SchemaFactory.newInstance
(XMLConstants.W3C_XML_SCHEMA_NS_URI);
ciqHelper = new CiqHelper();
}
catch (Exception e) {
String msg = e.getMessage();
}
}
. . .