Below is my jUnit test from which I am trying to call afterPropertiesSet
in my OSGiFramework class. But somehow getBundlesInformation
method doesn't gets called during that flow.
When I debug my jUnit test, afterPropertiesSet method gets called and then it goes to initializeModelFramework method and then it never goes to getBundlesInformation method.
@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);
}
}
Below are the methods in OSGiFramework class-
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");
}
Does anyone know what might be the problem?