AccessTokensBean implements AccessTokens, SmartLifecycle, BeanFactoryAware { protected final boolean isTestingConfigured() { if (StringUtils.hasText(System.getenv(OAUTH2_ACCESS_TOKENS)) && StringUtils.hasText(accessTokensBeanProperties.getTestTokens())) { logger.warn( "'Test-Tokens' configured in yaml-file as also in ENV-VARIABLE 'OAUTH2_ACCESS_TOKENS' ! CONFIGURE ONLY ONE!"); return true; } else if (StringUtils.hasText(System.getenv(OAUTH2_ACCESS_TOKENS))) { return true; } else if (StringUtils.hasText(accessTokensBeanProperties.getTestTokens())) { return true; } else if (StringUtils.hasText(System.getProperty(OAUTH2_ACCESS_TOKENS))) { return true; } return false; } AccessTokensBean(final AccessTokensBeanProperties accessTokensBeanProperties); @Override String get(final Object tokenId); @Override AccessToken getAccessToken(final Object tokenId); @Override void invalidate(final Object tokenId); @Override void setBeanFactory(BeanFactory beanFactory); void setMetricsListeners(List<MetricsListener> metricsListeners); @Override synchronized void start(); AbstractAccessTokenRefresher getDelegate(); @Override synchronized void stop(); @Override boolean isRunning(); @Override int getPhase(); @Override boolean isAutoStartup(); @Override void stop(final Runnable callback);  }
@Test public void testLocalTesting() { AccessTokensBeanProperties properties = new AccessTokensBeanProperties(); AccessTokensBean bean = new AccessTokensBean(properties); assertThat(bean.isTestingConfigured()).isFalse(); }
@Test public void testLocalTestingWhenYamlConfigured() { AccessTokensBeanProperties properties = new AccessTokensBeanProperties(); properties.setTestTokens("ANY_TEXT"); AccessTokensBean bean = new AccessTokensBean(properties); assertThat(bean.isTestingConfigured()).isTrue(); }
@Test public void testLocalTestingWhenEnvConfigured() { PowerMockito.mockStatic(System.class); when(System.getenv(OAUTH2_ACCESS_TOKENS)).thenReturn("ANY_TEXT"); when(System.getProperties()).thenReturn(new Properties()); AccessTokensBeanProperties properties = new AccessTokensBeanProperties(); AccessTokensBean bean = new AccessTokensBean(properties); assertThat(bean.isTestingConfigured()).isTrue(); }
@Test public void testLocalTestingWithEnvAndYamlConfig() { System.setProperty(OAUTH2_ACCESS_TOKENS, "ANY_TEXT"); AccessTokensBeanProperties properties = new AccessTokensBeanProperties(); properties.setTestTokens("ANY_TEXT"); AccessTokensBean bean = new AccessTokensBean(properties); assertThat(bean.isTestingConfigured()).isTrue(); }