diff --git a/spring-core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java index 8e8aad80ea8..38f4c36275c 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,13 +55,14 @@ import java.util.Map; * propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars); * * - * When an {@link Environment} is being used by an ApplicationContext, it is important - * that any such PropertySource manipulations be performed before the context's - * {@link org.springframework.context.support.AbstractApplicationContext#refresh() - * refresh()} method is called. This ensures that all property sources are available - * during the container bootstrap process, including use by - * {@linkplain org.springframework.context.support.PropertySourcesPlaceholderConfigurer - * property placeholder configurers}. + * When an {@link Environment} is being used by an {@code ApplicationContext}, it is + * important that any such {@code PropertySource} manipulations be performed + * before the context's {@link + * org.springframework.context.support.AbstractApplicationContext#refresh() refresh()} + * method is called. This ensures that all property sources are available during the + * container bootstrap process, including use by {@linkplain + * org.springframework.context.support.PropertySourcesPlaceholderConfigurer property + * placeholder configurers}. * * * @author Chris Beams @@ -78,7 +79,6 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper *
Any existing active profiles will be replaced with the given arguments; call * with zero arguments to clear the current set of active profiles. Use * {@link #addActiveProfile} to add a profile while preserving the existing set. - * * @see #addActiveProfile * @see #setDefaultProfiles * @see org.springframework.context.annotation.Profile @@ -123,12 +123,10 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper * Return the value of {@link System#getenv()} if allowed by the current * {@link SecurityManager}, otherwise return a map implementation that will attempt * to access individual keys using calls to {@link System#getenv(String)}. - * *
Note that most {@link Environment} implementations will include this system * environment map as a default {@link PropertySource} to be searched. Therefore, it * is recommended that this method not be used directly unless bypassing other * property sources is expressly intended. - * *
Calls to {@link Map#get(Object)} on the Map returned will never throw * {@link IllegalAccessException}; in cases where the SecurityManager forbids access * to a property, {@code null} will be returned and an INFO-level log message will be @@ -140,12 +138,10 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper * Return the value of {@link System#getProperties()} if allowed by the current * {@link SecurityManager}, otherwise return a map implementation that will attempt * to access individual keys using calls to {@link System#getProperty(String)}. - * *
Note that most {@code Environment} implementations will include this system * properties map as a default {@link PropertySource} to be searched. Therefore, it is * recommended that this method not be used directly unless bypassing other property * sources is expressly intended. - * *
Calls to {@link Map#get(Object)} on the Map returned will never throw * {@link IllegalAccessException}; in cases where the SecurityManager forbids access * to a property, {@code null} will be returned and an INFO-level log message will be diff --git a/spring-core/src/main/java/org/springframework/util/Assert.java b/spring-core/src/main/java/org/springframework/util/Assert.java index b78364a9f60..d1ecbe54c1f 100644 --- a/spring-core/src/main/java/org/springframework/util/Assert.java +++ b/spring-core/src/main/java/org/springframework/util/Assert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed 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 @@ -335,7 +335,7 @@ public abstract class Assert { notNull(type, "Type to check against must not be null"); if (!type.isInstance(obj)) { throw new IllegalArgumentException(message + - "Object of class [" + (obj != null ? obj.getClass().getName() : "null") + + ". Object of class [" + (obj != null ? obj.getClass().getName() : "null") + "] must be an instance of " + type); } } diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index 4a5881dcb71..f793eefe61c 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +16,6 @@ package org.springframework.core.env; -import static java.lang.String.format; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.junit.matchers.JUnitMatchers.hasItem; -import static org.junit.matchers.JUnitMatchers.hasItems; -import static org.springframework.core.env.AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME; -import static org.springframework.core.env.AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME; -import static org.springframework.core.env.AbstractEnvironment.RESERVED_DEFAULT_PROFILE_NAME; - import java.lang.reflect.Field; import java.security.AccessControlException; import java.security.Permission; @@ -40,8 +24,18 @@ import java.util.Collections; import java.util.Map; import org.junit.Test; + import org.springframework.mock.env.MockPropertySource; +import static java.lang.String.*; + +import static org.hamcrest.CoreMatchers.*; + +import static org.junit.Assert.*; +import static org.junit.matchers.JUnitMatchers.*; + +import static org.springframework.core.env.AbstractEnvironment.*; + /** * Unit tests for {@link StandardEnvironment}. * diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/AbstractApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/AbstractApplicationContextTests.java index eeafcb71055..2541dfe0520 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/AbstractApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/AbstractApplicationContextTests.java @@ -1,4 +1,21 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed 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 + * + * 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.springframework.web.context; + import java.util.Locale; import org.springframework.beans.TestBean; @@ -136,6 +153,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe } + @SuppressWarnings("serial") public static class MyEvent extends ApplicationEvent { public MyEvent(Object source) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index b20b13220bd..8d6660baf36 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -16,9 +16,6 @@ package org.springframework.web.context; -import static org.hamcrest.CoreMatchers.sameInstance; -import static org.junit.Assert.assertThat; - import java.util.Locale; import javax.servlet.ServletException; @@ -36,6 +33,10 @@ import org.springframework.context.TestListener; import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.support.XmlWebApplicationContext; +import static org.hamcrest.CoreMatchers.*; + +import static org.junit.Assert.*; + /** * @author Rod Johnson * @author Juergen Hoeller @@ -53,6 +54,7 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes root.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor(new BeanPostProcessor() { + @SuppressWarnings("unchecked") public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof TestBean) { ((TestBean) bean).getFriends().add("myFriend");