1 package org
.argeo
.slc
.osgi
.test
;
3 import junit
.framework
.TestCase
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.osgiboot
.OsgiBoot
;
8 import org
.osgi
.framework
.Bundle
;
9 import org
.osgi
.framework
.BundleContext
;
10 import org
.springframework
.osgi
.test
.platform
.EquinoxPlatform
;
11 import org
.springframework
.osgi
.test
.platform
.OsgiPlatform
;
12 import org
.springframework
.osgi
.util
.OsgiStringUtils
;
14 public abstract class AbstractOsgiRuntimeTest
extends TestCase
{
15 private final static Log log
= LogFactory
16 .getLog(AbstractOsgiRuntimeTest
.class);
18 protected OsgiBoot osgiBoot
= null;
19 protected OsgiPlatform osgiPlatform
= null;
21 protected OsgiPlatform
createOsgiPlatform() {
22 return new EquinoxPlatform();
25 protected void postStart() throws Exception
{
29 public void setUp() throws Exception
{
30 // To avoid xerces from the classpath being detected as the provider
32 .setProperty("javax.xml.parsers.DocumentBuilderFactory",
33 "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
34 System
.setProperty("javax.xml.parsers.SAXParserFactory",
35 "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
37 osgiPlatform
= createOsgiPlatform();
39 osgiBoot
= new OsgiBoot(osgiPlatform
.getBundleContext());
40 log
.info("OSGi platform " + osgiPlatform
+ " started.");
44 public void tearDown() throws Exception
{
48 log
.info("OSGi platform " + osgiPlatform
+ " stopped.");
51 protected void listInstalledBundles() {
52 BundleContext bundleContext
= osgiPlatform
.getBundleContext();
53 Bundle
[] bundles
= bundleContext
.getBundles();
54 for (int i
= 0; i
< bundles
.length
; i
++) {
56 .println(OsgiStringUtils
.nullSafeSymbolicName(bundles
[i
]));