0
내가 예를 들어 oracle.adf.share.security.identitymanagement.UserProfile
의 실물 크기의 모형을 만들기 위해 노력했습니다 동안 예외가 발생하는 클래스를 조롱JMockit 초기화
@Test
public void testMyTest(@Mocked final UserProfile userProfile) {
new Expectations() {
{
userProfile.getBusinessEmail();
result = "[email protected]";
}
};
unitUnderTest.methodUnderTest();
}
내가 그러나 찾는거야 것은 JMockit가하려고 할 때 예외가 발생한다는 것입니다 UserProfile
내가 그것을이
public class UserProfile implements Serializable {
...
private static UserManager _usrMgr = new UserManager();
...
}
같은 것을 가지고 볼 수 있습니다 디 컴파일 후 모의
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at oracle.jdevimpl.junit.runner.junit4.JUnit4Testable.run(JUnit4Testable.java:24)
at oracle.jdevimpl.junit.runner.TestExecution.run(TestExecution.java:27)
at oracle.jdevimpl.junit.runner.JUnitTestRunner.main(JUnitTestRunner.java:88)
Caused by: oracle.adf.share.security.ADFSecurityRuntimeException: EXC_FAILED_ID_STORE
at oracle.adf.share.security.identitymanagement.UserManager.<init>(UserManager.java:111)
at oracle.adf.share.security.identitymanagement.UserManager.<init>(UserManager.java:83)
at oracle.adf.share.security.identitymanagement.UserProfile.<clinit>(UserProfile.java:62)
을 구성
UserManager
생성자 ADFSecurityUtil.getIdentityManagementProviderClassName();
가 호출 될 때 지금은 뭔가를 반환하는 기대를 설정할 수 있습니다이
public UserManager() {
this((String) null);
}
public UserManager(String providerClassName) {
if (providerClassName != null) {
...
} else {
String clzName = ADFSecurityUtil.getIdentityManagementProviderClassName();
if (clzName != null) {
IdentityManagement provider = (IdentityManagement) createObject(clzName);
setIdentityManagementProvider(provider);
} else {
throw new ADFSecurityRuntimeException("EXC_FAILED_ID_STORE");
}
}
}
처럼하지만이 클래스를로드 할 때 나는 더 문제를 예견한다.
이 문제를 해결하는 가장 좋은 방법은 무엇입니까?
가장 좋은 해결책은 'UserProfile' 클래스를 모방하지 않는 것입니다. 원하는 "businessEmail"값으로 인스턴스화하고 채울 수없는 이유가 있습니까? –
'Oracle ADF' 보안 설정으로 컨테이너를 실행해야하는'UserManager' 정적과 동일한 문제가 발생할 것이기 때문에 – PDStat