### Question:
ServletRegistrationComponent implements RestServicesMBean { public void setEnableAuthentication( boolean enableAuthentication ) { this.logger.fine( "Authentication is now " + (enableAuthentication ? "enabled" : "disabled") + ". Updating the REST resource." ); this.enableAuthentication = enableAuthentication; if( this.authenticationFilter != null ) this.authenticationFilter.setAuthenticationEnabled( enableAuthentication ); } ServletRegistrationComponent( BundleContext bundleContext ); void starting(); void stopping(); void schedulerAppears(); void schedulerDisappears(); void mavenResolverAppears(); void mavenResolverDisappears(); void setHttpService( HttpService httpService ); void setManager( Manager manager ); void setEnableCors( boolean enableCors ); void setEnableAuthentication( boolean enableAuthentication ); void setAuthenticationRealm( String authenticationRealm ); void setSessionPeriod( long sessionPeriod ); void setScheduler( IScheduler scheduler ); void setMavenResolver( MavenResolver mavenResolver ); @Override int getCurrentWebSocketClientsCount(); @Override long getWebSocketConnectionErrorsCount(); @Override long getRestRequestsWithAuthFailureCount(); @Override long getRestRequestsCount(); @Override boolean isAuthenticationRequired(); @Override boolean isCorsEnabled(); @Override void reset(); static final String REST_CONTEXT; static final String WEBSOCKET_CONTEXT; final AtomicLong restRequestsCount; final AtomicLong restRequestsWithAuthFailureCount; static final AtomicLong WS_CONNECTION_ERRORS_COUNT; }### Answer:
@Test public void testSetEnableAuthentication() throws Exception { this.register.setEnableAuthentication( true ); this.register.setEnableAuthentication( false ); this.register.authenticationFilter = Mockito.mock( AuthenticationFilter.class ); this.register.setEnableAuthentication( true ); Mockito.verify( this.register.authenticationFilter, Mockito.only()).setAuthenticationEnabled( true ); this.register.stopping(); this.register.setEnableAuthentication( false ); Assert.assertFalse( this.register.isAuthenticationRequired()); this.register.setEnableAuthentication( true ); Assert.assertTrue( this.register.isAuthenticationRequired()); }