Skip to content

Commit a4743c0

Browse files
committed
Polishing
1 parent fd4b5ac commit a4743c0

File tree

14 files changed

+42
-56
lines changed

14 files changed

+42
-56
lines changed

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java

Lines changed: 7 additions & 12 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-2016 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.
@@ -37,16 +37,16 @@
3737
* @author Juergen Hoeller
3838
* @author Chris Beams
3939
*/
40-
public final class ArgumentBindingTests {
40+
public class ArgumentBindingTests {
4141

4242
@Test(expected=IllegalArgumentException.class)
4343
public void testBindingInPointcutUsedByAdvice() {
4444
TestBean tb = new TestBean();
4545
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
4646
proxyFactory.addAspect(NamedPointcutWithArgs.class);
4747

48-
ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy();
49-
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
48+
ITestBean proxiedTestBean = proxyFactory.getProxy();
49+
proxiedTestBean.setName("Supercalifragalisticexpialidocious");
5050
}
5151

5252
@Test(expected=IllegalStateException.class)
@@ -55,8 +55,8 @@ public void testAnnotationArgumentNameBinding() {
5555
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
5656
proxyFactory.addAspect(PointcutWithAnnotationArgument.class);
5757

58-
ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy();
59-
proxiedTestBean.doInTransaction(); // should throw
58+
ITransactionalBean proxiedTestBean = proxyFactory.getProxy();
59+
proxiedTestBean.doInTransaction();
6060
}
6161

6262
@Test
@@ -71,6 +71,7 @@ public void testParameterNameDiscoverWithReferencePointcut() throws Exception {
7171
assertEquals("formal", pnames[0]);
7272
}
7373

74+
7475
public void methodWithOneParam(String aParam) {
7576
}
7677

@@ -100,9 +101,6 @@ public void doInTransaction() {
100101
}
101102

102103

103-
/**
104-
* @author Juergen Hoeller
105-
*/
106104
@Aspect
107105
class PointcutWithAnnotationArgument {
108106

@@ -115,9 +113,6 @@ public Object around(ProceedingJoinPoint pjp, Transactional transaction) throws
115113
}
116114

117115

118-
/**
119-
* @author Adrian Colyer
120-
*/
121116
@Aspect
122117
class NamedPointcutWithArgs {
123118

spring-beans/src/test/resources/org/springframework/beans/factory/xml/import.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
2+
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
33

44
<beans>
55

spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
7272
* @param methodNames an array of method names indicating the methods to use
7373
* @see #setMethodMappings
7474
*/
75-
public void setManagedMethods(String[] methodNames) {
75+
public void setManagedMethods(String... methodNames) {
7676
this.managedMethods = new HashSet<>(Arrays.asList(methodNames));
7777
}
7878

spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java

Lines changed: 5 additions & 4 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-2016 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.
@@ -27,18 +27,19 @@
2727
* @author Adrian Colyer
2828
* @author Chris Beams
2929
*/
30-
public final class AnnotationBindingTests {
30+
public class AnnotationBindingTests {
3131

3232
private AnnotatedTestBean testBean;
3333

34+
3435
@Before
3536
public void setUp() {
3637
ClassPathXmlApplicationContext ctx =
37-
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
38-
38+
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
3939
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
4040
}
4141

42+
4243
@Test
4344
public void testAnnotationBindingInAroundAdvice() {
4445
assertEquals("this value", testBean.doThis());

spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java

Lines changed: 4 additions & 4 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-2016 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.
@@ -182,19 +182,19 @@ public Object lookup(String name) throws NamingException {
182182
}
183183

184184

185-
public static interface MyHome extends EJBLocalHome {
185+
public interface MyHome extends EJBLocalHome {
186186

187187
MyBusinessMethods create() throws CreateException;
188188
}
189189

190190

191-
public static interface MyBusinessMethods {
191+
public interface MyBusinessMethods {
192192

193193
int getValue();
194194
}
195195

196196

197-
public static interface MyEjb extends EJBLocalObject, MyBusinessMethods {
197+
public interface MyEjb extends EJBLocalObject, MyBusinessMethods {
198198
}
199199

200200
}

spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java

Lines changed: 5 additions & 6 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-2016 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.
@@ -279,26 +279,25 @@ public Object lookup(String name) throws NamingException {
279279
}
280280

281281

282-
protected static interface MyHome extends EJBHome {
282+
protected interface MyHome extends EJBHome {
283283

284284
MyBusinessMethods create() throws CreateException, RemoteException;
285285
}
286286

287287

288-
protected static interface MyBusinessMethods {
288+
protected interface MyBusinessMethods {
289289

290290
int getValue() throws RemoteException;
291291
}
292292

293293

294-
protected static interface MyLocalBusinessMethods {
294+
protected interface MyLocalBusinessMethods {
295295

296296
int getValue();
297297
}
298298

299299

300-
protected static interface MyEjb extends EJBObject, MyBusinessMethods {
301-
300+
protected interface MyEjb extends EJBObject, MyBusinessMethods {
302301
}
303302

304303
}

spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testGetAgeIsReadOnly() throws Exception {
4747
public void testWithFallThrough() throws Exception {
4848
MethodNameBasedMBeanInfoAssembler assembler =
4949
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
50-
assembler.setManagedMethods(new String[]{"getNickName", "setNickName"});
50+
assembler.setManagedMethods("getNickName", "setNickName");
5151

5252
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
5353
MBeanAttributeInfo attr = inf.getAttribute("NickName");

spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected int getExpectedAttributeCount() {
5252
@Override
5353
protected MBeanInfoAssembler getAssembler() {
5454
MethodNameBasedMBeanInfoAssembler assembler = new MethodNameBasedMBeanInfoAssembler();
55-
assembler.setManagedMethods(new String[] {"add", "myOperation", "getName", "setName", "getAge"});
55+
assembler.setManagedMethods("add", "myOperation", "getName", "setName", "getAge");
5656
return assembler;
5757
}
5858

spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.springframework.aop.target.dynamic.Refreshable;
2929
import org.springframework.beans.factory.BeanCreationException;
3030
import org.springframework.beans.factory.FactoryBean;
31-
import org.springframework.beans.factory.UnsatisfiedDependencyException;
3231
import org.springframework.beans.factory.config.BeanDefinition;
3332
import org.springframework.context.ApplicationContext;
3433
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -268,7 +267,7 @@ public void testScriptCompilationException() throws Exception {
268267
@Test
269268
public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
270269
ScriptSource script = mock(ScriptSource.class);
271-
final String badScript = "class Foo { public Foo(String foo) {}}";
270+
String badScript = "class Foo { public Foo(String foo) {}}";
272271
given(script.getScriptAsString()).willReturn(badScript);
273272
given(script.suggestedClassName()).willReturn("someName");
274273
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
@@ -278,25 +277,18 @@ public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
278277
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
279278
}
280279
catch (ScriptCompilationException expected) {
281-
assertTrue(expected.contains(InstantiationException.class));
280+
assertTrue(expected.contains(NoSuchMethodException.class));
282281
}
283282
}
284283

285284
@Test
286285
public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
287286
ScriptSource script = mock(ScriptSource.class);
288-
final String badScript = "class Foo { protected Foo() {}}";
287+
String badScript = "class Foo { protected Foo() {} \n String toString() { 'X' }}";
289288
given(script.getScriptAsString()).willReturn(badScript);
290289
given(script.suggestedClassName()).willReturn("someName");
291-
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
292-
+ badScript);
293-
try {
294-
factory.getScriptedObject(script);
295-
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
296-
}
297-
catch (ScriptCompilationException expected) {
298-
assertTrue(expected.contains(IllegalAccessException.class));
299-
}
290+
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript);
291+
assertEquals("X", factory.getScriptedObject(script).toString());
300292
}
301293

302294
@Test
@@ -553,7 +545,7 @@ public void testMetaClassWithXsd() {
553545
testMetaClass("org/springframework/scripting/groovy/calculators-with-xsd.xml");
554546
}
555547

556-
private void testMetaClass(final String xmlFile) {
548+
private void testMetaClass(String xmlFile) {
557549
// expect the exception we threw in the custom metaclass to show it got invoked
558550
try {
559551
ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile);

spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ private <T> T getRequiredAttribute(String attributeName, Class<T> expectedType)
350350
}
351351

352352
private void assertAttributePresence(String attributeName, Object attributeValue) {
353-
Assert.notNull(attributeValue, () -> String.format("Attribute '%s' not found in attributes for annotation [%s]",
353+
Assert.notNull(attributeValue, () -> String.format(
354+
"Attribute '%s' not found in attributes for annotation [%s]",
354355
attributeName, this.displayName));
355356
}
356357

0 commit comments

Comments
 (0)