提交 d6002092 编写于 作者: S Sam Brannen

Clean up build warnings for ApplicationContextExpressionTests

上级 01fb35bd
...@@ -36,7 +36,6 @@ import org.springframework.beans.factory.ObjectFactory; ...@@ -36,7 +36,6 @@ import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.config.Scope; import org.springframework.beans.factory.config.Scope;
import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.support.AutowireCandidateQualifier; import org.springframework.beans.factory.support.AutowireCandidateQualifier;
...@@ -66,13 +65,14 @@ import static org.springframework.tests.TestGroup.PERFORMANCE; ...@@ -66,13 +65,14 @@ import static org.springframework.tests.TestGroup.PERFORMANCE;
* @author Sam Brannen * @author Sam Brannen
* @since 3.0 * @since 3.0
*/ */
public class ApplicationContextExpressionTests { class ApplicationContextExpressionTests {
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class); private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
@Test @Test
public void genericApplicationContext() throws Exception { @SuppressWarnings("deprecation")
void genericApplicationContext() throws Exception {
GenericApplicationContext ac = new GenericApplicationContext(); GenericApplicationContext ac = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac); AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
...@@ -105,7 +105,8 @@ public class ApplicationContextExpressionTests { ...@@ -105,7 +105,8 @@ public class ApplicationContextExpressionTests {
ac.getBeanFactory().setConversionService(new DefaultConversionService()); ac.getBeanFactory().setConversionService(new DefaultConversionService());
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc =
new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
Properties placeholders = new Properties(); Properties placeholders = new Properties();
placeholders.setProperty("code", "123"); placeholders.setProperty("code", "123");
ppc.setProperties(placeholders); ppc.setProperties(placeholders);
...@@ -211,7 +212,7 @@ public class ApplicationContextExpressionTests { ...@@ -211,7 +212,7 @@ public class ApplicationContextExpressionTests {
} }
@Test @Test
public void prototypeCreationReevaluatesExpressions() { void prototypeCreationReevaluatesExpressions() {
GenericApplicationContext ac = new GenericApplicationContext(); GenericApplicationContext ac = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac); AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
GenericConversionService cs = new GenericConversionService(); GenericConversionService cs = new GenericConversionService();
...@@ -247,7 +248,7 @@ public class ApplicationContextExpressionTests { ...@@ -247,7 +248,7 @@ public class ApplicationContextExpressionTests {
@Test @Test
@EnabledForTestGroups(PERFORMANCE) @EnabledForTestGroups(PERFORMANCE)
public void prototypeCreationIsFastEnough() { void prototypeCreationIsFastEnough() {
Assume.notLogging(factoryLog); Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext(); GenericApplicationContext ac = new GenericApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
...@@ -273,10 +274,11 @@ public class ApplicationContextExpressionTests { ...@@ -273,10 +274,11 @@ public class ApplicationContextExpressionTests {
System.getProperties().remove("name"); System.getProperties().remove("name");
} }
assertThat(sw.getTotalTimeMillis() < 6000).as("Prototype creation took too long: " + sw.getTotalTimeMillis()).isTrue(); assertThat(sw.getTotalTimeMillis() < 6000).as("Prototype creation took too long: " + sw.getTotalTimeMillis()).isTrue();
ac.close();
} }
@Test @Test
public void systemPropertiesSecurityManager() { void systemPropertiesSecurityManager() {
AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
GenericBeanDefinition bd = new GenericBeanDefinition(); GenericBeanDefinition bd = new GenericBeanDefinition();
...@@ -309,10 +311,11 @@ public class ApplicationContextExpressionTests { ...@@ -309,10 +311,11 @@ public class ApplicationContextExpressionTests {
System.setSecurityManager(oldSecurityManager); System.setSecurityManager(oldSecurityManager);
System.getProperties().remove("country"); System.getProperties().remove("country");
} }
ac.close();
} }
@Test @Test
public void stringConcatenationWithDebugLogging() { void stringConcatenationWithDebugLogging() {
AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
GenericBeanDefinition bd = new GenericBeanDefinition(); GenericBeanDefinition bd = new GenericBeanDefinition();
...@@ -323,10 +326,11 @@ public class ApplicationContextExpressionTests { ...@@ -323,10 +326,11 @@ public class ApplicationContextExpressionTests {
String str = ac.getBean("str", String.class); String str = ac.getBean("str", String.class);
assertThat(str.startsWith("test-")).isTrue(); assertThat(str.startsWith("test-")).isTrue();
ac.close();
} }
@Test @Test
public void resourceInjection() throws IOException { void resourceInjection() throws IOException {
System.setProperty("logfile", "do_not_delete_me.txt"); System.setProperty("logfile", "do_not_delete_me.txt");
try (AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(ResourceInjectionBean.class)) { try (AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(ResourceInjectionBean.class)) {
ResourceInjectionBean resourceInjectionBean = ac.getBean(ResourceInjectionBean.class); ResourceInjectionBean resourceInjectionBean = ac.getBean(ResourceInjectionBean.class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册