### Question:
Activator implements BundleActivator { public void stop( BundleContext bundleContext ) { if ( this.urlTransformerRegistration != null ) { try { this.urlTransformerRegistration.unregister(); } catch ( RuntimeException ignored ) { } this.urlTransformerRegistration = null; this.urlTransformer = null; } if ( this.urlHandlerRegistration != null ) { try { this.urlHandlerRegistration.unregister(); } catch ( RuntimeException ignored ) { } this.urlHandlerRegistration = null; this.urlHandler = null; } }  void start( BundleContext bundleContext ); void stop( BundleContext bundleContext );  }### Answer:
@Test public void stop() throws Exception { BundleContext mockBundleContext = mock( BundleContext.class ); final ServiceRegistration mockArtifactUrlTransformerRegistration = mock( ServiceRegistration.class ); when( mockBundleContext .registerService( eq( ArtifactUrlTransformer.class ), any( ArtifactUrlTransformer.class ), any() ) ) .thenReturn( mockArtifactUrlTransformerRegistration ); final ServiceRegistration mockURLStreamHandlerServiceRegistration = mock( ServiceRegistration.class ); when( mockBundleContext .registerService( eq( URLStreamHandlerService.class ), any( URLStreamHandlerService.class ), any() ) ) .thenReturn( mockURLStreamHandlerServiceRegistration ); this.activator.start( mockBundleContext ); this.activator.stop( mockBundleContext ); verify( mockArtifactUrlTransformerRegistration, times( 1 ) ).unregister(); verify( mockURLStreamHandlerServiceRegistration, times( 1 ) ).unregister(); }