List of usage examples for org.springframework.mock.env MockEnvironment setProperty
public void setProperty(String key, String value)
From source file:org.cloudfoundry.identity.uaa.db.DatabaseParametersTests.java
@Override @Before//from w ww . j a v a 2 s . c o m public void setUp() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("database.initialsize", "0"); environment.setProperty("database.validationquerytimeout", "5"); environment.setProperty("database.connecttimeout", "5"); if (System.getProperty("spring.profiles.active") != null) { environment.setActiveProfiles( StringUtils.commaDelimitedListToStringArray(System.getProperty("spring.profiles.active"))); } super.setUp(environment); vendor = webApplicationContext.getBean(DatabaseUrlModifier.class).getDatabaseType(); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerMockMvcTests.java
@Test public void testCustomSignupLink() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("links.signup", "http://www.example.com/signup"); RemoteUaaController controller = new RemoteUaaController(environment, new RestTemplate()); Prompt first = new Prompt("how", "text", "How did I get here?"); Prompt second = new Prompt("where", "password", "Where does that highway go to?"); controller.setPrompts(Arrays.asList(first, second)); MockMvc mockMvc = getMockMvc(controller); mockMvc.perform(get("/login").accept(TEXT_HTML)).andExpect(status().isOk()) .andExpect(model().attribute("createAccountLink", "http://www.example.com/signup")); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerMockMvcTests.java
@Test public void testLocalSignupDisabled() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("login.selfServiceLinksEnabled", "false"); RemoteUaaController controller = new RemoteUaaController(environment, new RestTemplate()); Prompt first = new Prompt("how", "text", "How did I get here?"); Prompt second = new Prompt("where", "password", "Where does that highway go to?"); controller.setPrompts(Arrays.asList(first, second)); MockMvc mockMvc = getMockMvc(controller); mockMvc.perform(get("/login").accept(TEXT_HTML)).andExpect(status().isOk()) .andExpect(model().attribute("createAccountLink", nullValue())); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerMockMvcTests.java
@Test public void testCustomSignupLinkWithLocalSignupDisabled() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("login.selfServiceLinksEnabled", "false"); environment.setProperty("links.signup", "http://www.example.com/signup"); environment.setProperty("links.passwd", "http://www.example.com/passwd"); RemoteUaaController controller = new RemoteUaaController(environment, new RestTemplate()); Prompt first = new Prompt("how", "text", "How did I get here?"); Prompt second = new Prompt("where", "password", "Where does that highway go to?"); controller.setPrompts(Arrays.asList(first, second)); MockMvc mockMvc = getMockMvc(controller); mockMvc.perform(get("/login").accept(TEXT_HTML)).andExpect(status().isOk()) .andExpect(model().attribute("createAccountLink", nullValue())) .andExpect(model().attribute("forgotPasswordLink", nullValue())); }
From source file:io.lavagna.service.config.TestServiceConfig.java
@Bean public Environment env() { MockEnvironment m = new MockEnvironment(); String dialect = System.getProperty("datasource.dialect", "HSQLDB"); for (Entry<String, String> kv : datasourceConf().get(dialect).entrySet()) { m.setProperty(kv.getKey(), kv.getValue()); }//from w w w.j a v a 2s. c o m return m; }
From source file:org.springframework.boot.logging.logback.LogbackLoggingSystemTests.java
@Test public void testConsolePatternProperty() { MockEnvironment environment = new MockEnvironment(); environment.setProperty("logging.pattern.console", "%logger %msg"); LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment); this.loggingSystem.initialize(loggingInitializationContext, null, null); this.logger.info("Hello world"); String output = this.output.toString().trim(); assertFalse("Wrong output pattern:\n" + output, getLineWithText(output, "Hello world").contains("INFO")); }
From source file:org.springframework.boot.logging.logback.LogbackLoggingSystemTests.java
@Test public void testLevelPatternProperty() { MockEnvironment environment = new MockEnvironment(); environment.setProperty("logging.pattern.level", "X%clr(%p)X"); LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment); this.loggingSystem.initialize(loggingInitializationContext, null, null); this.logger.info("Hello world"); String output = this.output.toString().trim(); assertTrue("Wrong output pattern:\n" + output, getLineWithText(output, "Hello world").contains("XINFOX")); }
From source file:org.springframework.boot.logging.logback.LogbackLoggingSystemTests.java
@Test public void testFilePatternProperty() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("logging.pattern.file", "%logger %msg"); LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment); File file = new File(tmpDir(), "logback-test.log"); LogFile logFile = getLogFile(file.getPath(), null); this.loggingSystem.initialize(loggingInitializationContext, null, logFile); this.logger.info("Hello world"); String output = this.output.toString().trim(); assertTrue("Wrong console output pattern:\n" + output, getLineWithText(output, "Hello world").contains("INFO")); assertFalse("Wrong file output pattern:\n" + output, getLineWithText(file, "Hello world").contains("INFO")); }