다음은 내 OSGiFramework 클래스에서 afterPropertiesSet
을 호출하려고하는 jUnit 테스트입니다. 그러나 어떻게 든 그 흐름 중에 getBundlesInformation
메소드가 호출되지 않습니다.jUnit 테스트에서 메소드 호출하기
내 jUnit 테스트를 디버깅 할 때 afterPropertiesSet 메서드가 호출 된 다음 initializeModelFramework 메서드로 이동 한 다음 getBundlesInformation 메서드로 이동하지 않습니다.
@Test
public void testOSGiFramework() {
Method method;
try {
method = OSGiFramework.class.getDeclaredMethod("afterPropertiesSet", null);
Object o = method.invoke(new OSGiFramework(), null);
Assert.assertEquals(false, o instanceof Void);
}
}
다음은 OSGiFramework의 방법
을 클래스 -입니다private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
@Override
public void afterPropertiesSet() throws Exception {
try {
initializeModelFramework();
}
}
private void initializeModelFramework() {
final ScheduledFuture<?> taskHandle = scheduler.scheduleAtFixedRate(
new Runnable() {
public void run() {
try {
getBundlesInformation();
}catch(Exception ex) {
LOG.log(Level.SEVERE, "Exception in OSGiFramework::initializeModelFramework " +ex);
ex.printStackTrace();
}
}
}, 0, 30, TimeUnit.MINUTES);
}
protected static void getBundlesInformation() throws BundleException, Exception {
System.out.println("Hello");
}
사람이 문제가 무엇인지 알고 있나요?
정말 이니? 내 응용 프로그램을 실행하는 경우 동일한 코드가 잘 작동하기 때문입니다. 하지만 jUnit 테스트를 통해 호출하는 경우 작동하지 않습니다. – ferhan
jUnit없이 작동하는 경우, 잘못된 것입니다. –