Polishing
This commit is contained in:
parent
fd4b5ac892
commit
a4743c07d4
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +37,7 @@ import static org.junit.Assert.*;
|
|||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ArgumentBindingTests {
|
||||
public class ArgumentBindingTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testBindingInPointcutUsedByAdvice() {
|
||||
|
@ -45,8 +45,8 @@ public final class ArgumentBindingTests {
|
|||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||
proxyFactory.addAspect(NamedPointcutWithArgs.class);
|
||||
|
||||
ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy();
|
||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
||||
ITestBean proxiedTestBean = proxyFactory.getProxy();
|
||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
|
@ -55,8 +55,8 @@ public final class ArgumentBindingTests {
|
|||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||
proxyFactory.addAspect(PointcutWithAnnotationArgument.class);
|
||||
|
||||
ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy();
|
||||
proxiedTestBean.doInTransaction(); // should throw
|
||||
ITransactionalBean proxiedTestBean = proxyFactory.getProxy();
|
||||
proxiedTestBean.doInTransaction();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -71,6 +71,7 @@ public final class ArgumentBindingTests {
|
|||
assertEquals("formal", pnames[0]);
|
||||
}
|
||||
|
||||
|
||||
public void methodWithOneParam(String aParam) {
|
||||
}
|
||||
|
||||
|
@ -100,9 +101,6 @@ public final class ArgumentBindingTests {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Aspect
|
||||
class PointcutWithAnnotationArgument {
|
||||
|
||||
|
@ -115,9 +113,6 @@ class PointcutWithAnnotationArgument {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrian Colyer
|
||||
*/
|
||||
@Aspect
|
||||
class NamedPointcutWithArgs {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
|
|||
* @param methodNames an array of method names indicating the methods to use
|
||||
* @see #setMethodMappings
|
||||
*/
|
||||
public void setManagedMethods(String[] methodNames) {
|
||||
public void setManagedMethods(String... methodNames) {
|
||||
this.managedMethods = new HashSet<>(Arrays.asList(methodNames));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,18 +27,19 @@ import static org.junit.Assert.*;
|
|||
* @author Adrian Colyer
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class AnnotationBindingTests {
|
||||
public class AnnotationBindingTests {
|
||||
|
||||
private AnnotatedTestBean testBean;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ClassPathXmlApplicationContext ctx =
|
||||
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
|
||||
|
||||
testBean = (AnnotatedTestBean) ctx.getBean("testBean");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAnnotationBindingInAroundAdvice() {
|
||||
assertEquals("this value", testBean.doThis());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -182,19 +182,19 @@ public class LocalStatelessSessionProxyFactoryBeanTests {
|
|||
}
|
||||
|
||||
|
||||
public static interface MyHome extends EJBLocalHome {
|
||||
public interface MyHome extends EJBLocalHome {
|
||||
|
||||
MyBusinessMethods create() throws CreateException;
|
||||
}
|
||||
|
||||
|
||||
public static interface MyBusinessMethods {
|
||||
public interface MyBusinessMethods {
|
||||
|
||||
int getValue();
|
||||
}
|
||||
|
||||
|
||||
public static interface MyEjb extends EJBLocalObject, MyBusinessMethods {
|
||||
public interface MyEjb extends EJBLocalObject, MyBusinessMethods {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -279,26 +279,25 @@ public class SimpleRemoteStatelessSessionProxyFactoryBeanTests extends SimpleRem
|
|||
}
|
||||
|
||||
|
||||
protected static interface MyHome extends EJBHome {
|
||||
protected interface MyHome extends EJBHome {
|
||||
|
||||
MyBusinessMethods create() throws CreateException, RemoteException;
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyBusinessMethods {
|
||||
protected interface MyBusinessMethods {
|
||||
|
||||
int getValue() throws RemoteException;
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyLocalBusinessMethods {
|
||||
protected interface MyLocalBusinessMethods {
|
||||
|
||||
int getValue();
|
||||
}
|
||||
|
||||
|
||||
protected static interface MyEjb extends EJBObject, MyBusinessMethods {
|
||||
|
||||
protected interface MyEjb extends EJBObject, MyBusinessMethods {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
|
|||
public void testWithFallThrough() throws Exception {
|
||||
MethodNameBasedMBeanInfoAssembler assembler =
|
||||
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
|
||||
assembler.setManagedMethods(new String[]{"getNickName", "setNickName"});
|
||||
assembler.setManagedMethods("getNickName", "setNickName");
|
||||
|
||||
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
|
|||
@Override
|
||||
protected MBeanInfoAssembler getAssembler() {
|
||||
MethodNameBasedMBeanInfoAssembler assembler = new MethodNameBasedMBeanInfoAssembler();
|
||||
assembler.setManagedMethods(new String[] {"add", "myOperation", "getName", "setName", "getAge"});
|
||||
assembler.setManagedMethods("add", "myOperation", "getName", "setName", "getAge");
|
||||
return assembler;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.springframework.aop.support.AopUtils;
|
|||
import org.springframework.aop.target.dynamic.Refreshable;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
@ -268,7 +267,7 @@ public class GroovyScriptFactoryTests {
|
|||
@Test
|
||||
public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
|
||||
ScriptSource script = mock(ScriptSource.class);
|
||||
final String badScript = "class Foo { public Foo(String foo) {}}";
|
||||
String badScript = "class Foo { public Foo(String foo) {}}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
given(script.suggestedClassName()).willReturn("someName");
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
|
||||
|
@ -278,25 +277,18 @@ public class GroovyScriptFactoryTests {
|
|||
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
|
||||
}
|
||||
catch (ScriptCompilationException expected) {
|
||||
assertTrue(expected.contains(InstantiationException.class));
|
||||
assertTrue(expected.contains(NoSuchMethodException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
|
||||
ScriptSource script = mock(ScriptSource.class);
|
||||
final String badScript = "class Foo { protected Foo() {}}";
|
||||
String badScript = "class Foo { protected Foo() {} \n String toString() { 'X' }}";
|
||||
given(script.getScriptAsString()).willReturn(badScript);
|
||||
given(script.suggestedClassName()).willReturn("someName");
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
|
||||
+ badScript);
|
||||
try {
|
||||
factory.getScriptedObject(script);
|
||||
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
|
||||
}
|
||||
catch (ScriptCompilationException expected) {
|
||||
assertTrue(expected.contains(IllegalAccessException.class));
|
||||
}
|
||||
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript);
|
||||
assertEquals("X", factory.getScriptedObject(script).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -553,7 +545,7 @@ public class GroovyScriptFactoryTests {
|
|||
testMetaClass("org/springframework/scripting/groovy/calculators-with-xsd.xml");
|
||||
}
|
||||
|
||||
private void testMetaClass(final String xmlFile) {
|
||||
private void testMetaClass(String xmlFile) {
|
||||
// expect the exception we threw in the custom metaclass to show it got invoked
|
||||
try {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(xmlFile);
|
||||
|
|
|
@ -350,7 +350,8 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
|||
}
|
||||
|
||||
private void assertAttributePresence(String attributeName, Object attributeValue) {
|
||||
Assert.notNull(attributeValue, () -> String.format("Attribute '%s' not found in attributes for annotation [%s]",
|
||||
Assert.notNull(attributeValue, () -> String.format(
|
||||
"Attribute '%s' not found in attributes for annotation [%s]",
|
||||
attributeName, this.displayName));
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class SerializableTypeWrapperTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void forTypeParamters() throws Exception {
|
||||
public void forTypeParameters() throws Exception {
|
||||
Type type = SerializableTypeWrapper.forTypeParameters(List.class)[0];
|
||||
assertThat(type.toString(), equalTo("E"));
|
||||
assertSerializable(type);
|
||||
|
|
|
@ -107,7 +107,7 @@ import org.springframework.util.StringUtils;
|
|||
* </pre>
|
||||
*
|
||||
* <p>Note that the above examples aim to demonstrate the general idea of using
|
||||
* header accessors. The most likely usage however is through sub-classes.
|
||||
* header accessors. The most likely usage however is through subclasses.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<!-- File containing all charcter entity references definied
|
||||
<!-- File containing all character entity references defined
|
||||
by the HTML 4.0 standard. -->
|
||||
<!-- Valuable informations and a complete description of the
|
||||
<!-- Valuable information and a complete description of the
|
||||
HTML 4.0 character set can be found at
|
||||
http://www.w3.org/TR/html4/charset.html.
|
||||
-->
|
||||
|
||||
http://www.w3.org/TR/html4/charset.html. -->
|
||||
|
||||
<!-- Portions © International Organization for Standardization 1986
|
||||
Permission to copy in any form is granted for use with
|
||||
|
|
Loading…
Reference in New Issue