forked from apereo/java-cas-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apereo#94 from leleuj/casc-91
Issue-91: Introduce system properties configuration option
- Loading branch information
Showing
4 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...in/java/org/jasig/cas/client/configuration/SystemPropertiesConfigurationStrategyImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to Jasig under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work | ||
* for additional information regarding copyright ownership. | ||
* Jasig licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a | ||
* copy of the License at the following location: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jasig.cas.client.configuration; | ||
|
||
import javax.servlet.Filter; | ||
import javax.servlet.FilterConfig; | ||
|
||
/** | ||
* Load all configuration from system properties. | ||
* | ||
* @author Jerome Leleu | ||
* @since 3.4.0 | ||
*/ | ||
public class SystemPropertiesConfigurationStrategyImpl extends BaseConfigurationStrategy { | ||
|
||
public void init(FilterConfig filterConfig, Class<? extends Filter> filterClazz) { | ||
} | ||
|
||
@Override | ||
protected String get(ConfigurationKey configurationKey) { | ||
return System.getProperty(configurationKey.getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...va/org/jasig/cas/client/configuration/SystemPropertiesConfigurationStrategyImplTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to Jasig under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work | ||
* for additional information regarding copyright ownership. | ||
* Jasig licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a | ||
* copy of the License at the following location: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jasig.cas.client.configuration; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.jasig.cas.client.util.AbstractCasFilter; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.mock.web.MockFilterConfig; | ||
|
||
/** | ||
* Tests {@link SystemPropertiesConfigurationStrategyImpl}. | ||
* | ||
* @author Jerome Leleu | ||
* @since 3.4.0 | ||
*/ | ||
public class SystemPropertiesConfigurationStrategyImplTests { | ||
|
||
private final static String PARAMETER_NAME = "parameter"; | ||
|
||
private SystemPropertiesConfigurationStrategyImpl impl; | ||
|
||
private MockFilterConfig filterConfig; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
this.filterConfig = new MockFilterConfig(); | ||
this.impl = new SystemPropertiesConfigurationStrategyImpl(); | ||
this.impl.init(this.filterConfig, AbstractCasFilter.class); | ||
} | ||
|
||
@Test | ||
public void testNoSystemPropertyDefined() { | ||
final ConfigurationKey<String> key = ConfigurationKeys.SERVER_NAME; | ||
// no system property defined | ||
assertEquals(key.getDefaultValue(), impl.getString(key)); | ||
} | ||
|
||
@Test | ||
public void testWithSystemProperty() { | ||
final ConfigurationKey<String> key = ConfigurationKeys.ARTIFACT_PARAMETER_NAME; | ||
System.setProperty(key.getName(), PARAMETER_NAME); | ||
assertEquals(PARAMETER_NAME, impl.getString(key)); | ||
} | ||
} |