我有这样的单例课程
public class EventProcessor{
//........
private EventProcessor() {
Client client = ClientBuilder.newClient();
String scheme = requiredHttps() ? "https" : "http";
m_webTarget = client.target(..........);
}
public static EventProcessor getAuditEventProcessor() {
return m_EventProcessor.instance();
}
protected boolean requiredHttps() {
// read value from config file
// Configuration class is also a singleton and getConfig() is a static method
Map map = Configuration.getConfig().getCurrent().getSecuritySettings().getSettings();
//...............
}
}
在编写单元测试时,我有这样的设置方法
private EventProcessor m_EventProcessor;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
m_EventProcessor = EventProcessor.getAuditEventProcessor();
}
我为“ m_EventProcessor = EventProcessor.getAuditEventProcessor();”得到了ExceptionInInitializerError。有人可以帮我弄清楚这是什么问题吗?是因为在另一个单例类中调用一个单例类吗?