Skip to content

Commit dc36bb3

Browse files
committed
Polishing
1 parent 6735e23 commit dc36bb3

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.util.HashMap;
2020
import java.util.Map;
2121

22-
import org.junit.Before;
2322
import org.junit.Test;
2423

2524
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -37,21 +36,18 @@
3736
public class CustomScopeConfigurerTests {
3837

3938
private static final String FOO_SCOPE = "fooScope";
40-
private ConfigurableListableBeanFactory factory;
4139

42-
@Before
43-
public void setUp() {
44-
factory = new DefaultListableBeanFactory();
45-
}
40+
private final ConfigurableListableBeanFactory factory = new DefaultListableBeanFactory();
41+
4642

4743
@Test
48-
public void testWithNoScopes() throws Exception {
44+
public void testWithNoScopes() {
4945
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
5046
figurer.postProcessBeanFactory(factory);
5147
}
5248

5349
@Test
54-
public void testSunnyDayWithBonaFideScopeInstance() throws Exception {
50+
public void testSunnyDayWithBonaFideScopeInstance() {
5551
Scope scope = mock(Scope.class);
5652
factory.registerScope(FOO_SCOPE, scope);
5753
Map<String, Object> scopes = new HashMap<>();
@@ -62,7 +58,7 @@ public void testSunnyDayWithBonaFideScopeInstance() throws Exception {
6258
}
6359

6460
@Test
65-
public void testSunnyDayWithBonaFideScopeClass() throws Exception {
61+
public void testSunnyDayWithBonaFideScopeClass() {
6662
Map<String, Object> scopes = new HashMap<>();
6763
scopes.put(FOO_SCOPE, NoOpScope.class);
6864
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@@ -72,7 +68,7 @@ public void testSunnyDayWithBonaFideScopeClass() throws Exception {
7268
}
7369

7470
@Test
75-
public void testSunnyDayWithBonaFideScopeClassname() throws Exception {
71+
public void testSunnyDayWithBonaFideScopeClassName() {
7672
Map<String, Object> scopes = new HashMap<>();
7773
scopes.put(FOO_SCOPE, NoOpScope.class.getName());
7874
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@@ -82,7 +78,7 @@ public void testSunnyDayWithBonaFideScopeClassname() throws Exception {
8278
}
8379

8480
@Test(expected = IllegalArgumentException.class)
85-
public void testWhereScopeMapHasNullScopeValueInEntrySet() throws Exception {
81+
public void testWhereScopeMapHasNullScopeValueInEntrySet() {
8682
Map<String, Object> scopes = new HashMap<>();
8783
scopes.put(FOO_SCOPE, null);
8884
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
@@ -91,19 +87,19 @@ public void testWhereScopeMapHasNullScopeValueInEntrySet() throws Exception {
9187
}
9288

9389
@Test(expected = IllegalArgumentException.class)
94-
public void testWhereScopeMapHasNonScopeInstanceInEntrySet() throws Exception {
90+
public void testWhereScopeMapHasNonScopeInstanceInEntrySet() {
9591
Map<String, Object> scopes = new HashMap<>();
96-
scopes.put(FOO_SCOPE, this); // <-- not a valid value...
92+
scopes.put(FOO_SCOPE, this); // <-- not a valid value...
9793
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
9894
figurer.setScopes(scopes);
9995
figurer.postProcessBeanFactory(factory);
10096
}
10197

10298
@SuppressWarnings("unchecked")
10399
@Test(expected = ClassCastException.class)
104-
public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() throws Exception {
100+
public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() {
105101
Map scopes = new HashMap();
106-
scopes.put(this, new NoOpScope()); // <-- not a valid value (the key)...
102+
scopes.put(this, new NoOpScope()); // <-- not a valid value (the key)...
107103
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
108104
figurer.setScopes(scopes);
109105
figurer.postProcessBeanFactory(factory);

spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,28 +28,23 @@
2828
*/
2929
public class DeprecatedBeanWarnerTests {
3030

31-
private DefaultListableBeanFactory beanFactory;
32-
3331
private String beanName;
3432

3533
private BeanDefinition beanDefinition;
3634

37-
private DeprecatedBeanWarner warner;
38-
3935

4036
@Test
4137
@SuppressWarnings("deprecation")
4238
public void postProcess() {
43-
beanFactory = new DefaultListableBeanFactory();
39+
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
4440
BeanDefinition def = new RootBeanDefinition(MyDeprecatedBean.class);
4541
String beanName = "deprecated";
4642
beanFactory.registerBeanDefinition(beanName, def);
4743

48-
warner = new MyDeprecatedBeanWarner();
44+
DeprecatedBeanWarner warner = new MyDeprecatedBeanWarner();
4945
warner.postProcessBeanFactory(beanFactory);
5046
assertEquals(beanName, this.beanName);
5147
assertEquals(def, this.beanDefinition);
52-
5348
}
5449

5550

0 commit comments

Comments
 (0)