0
所以基本上我正在尝试使用powermockito为适用于服务类的适配器编写一个使用web服务的Junit。Powermockito无法模拟超级调用
我有一个适配器,带有一个构造函数,inturn通过调用超类在它自己的构造函数中创建一个新的服务对象。我必须测试我的适配器。我用mockito来模拟我的适配器以及我的服务类,但我不认为模拟对象能够执行超级调用。以下是我的代码结构。我希望超类能够在通话时返回我的模拟对象。
public class CommonPoolingServiceAdp {
private CPSSecurity cpsServicePort;
public CommonPoolingServiceAdp() {
CommonPoolingService service= new CommonPoolingService();
cpsServicePort=service.getCommonPoolingServicePort();
}
public SercurityDataResponse getBroadcastElements(broadcastReqObj)
{
SercurityDataResponse=null;
response=cpsServicePort.getBroadcastElements(broadcaseRequestObj);
}
}
public class CommonPoolingService extends Service {
{
static
{
//few mandatory initializations
}
public CommonPoolingService()
{
super(WSDL_Location,QName);
}
public CSPSecurity getCommonPoolingServicePort() {
return super.getPort(QName);
}
}
}
你可以发布你当前的测试代码。所以你想调用'super.getPort(QName)'来返回一个模拟'CSPSecurity'? – clD 2015-02-09 12:16:24