mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
1 parent
127d78b1b8
commit
df7f8c8af2
1 file changed
+16
@@ -31,6 +31,7 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -51,6 +52,12 @@ public class SystemPropertiesTest {
|
||||
new SystemProperties.Listener().contextInitialized(new ServletContextEvent(j.jenkins.servletContext));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
System.clearProperty("foo.bar");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldReturnNullIfUndefined() throws Exception {
|
||||
assertThat("Properties should be null by default",
|
||||
@@ -81,6 +88,15 @@ public class SystemPropertiesTest {
|
||||
SystemProperties.getString("install-wizard-path"), equalTo("myVal2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnWebAppPropertyIfSystemPropertyNotSetAndDefaultIsSet() throws Exception {
|
||||
assertThat("Property is undefined before test",
|
||||
SystemProperties.getString("foo.bar"), equalTo(null));
|
||||
setWebAppInitParameter("foo.bar", "myVal");
|
||||
assertThat("Should return web app property if system property is not set and default value is set",
|
||||
SystemProperties.getString("foo.bar", "defaultVal"), equalTo("myVal"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack to set a web app initial parameter afterwards. Only works with Jetty.
|
||||
* @param property property to set
|
||||
|
||||
Reference in new issue
Block a user