我有一个遗留类,其中包含一个new()调用来实例化LoginContext():
public class TestedClass {
public LoginContext login(String user, String password) {
LoginContext lc = new LoginContext("login", callbackHandler);
}
}
Run Code Online (Sandbox Code Playgroud)
我想使用Mockito测试这个类来模拟LoginContext,因为它要求在实例化之前设置JAAS安全性东西,但是我不知道如何在不更改login()方法来外化LoginContext的情况下这样做.是否可以使用Mockito来模拟LoginContext类?