code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@Override
protected boolean isVisible(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) {
return !determineFeatureState(context, attributeValue, true);
} | Processor for the <code>inactive</code> attribute in {@link TogglzDialect}. It shows or hides the given DOM container
based on feature state: <br>
<br>
<pre>
<span togglz:inactive="FEATURE">
Only visible when FEATURE is inactive.
</span>
</pre>
Features may also be specified dynamically by using expres... | isVisible | java | togglz/togglz | spring-boot/autoconfigure/src/main/java/org/togglz/spring/boot/actuate/thymeleaf/processor/FeatureInactiveAttrProcessor.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/main/java/org/togglz/spring/boot/actuate/thymeleaf/processor/FeatureInactiveAttrProcessor.java | Apache-2.0 |
@Test
public void getAllFeatures() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
"manageme... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | getAllFeatures | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void getEnumFeatureMetaData() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
"mana... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | getEnumFeatureMetaData | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void getFeature() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
"management.endpo... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | getFeature | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldEnableAFeature() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldEnableAFeature | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldChangeStrategy() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
"ma... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldChangeStrategy | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldChangeStrategyParameters() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withP... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldChangeStrategyParameters | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldDisableAFeature() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
.withPropertyValues(
... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldDisableAFeature | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldThrowAnIllegalArgumentExceptionIfTheFeatureDoesNotExist() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldThrowAnIllegalArgumentExceptionIfTheFeatureDoesNotExist | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void shouldThrowAnIllegalArgumentExceptionIfFormatOfParameterIsIncorrect() {
contextRunner.withConfiguration(AutoConfigurations.of(
DispatcherServletPathConfig.class,
TogglzAutoConfiguration.class,
TogglzEndpointAutoConfiguration.class))
... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | shouldThrowAnIllegalArgumentExceptionIfFormatOfParameterIsIncorrect | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void endpointDisabled() {
contextRunnerWithFeatureProviderConfig()
.withPropertyValues(
"management.endpoint.togglz.enabled: true")
.run((context) -> {
assertEquals(1, context.getBeansOfType(TogglzEndpoint.class).size());
}... | Tests for Spring Boot 2 compatible {@link TogglzEndpoint}.
@author Marcel Overdijk
@author Rui Figueira | endpointDisabled | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/TogglzEndpointTest.java | Apache-2.0 |
@Test
public void consoleWithCustomManagementContextPath() {
// With TogglzManagementContextConfiguration responsible for creating the admin console servlet registration bean,
// if a custom management context path is provided it should be used as prefix.
contextRunnerWithFeatureProviderConf... | Tests for Spring Boot 2 compatible {@link TogglzAutoConfiguration}.
@author Marcel Overdijk
@author Rui Figueira | consoleWithCustomManagementContextPath | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | Apache-2.0 |
@Test
public void customConsolePath() {
contextRunnerWithFeatureProviderConfig()
.withPropertyValues("togglz.console.path: /custom")
.run((context) -> assertThat(getUrlMappings(context)).contains("/custom/*"));
} | Tests for Spring Boot 2 compatible {@link TogglzAutoConfiguration}.
@author Marcel Overdijk
@author Rui Figueira | customConsolePath | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | Apache-2.0 |
@Test
public void customConsolePathWithTrailingSlash() {
contextRunnerWithFeatureProviderConfig()
.withPropertyValues("togglz.console.path: /custom/")
.run((context) -> assertThat(getUrlMappings(context)).contains("/custom/*"));
} | Tests for Spring Boot 2 compatible {@link TogglzAutoConfiguration}.
@author Marcel Overdijk
@author Rui Figueira | customConsolePathWithTrailingSlash | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | Apache-2.0 |
@SuppressWarnings("unchecked")
protected Collection<String> getUrlMappings(AssertableWebApplicationContext context) throws BeansException {
assertEquals(1, context.getBeansOfType(ServletRegistrationBean.class).size());
return context.getBean(ServletRegistrationBean.class).getUrlMappings();
} | Tests for Spring Boot 2 compatible {@link TogglzAutoConfiguration}.
@author Marcel Overdijk
@author Rui Figueira | getUrlMappings | java | togglz/togglz | spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | https://github.com/togglz/togglz/blob/master/spring-boot/autoconfigure/src/test/java/org/togglz/spring/boot/actuate/autoconfigure/TogglzManagementContextConfigurationTest.java | Apache-2.0 |
@Override
public String getId() {
return ID;
} | <p>
An activation strategy based on the values of properties accessible within the Spring environment.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NAM... | getId | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | Apache-2.0 |
@Override
public String getName() {
return "Spring Environment Property";
} | <p>
An activation strategy based on the values of properties accessible within the Spring environment.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NAM... | getName | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | Apache-2.0 |
@Override
protected String getPropertyValue(FeatureState featureState, FeatureUser user, String name) {
ApplicationContext applicationContext = ContextClassLoaderApplicationContextHolder.get();
if (applicationContext == null) {
throw new IllegalStateException("ApplicationContext could no... | <p>
An activation strategy based on the values of properties accessible within the Spring environment.
</p>
<p>
It can either be based on a given property name, passed via the "{@value #PARAM_NAME}" parameter, or a property name
derived from the {@link Feature} itself (e.g. "{@value #DEFAULT_PROPERTY_PREFIX}FEATURE_NAM... | getPropertyValue | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategy.java | Apache-2.0 |
private static List<String> getActiveProfileNames(ApplicationContext applicationContext) {
String[] names = applicationContext.getEnvironment().getActiveProfiles();
List<String> result = new ArrayList<>(names.length);
for (String name : names) {
result.add(name.toLowerCase());
... | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getActiveProfileNames | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public String getId() {
return ID;
} | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getId | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public String getName() {
return "Spring Profile";
} | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getName | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public boolean isActive(FeatureState featureState, FeatureUser user, List<Token> tokens) {
ApplicationContext applicationContext = ContextClassLoaderApplicationContextHolder.get();
if (applicationContext == null) {
throw new IllegalStateException("ApplicationContext could not b... | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | isActive | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public Parameter[] getParameters() {
return new Parameter[] {
ParameterBuilder.create(PARAM_PROFILES)
.label("Profile Names")
.description("A comma-separated list of profile names for which the feature should be active. A "
+ "profile... | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getParameters | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public String getTokenParameterName() {
return PARAM_PROFILES;
} | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getTokenParameterName | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public TokenTransformer getTokenParameterTransformer() {
return new TokenTransformer() {
@Override
public String transform(String value) {
return value.toLowerCase();
}
};
} | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | getTokenParameterTransformer | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public String transform(String value) {
return value.toLowerCase();
} | <p>
An activation strategy based on the profiles that are active within the Spring environment.
</p>
<p>
One or more profiles can be specified in a comma-separated value via the "{@value #PARAM_PROFILES}" parameter. This
strategy works by only activating the feature if at least one of the profiles are currently active.... | transform | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/activation/SpringProfileActivationStrategy.java | Apache-2.0 |
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent && filter.test((ContextRefreshedEvent) event)) {
if (ContextClassLoaderApplicationContextHolder.get() != null) {
log.warn("ApplicationContext already bound to current con... | {@link ApplicationListener} that binds the {@link ApplicationContext}
to the Togglz {@link ContextClassLoaderApplicationContextHolder}.
@author Marcel Overdijk | onApplicationEvent | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListener.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListener.java | Apache-2.0 |
@Override
public FeatureManager getObject() throws Exception {
return builder.build();
} | <p>
{@link FactoryBean} for creating a {@link FeatureManager} managed by Spring.
</p>
<p>
Example usage:
</p>
<pre>
<bean id="userProvider" class="org.togglz.core.user.NoOpUserProvider" />
<bean id="stateRepository" class="org.togglz.core.repository.mem.InMemoryStateRepository" />
<bean id="featureMa... | getObject | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | Apache-2.0 |
@Override
public Class<?> getObjectType() {
return FeatureManager.class;
} | <p>
{@link FactoryBean} for creating a {@link FeatureManager} managed by Spring.
</p>
<p>
Example usage:
</p>
<pre>
<bean id="userProvider" class="org.togglz.core.user.NoOpUserProvider" />
<bean id="stateRepository" class="org.togglz.core.repository.mem.InMemoryStateRepository" />
<bean id="featureMa... | getObjectType | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | Apache-2.0 |
@Override
public boolean isSingleton() {
return false;
} | <p>
{@link FactoryBean} for creating a {@link FeatureManager} managed by Spring.
</p>
<p>
Example usage:
</p>
<pre>
<bean id="userProvider" class="org.togglz.core.user.NoOpUserProvider" />
<bean id="stateRepository" class="org.togglz.core.repository.mem.InMemoryStateRepository" />
<bean id="featureMa... | isSingleton | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/manager/FeatureManagerFactory.java | Apache-2.0 |
@Override
public void afterPropertiesSet() {
Validate.notNull(feature, "The 'feature' property is required");
Validate.notBlank(feature.name(), "The 'feature.name' property is required");
Validate.notNull(active, "The 'active' property is required");
Validate.notNull(inactive, "The '... | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | afterPropertiesSet | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
@Override
public Object getObject() {
// make sure the factory is fully initialized
if (!initialized) {
throw new FactoryBeanNotInitializedException();
}
// create the invocation handler that switches between implementations
FeatureProxyInvocationHandler proxy =... | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getObject | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
private Class<?> getEffectiveProxyType() {
// prefer the business interface manually set by the user
if (proxyType != null) {
return proxyType;
}
// check which interfaces the both delegates implements
HashSet<Class<?>> activeInterfaces = new HashSet<Class<?>>(Array... | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getEffectiveProxyType | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
private ClassLoader getSuitableClassLoader() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
}
return classLoader;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getSuitableClassLoader | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
@Override
public Class<?> getObjectType() {
if (initialized) {
return getEffectiveProxyType();
} else {
return null;
}
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getObjectType | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
@Override
public boolean isSingleton() {
return true;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | isSingleton | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public String getFeature() {
return feature.name();
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getFeature | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public void setFeature(Feature feature) {
this.feature = feature;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | setFeature | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public Object getActive() {
return active;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getActive | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public void setActive(Object active) {
this.active = active;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | setActive | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public Object getInactive() {
return inactive;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getInactive | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public void setInactive(Object inactive) {
this.inactive = inactive;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | setInactive | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public Class<?> getProxyType() {
return proxyType;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | getProxyType | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
public void setProxyType(Class<?> proxyType) {
this.proxyType = proxyType;
} | <p>
Implementation of {@link FactoryBean} that creates a proxy that delegates invocation to one of two target beans depending on
that state of a given feature.
</p>
<p>
You can use the factory like this:
</p>
<pre>
<bean id="someService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean">
<property na... | setProxyType | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/proxy/FeatureProxyFactoryBean.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(Feature feature) {
return delegate.getFeatureState(feature);
} | Creates a facade for the supplied {@link StateRepository}.
@param delegate The repository to delegate invocations to
@param applicationEventPublisher The {@link ApplicationEventPublisher} to publish the {@link FeatureStateChangedEvent} to | getFeatureState | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/repository/ApplicationEventPublisherRepository.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/repository/ApplicationEventPublisherRepository.java | Apache-2.0 |
@Override
public void setFeatureState(FeatureState featureState) {
FeatureState previousFeatureState = getFeatureState(featureState.getFeature());
delegate.setFeatureState(featureState);
applicationEventPublisher.publishEvent(new FeatureStateChangedEvent(previousFeatureState, featureState));... | Creates a facade for the supplied {@link StateRepository}.
@param delegate The repository to delegate invocations to
@param applicationEventPublisher The {@link ApplicationEventPublisher} to publish the {@link FeatureStateChangedEvent} to | setFeatureState | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/repository/ApplicationEventPublisherRepository.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/repository/ApplicationEventPublisherRepository.java | Apache-2.0 |
public FeatureState getPreviousFeatureState() {
return previousFeatureState;
} | An {@link ApplicationEvent} that is published whenever a {@link FeatureState} is changed
@author Igor Khudoshin | getPreviousFeatureState | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/repository/FeatureStateChangedEvent.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/repository/FeatureStateChangedEvent.java | Apache-2.0 |
public FeatureState getFeatureState() {
return (FeatureState) getSource();
} | An {@link ApplicationEvent} that is published whenever a {@link FeatureState} is changed
@author Igor Khudoshin | getFeatureState | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/repository/FeatureStateChangedEvent.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/repository/FeatureStateChangedEvent.java | Apache-2.0 |
@Override
protected ApplicationContext getApplicationContext(Object context) {
return ContextClassLoaderApplicationContextHolder.get();
} | Simple implementation of {@link org.togglz.core.spi.BeanFinder} which uses
{@link ContextClassLoaderApplicationContextHolder}. | getApplicationContext | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/spi/SpringCoreBeanFinder.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/spi/SpringCoreBeanFinder.java | Apache-2.0 |
public static ApplicationContext get() {
ClassLoader classLoader = getContextClassLoader();
while (classLoader != null) {
ApplicationContext applicationContext = contextMap.get(classLoader);
if (applicationContext != null) {
return applicationContext;
... | Returns the {@link ApplicationContext} bound to the current context class loader or any of
its parent class loaders. Walking up the class loader hierarchy is required to support
special class loader scenarios like Spring Boot's reloading mechanism. | get | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | Apache-2.0 |
public static void bind(ApplicationContext context) {
Object old = contextMap.putIfAbsent(getContextClassLoader(), context);
if (old != null) {
throw new IllegalStateException(
"There is already a ApplicationContext associated with the context ClassLoader of the current threa... | Binds the {@link ApplicationContext} to the current context class loader . | bind | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | Apache-2.0 |
private static ClassLoader getContextClassLoader() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
throw new IllegalStateException("Unable to get the context class loader for the current thread!");
}
return classLoader;
... | Releases the {@link ApplicationContext} associated with the current context class loader. | getContextClassLoader | java | togglz/togglz | spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | https://github.com/togglz/togglz/blob/master/spring-core/src/main/java/org/togglz/spring/util/ContextClassLoaderApplicationContextHolder.java | Apache-2.0 |
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
when(mockApplicationContext.getEnvironment()).thenReturn(mockEnvironment);
strategy = new SpringEnvironmentPropertyActivationStrategy();
} | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | setUp | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@AfterEach
void tearDown() {
ContextClassLoaderApplicationContextHolder.release();
} | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | tearDown | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetId() {
assertEquals(SpringEnvironmentPropertyActivationStrategy.ID, strategy.getId());
} | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetId | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetName() {
assertTrue(Strings.isNotBlank(strategy.getName()));
} | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetName | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@ParameterizedTest
@ValueSource(booleans = {true, false})
void testIsActiveWithNoParam(boolean enabled) {
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, !enabled);
ContextClassLoaderApplicationContextHolder.bind(mockApplicationContext);
when(mockEnvironment.getP... | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testIsActiveWithNoParam | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@ParameterizedTest
@ValueSource(booleans = {true, false})
void testIsActiveWithParam(boolean enabled) {
String paramValue = "foo";
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, !enabled);
featureState.setParameter(SpringEnvironmentPropertyActivationStrategy.PARAM... | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testIsActiveWithParam | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@Test
void testIsActiveThrowsWhenNoApplicationContext() {
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, true);
assertThrows(IllegalStateException.class, () -> strategy.isActive(featureState, null));
} | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testIsActiveThrowsWhenNoApplicationContext | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetParameters() {
Parameter[] parameters = strategy.getParameters();
assertEquals(2, parameters.length);
Parameter parameter = parameters[0];
assertNotNull(parameter);
assertEquals(AbstractPropertyDrivenActivationStrategy.PARAM_NAME, parameter.getName());
... | <p>
Tests for the {@link SpringEnvironmentPropertyActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetParameters | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringEnvironmentPropertyActivationStrategyTest.java | Apache-2.0 |
private static Stream<Arguments> activeTestCases() {
return Stream.of(
Arguments.of(new IsActiveTestCase("profile is not active", false, "p1", "p2")),
Arguments.of(new IsActiveTestCase("profile is not active but param is negated", true, "!p1", "p2")),
Arguments.of... | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | activeTestCases | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
activeProfiles = new String[0];
when(mockEnvironment.getActiveProfiles()).thenAnswer(invocationOnMock -> activeProfiles);
when(mockApplicationContext.getEnvironment()).thenReturn(mockEnvironment);
ContextClassL... | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | setUp | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@AfterEach
void tearDown() {
ContextClassLoaderApplicationContextHolder.release();
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | tearDown | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetId() {
assertEquals(SpringProfileActivationStrategy.ID, strategy.getId());
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetId | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetName() {
assertTrue(Strings.isNotBlank(strategy.getName()));
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetName | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@ParameterizedTest
@MethodSource("activeTestCases")
void testIsActive(IsActiveTestCase testCase) {
activeProfiles = testCase.activeProfiles;
testCase.run(strategy);
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testIsActive | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testIsActiveThrowsWhenNoApplicationContext() {
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, true);
ContextClassLoaderApplicationContextHolder.release();
assertThrows(IllegalStateException.class, () -> strategy.isActive(featureState, null));
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testIsActiveThrowsWhenNoApplicationContext | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetParameters() {
Parameter[] parameters = strategy.getParameters();
assertEquals(1, parameters.length);
Parameter parameter = parameters[0];
assertNotNull(parameter);
assertEquals(SpringProfileActivationStrategy.PARAM_PROFILES, parameter.getName());
... | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetParameters | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetTokenParameterName() {
assertEquals(SpringProfileActivationStrategy.PARAM_PROFILES, strategy.getTokenParameterName());
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetTokenParameterName | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@Test
void testGetTokenParameterTransformer() {
TokenTransformer transformer = strategy.getTokenParameterTransformer();
assertNotNull(transformer);
assertEquals("foo", transformer.transform("FOO"));
} | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | testGetTokenParameterTransformer | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
void run(SpringProfileActivationStrategy strategy) {
FeatureState featureState = new FeatureState(TestFeatures.FEATURE_ONE, !expected);
featureState.setParameter(SpringProfileActivationStrategy.PARAM_PROFILES, profilesParam);
assertEquals(expected, strategy.isActive(featureState, nu... | <p>
Tests for the {@link SpringProfileActivationStrategy} class.
</p>
@author Alasdair Mercer | run | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/activation/SpringProfileActivationStrategyTest.java | Apache-2.0 |
@BeforeEach
void setUp() {
applicationListener = new TogglzApplicationContextBinderApplicationListener();
ignoringApplicationListener = new TogglzApplicationContextBinderApplicationListener(t -> false);
applicationContext = mock(ApplicationContext.class);
} | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | setUp | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@AfterEach
void tearDown() {
ContextClassLoaderApplicationContextHolder.release();
} | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | tearDown | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@Test
void contextRefreshed() {
ContextRefreshedEvent contextRefreshedEvent = mock(ContextRefreshedEvent.class);
when(contextRefreshedEvent.getApplicationContext()).thenReturn(applicationContext);
// Invoke context refreshed event
applicationListener.onApplicationEvent(contextRefres... | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | contextRefreshed | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@Test
void contextRefreshedWhileContextAlreadyBound() {
// Bind application context before context refreshed event invoked
ContextClassLoaderApplicationContextHolder.bind(mock(ApplicationContext.class));
applicationContext = mock(ApplicationContext.class);
ContextRefreshedEvent conte... | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | contextRefreshedWhileContextAlreadyBound | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@Test
void contextRefreshedIgnored() {
// Release any application context before context refreshed event invoked
ContextClassLoaderApplicationContextHolder.release();
applicationContext = mock(ApplicationContext.class);
ContextRefreshedEvent contextRefreshedEvent = mock(ContextRefres... | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | contextRefreshedIgnored | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@Test
void contextClosed() {
// Bind application context before context closed event invoked
ContextClassLoaderApplicationContextHolder.bind(applicationContext);
ContextClosedEvent contextClosedEvent = mock(ContextClosedEvent.class);
// Invoke context closed event
applicatio... | Tests for {@link TogglzApplicationContextBinderApplicationListener}.
@author Marcel Overdijk | contextClosed | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/listener/TogglzApplicationContextBinderApplicationListenerTest.java | Apache-2.0 |
@Test
@DisplayName("doesn't support null feature")
void doesntSupportNullFeature() {
FeatureProxyFactoryBean bean = new FeatureProxyFactoryBean();
Feature feature = null;
bean.setFeature(feature);
assertThrows(IllegalArgumentException.class, bean::afterPropertiesSet);
} | Tests for {@link FeatureProxyFactoryBean}.
@author Jakub Klebek | doesntSupportNullFeature | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/proxy/FeatureProxyFactoryBeanTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/proxy/FeatureProxyFactoryBeanTest.java | Apache-2.0 |
@Test
@DisplayName("doesn't support feature with empty name")
void doesntSupportFeatureWithEmptyName() {
FeatureProxyFactoryBean bean = new FeatureProxyFactoryBean();
Feature feature = new NamedFeature("");
bean.setFeature(feature);
assertThrows(IllegalArgumentException.class, b... | Tests for {@link FeatureProxyFactoryBean}.
@author Jakub Klebek | doesntSupportFeatureWithEmptyName | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/proxy/FeatureProxyFactoryBeanTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/proxy/FeatureProxyFactoryBeanTest.java | Apache-2.0 |
@BeforeEach
void setup() {
MockitoAnnotations.initMocks(this);
doNothing().when(mockApplicationEventPublisher).publishEvent(mockEvent);
delegate = mock(StateRepository.class);
// the mock supports the ENUM
when(delegate.getFeatureState(DummyFeature.TEST))
.thenR... | Unit test for {@link ApplicationEventPublisherRepository}.
@author Igor Khudoshin | setup | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | Apache-2.0 |
@AfterEach
public void tearDown() {
delegate = null;
} | Unit test for {@link ApplicationEventPublisherRepository}.
@author Igor Khudoshin | tearDown | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | Apache-2.0 |
@Test
void saveFeatureStatePublishesEvent() {
StateRepository repository = new ApplicationEventPublisherRepository(delegate, mockApplicationEventPublisher);
FeatureState newFeatureState = new FeatureState(DummyFeature.TEST, false);
repository.setFeatureState(newFeatureState);
// d... | Unit test for {@link ApplicationEventPublisherRepository}.
@author Igor Khudoshin | saveFeatureStatePublishesEvent | java | togglz/togglz | spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | https://github.com/togglz/togglz/blob/master/spring-core/src/test/java/org/togglz/spring/repository/ApplicationEventPublisherRepositoryTest.java | Apache-2.0 |
@Override
public CSRFToken getToken(HttpServletRequest request) {
CsrfToken token = (CsrfToken) request.getAttribute("_csrf");
if (token != null) {
return new CSRFToken(token.getParameterName(), token.getToken());
}
return null;
} | Implementation of CSRFTokenProvider for Spring Security.
@see org.togglz.servlet.spi.CSRFTokenProvider | getToken | java | togglz/togglz | spring-security/src/main/java/org/togglz/spring/security/SpringSecurityTokenProvider.java | https://github.com/togglz/togglz/blob/master/spring-security/src/main/java/org/togglz/spring/security/SpringSecurityTokenProvider.java | Apache-2.0 |
public A getAnnotation() {
return this.annotation;
} | Used to store annotations in a ConcurrentHashMap which does not allow storing {@code null} values.
@param <A> annotation type | getAnnotation | java | togglz/togglz | spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | https://github.com/togglz/togglz/blob/master/spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | Apache-2.0 |
public boolean hasAnnotation() {
return this.annotation != null;
} | Used to store annotations in a ConcurrentHashMap which does not allow storing {@code null} values.
@param <A> annotation type | hasAnnotation | java | togglz/togglz | spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | https://github.com/togglz/togglz/blob/master/spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | Apache-2.0 |
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
final HandlerMethod handlerMethod = (HandlerMethod) handler;
AnnotationHolder<FeaturesAreActive> a... | Caches the annotations on the {@link HandlerMethod}s to avoid expensive reflection calls for every request. | preHandle | java | togglz/togglz | spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | https://github.com/togglz/togglz/blob/master/spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | Apache-2.0 |
protected static <A extends Annotation> A handlerAnnotation(final HandlerMethod handlerMethod, final Class<A> annotationClass) {
A annotation = handlerMethod.getMethodAnnotation(annotationClass);
if (annotation == null) {
annotation = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(... | Caches the annotations on the {@link HandlerMethod}s to avoid expensive reflection calls for every request. | handlerAnnotation | java | togglz/togglz | spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | https://github.com/togglz/togglz/blob/master/spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | Apache-2.0 |
protected static Set<String> getFeatureNames(final FeatureManager featureManager) {
return featureManager.getFeatures().stream()
.map(Feature::name)
.collect(Collectors.toSet());
} | Caches the annotations on the {@link HandlerMethod}s to avoid expensive reflection calls for every request. | getFeatureNames | java | togglz/togglz | spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | https://github.com/togglz/togglz/blob/master/spring-web/src/main/java/org/togglz/spring/web/FeatureInterceptor.java | Apache-2.0 |
@Override
public String getName() {
return this.getClass().getSimpleName() + ":" + featureEnum.getSimpleName();
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getName | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public Set<Feature> getFeatures() {
return new HashSet<>(Arrays.asList(featureEnum.getEnumConstants()));
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getFeatures | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public FeatureMetaData getMetaData(Feature feature) {
return new EnumFeatureMetaData(feature);
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getMetaData | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public boolean isActive(Feature feature) {
return activeFeatures.contains(feature.name());
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | isActive | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public FeatureUser getCurrentFeatureUser() {
return null;
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getCurrentFeatureUser | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public FeatureState getFeatureState(Feature feature) {
return new FeatureState(feature, isActive(feature));
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getFeatureState | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public void setFeatureState(FeatureState state) {
if (state.isEnabled()) {
activeFeatures.add(state.getFeature().name());
} else {
activeFeatures.remove(state.getFeature().name());
}
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | setFeatureState | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public List<ActivationStrategy> getActivationStrategies() {
return emptyList();
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | getActivationStrategies | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public void enable(Feature feature) {
activeFeatures.add(feature.name());
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | enable | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public void disable(Feature feature) {
activeFeatures.remove(feature.name());
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | disable | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
public void enableAll() {
for (Feature feature : featureEnum.getEnumConstants()) {
enable(feature);
}
} | A {@link FeatureManager} implementation that allows easy manipulation of features in testing environments.
@author Christian Kaltepoth | enableAll | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManager.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManager.java | Apache-2.0 |
@Override
public int priority() {
// very high priority
return 10;
} | This {@link FeatureManagerProvider} is used by the testing integration modules to provide a FeatureManager in unit tests.
@author Christian Kaltepoth | priority | java | togglz/togglz | testing/src/main/java/org/togglz/testing/TestFeatureManagerProvider.java | https://github.com/togglz/togglz/blob/master/testing/src/main/java/org/togglz/testing/TestFeatureManagerProvider.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.