Skip to content

Commit 9dea9d5

Browse files
committed
Polishing
1 parent c85127d commit 9dea9d5

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

spring-context/src/test/java/org/springframework/aop/framework/ClassWithComplexConstructor.java

Lines changed: 3 additions & 2 deletions
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-2015 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.
@@ -35,10 +35,11 @@ public ClassWithComplexConstructor(Dependency dependency) {
3535
}
3636

3737
public Dependency getDependency() {
38-
return dependency;
38+
return this.dependency;
3939
}
4040

4141
public void method() {
4242
this.dependency.method();
4343
}
44+
4445
}

spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java

Lines changed: 2 additions & 3 deletions
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-2015 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.
@@ -34,8 +34,6 @@ public class ObjenesisProxyTests {
3434

3535
@Test
3636
public void appliesAspectToClassWithComplexConstructor() {
37-
38-
@SuppressWarnings("resource")
3937
ApplicationContext context = new ClassPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClass());
4038

4139
ClassWithComplexConstructor bean = context.getBean(ClassWithComplexConstructor.class);
@@ -45,4 +43,5 @@ public void appliesAspectToClassWithComplexConstructor() {
4543
assertThat(interceptor.getCount(), is(1L));
4644
assertThat(bean.getDependency().getValue(), is(1));
4745
}
46+
4847
}

spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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,9 +20,10 @@
2020
import java.lang.reflect.Proxy;
2121
import java.util.Map;
2222

23-
import junit.framework.TestCase;
2423
import org.aopalliance.intercept.MethodInterceptor;
2524
import org.aopalliance.intercept.MethodInvocation;
25+
import org.junit.Before;
26+
import org.junit.Test;
2627

2728
import org.springframework.aop.support.AopUtils;
2829
import org.springframework.aop.support.StaticMethodMatcherPointcut;
@@ -40,51 +41,61 @@
4041
import org.springframework.transaction.TransactionException;
4142
import org.springframework.transaction.TransactionStatus;
4243

44+
import static org.junit.Assert.*;
4345
import static org.mockito.BDDMockito.*;
4446

47+
4548
/**
4649
* Test cases for AOP transaction management.
4750
*
4851
* @author Rod Johnson
52+
* @author Juergen Hoeller
4953
* @since 23.04.2003
5054
*/
51-
public class BeanFactoryTransactionTests extends TestCase {
55+
public class BeanFactoryTransactionTests {
5256

5357
private DefaultListableBeanFactory factory;
5458

55-
@Override
59+
60+
@Before
5661
public void setUp() {
5762
this.factory = new DefaultListableBeanFactory();
5863
new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions(
5964
new ClassPathResource("transactionalBeanFactory.xml", getClass()));
6065
}
6166

67+
68+
@Test
6269
public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException {
6370
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1");
6471
assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
6572
doTestGetsAreNotTransactional(testBean);
6673
}
6774

75+
@Test
6876
public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() throws NoSuchMethodException {
6977
this.factory.preInstantiateSingletons();
7078
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy");
7179
assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
7280
doTestGetsAreNotTransactional(testBean);
7381
}
7482

83+
@Test
7584
public void testGetsAreNotTransactionalWithProxyFactory2Cglib() throws NoSuchMethodException {
7685
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib");
7786
assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(testBean));
7887
doTestGetsAreNotTransactional(testBean);
7988
}
8089

90+
@Test
8191
public void testProxyFactory2Lazy() throws NoSuchMethodException {
8292
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy");
8393
assertFalse(factory.containsSingleton("target"));
8494
assertEquals(666, testBean.getAge());
8595
assertTrue(factory.containsSingleton("target"));
8696
}
8797

98+
@Test
8899
public void testCglibTransactionProxyImplementsNoInterfaces() throws NoSuchMethodException {
89100
ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces");
90101
assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(ini));
@@ -99,6 +110,7 @@ public void testCglibTransactionProxyImplementsNoInterfaces() throws NoSuchMetho
99110
assertEquals(2, ptm.commits);
100111
}
101112

113+
@Test
102114
public void testGetsAreNotTransactionalWithProxyFactory3() throws NoSuchMethodException {
103115
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3");
104116
assertTrue("testBean is a full proxy", testBean instanceof DerivedTestBean);
@@ -158,6 +170,7 @@ public void rollback(TransactionStatus status) throws TransactionException {
158170
assertTrue(testBean.getAge() == age);
159171
}
160172

173+
@Test
161174
public void testGetBeansOfTypeWithAbstract() {
162175
Map<String, ITestBean> beansOfType = factory.getBeansOfType(ITestBean.class, true, true);
163176
assertNotNull(beansOfType);
@@ -166,6 +179,7 @@ public void testGetBeansOfTypeWithAbstract() {
166179
/**
167180
* Check that we fail gracefully if the user doesn't set any transaction attributes.
168181
*/
182+
@Test
169183
public void testNoTransactionAttributeSource() {
170184
try {
171185
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
@@ -181,6 +195,7 @@ public void testNoTransactionAttributeSource() {
181195
/**
182196
* Test that we can set the target to a dynamic TargetSource.
183197
*/
198+
@Test
184199
public void testDynamicTargetSource() throws NoSuchMethodException {
185200
// Install facade
186201
CallCountingTransactionManager txMan = new CallCountingTransactionManager();

0 commit comments

Comments
 (0)