### Question:
LocalizationBundleListener implements BundleListener { @Override public void bundleChanged( BundleEvent event ) { switch ( event.getType() ) { case BundleEvent.STARTED: case BundleEvent.STOPPED: try { localizationManager.bundleChanged( event.getBundle() ); } catch ( Exception e ) { log.error( e.getMessage(), e ); } break; } }  void setLocalizationManager( LocalizationManager localizationManager ); void setBundleContext( BundleContext bundleContext ); @Override void bundleChanged( BundleEvent event ); void init();  }### Answer:
@Test public void testBundleStart() throws IOException, ParseException { when( bundleEvent.getType() ).thenReturn( BundleEvent.STARTED ); localizationBundleListener.bundleChanged( bundleEvent ); verify( localizationManager ).bundleChanged( bundle ); }
@Test public void testBundleStop() throws IOException, ParseException { when( bundleEvent.getType() ).thenReturn( BundleEvent.STOPPED ); localizationBundleListener.bundleChanged( bundleEvent ); verify( localizationManager ).bundleChanged( bundle ); }
@Test public void testBundleOther() throws IOException, ParseException { when( bundleEvent.getType() ).thenReturn( BundleEvent.INSTALLED ); localizationBundleListener.bundleChanged( bundleEvent ); verifyNoMoreInteractions( localizationManager ); }
@Test public void testBundleStartException() throws IOException, ParseException { when( bundleEvent.getType() ).thenReturn( BundleEvent.STARTED ); RuntimeException runtimeException = new RuntimeException( "Message" ); doThrow( runtimeException ).when( localizationManager ).bundleChanged( bundle ); localizationBundleListener.bundleChanged( bundleEvent ); verify( localizationManager ).bundleChanged( bundle ); verify( log ).error( runtimeException.getMessage(), runtimeException ); }