### Question:
AuthorizationServiceImpl implements AuthorizationService, PostConstruct { @Override public void initialize(final SecurityConfiguration securityServiceConfiguration) { if ( InitializationState.NOT_INITIALIZED != initialized ) { return; } try { if ( !( securityServiceConfiguration instanceof org.glassfish.security.services.config.AuthorizationService ) ) { throw new IllegalStateException( localStrings.getLocalString("service.atz.not_config","The Authorization service is not configured in the domain configuration file.")); } atzSvCfg = (org.glassfish.security.services.config.AuthorizationService) securityServiceConfiguration; List<SecurityProvider> providersConfig = atzSvCfg.getSecurityProviders(); if ( (providersConfig == null) || ( (atzPrvConfig = providersConfig.get(0)) == null ) ) { throw new IllegalStateException( localStrings.getLocalString("service.atz.no_prov_config","No provider configured for the Authorization service in the domain configuration file.")); } final String providerName = atzPrvConfig.getName(); if ( isDebug() ) { logger.log(DEBUG_LEVEL, "Attempting to get Authorization provider \"{0}\".", providerName ); } provider = AccessController.doPrivileged( new PrivilegedLookup<AuthorizationProvider>( serviceLocator, AuthorizationProvider.class, providerName)); if (provider == null) { throw new IllegalStateException( localStrings.getLocalString("service.atz.not_provider","Authorization Provider {0} not found.", providerName)); } provider.initialize(atzPrvConfig); initialized = InitializationState.SUCCESS_INIT; reasonInitFailed = null; logger.log(Level.FINE, ATZSVC_INITIALIZED); } catch ( Exception e ) { String eMsg = e.getMessage(); String eClass = e.getClass().getName(); reasonInitFailed = localStrings.getLocalString("service.atz.init_failed", "Authorization Service initialization failed, exception {0}, message {1}", eClass, eMsg); logger.log(Level.WARNING, ATZSVC_INIT_FAILED, new Object[] {eClass, eMsg}); throw new RuntimeException( reasonInitFailed, e ); } finally { if ( InitializationState.SUCCESS_INIT != initialized ) { initialized = InitializationState.FAILED_INIT; } } }  @Override void initialize(final SecurityConfiguration securityServiceConfiguration); @Override boolean isPermissionGranted(
        final Subject subject, final Permission permission); @Override boolean isAuthorized(Subject subject, URI resource); @Override boolean isAuthorized(final Subject subject, final URI resource, final String action); @Override AzResult getAuthorizationDecision(
            final AzSubject subject,
            final AzResource resource,
            final AzAction action); @Override AzSubject makeAzSubject(final Subject subject); @Override AzResource makeAzResource(final URI resource); @Override AzAction makeAzAction(final String action); @Override PolicyDeploymentContext findOrCreateDeploymentContext(
            final String appContext); @Override void postConstruct(); @Override boolean appendAttributeResolver(AzAttributeResolver resolver); @Override void setAttributeResolvers(List<AzAttributeResolver> resolverList); @Override List<AzAttributeResolver> getAttributeResolvers(); @Override boolean removeAllAttributeResolvers();  }### Answer:
@Test public void testInitialize() throws Exception { assertSame( "NOT_INITIALIZED", NOT_INITIALIZED, impl.getInitializationState() ); try { impl.initialize(null); fail( "Expected initialize to fail." ); } catch ( RuntimeException e ) { } assertSame( "FAILED_INIT", FAILED_INIT, impl.getInitializationState() ); assertNotNull( "getReasonInitializationFailed", impl.getReasonInitializationFailed() ); }