Skip to content

Commit b2b0df8

Browse files
committed
Merge branch '5.1.x'
2 parents 412c673 + d034c05 commit b2b0df8

File tree

58 files changed

+1934
-2144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1934
-2144
lines changed

spring-aop/src/main/java/org/aopalliance/intercept/Interceptor.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -33,7 +33,7 @@
3333
*
3434
* <pre class=code>
3535
* class DebuggingInterceptor implements MethodInterceptor,
36-
* ConstructorInterceptor, FieldInterceptor {
36+
* ConstructorInterceptor {
3737
*
3838
* Object invoke(MethodInvocation i) throws Throwable {
3939
* debug(i.getMethod(), i.getThis(), i.getArgs());
@@ -45,16 +45,6 @@
4545
* return i.proceed();
4646
* }
4747
*
48-
* Object get(FieldAccess fa) throws Throwable {
49-
* debug(fa.getField(), fa.getThis(), null);
50-
* return fa.proceed();
51-
* }
52-
*
53-
* Object set(FieldAccess fa) throws Throwable {
54-
* debug(fa.getField(), fa.getThis(), fa.getValueToSet());
55-
* return fa.proceed();
56-
* }
57-
*
5848
* void debug(AccessibleObject ao, Object this, Object value) {
5949
* ...
6050
* }

spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -20,7 +20,6 @@
2020

2121
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2222
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
23-
import org.springframework.core.io.Resource;
2423

2524
import static org.junit.Assert.*;
2625
import static org.springframework.tests.TestResourceUtils.*;
@@ -33,13 +32,11 @@
3332
*/
3433
public class TopLevelAopTagTests {
3534

36-
private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml");
37-
3835
@Test
39-
public void testParse() throws Exception {
36+
public void testParse() {
4037
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
41-
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
42-
reader.loadBeanDefinitions(CONTEXT);
38+
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
39+
qualifiedResource(TopLevelAopTagTests.class, "context.xml"));
4340

4441
assertTrue(beanFactory.containsBeanDefinition("testPointcut"));
4542
}

spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -36,6 +36,7 @@ public class PrototypeTargetTests {
3636

3737
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml");
3838

39+
3940
@Test
4041
public void testPrototypeProxyWithPrototypeTarget() {
4142
TestBeanImpl.constructionCount = 0;
@@ -64,12 +65,15 @@ public void testSingletonProxyWithPrototypeTarget() {
6465
assertEquals(10, interceptor.invocationCount);
6566
}
6667

67-
public static interface TestBean {
68-
public void doSomething();
68+
69+
public interface TestBean {
70+
71+
void doSomething();
6972
}
7073

7174

7275
public static class TestBeanImpl implements TestBean {
76+
7377
private static int constructionCount = 0;
7478

7579
public TestBeanImpl() {
@@ -83,6 +87,7 @@ public void doSomething() {
8387

8488

8589
public static class TestInterceptor implements MethodInterceptor {
90+
8691
private int invocationCount = 0;
8792

8893
@Override

spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -21,7 +21,6 @@
2121

2222
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2323
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
24-
import org.springframework.core.io.Resource;
2524
import org.springframework.tests.sample.beans.ITestBean;
2625
import org.springframework.tests.sample.beans.TestBean;
2726

@@ -36,13 +35,11 @@
3635
*/
3736
public class ExposeInvocationInterceptorTests {
3837

39-
private static final Resource CONTEXT =
40-
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml");
41-
4238
@Test
4339
public void testXmlConfig() {
4440
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
45-
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
41+
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
42+
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
4643
ITestBean tb = (ITestBean) bf.getBean("proxy");
4744
String name = "tony";
4845
tb.setName(name);
@@ -74,6 +71,7 @@ public void absquatulate() {
7471

7572

7673
class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
74+
7775
@Override
7876
protected void assertions(MethodInvocation invocation) {
7977
assertTrue(invocation.getThis() == this);

spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java

+7-10
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-2019 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.
@@ -22,7 +22,6 @@
2222

2323
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2424
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
25-
import org.springframework.core.io.Resource;
2625

2726
import static org.junit.Assert.*;
2827
import static org.springframework.tests.TestResourceUtils.*;
@@ -34,16 +33,12 @@
3433
*/
3534
public class ScopedProxyAutowireTests {
3635

37-
private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT =
38-
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml");
39-
private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT =
40-
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml");
41-
42-
4336
@Test
4437
public void testScopedProxyInheritsAutowireCandidateFalse() {
4538
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
46-
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_FALSE_CONTEXT);
39+
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
40+
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
41+
4742
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
4843
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
4944
assertFalse(bf.containsSingleton("scoped"));
@@ -55,7 +50,9 @@ public void testScopedProxyInheritsAutowireCandidateFalse() {
5550
@Test
5651
public void testScopedProxyReplacesAutowireCandidateTrue() {
5752
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
58-
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_TRUE_CONTEXT);
53+
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
54+
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml"));
55+
5956
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
6057
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
6158
assertFalse(bf.containsSingleton("scoped"));

spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -39,7 +39,8 @@
3939
public class RegexpMethodPointcutAdvisorIntegrationTests {
4040

4141
private static final Resource CONTEXT =
42-
qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml");
42+
qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml");
43+
4344

4445
@Test
4546
public void testSinglePattern() throws Throwable {

spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java

+13-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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.
@@ -25,7 +25,6 @@
2525
import org.springframework.aop.support.DefaultPointcutAdvisor;
2626
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2727
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
28-
import org.springframework.core.io.Resource;
2928
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
3029
import org.springframework.tests.sample.beans.Person;
3130
import org.springframework.tests.sample.beans.SerializablePerson;
@@ -41,31 +40,31 @@
4140
*/
4241
public class HotSwappableTargetSourceTests {
4342

44-
private static final Resource CONTEXT = qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml");
45-
4643
/** Initial count value set in bean factory XML */
4744
private static final int INITIAL_COUNT = 10;
4845

4946
private DefaultListableBeanFactory beanFactory;
5047

48+
5149
@Before
52-
public void setUp() throws Exception {
50+
public void setup() {
5351
this.beanFactory = new DefaultListableBeanFactory();
54-
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
52+
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
53+
qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"));
5554
}
5655

5756
/**
5857
* We must simulate container shutdown, which should clear threads.
5958
*/
6059
@After
61-
public void tearDown() {
60+
public void close() {
6261
// Will call pool.close()
6362
this.beanFactory.destroySingletons();
6463
}
6564

65+
6666
/**
6767
* Check it works like a normal invoker
68-
*
6968
*/
7069
@Test
7170
public void testBasicFunctionality() {
@@ -106,18 +105,13 @@ public void testValidSwaps() {
106105
assertEquals(target1.getCount(), proxied.getCount());
107106
}
108107

109-
110-
/**
111-
*
112-
* @param invalid
113-
* @return the message
114-
*/
115-
private IllegalArgumentException testRejectsSwapToInvalidValue(Object invalid) {
108+
@Test
109+
public void testRejectsSwapToNull() {
116110
HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
117111
IllegalArgumentException aopex = null;
118112
try {
119-
swapper.swap(invalid);
120-
fail("Shouldn't be able to swap to invalid value [" + invalid + "]");
113+
swapper.swap(null);
114+
fail("Shouldn't be able to swap to invalid value");
121115
}
122116
catch (IllegalArgumentException ex) {
123117
// Ok
@@ -126,19 +120,9 @@ private IllegalArgumentException testRejectsSwapToInvalidValue(Object invalid) {
126120

127121
// It shouldn't be corrupted, it should still work
128122
testBasicFunctionality();
129-
return aopex;
123+
assertTrue(aopex.getMessage().contains("null"));
130124
}
131125

132-
@Test
133-
public void testRejectsSwapToNull() {
134-
IllegalArgumentException ex = testRejectsSwapToInvalidValue(null);
135-
assertTrue(ex.getMessage().contains("null"));
136-
}
137-
138-
// TODO test reject swap to wrong interface or class?
139-
// how to decide what's valid?
140-
141-
142126
@Test
143127
public void testSerialization() throws Exception {
144128
SerializablePerson sp1 = new SerializablePerson();
@@ -165,4 +149,5 @@ public void testSerialization() throws Exception {
165149
assertEquals(sp1.getName(), p.getName());
166150

167151
}
152+
168153
}

spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2019 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,11 +19,8 @@
1919
import org.junit.Before;
2020
import org.junit.Test;
2121

22-
import org.springframework.beans.factory.BeanFactory;
23-
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
2422
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2523
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
26-
import org.springframework.core.io.Resource;
2724
import org.springframework.tests.sample.beans.SideEffectBean;
2825

2926
import static org.junit.Assert.*;
@@ -35,19 +32,20 @@
3532
*/
3633
public class PrototypeTargetSourceTests {
3734

38-
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetSourceTests.class, "context.xml");
39-
4035
/** Initial count value set in bean factory XML */
4136
private static final int INITIAL_COUNT = 10;
4237

43-
private BeanFactory beanFactory;
38+
private DefaultListableBeanFactory beanFactory;
39+
4440

4541
@Before
46-
public void setUp() throws Exception {
42+
public void setup() {
4743
this.beanFactory = new DefaultListableBeanFactory();
48-
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
44+
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
45+
qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"));
4946
}
5047

48+
5149
/**
5250
* Test that multiple invocations of the prototype bean will result
5351
* in no change to visible state, as a new instance is used.
@@ -66,5 +64,4 @@ public void testPrototypeAndSingletonBehaveDifferently() {
6664
assertEquals(INITIAL_COUNT, prototype.getCount());
6765
}
6866

69-
7067
}

0 commit comments

Comments
 (0)