Hi there,

Don’t know if user’s question can be asked in this mailing list. If not, would 
you let me know the correct mailing list, thanks!


I have the following problem, anyone can help…?

In TestA.java:

@Before
Public void before() throws Exception
ModuleB objB = new ModuleB();
objB.init();
}


In ModuleB.java:

import org.osgi.framework.FrameworkUtil;
public void init() {
  registerWithOSGIConsole()
}

private void registerWithOSGIConsole() {
BundleContext bundleContext =
FrameworkUtil.getBundle(this.getClass()).getBundleContext();
}

I proceed the JUnit test by executing “mvn clean install”, then in the output 
we know that:
“FrameworkUtil.getBundle(this.getClass())” returns Null so that an error occurs 
here.

TestA.java is just used for testing, I write many test functions in it.
ModuleB.java is one of the modules of an OSGi bundle I wrote (say, BundleC.jar).

In OGSi, the BundleC.jar can be installed and activated successfully and 
ModuleB’s init() would be automatically called.
That is, FrameworkUtil.getBundle(this.getClass())’s return value is not Null.

So, what should I do to make FrameworkUtil.getBundle() successful when JUnit 
testing?
Or did I do anything wrong?

Thanks!
Christine




====================================================================
本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內容,並請銷毀此信件。 
This email may contain confidential information. Please do not use or disclose 
it in any way and delete it if you are not the intended recipient.
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to