我有一个方法如下
private void validate(String schemaName){
....
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);**strong text**
Source schemaFile = new SteamSource(getClass().getClassLoader().getResourceAsStream(schemaName));
Schema schema = factory.newSchema(schemaFile);
....
}
这个方法是从我需要测试的另一个方法中调用的(使用easymock和powermock)。我正在努力模拟以下行
Source schemaFile = new SteamSource(getClass().getClassLoader().getResourceAsStream(schemaName));
有人可以给我一个线索吗?
当前状态
以下是模拟语句
expectNew(StreamSource.class, anyObject(InputStream.class)).andReturn(mockedobject);
Powermock.replay(mockedobject, StreamSrouce.class);
这会引发以下异常。
org.powermock.reflect.exceptions.TooManyConstructorsFoundException: Several matching constructors found, please specify the argument parameter types so that PowerMock can determine which method you're referring to.
Matching constructors in class javax.xml.transform.stream.StreamSource were: