### Question:
PentahoOSGIActivator implements BundleActivator { @Override public void start( BundleContext bundleContext ) throws Exception { IApplicationContext applicationContext = PentahoSystem.getApplicationContext(); Object innerContext = applicationContext.getContext(); if ( innerContext instanceof ServletContext ) { ServletContext servletContext = (ServletContext) innerContext; servletContext.setAttribute( BundleContext.class.getName(), bundleContext ); updateRootContextInConfigurationAdmin( bundleContext, applicationContext ); } }  @Override void start( BundleContext bundleContext ); @Override void stop( BundleContext bundleContext );  }### Answer:
@Test @SuppressWarnings( "unchecked" ) public void testStart() throws Exception { BundleContext bundleContext = mock( BundleContext.class ); ServiceReference<ConfigurationAdmin> adminRef = (ServiceReference<ConfigurationAdmin>) mock( ServiceReference.class); when( bundleContext.getServiceReference( ConfigurationAdmin.class )).thenReturn( adminRef ); ConfigurationAdmin configurationAdmin = mock(ConfigurationAdmin.class); when( bundleContext.getService( adminRef )).thenReturn( configurationAdmin ); Configuration config = mock( Configuration.class ); when(configurationAdmin.getConfiguration( "org.pentaho.requirejs", null )).thenReturn( config ); IApplicationContext applicationContext = mock(IApplicationContext.class); PentahoSystem.init(applicationContext); when(applicationContext.getFullyQualifiedServerURL()).thenReturn("http: when(applicationContext.getContext()).thenReturn( mock( ServletContext.class ) ); ArgumentCaptor<Dictionary> params = ArgumentCaptor.forClass( Dictionary.class ); PentahoOSGIActivator activator = new PentahoOSGIActivator(); activator.start( bundleContext ); verify( config, times( 1 ) ).update( params.capture() ); assertEquals("/pentaho/osgi/", params.getValue().get( "context.root" )); reset(config); when(applicationContext.getFullyQualifiedServerURL()).thenReturn("http: activator.start( bundleContext ); verify( config, times( 1 ) ).update( params.capture() ); assertEquals("/osgi/", params.getValue().get( "context.root" )); activator.stop( bundleContext ); }