Spring Framework MockEnvironment - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MockEnvironment class.

This code example shows how to use the following methods:setProperty
	public void testContainerAttributesWithCustomContainerIpAndHostname() { 
 
		final String customIp = "123.123.123.123";
		final String customHostname = "testhost";
 
		MockEnvironment environment = new MockEnvironment();
		environment.setProperty(CONTAINER_IP_KEY, customIp);
		environment.setProperty(CONTAINER_HOST_KEY, customHostname);
 
		final ContainerServerApplication containerServerApplication = new ContainerServerApplication();
		containerServerApplication.setEnvironment(environment);
 
		final ContainerAttributes containerAttributes = containerServerApplication.containerAttributes();
		Assert.assertNotNull(containerAttributes);
		Assert.assertEquals(customIp, containerAttributes.getIp());
		Assert.assertEquals(customHostname, containerAttributes.getHost());
	} 
 
	@Test
	public void testContainerAttributesWithCustomEmptyStringContainerIpAndHostname() { 
5
CodeRank
This code example shows how to use the following methods:
    private MockEnvironment environment; 
 
    @Before 
    public void setUp() { 
        webApplicationContext = new XmlWebApplicationContext(); 
        environment = new MockEnvironment(); 
        webApplicationContext.setEnvironment(environment); 
        webApplicationContext.setServletContext(new MockServletContext()); 
        new YamlServletProfileInitializer().initialize(webApplicationContext); 
        webApplicationContext.setConfigLocation("file:./src/main/webapp/WEB-INF/spring-servlet.xml"); 
    } 
    /** 
     * We have a condition in the AutzhAuthenticationManager that automatically 
     * fails a password validation for zero length password. 
     * This test prevents that the authzAuthenticationMgr gets swapped out without 
     * the developer being notified. 
     * @throws Exception 
     */ 
    @Test 
    public void verifyAuthzAuthenticationManagerClassInStandardProfile() throws Exception { 
5
CodeRank
See Code Examples for Spring Framework MockEnvironment Methods: