以下は、OSGiFramework クラスで呼び出そうとする jUnit テストですafterPropertiesSet
。しかし、どういうわけかgetBundlesInformation
、そのフロー中にメソッドが呼び出されません。
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");
}
何が問題なのか誰か知っていますか?