Consistent Class array vs vararg declarations (and related polishing)
This commit is contained in:
parent
46cbdff5c3
commit
3b810f3544
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -47,7 +47,7 @@ public class ConcurrencyThrottleInterceptorTests {
|
|||
public void testSerializable() throws Exception {
|
||||
DerivedTestBean tb = new DerivedTestBean();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setInterfaces(new Class[] {ITestBean.class});
|
||||
proxyFactory.setInterfaces(ITestBean.class);
|
||||
ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
|
||||
proxyFactory.addAdvice(cti);
|
||||
proxyFactory.setTarget(tb);
|
||||
|
|
@ -75,7 +75,7 @@ public class ConcurrencyThrottleInterceptorTests {
|
|||
private void testMultipleThreads(int concurrencyLimit) {
|
||||
TestBean tb = new TestBean();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setInterfaces(new Class[] {ITestBean.class});
|
||||
proxyFactory.setInterfaces(ITestBean.class);
|
||||
ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
|
||||
cti.setConcurrencyLimit(concurrencyLimit);
|
||||
proxyFactory.addAdvice(cti);
|
||||
|
|
@ -95,7 +95,7 @@ public class ConcurrencyThrottleInterceptorTests {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
threads[i] = new ConcurrencyThread(proxy,
|
||||
i % 2 == 0 ? (Throwable) new OutOfMemoryError() : (Throwable) new IllegalStateException());
|
||||
i % 2 == 0 ? new OutOfMemoryError() : new IllegalStateException());
|
||||
threads[i].start();
|
||||
}
|
||||
for (int i = 0; i < NR_OF_THREADS; i++) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -83,7 +83,7 @@ public class CustomizableTraceInterceptorTests {
|
|||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
|
||||
Log log = mock(Log.class);
|
||||
|
|
@ -101,7 +101,7 @@ public class CustomizableTraceInterceptorTests {
|
|||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
given(methodInvocation.proceed()).willThrow(exception);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -34,7 +34,7 @@ public class SimpleTraceInterceptorTests {
|
|||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
|
||||
Log log = mock(Log.class);
|
||||
|
|
@ -48,7 +48,7 @@ public class SimpleTraceInterceptorTests {
|
|||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
given(mi.proceed()).willThrow(exception);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -226,14 +226,14 @@ public class BeanUtilsTests {
|
|||
|
||||
@Test
|
||||
public void testResolveWithAndWithoutArgList() throws Exception {
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingElse", new Class[]{String.class, int.class});
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingElse", String.class, int.class);
|
||||
assertSignatureEquals(desiredMethod, "doSomethingElse");
|
||||
assertNull(BeanUtils.resolveSignature("doSomethingElse()", MethodSignatureBean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveTypedSignature() throws Exception {
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingElse", new Class[]{String.class, int.class});
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingElse", String.class, int.class);
|
||||
assertSignatureEquals(desiredMethod, "doSomethingElse(java.lang.String, int)");
|
||||
}
|
||||
|
||||
|
|
@ -244,20 +244,20 @@ public class BeanUtilsTests {
|
|||
assertSignatureEquals(desiredMethod, "overloaded()");
|
||||
|
||||
// resolve with single arg
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("overloaded", new Class[]{String.class});
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("overloaded", String.class);
|
||||
assertSignatureEquals(desiredMethod, "overloaded(java.lang.String)");
|
||||
|
||||
// resolve with two args
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("overloaded", new Class[]{String.class, BeanFactory.class});
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("overloaded", String.class, BeanFactory.class);
|
||||
assertSignatureEquals(desiredMethod, "overloaded(java.lang.String, org.springframework.beans.factory.BeanFactory)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveSignatureWithArray() throws Exception {
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingWithAnArray", new Class[]{String[].class});
|
||||
Method desiredMethod = MethodSignatureBean.class.getMethod("doSomethingWithAnArray", String[].class);
|
||||
assertSignatureEquals(desiredMethod, "doSomethingWithAnArray(java.lang.String[])");
|
||||
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("doSomethingWithAMultiDimensionalArray", new Class[]{String[][].class});
|
||||
desiredMethod = MethodSignatureBean.class.getMethod("doSomethingWithAMultiDimensionalArray", String[][].class);
|
||||
assertSignatureEquals(desiredMethod, "doSomethingWithAMultiDimensionalArray(java.lang.String[][])");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -34,60 +34,54 @@ public class AutowireUtilsTests {
|
|||
|
||||
@Test
|
||||
public void genericMethodReturnTypes() {
|
||||
Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized", new Class[]{});
|
||||
Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized");
|
||||
assertEquals(String.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[]{}, getClass().getClassLoader()));
|
||||
|
||||
Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments",
|
||||
new Class[] { Integer.class, Boolean.class });
|
||||
Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments", Integer.class, Boolean.class);
|
||||
assertEquals(String.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterizedWithArguments, new Object[] { 99, true }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterizedWithArguments, new Object[] {99, true}, getClass().getClassLoader()));
|
||||
|
||||
Method createProxy = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createProxy", new Class[] { Object.class });
|
||||
Method createProxy = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createProxy", Object.class);
|
||||
assertEquals(String.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createProxy, new Object[] { "foo" }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createProxy, new Object[] {"foo"}, getClass().getClassLoader()));
|
||||
|
||||
Method createNamedProxyWithDifferentTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy",
|
||||
new Class[] { String.class, Object.class });
|
||||
Method createNamedProxyWithDifferentTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", String.class, Object.class);
|
||||
assertEquals(Long.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDifferentTypes, new Object[] { "enigma", 99L }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDifferentTypes, new Object[] {"enigma", 99L}, getClass().getClassLoader()));
|
||||
|
||||
Method createNamedProxyWithDuplicateTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy",
|
||||
new Class[] { String.class, Object.class });
|
||||
Method createNamedProxyWithDuplicateTypes = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedProxy", String.class, Object.class);
|
||||
assertEquals(String.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDuplicateTypes, new Object[] { "enigma", "foo" }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedProxyWithDuplicateTypes, new Object[] {"enigma", "foo"}, getClass().getClassLoader()));
|
||||
|
||||
Method createMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createMock", new Class[] { Class.class });
|
||||
Method createMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createMock", Class.class);
|
||||
assertEquals(Runnable.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] { Runnable.class }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] {Runnable.class}, getClass().getClassLoader()));
|
||||
assertEquals(Runnable.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] { Runnable.class.getName() }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createMock, new Object[] {Runnable.class.getName()}, getClass().getClassLoader()));
|
||||
|
||||
Method createNamedMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedMock", new Class[] { String.class,
|
||||
Class.class });
|
||||
Method createNamedMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createNamedMock", String.class, Class.class);
|
||||
assertEquals(Runnable.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedMock, new Object[] { "foo", Runnable.class }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createNamedMock, new Object[] {"foo", Runnable.class}, getClass().getClassLoader()));
|
||||
|
||||
Method createVMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createVMock",
|
||||
new Class[] { Object.class, Class.class });
|
||||
Method createVMock = ReflectionUtils.findMethod(MyTypeWithMethods.class, "createVMock", Object.class, Class.class);
|
||||
assertEquals(Runnable.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createVMock, new Object[] { "foo", Runnable.class }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(createVMock, new Object[] {"foo", Runnable.class}, getClass().getClassLoader()));
|
||||
|
||||
// Ideally we would expect String.class instead of Object.class, but
|
||||
// resolveReturnTypeForFactoryMethod() does not currently support this form of
|
||||
// look-up.
|
||||
Method extractValueFrom = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractValueFrom",
|
||||
new Class[] { MyInterfaceType.class });
|
||||
Method extractValueFrom = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractValueFrom", MyInterfaceType.class);
|
||||
assertEquals(Object.class,
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(extractValueFrom, new Object[] { new MySimpleInterfaceType() }, getClass().getClassLoader()));
|
||||
AutowireUtils.resolveReturnTypeForFactoryMethod(extractValueFrom, new Object[] {new MySimpleInterfaceType()}, getClass().getClassLoader()));
|
||||
|
||||
// Ideally we would expect Boolean.class instead of Object.class, but this
|
||||
// information is not available at run-time due to type erasure.
|
||||
Map<Integer, Boolean> map = new HashMap<>();
|
||||
map.put(0, false);
|
||||
map.put(1, true);
|
||||
Method extractMagicValue = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractMagicValue", new Class[] { Map.class });
|
||||
assertEquals(Object.class, AutowireUtils.resolveReturnTypeForFactoryMethod(extractMagicValue, new Object[] { map }, getClass().getClassLoader()));
|
||||
Method extractMagicValue = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractMagicValue", Map.class);
|
||||
assertEquals(Object.class, AutowireUtils.resolveReturnTypeForFactoryMethod(extractMagicValue, new Object[] {map}, getClass().getClassLoader()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -139,7 +139,7 @@ public abstract class AbstractSlsbInvokerInterceptor extends JndiObjectLocator
|
|||
protected Method getCreateMethod(Object home) throws EjbAccessException {
|
||||
try {
|
||||
// Cache the EJB create() method that must be declared on the home interface.
|
||||
return home.getClass().getMethod("create", (Class[]) null);
|
||||
return home.getClass().getMethod("create");
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new EjbAccessException("EJB home [" + home + "] has no no-arg create() method");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -34,11 +34,11 @@ import reactor.core.publisher.Mono;
|
|||
import org.springframework.tests.sample.objects.TestObject;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Conventions}.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
|
|
@ -50,13 +50,10 @@ public class ConventionsTests {
|
|||
|
||||
@Test
|
||||
public void simpleObject() {
|
||||
|
||||
assertEquals("Incorrect singular variable name",
|
||||
"testObject", Conventions.getVariableName(new TestObject()));
|
||||
|
||||
assertEquals("Incorrect singular variable name", "testObject",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(TestObject.class)));
|
||||
|
||||
assertEquals("Incorrect singular variable name", "testObject",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(TestObject.class)));
|
||||
}
|
||||
|
|
@ -69,13 +66,10 @@ public class ConventionsTests {
|
|||
|
||||
@Test
|
||||
public void list() {
|
||||
|
||||
assertEquals("Incorrect plural List form", "testObjectList",
|
||||
Conventions.getVariableName(Collections.singletonList(new TestObject())));
|
||||
|
||||
assertEquals("Incorrect plural List form", "testObjectList",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(List.class)));
|
||||
|
||||
assertEquals("Incorrect plural List form", "testObjectList",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(List.class)));
|
||||
}
|
||||
|
|
@ -88,58 +82,47 @@ public class ConventionsTests {
|
|||
|
||||
@Test
|
||||
public void set() {
|
||||
|
||||
assertEquals("Incorrect plural Set form", "testObjectList",
|
||||
Conventions.getVariableName(Collections.singleton(new TestObject())));
|
||||
|
||||
assertEquals("Incorrect plural Set form", "testObjectList",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(Set.class)));
|
||||
|
||||
assertEquals("Incorrect plural Set form", "testObjectList",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveParameters() throws Exception {
|
||||
|
||||
public void reactiveParameters() {
|
||||
assertEquals("testObjectMono",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(Mono.class)));
|
||||
|
||||
assertEquals("testObjectFlux",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(Flux.class)));
|
||||
|
||||
assertEquals("testObjectSingle",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(Single.class)));
|
||||
|
||||
assertEquals("testObjectObservable",
|
||||
Conventions.getVariableNameForParameter(getMethodParameter(Observable.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveReturnTypes() throws Exception {
|
||||
|
||||
public void reactiveReturnTypes() {
|
||||
assertEquals("testObjectMono",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(Mono.class)));
|
||||
|
||||
assertEquals("testObjectFlux",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(Flux.class)));
|
||||
|
||||
assertEquals("testObjectSingle",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(Single.class)));
|
||||
|
||||
assertEquals("testObjectObservable",
|
||||
Conventions.getVariableNameForReturnType(getMethodForReturnType(Observable.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attributeNameToPropertyName() throws Exception {
|
||||
public void attributeNameToPropertyName() {
|
||||
assertEquals("transactionManager", Conventions.attributeNameToPropertyName("transaction-manager"));
|
||||
assertEquals("pointcutRef", Conventions.attributeNameToPropertyName("pointcut-ref"));
|
||||
assertEquals("lookupOnStartup", Conventions.attributeNameToPropertyName("lookup-on-startup"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getQualifiedAttributeName() throws Exception {
|
||||
public void getQualifiedAttributeName() {
|
||||
String baseName = "foo";
|
||||
Class<String> cls = String.class;
|
||||
String desiredResult = "java.lang.String.foo";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -39,7 +39,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
|
||||
@Test
|
||||
public void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
|
||||
Method getName = TestObject.class.getMethod("getName", new Class[0]);
|
||||
Method getName = TestObject.class.getMethod("getName");
|
||||
String[] names = discoverer.getParameterNames(getName);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("no argument names", 0, names.length);
|
||||
|
|
@ -47,7 +47,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
|
||||
@Test
|
||||
public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException {
|
||||
Method setName = TestObject.class.getMethod("setName", new Class[] { String.class });
|
||||
Method setName = TestObject.class.getMethod("setName", String.class);
|
||||
String[] names = discoverer.getParameterNames(setName);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("one argument", 1, names.length);
|
||||
|
|
@ -56,7 +56,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
|
||||
@Test
|
||||
public void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
|
||||
Constructor<TestObject> noArgsCons = TestObject.class.getConstructor(new Class[0]);
|
||||
Constructor<TestObject> noArgsCons = TestObject.class.getConstructor();
|
||||
String[] names = discoverer.getParameterNames(noArgsCons);
|
||||
assertNotNull("should find cons info", names);
|
||||
assertEquals("no argument names", 0, names.length);
|
||||
|
|
@ -64,7 +64,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
|
||||
@Test
|
||||
public void consParameterNameDiscoveryArgs() throws NoSuchMethodException {
|
||||
Constructor<TestObject> twoArgCons = TestObject.class.getConstructor(new Class[] { String.class, int.class });
|
||||
Constructor<TestObject> twoArgCons = TestObject.class.getConstructor(String.class, int.class);
|
||||
String[] names = discoverer.getParameterNames(twoArgCons);
|
||||
assertNotNull("should find cons info", names);
|
||||
assertEquals("one argument", 2, names.length);
|
||||
|
|
@ -74,7 +74,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
|
||||
@Test
|
||||
public void staticMethodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
|
||||
Method m = getClass().getMethod("staticMethodNoLocalVars", new Class[0]);
|
||||
Method m = getClass().getMethod("staticMethodNoLocalVars");
|
||||
String[] names = discoverer.getParameterNames(m);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("no argument names", 0, names.length);
|
||||
|
|
@ -84,14 +84,14 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
public void overloadedStaticMethod() throws Exception {
|
||||
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
|
||||
|
||||
Method m1 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE, Long.TYPE });
|
||||
Method m1 = clazz.getMethod("staticMethod", Long.TYPE, Long.TYPE);
|
||||
String[] names = discoverer.getParameterNames(m1);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("two arguments", 2, names.length);
|
||||
assertEquals("x", names[0]);
|
||||
assertEquals("y", names[1]);
|
||||
|
||||
Method m2 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE, Long.TYPE, Long.TYPE });
|
||||
Method m2 = clazz.getMethod("staticMethod", Long.TYPE, Long.TYPE, Long.TYPE);
|
||||
names = discoverer.getParameterNames(m2);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("three arguments", 3, names.length);
|
||||
|
|
@ -104,13 +104,13 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
public void overloadedStaticMethodInInnerClass() throws Exception {
|
||||
Class<InnerClass> clazz = InnerClass.class;
|
||||
|
||||
Method m1 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE });
|
||||
Method m1 = clazz.getMethod("staticMethod", Long.TYPE);
|
||||
String[] names = discoverer.getParameterNames(m1);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("one argument", 1, names.length);
|
||||
assertEquals("x", names[0]);
|
||||
|
||||
Method m2 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE, Long.TYPE });
|
||||
Method m2 = clazz.getMethod("staticMethod", Long.TYPE, Long.TYPE);
|
||||
names = discoverer.getParameterNames(m2);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("two arguments", 2, names.length);
|
||||
|
|
@ -122,14 +122,14 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
public void overloadedMethod() throws Exception {
|
||||
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
|
||||
|
||||
Method m1 = clazz.getMethod("instanceMethod", new Class[] { Double.TYPE, Double.TYPE });
|
||||
Method m1 = clazz.getMethod("instanceMethod", Double.TYPE, Double.TYPE);
|
||||
String[] names = discoverer.getParameterNames(m1);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("two arguments", 2, names.length);
|
||||
assertEquals("x", names[0]);
|
||||
assertEquals("y", names[1]);
|
||||
|
||||
Method m2 = clazz.getMethod("instanceMethod", new Class[] { Double.TYPE, Double.TYPE, Double.TYPE });
|
||||
Method m2 = clazz.getMethod("instanceMethod", Double.TYPE, Double.TYPE, Double.TYPE);
|
||||
names = discoverer.getParameterNames(m2);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("three arguments", 3, names.length);
|
||||
|
|
@ -142,13 +142,13 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
public void overloadedMethodInInnerClass() throws Exception {
|
||||
Class<InnerClass> clazz = InnerClass.class;
|
||||
|
||||
Method m1 = clazz.getMethod("instanceMethod", new Class[] { String.class });
|
||||
Method m1 = clazz.getMethod("instanceMethod", String.class);
|
||||
String[] names = discoverer.getParameterNames(m1);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("one argument", 1, names.length);
|
||||
assertEquals("aa", names[0]);
|
||||
|
||||
Method m2 = clazz.getMethod("instanceMethod", new Class[] { String.class, String.class });
|
||||
Method m2 = clazz.getMethod("instanceMethod", String.class, String.class);
|
||||
names = discoverer.getParameterNames(m2);
|
||||
assertNotNull("should find method info", names);
|
||||
assertEquals("two arguments", 2, names.length);
|
||||
|
|
@ -223,6 +223,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
assertNull(names);
|
||||
}
|
||||
|
||||
|
||||
public static void staticMethodNoLocalVars() {
|
||||
}
|
||||
|
||||
|
|
@ -246,6 +247,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
return u;
|
||||
}
|
||||
|
||||
|
||||
public static class InnerClass {
|
||||
|
||||
public int waz = 0;
|
||||
|
|
@ -278,7 +280,9 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static class GenerifiedClass<K, V> {
|
||||
|
||||
private static long date;
|
||||
|
||||
static {
|
||||
|
|
@ -317,4 +321,5 @@ public class LocalVariableTableParameterNameDiscovererTests {
|
|||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class PrioritizedParameterNameDiscovererTests {
|
|||
private final Method anyMethod;
|
||||
|
||||
public PrioritizedParameterNameDiscovererTests() throws SecurityException, NoSuchMethodException {
|
||||
anyMethod = TestObject.class.getMethod("getAge", (Class[]) null);
|
||||
anyMethod = TestObject.class.getMethod("getAge");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -309,30 +309,30 @@ public class AnnotationMetadataTests {
|
|||
AnnotationAttributes nestedAnno = specialAttrs.getAnnotation("nestedAnno");
|
||||
assertThat("na", is(nestedAnno.getString("value")));
|
||||
assertTrue(nestedAnno.getEnum("anEnum").equals(SomeEnum.LABEL1));
|
||||
assertArrayEquals(new Class[] { String.class }, (Class[]) nestedAnno.get("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {String.class}, (Class<?>[]) nestedAnno.get("classArray"));
|
||||
|
||||
AnnotationAttributes[] nestedAnnoArray = specialAttrs.getAnnotationArray("nestedAnnoArray");
|
||||
assertThat(nestedAnnoArray.length, is(2));
|
||||
assertThat(nestedAnnoArray[0].getString("value"), is("default"));
|
||||
assertTrue(nestedAnnoArray[0].getEnum("anEnum").equals(SomeEnum.DEFAULT));
|
||||
assertArrayEquals(new Class[] { Void.class }, (Class[]) nestedAnnoArray[0].get("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Void.class}, (Class<?>[]) nestedAnnoArray[0].get("classArray"));
|
||||
assertThat(nestedAnnoArray[1].getString("value"), is("na1"));
|
||||
assertTrue(nestedAnnoArray[1].getEnum("anEnum").equals(SomeEnum.LABEL2));
|
||||
assertArrayEquals(new Class[] { Number.class }, (Class[]) nestedAnnoArray[1].get("classArray"));
|
||||
assertArrayEquals(new Class[] { Number.class }, nestedAnnoArray[1].getClassArray("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Number.class}, (Class<?>[]) nestedAnnoArray[1].get("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Number.class}, nestedAnnoArray[1].getClassArray("classArray"));
|
||||
|
||||
AnnotationAttributes optional = specialAttrs.getAnnotation("optional");
|
||||
assertThat(optional.getString("value"), is("optional"));
|
||||
assertTrue(optional.getEnum("anEnum").equals(SomeEnum.DEFAULT));
|
||||
assertArrayEquals(new Class[] { Void.class }, (Class[]) optional.get("classArray"));
|
||||
assertArrayEquals(new Class[] { Void.class }, optional.getClassArray("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Void.class}, (Class<?>[]) optional.get("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Void.class}, optional.getClassArray("classArray"));
|
||||
|
||||
AnnotationAttributes[] optionalArray = specialAttrs.getAnnotationArray("optionalArray");
|
||||
assertThat(optionalArray.length, is(1));
|
||||
assertThat(optionalArray[0].getString("value"), is("optional"));
|
||||
assertTrue(optionalArray[0].getEnum("anEnum").equals(SomeEnum.DEFAULT));
|
||||
assertArrayEquals(new Class[] { Void.class }, (Class[]) optionalArray[0].get("classArray"));
|
||||
assertArrayEquals(new Class[] { Void.class }, optionalArray[0].getClassArray("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Void.class}, (Class<?>[]) optionalArray[0].get("classArray"));
|
||||
assertArrayEquals(new Class<?>[] {Void.class}, optionalArray[0].getClassArray("classArray"));
|
||||
|
||||
assertEquals("direct", metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"));
|
||||
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.type;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -30,9 +31,9 @@ abstract class ClassloadingAssertions {
|
|||
|
||||
private static boolean isClassLoaded(String className) {
|
||||
ClassLoader cl = ClassUtils.getDefaultClassLoader();
|
||||
Method findLoadeClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", new Class[] { String.class });
|
||||
ReflectionUtils.makeAccessible(findLoadeClassMethod);
|
||||
Class<?> loadedClass = (Class<?>) ReflectionUtils.invokeMethod(findLoadeClassMethod, cl, new Object[] { className });
|
||||
Method findLoadedClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", String.class);
|
||||
ReflectionUtils.makeAccessible(findLoadedClassMethod);
|
||||
Class<?> loadedClass = (Class<?>) ReflectionUtils.invokeMethod(findLoadedClassMethod, cl, className);
|
||||
return loadedClass != null;
|
||||
}
|
||||
|
||||
|
|
@ -40,4 +41,4 @@ abstract class ClassloadingAssertions {
|
|||
assertFalse("Class [" + className + "] should not have been loaded", isClassLoaded(className));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -212,7 +212,7 @@ public class ClassUtilsTests {
|
|||
assertNotNull(method);
|
||||
assertEquals("size", method.getName());
|
||||
|
||||
method = ClassUtils.getMethodIfAvailable(Collection.class, "remove", new Class[] {Object.class});
|
||||
method = ClassUtils.getMethodIfAvailable(Collection.class, "remove", Object.class);
|
||||
assertNotNull(method);
|
||||
assertEquals("remove", method.getName());
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ public class ClassUtilsTests {
|
|||
|
||||
@Test
|
||||
public void testNoArgsStaticMethod() throws IllegalAccessException, InvocationTargetException {
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod", (Class[]) null);
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod");
|
||||
method.invoke(null, (Object[]) null);
|
||||
assertTrue("no argument method was not invoked.",
|
||||
InnerClass.noArgCalled);
|
||||
|
|
@ -247,19 +247,16 @@ public class ClassUtilsTests {
|
|||
|
||||
@Test
|
||||
public void testArgsStaticMethod() throws IllegalAccessException, InvocationTargetException {
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "argStaticMethod",
|
||||
new Class[] {String.class});
|
||||
method.invoke(null, new Object[] {"test"});
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "argStaticMethod", String.class);
|
||||
method.invoke(null, "test");
|
||||
assertTrue("argument method was not invoked.", InnerClass.argCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverloadedStaticMethod() throws IllegalAccessException, InvocationTargetException {
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod",
|
||||
new Class[] {String.class});
|
||||
method.invoke(null, new Object[] {"test"});
|
||||
assertTrue("argument method was not invoked.",
|
||||
InnerClass.overloadedCalled);
|
||||
Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod", String.class);
|
||||
method.invoke(null, "test");
|
||||
assertTrue("argument method was not invoked.", InnerClass.overloadedCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -60,10 +60,10 @@ public class ObjectUtilsTests {
|
|||
|
||||
@Test
|
||||
public void isCompatibleWithThrowsClause() {
|
||||
Class<?>[] empty = new Class[0];
|
||||
Class<?>[] exception = new Class[] {Exception.class};
|
||||
Class<?>[] sqlAndIO = new Class[] {SQLException.class, IOException.class};
|
||||
Class<?>[] throwable = new Class[] {Throwable.class};
|
||||
Class<?>[] empty = new Class<?>[0];
|
||||
Class<?>[] exception = new Class<?>[] {Exception.class};
|
||||
Class<?>[] sqlAndIO = new Class<?>[] {SQLException.class, IOException.class};
|
||||
Class<?>[] throwable = new Class<?>[] {Throwable.class};
|
||||
|
||||
assertTrue(ObjectUtils.isCompatibleWithThrowsClause(new RuntimeException()));
|
||||
assertTrue(ObjectUtils.isCompatibleWithThrowsClause(new RuntimeException(), empty));
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class ReflectionUtilsTests {
|
|||
TestObject bean = new TestObject();
|
||||
bean.setName(rob);
|
||||
|
||||
Method getName = TestObject.class.getMethod("getName", (Class[]) null);
|
||||
Method getName = TestObject.class.getMethod("getName");
|
||||
Method setName = TestObject.class.getMethod("setName", String.class);
|
||||
|
||||
Object name = ReflectionUtils.invokeMethod(getName, bean);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class IndexingTests {
|
|||
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class[] { Map.class };
|
||||
return new Class<?>[] {Map.class};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
|||
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class[] {String.class};
|
||||
return new Class<?>[] {String.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4957,7 +4957,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
private Method method;
|
||||
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class[] {Payload2.class};
|
||||
return new Class<?>[] {Payload2.class};
|
||||
}
|
||||
|
||||
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
|
||||
|
|
@ -5043,7 +5043,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
|||
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class[] {Map.class};
|
||||
return new Class<?>[] {Map.class};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -438,9 +438,7 @@ public class SpelDocumentationTests extends AbstractExpressionTests {
|
|||
public void testFunctions() throws Exception {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
|
||||
context.registerFunction("reverseString", StringUtils.class.getDeclaredMethod(
|
||||
"reverseString", new Class[] { String.class }));
|
||||
context.registerFunction("reverseString", StringUtils.class.getDeclaredMethod("reverseString", String.class));
|
||||
|
||||
String helloWorldReversed = parser.parseExpression("#reverseString('hello world')").getValue(context, String.class);
|
||||
assertEquals("dlrow olleh",helloWorldReversed);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -117,10 +117,10 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
StandardTypeConverter tc = new StandardTypeConverter();
|
||||
|
||||
// Calling foo(String) with (String) is exact match
|
||||
checkMatch(new Class[] {String.class}, new Class[] {String.class}, tc, ReflectionHelper.ArgumentsMatchKind.EXACT);
|
||||
checkMatch(new Class<?>[] {String.class}, new Class<?>[] {String.class}, tc, ReflectionHelper.ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Calling foo(String,Integer) with (String,Integer) is exact match
|
||||
checkMatch(new Class[] {String.class, Integer.class}, new Class[] {String.class, Integer.class}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch(new Class<?>[] {String.class, Integer.class}, new Class<?>[] {String.class, Integer.class}, tc, ArgumentsMatchKind.EXACT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -128,13 +128,13 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
StandardTypeConverter tc = new StandardTypeConverter();
|
||||
|
||||
// Calling foo(List) with (ArrayList) is close match (no conversion required)
|
||||
checkMatch(new Class[] {ArrayList.class}, new Class[] {List.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {ArrayList.class}, new Class<?>[] {List.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (Sub,String) on call to foo(Super,String) is close match
|
||||
checkMatch(new Class[] {Sub.class, String.class}, new Class[] {Super.class, String.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {Sub.class, String.class}, new Class<?>[] {Super.class, String.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (String,Sub) on call to foo(String,Super) is close match
|
||||
checkMatch(new Class[] {String.class, Sub.class}, new Class[] {String.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {String.class, Sub.class}, new Class<?>[] {String.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -142,16 +142,16 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
StandardTypeConverter tc = new StandardTypeConverter();
|
||||
|
||||
// Calling foo(String,int) with (String,Integer) requires boxing conversion of argument one
|
||||
checkMatch(new Class[] {String.class, Integer.TYPE}, new Class[] {String.class,Integer.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {String.class, Integer.TYPE}, new Class<?>[] {String.class,Integer.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,String) on call to foo(Integer,String) requires boxing conversion of argument zero
|
||||
checkMatch(new Class[] {Integer.TYPE, String.class}, new Class[] {Integer.class, String.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {Integer.TYPE, String.class}, new Class<?>[] {Integer.class, String.class},tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,Sub) on call to foo(Integer,Super) requires boxing conversion of argument zero
|
||||
checkMatch(new Class[] {Integer.TYPE, Sub.class}, new Class[] {Integer.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch(new Class<?>[] {Integer.TYPE, Sub.class}, new Class<?>[] {Integer.class, Super.class}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (int,Sub,boolean) on call to foo(Integer,Super,Boolean) requires boxing conversion of arguments zero and two
|
||||
// TODO checkMatch(new Class[] {Integer.TYPE, Sub.class, Boolean.TYPE}, new Class[] {Integer.class, Super.class, Boolean.class}, tc, ArgsMatchKind.REQUIRES_CONVERSION);
|
||||
// TODO checkMatch(new Class<?>[] {Integer.TYPE, Sub.class, Boolean.TYPE}, new Class<?>[] {Integer.class, Super.class, Boolean.class}, tc, ArgsMatchKind.REQUIRES_CONVERSION);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -159,7 +159,7 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
StandardTypeConverter typeConverter = new StandardTypeConverter();
|
||||
|
||||
// Passing (Super,String) on call to foo(Sub,String) is not a match
|
||||
checkMatch(new Class[] {Super.class,String.class}, new Class[] {Sub.class,String.class},typeConverter,null);
|
||||
checkMatch(new Class<?>[] {Super.class,String.class}, new Class<?>[] {Sub.class,String.class},typeConverter,null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -169,49 +169,49 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
Class<?> integerArrayClass = new Integer[0].getClass();
|
||||
|
||||
// Passing (String[]) on call to (String[]) is exact match
|
||||
checkMatch2(new Class[] {stringArrayClass}, new Class[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch2(new Class<?>[] {stringArrayClass}, new Class<?>[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Passing (Integer, String[]) on call to (Integer, String[]) is exact match
|
||||
checkMatch2(new Class[] {Integer.class, stringArrayClass}, new Class[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch2(new Class<?>[] {Integer.class, stringArrayClass}, new Class<?>[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Passing (String, Integer, String[]) on call to (String, String, String[]) is exact match
|
||||
checkMatch2(new Class[] {String.class, Integer.class, stringArrayClass}, new Class[] {String.class,Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch2(new Class<?>[] {String.class, Integer.class, stringArrayClass}, new Class<?>[] {String.class,Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Passing (Sub, String[]) on call to (Super, String[]) is exact match
|
||||
checkMatch2(new Class[] {Sub.class, stringArrayClass}, new Class[] {Super.class,stringArrayClass}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch2(new Class<?>[] {Sub.class, stringArrayClass}, new Class<?>[] {Super.class,stringArrayClass}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (Integer, String[]) on call to (String, String[]) is exact match
|
||||
checkMatch2(new Class[] {Integer.class, stringArrayClass}, new Class[] {String.class, stringArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
checkMatch2(new Class<?>[] {Integer.class, stringArrayClass}, new Class<?>[] {String.class, stringArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
|
||||
// Passing (Integer, Sub, String[]) on call to (String, Super, String[]) is exact match
|
||||
checkMatch2(new Class[] {Integer.class, Sub.class, String[].class}, new Class[] {String.class,Super .class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
checkMatch2(new Class<?>[] {Integer.class, Sub.class, String[].class}, new Class<?>[] {String.class,Super .class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
|
||||
// Passing (String) on call to (String[]) is exact match
|
||||
checkMatch2(new Class[] {String.class}, new Class[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch2(new Class<?>[] {String.class}, new Class<?>[] {stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Passing (Integer,String) on call to (Integer,String[]) is exact match
|
||||
checkMatch2(new Class[] {Integer.class, String.class}, new Class[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
checkMatch2(new Class<?>[] {Integer.class, String.class}, new Class<?>[] {Integer.class, stringArrayClass}, tc, ArgumentsMatchKind.EXACT);
|
||||
|
||||
// Passing (String) on call to (Integer[]) is conversion match (String to Integer)
|
||||
checkMatch2(new Class[] {String.class}, new Class[] {integerArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
checkMatch2(new Class<?>[] {String.class}, new Class<?>[] {integerArrayClass}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
|
||||
// Passing (Sub) on call to (Super[]) is close match
|
||||
checkMatch2(new Class[] {Sub.class}, new Class[] {new Super[0].getClass()}, tc, ArgumentsMatchKind.CLOSE);
|
||||
checkMatch2(new Class<?>[] {Sub.class}, new Class<?>[] {new Super[0].getClass()}, tc, ArgumentsMatchKind.CLOSE);
|
||||
|
||||
// Passing (Super) on call to (Sub[]) is not a match
|
||||
checkMatch2(new Class[] {Super.class}, new Class[] {new Sub[0].getClass()}, tc, null);
|
||||
checkMatch2(new Class<?>[] {Super.class}, new Class<?>[] {new Sub[0].getClass()}, tc, null);
|
||||
|
||||
checkMatch2(new Class[] {Unconvertable.class, String.class}, new Class[] {Sub.class, Super[].class}, tc, null);
|
||||
checkMatch2(new Class<?>[] {Unconvertable.class, String.class}, new Class<?>[] {Sub.class, Super[].class}, tc, null);
|
||||
|
||||
checkMatch2(new Class[] {Integer.class, Integer.class, String.class}, new Class[] {String.class, String.class, Super[].class}, tc, null);
|
||||
checkMatch2(new Class<?>[] {Integer.class, Integer.class, String.class}, new Class<?>[] {String.class, String.class, Super[].class}, tc, null);
|
||||
|
||||
checkMatch2(new Class[] {Unconvertable.class, String.class}, new Class[] {Sub.class, Super[].class}, tc, null);
|
||||
checkMatch2(new Class<?>[] {Unconvertable.class, String.class}, new Class<?>[] {Sub.class, Super[].class}, tc, null);
|
||||
|
||||
checkMatch2(new Class[] {Integer.class, Integer.class, String.class}, new Class[] {String.class, String.class, Super[].class}, tc, null);
|
||||
checkMatch2(new Class<?>[] {Integer.class, Integer.class, String.class}, new Class<?>[] {String.class, String.class, Super[].class}, tc, null);
|
||||
|
||||
checkMatch2(new Class[] {Integer.class, Integer.class, Sub.class}, new Class[] {String.class, String.class, Super[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
checkMatch2(new Class<?>[] {Integer.class, Integer.class, Sub.class}, new Class<?>[] {String.class, String.class, Super[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
|
||||
checkMatch2(new Class[] {Integer.class, Integer.class, Integer.class}, new Class[] {Integer.class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
checkMatch2(new Class<?>[] {Integer.class, Integer.class, Integer.class}, new Class<?>[] {Integer.class, String[].class}, tc, ArgumentsMatchKind.REQUIRES_CONVERSION);
|
||||
// what happens on (Integer,String) passed to (Integer[]) ?
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,8 @@ public class ReflectionHelperTests extends AbstractExpressionTests {
|
|||
|
||||
@Test
|
||||
public void testSetupArguments() {
|
||||
Object[] newArray = ReflectionHelper.setupArgumentsForVarargsInvocation(new Class[] {new String[0].getClass()},"a","b","c");
|
||||
Object[] newArray = ReflectionHelper.setupArgumentsForVarargsInvocation(
|
||||
new Class<?>[] {new String[0].getClass()},"a","b","c");
|
||||
|
||||
assertEquals(1, newArray.length);
|
||||
Object firstParam = newArray[0];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -45,7 +45,7 @@ public class TableMetaDataProviderFactory {
|
|||
*/
|
||||
public static TableMetaDataProvider createMetaDataProvider(DataSource dataSource, TableMetaDataContext context) {
|
||||
try {
|
||||
TableMetaDataProvider result = (TableMetaDataProvider) JdbcUtils.extractDatabaseMetaData(dataSource, databaseMetaData -> {
|
||||
return (TableMetaDataProvider) JdbcUtils.extractDatabaseMetaData(dataSource, databaseMetaData -> {
|
||||
String databaseProductName =
|
||||
JdbcUtils.commonDatabaseName(databaseMetaData.getDatabaseProductName());
|
||||
boolean accessTableColumnMetaData = context.isAccessTableColumnMetaData();
|
||||
|
|
@ -71,12 +71,11 @@ public class TableMetaDataProviderFactory {
|
|||
}
|
||||
provider.initializeWithMetaData(databaseMetaData);
|
||||
if (accessTableColumnMetaData) {
|
||||
provider.initializeWithTableColumnMetaData(databaseMetaData, context.getCatalogName(),
|
||||
context.getSchemaName(), context.getTableName());
|
||||
provider.initializeWithTableColumnMetaData(databaseMetaData,
|
||||
context.getCatalogName(), context.getSchemaName(), context.getTableName());
|
||||
}
|
||||
return provider;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
catch (MetaDataAccessException ex) {
|
||||
throw new DataAccessResourceFailureException("Error retrieving database metadata", ex);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -95,7 +95,7 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
|
|||
this.wsDataSourceClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSDataSource");
|
||||
Class<?> jdbcConnSpecClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.JDBCConnectionSpec");
|
||||
Class<?> wsrraFactoryClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSRRAFactory");
|
||||
this.newJdbcConnSpecMethod = wsrraFactoryClass.getMethod("createJDBCConnectionSpec", (Class<?>[]) null);
|
||||
this.newJdbcConnSpecMethod = wsrraFactoryClass.getMethod("createJDBCConnectionSpec");
|
||||
this.wsDataSourceGetConnectionMethod =
|
||||
this.wsDataSourceClass.getMethod("getConnection", jdbcConnSpecClass);
|
||||
this.setTransactionIsolationMethod =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.jdbc.support;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
|
|
@ -356,8 +355,7 @@ public abstract class JdbcUtils {
|
|||
return (T) extractDatabaseMetaData(dataSource,
|
||||
dbmd -> {
|
||||
try {
|
||||
Method method = DatabaseMetaData.class.getMethod(metaDataMethodName, (Class[]) null);
|
||||
return method.invoke(dbmd, (Object[]) null);
|
||||
return DatabaseMetaData.class.getMethod(metaDataMethodName).invoke(dbmd);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new MetaDataAccessException("No method named '" + metaDataMethodName +
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -38,180 +38,183 @@ import static org.mockito.BDDMockito.*;
|
|||
*/
|
||||
public class ResultSetWrappingRowSetTests {
|
||||
|
||||
private ResultSet rset;
|
||||
private ResultSetWrappingSqlRowSet rowset;
|
||||
private ResultSet resultSet;
|
||||
|
||||
private ResultSetWrappingSqlRowSet rowSet;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
rset = mock(ResultSet.class);
|
||||
rowset = new ResultSetWrappingSqlRowSet(rset);
|
||||
public void setup() throws Exception {
|
||||
resultSet = mock(ResultSet.class);
|
||||
rowSet = new ResultSetWrappingSqlRowSet(resultSet);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetBigDecimalInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBigDecimal", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBigDecimal", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBigDecimal", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBigDecimal", int.class);
|
||||
doTest(rset, rowset, 1, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBigDecimalString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBigDecimal", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBigDecimal", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBigDecimal", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBigDecimal", String.class);
|
||||
doTest(rset, rowset, "test", BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStringInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getString", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getString", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getString", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getString", int.class);
|
||||
doTest(rset, rowset, 1, "test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStringString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getString", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getString", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getString", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getString", String.class);
|
||||
doTest(rset, rowset, "test", "test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimestampInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
doTest(rset, rowset, 1, new Timestamp(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimestampString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTimestamp", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTimestamp", String.class);
|
||||
doTest(rset, rowset, "test", new Timestamp(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDateInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", int.class);
|
||||
doTest(rset, rowset, 1, new Date(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDateString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDate", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDate", String.class);
|
||||
doTest(rset, rowset, "test", new Date(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimeInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", int.class);
|
||||
doTest(rset, rowset, 1, new Time(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTimeString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getTime", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getTime", String.class);
|
||||
doTest(rset, rowset, "test", new Time(1234l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getObject", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getObject", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getObject", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getObject", int.class);
|
||||
doTest(rset, rowset, 1, new Object());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getObject", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getObject", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getObject", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getObject", String.class);
|
||||
doTest(rset, rowset, "test", new Object());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIntInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getInt", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getInt", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getInt", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getInt", int.class);
|
||||
doTest(rset, rowset, 1, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIntString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getInt", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getInt", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getInt", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getInt", String.class);
|
||||
doTest(rset, rowset, "test", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFloatInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getFloat", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getFloat", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getFloat", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getFloat", int.class);
|
||||
doTest(rset, rowset, 1, 1.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFloatString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getFloat", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getFloat", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getFloat", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getFloat", String.class);
|
||||
doTest(rset, rowset, "test", 1.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDoubleInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDouble", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDouble", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDouble", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDouble", int.class);
|
||||
doTest(rset, rowset, 1, 1.0d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDoubleString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDouble", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDouble", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getDouble", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getDouble", String.class);
|
||||
doTest(rset, rowset, "test", 1.0d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLongInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getLong", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getLong", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getLong", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getLong", int.class);
|
||||
doTest(rset, rowset, 1, 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLongString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getLong", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getLong", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getLong", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getLong", String.class);
|
||||
doTest(rset, rowset, "test", 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBooleanInt() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBoolean", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBoolean", new Class[] {int.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBoolean", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBoolean", int.class);
|
||||
doTest(rset, rowset, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBooleanString() throws Exception {
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBoolean", new Class[] {int.class});
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBoolean", new Class[] {String.class});
|
||||
Method rset = ResultSet.class.getDeclaredMethod("getBoolean", int.class);
|
||||
Method rowset = ResultSetWrappingSqlRowSet.class.getDeclaredMethod("getBoolean", String.class);
|
||||
doTest(rset, rowset, "test", true);
|
||||
}
|
||||
|
||||
private void doTest(Method rsetMethod, Method rowsetMethod, Object arg, Object ret) throws Exception {
|
||||
if (arg instanceof String) {
|
||||
given(rset.findColumn((String) arg)).willReturn(1);
|
||||
given(rsetMethod.invoke(rset, 1)).willReturn(ret).willThrow(new SQLException("test"));
|
||||
given(resultSet.findColumn((String) arg)).willReturn(1);
|
||||
given(rsetMethod.invoke(resultSet, 1)).willReturn(ret).willThrow(new SQLException("test"));
|
||||
}
|
||||
else {
|
||||
given(rsetMethod.invoke(rset, arg)).willReturn(ret).willThrow(new SQLException("test"));
|
||||
given(rsetMethod.invoke(resultSet, arg)).willReturn(ret).willThrow(new SQLException("test"));
|
||||
}
|
||||
rowsetMethod.invoke(rowset, arg);
|
||||
rowsetMethod.invoke(rowSet, arg);
|
||||
try {
|
||||
rowsetMethod.invoke(rowset, arg);
|
||||
rowsetMethod.invoke(rowSet, arg);
|
||||
fail("InvalidResultSetAccessException should have been thrown");
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -60,7 +60,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
@SuppressWarnings("resource")
|
||||
GenericApplicationContext cxt = new GenericApplicationContext();
|
||||
cxt.refresh();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -164,7 +164,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
|||
@Test
|
||||
public void testPublicExtendedPersistenceContextSetterWithSerialization() throws Exception {
|
||||
DummyInvocationHandler ih = new DummyInvocationHandler();
|
||||
Object mockEm = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {EntityManager.class}, ih);
|
||||
Object mockEm = Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] {EntityManager.class}, ih);
|
||||
given(mockEmf.createEntityManager()).willReturn((EntityManager) mockEm);
|
||||
|
||||
GenericApplicationContext gac = new GenericApplicationContext();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -87,7 +87,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests<CastorMar
|
|||
@Test
|
||||
public void unmarshalTargetClass() throws Exception {
|
||||
CastorMarshaller unmarshaller = new CastorMarshaller();
|
||||
unmarshaller.setTargetClasses(new Class[] {Flights.class});
|
||||
unmarshaller.setTargetClasses(Flights.class);
|
||||
unmarshaller.afterPropertiesSet();
|
||||
StreamSource source = new StreamSource(new ByteArrayInputStream(INPUT_STRING.getBytes("UTF-8")));
|
||||
Object flights = unmarshaller.unmarshal(source);
|
||||
|
|
@ -98,7 +98,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests<CastorMar
|
|||
public void setBothTargetClassesAndMapping() throws IOException {
|
||||
CastorMarshaller unmarshaller = new CastorMarshaller();
|
||||
unmarshaller.setMappingLocation(new ClassPathResource("order-mapping.xml", CastorMarshaller.class));
|
||||
unmarshaller.setTargetClasses(new Class[] {Order.class});
|
||||
unmarshaller.setTargetClasses(Order.class);
|
||||
unmarshaller.afterPropertiesSet();
|
||||
|
||||
String xml = "<order>" +
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -202,7 +202,7 @@ public class XStreamMarshallerTests {
|
|||
|
||||
@Test
|
||||
public void useAttributesFor() throws Exception {
|
||||
marshaller.setUseAttributeForTypes(new Class[]{Long.TYPE});
|
||||
marshaller.setUseAttributeForTypes(Long.TYPE);
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight flightNumber=\"42\" />";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -74,8 +74,7 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.*;
|
|||
*/
|
||||
public class SpringJUnit4ConcurrencyTests {
|
||||
|
||||
// @formatter:off
|
||||
private final Class<?>[] testClasses = new Class[] {
|
||||
private final Class<?>[] testClasses = new Class<?>[] {
|
||||
// Basics
|
||||
SpringJUnit4ClassRunnerAppCtxTests.class,
|
||||
InheritedConfigSpringJUnit4ClassRunnerAppCtxTests.class,
|
||||
|
|
@ -94,7 +93,7 @@ public class SpringJUnit4ConcurrencyTests {
|
|||
WebAppResourceTests.class,
|
||||
SampleTests.class
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void abortIfLongRunningTestGroupIsNotEnabled() {
|
||||
|
|
@ -109,7 +108,7 @@ public class SpringJUnit4ConcurrencyTests {
|
|||
final int TESTS = countAnnotatedMethods(Test.class) - IGNORED;
|
||||
|
||||
runTestsAndAssertCounters(new ParallelComputer(true, true), TESTS, FAILED, TESTS, IGNORED, ABORTED,
|
||||
this.testClasses);
|
||||
this.testClasses);
|
||||
}
|
||||
|
||||
private int countAnnotatedMethods(Class<? extends Annotation> annotationType) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -57,8 +57,8 @@ public class DelegatingSmartContextLoaderTests {
|
|||
|
||||
@Test
|
||||
public void processContextConfigurationWithDefaultXmlConfigGeneration() {
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(XmlTestCase.class,
|
||||
EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
|
||||
XmlTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
loader.processContextConfiguration(configAttributes);
|
||||
assertEquals(1, configAttributes.getLocations().length);
|
||||
assertEmpty(configAttributes.getClasses());
|
||||
|
|
@ -66,8 +66,8 @@ public class DelegatingSmartContextLoaderTests {
|
|||
|
||||
@Test
|
||||
public void processContextConfigurationWithDefaultConfigurationClassGeneration() {
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(ConfigClassTestCase.class,
|
||||
EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
|
||||
ConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
loader.processContextConfiguration(configAttributes);
|
||||
assertEquals(1, configAttributes.getClasses().length);
|
||||
assertEmpty(configAttributes.getLocations());
|
||||
|
|
@ -79,16 +79,16 @@ public class DelegatingSmartContextLoaderTests {
|
|||
expectedException.expectMessage(containsString("both default locations AND default configuration classes were detected"));
|
||||
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
|
||||
ImproperDuplicateDefaultXmlAndConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, true, null,
|
||||
true, ContextLoader.class);
|
||||
ImproperDuplicateDefaultXmlAndConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY,
|
||||
true, null, true, ContextLoader.class);
|
||||
loader.processContextConfiguration(configAttributes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processContextConfigurationWithLocation() {
|
||||
String[] locations = new String[] { "classpath:/foo.xml" };
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(getClass(), locations,
|
||||
EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
String[] locations = new String[] {"classpath:/foo.xml"};
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
|
||||
getClass(), locations, EMPTY_CLASS_ARRAY, true, null, true, ContextLoader.class);
|
||||
loader.processContextConfiguration(configAttributes);
|
||||
assertArrayEquals(locations, configAttributes.getLocations());
|
||||
assertEmpty(configAttributes.getClasses());
|
||||
|
|
@ -96,9 +96,9 @@ public class DelegatingSmartContextLoaderTests {
|
|||
|
||||
@Test
|
||||
public void processContextConfigurationWithConfigurationClass() {
|
||||
Class<?>[] classes = new Class<?>[] { getClass() };
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(getClass(),
|
||||
EMPTY_STRING_ARRAY, classes, true, null, true, ContextLoader.class);
|
||||
Class<?>[] classes = new Class<?>[] {getClass()};
|
||||
ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
|
||||
getClass(), EMPTY_STRING_ARRAY, classes, true, null, true, ContextLoader.class);
|
||||
loader.processContextConfiguration(configAttributes);
|
||||
assertArrayEquals(classes, configAttributes.getClasses());
|
||||
assertEmpty(configAttributes.getLocations());
|
||||
|
|
@ -118,8 +118,8 @@ public class DelegatingSmartContextLoaderTests {
|
|||
expectedException.expectMessage(startsWith("Neither"));
|
||||
expectedException.expectMessage(containsString("was able to load an ApplicationContext from"));
|
||||
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,
|
||||
EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(
|
||||
getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
|
||||
loader.loadContext(mergedConfig);
|
||||
}
|
||||
|
||||
|
|
@ -133,12 +133,13 @@ public class DelegatingSmartContextLoaderTests {
|
|||
expectedException.expectMessage(endsWith("declare either 'locations' or 'classes' but not both."));
|
||||
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(),
|
||||
new String[] { "test.xml" }, new Class[] { getClass() }, EMPTY_STRING_ARRAY, loader);
|
||||
new String[] {"test.xml"}, new Class<?>[] {getClass()}, EMPTY_STRING_ARRAY, loader);
|
||||
loader.loadContext(mergedConfig);
|
||||
}
|
||||
|
||||
private void assertApplicationContextLoadsAndContainsFooString(MergedContextConfiguration mergedConfig)
|
||||
throws Exception {
|
||||
|
||||
ApplicationContext applicationContext = loader.loadContext(mergedConfig);
|
||||
assertNotNull(applicationContext);
|
||||
assertEquals("foo", applicationContext.getBean(String.class));
|
||||
|
|
@ -149,16 +150,16 @@ public class DelegatingSmartContextLoaderTests {
|
|||
@Test
|
||||
public void loadContextWithXmlConfig() throws Exception {
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(
|
||||
XmlTestCase.class,
|
||||
new String[] { "classpath:/org/springframework/test/context/support/DelegatingSmartContextLoaderTests$XmlTestCase-context.xml" },
|
||||
EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
|
||||
XmlTestCase.class,
|
||||
new String[] {"classpath:/org/springframework/test/context/support/DelegatingSmartContextLoaderTests$XmlTestCase-context.xml"},
|
||||
EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
|
||||
assertApplicationContextLoadsAndContainsFooString(mergedConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadContextWithConfigurationClass() throws Exception {
|
||||
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(ConfigClassTestCase.class,
|
||||
EMPTY_STRING_ARRAY, new Class<?>[] { ConfigClassTestCase.Config.class }, EMPTY_STRING_ARRAY, loader);
|
||||
EMPTY_STRING_ARRAY, new Class<?>[] {ConfigClassTestCase.Config.class}, EMPTY_STRING_ARRAY, loader);
|
||||
assertApplicationContextLoadsAndContainsFooString(mergedConfig);
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +193,6 @@ public class DelegatingSmartContextLoaderTests {
|
|||
}
|
||||
|
||||
static class NotAConfigClass {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -44,19 +44,21 @@ import static org.springframework.test.util.MetaAnnotationUtils.*;
|
|||
*/
|
||||
public class MetaAnnotationUtilsTests {
|
||||
|
||||
private void assertAtComponentOnComposedAnnotation(Class<?> rootDeclaringClass, String name,
|
||||
Class<? extends Annotation> composedAnnotationType) {
|
||||
private void assertAtComponentOnComposedAnnotation(
|
||||
Class<?> rootDeclaringClass, String name, Class<? extends Annotation> composedAnnotationType) {
|
||||
|
||||
assertAtComponentOnComposedAnnotation(rootDeclaringClass, rootDeclaringClass, name, composedAnnotationType);
|
||||
}
|
||||
|
||||
private void assertAtComponentOnComposedAnnotation(Class<?> startClass, Class<?> rootDeclaringClass, String name,
|
||||
Class<? extends Annotation> composedAnnotationType) {
|
||||
assertAtComponentOnComposedAnnotation(rootDeclaringClass, rootDeclaringClass, composedAnnotationType, name,
|
||||
composedAnnotationType);
|
||||
private void assertAtComponentOnComposedAnnotation(
|
||||
Class<?> startClass, Class<?> rootDeclaringClass, String name, Class<? extends Annotation> composedAnnotationType) {
|
||||
|
||||
assertAtComponentOnComposedAnnotation(startClass, rootDeclaringClass, composedAnnotationType, name, composedAnnotationType);
|
||||
}
|
||||
|
||||
private void assertAtComponentOnComposedAnnotation(Class<?> startClass, Class<?> rootDeclaringClass,
|
||||
Class<?> declaringClass, String name, Class<? extends Annotation> composedAnnotationType) {
|
||||
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(startClass, Component.class);
|
||||
assertNotNull("AnnotationDescriptor should not be null", descriptor);
|
||||
assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass());
|
||||
|
|
@ -67,25 +69,29 @@ public class MetaAnnotationUtilsTests {
|
|||
assertEquals("composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType());
|
||||
}
|
||||
|
||||
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass, String name,
|
||||
Class<? extends Annotation> composedAnnotationType) {
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(startClass, startClass, name,
|
||||
composedAnnotationType);
|
||||
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
Class<?> startClass, String name, Class<? extends Annotation> composedAnnotationType) {
|
||||
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
startClass, startClass, name, composedAnnotationType);
|
||||
}
|
||||
|
||||
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass,
|
||||
Class<?> rootDeclaringClass, String name, Class<? extends Annotation> composedAnnotationType) {
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(startClass, rootDeclaringClass,
|
||||
composedAnnotationType, name, composedAnnotationType);
|
||||
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
startClass, rootDeclaringClass, composedAnnotationType, name, composedAnnotationType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(Class<?> startClass,
|
||||
Class<?> rootDeclaringClass, Class<?> declaringClass, String name,
|
||||
Class<? extends Annotation> composedAnnotationType) {
|
||||
|
||||
Class<Component> annotationType = Component.class;
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
|
||||
annotationType, Order.class, Transactional.class);
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
startClass, Service.class, annotationType, Order.class, Transactional.class);
|
||||
|
||||
assertNotNull("UntypedAnnotationDescriptor should not be null", descriptor);
|
||||
assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass());
|
||||
assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass());
|
||||
|
|
@ -96,28 +102,27 @@ public class MetaAnnotationUtilsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorWithNoAnnotationPresent() throws Exception {
|
||||
public void findAnnotationDescriptorWithNoAnnotationPresent() {
|
||||
assertNull(findAnnotationDescriptor(NonAnnotatedInterface.class, Transactional.class));
|
||||
assertNull(findAnnotationDescriptor(NonAnnotatedClass.class, Transactional.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorWithInheritedAnnotationOnClass() throws Exception {
|
||||
public void findAnnotationDescriptorWithInheritedAnnotationOnClass() {
|
||||
// Note: @Transactional is inherited
|
||||
assertEquals(InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptor(InheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptor(InheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
assertEquals(InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptor(SubInheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptor(SubInheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorWithInheritedAnnotationOnInterface() throws Exception {
|
||||
public void findAnnotationDescriptorWithInheritedAnnotationOnInterface() {
|
||||
// Note: @Transactional is inherited
|
||||
Transactional rawAnnotation = InheritedAnnotationInterface.class.getAnnotation(Transactional.class);
|
||||
|
||||
AnnotationDescriptor<Transactional> descriptor;
|
||||
|
||||
descriptor = findAnnotationDescriptor(InheritedAnnotationInterface.class, Transactional.class);
|
||||
AnnotationDescriptor<Transactional> descriptor =
|
||||
findAnnotationDescriptor(InheritedAnnotationInterface.class, Transactional.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(InheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(InheritedAnnotationInterface.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -137,22 +142,21 @@ public class MetaAnnotationUtilsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForNonInheritedAnnotationOnClass() throws Exception {
|
||||
public void findAnnotationDescriptorForNonInheritedAnnotationOnClass() {
|
||||
// Note: @Order is not inherited.
|
||||
assertEquals(NonInheritedAnnotationClass.class,
|
||||
findAnnotationDescriptor(NonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptor(NonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
assertEquals(NonInheritedAnnotationClass.class,
|
||||
findAnnotationDescriptor(SubNonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptor(SubNonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForNonInheritedAnnotationOnInterface() throws Exception {
|
||||
public void findAnnotationDescriptorForNonInheritedAnnotationOnInterface() {
|
||||
// Note: @Order is not inherited.
|
||||
Order rawAnnotation = NonInheritedAnnotationInterface.class.getAnnotation(Order.class);
|
||||
|
||||
AnnotationDescriptor<Order> descriptor;
|
||||
|
||||
descriptor = findAnnotationDescriptor(NonInheritedAnnotationInterface.class, Order.class);
|
||||
AnnotationDescriptor<Order> descriptor =
|
||||
findAnnotationDescriptor(NonInheritedAnnotationInterface.class, Order.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(NonInheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(NonInheritedAnnotationInterface.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -166,15 +170,16 @@ public class MetaAnnotationUtilsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorWithMetaComponentAnnotation() throws Exception {
|
||||
public void findAnnotationDescriptorWithMetaComponentAnnotation() {
|
||||
assertAtComponentOnComposedAnnotation(HasMetaComponentAnnotation.class, "meta1", Meta1.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorWithLocalAndMetaComponentAnnotation() throws Exception {
|
||||
public void findAnnotationDescriptorWithLocalAndMetaComponentAnnotation() {
|
||||
Class<Component> annotationType = Component.class;
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(HasLocalAndMetaComponentAnnotation.class,
|
||||
annotationType);
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(
|
||||
HasLocalAndMetaComponentAnnotation.class, annotationType);
|
||||
|
||||
assertEquals(HasLocalAndMetaComponentAnnotation.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(annotationType, descriptor.getAnnotationType());
|
||||
assertNull(descriptor.getComposedAnnotation());
|
||||
|
|
@ -188,12 +193,10 @@ public class MetaAnnotationUtilsTests {
|
|||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForClassWithMetaAnnotatedInterface() {
|
||||
Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class,
|
||||
Component.class);
|
||||
Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class);
|
||||
AnnotationDescriptor<Component> descriptor =
|
||||
findAnnotationDescriptor(ClassWithMetaAnnotatedInterface.class, Component.class);
|
||||
|
||||
AnnotationDescriptor<Component> descriptor;
|
||||
|
||||
descriptor = findAnnotationDescriptor(ClassWithMetaAnnotatedInterface.class, Component.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(Meta1.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -204,7 +207,7 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
public void findAnnotationDescriptorForClassWithLocalMetaAnnotationAndAnnotatedSuperclass() {
|
||||
AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor(
|
||||
MetaAnnotatedAndSuperAnnotatedContextConfigClass.class, ContextConfiguration.class);
|
||||
MetaAnnotatedAndSuperAnnotatedContextConfigClass.class, ContextConfiguration.class);
|
||||
|
||||
assertNotNull("AnnotationDescriptor should not be null", descriptor);
|
||||
assertEquals("rootDeclaringClass", MetaAnnotatedAndSuperAnnotatedContextConfigClass.class, descriptor.getRootDeclaringClass());
|
||||
|
|
@ -213,20 +216,19 @@ public class MetaAnnotationUtilsTests {
|
|||
assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation());
|
||||
assertEquals("composedAnnotationType", MetaConfig.class, descriptor.getComposedAnnotationType());
|
||||
|
||||
assertArrayEquals("configured classes", new Class[] { String.class },
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
assertArrayEquals("configured classes", new Class<?>[] {String.class},
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForClassWithLocalMetaAnnotationAndMetaAnnotatedInterface() {
|
||||
assertAtComponentOnComposedAnnotation(ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2",
|
||||
Meta2.class);
|
||||
assertAtComponentOnComposedAnnotation(ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2", Meta2.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForSubClassWithLocalMetaAnnotationAndMetaAnnotatedInterface() {
|
||||
assertAtComponentOnComposedAnnotation(SubClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class,
|
||||
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2", Meta2.class);
|
||||
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2", Meta2.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -253,8 +255,8 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
public void findAnnotationDescriptorOnAnnotatedClassWithMissingTargetMetaAnnotation() {
|
||||
// InheritedAnnotationClass is NOT annotated or meta-annotated with @Component
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(InheritedAnnotationClass.class,
|
||||
Component.class);
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(
|
||||
InheritedAnnotationClass.class, Component.class);
|
||||
assertNull("Should not find @Component on InheritedAnnotationClass", descriptor);
|
||||
}
|
||||
|
||||
|
|
@ -263,8 +265,8 @@ public class MetaAnnotationUtilsTests {
|
|||
*/
|
||||
@Test
|
||||
public void findAnnotationDescriptorOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(MetaCycleAnnotatedClass.class,
|
||||
Component.class);
|
||||
AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(
|
||||
MetaCycleAnnotatedClass.class, Component.class);
|
||||
assertNull("Should not find @Component on MetaCycleAnnotatedClass", descriptor);
|
||||
}
|
||||
|
||||
|
|
@ -272,32 +274,30 @@ public class MetaAnnotationUtilsTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithNoAnnotationPresent() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithNoAnnotationPresent() {
|
||||
assertNull(findAnnotationDescriptorForTypes(NonAnnotatedInterface.class, Transactional.class, Component.class));
|
||||
assertNull(findAnnotationDescriptorForTypes(NonAnnotatedClass.class, Transactional.class, Order.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithInheritedAnnotationOnClass() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithInheritedAnnotationOnClass() {
|
||||
// Note: @Transactional is inherited
|
||||
assertEquals(InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(InheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
assertEquals(
|
||||
InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(InheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
assertEquals(
|
||||
InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(SubInheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
InheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(SubInheritedAnnotationClass.class, Transactional.class).getRootDeclaringClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithInheritedAnnotationOnInterface() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithInheritedAnnotationOnInterface() {
|
||||
// Note: @Transactional is inherited
|
||||
Transactional rawAnnotation = InheritedAnnotationInterface.class.getAnnotation(Transactional.class);
|
||||
|
||||
UntypedAnnotationDescriptor descriptor;
|
||||
|
||||
descriptor = findAnnotationDescriptorForTypes(InheritedAnnotationInterface.class, Transactional.class);
|
||||
UntypedAnnotationDescriptor descriptor =
|
||||
findAnnotationDescriptorForTypes(InheritedAnnotationInterface.class, Transactional.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(InheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(InheritedAnnotationInterface.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -318,23 +318,22 @@ public class MetaAnnotationUtilsTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesForNonInheritedAnnotationOnClass() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesForNonInheritedAnnotationOnClass() {
|
||||
// Note: @Order is not inherited.
|
||||
assertEquals(NonInheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(NonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptorForTypes(NonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
assertEquals(NonInheritedAnnotationClass.class,
|
||||
findAnnotationDescriptorForTypes(SubNonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
findAnnotationDescriptorForTypes(SubNonInheritedAnnotationClass.class, Order.class).getRootDeclaringClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesForNonInheritedAnnotationOnInterface() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesForNonInheritedAnnotationOnInterface() {
|
||||
// Note: @Order is not inherited.
|
||||
Order rawAnnotation = NonInheritedAnnotationInterface.class.getAnnotation(Order.class);
|
||||
|
||||
UntypedAnnotationDescriptor descriptor;
|
||||
|
||||
descriptor = findAnnotationDescriptorForTypes(NonInheritedAnnotationInterface.class, Order.class);
|
||||
UntypedAnnotationDescriptor descriptor =
|
||||
findAnnotationDescriptorForTypes(NonInheritedAnnotationInterface.class, Order.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(NonInheritedAnnotationInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(NonInheritedAnnotationInterface.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -349,10 +348,10 @@ public class MetaAnnotationUtilsTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithLocalAndMetaComponentAnnotation() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithLocalAndMetaComponentAnnotation() {
|
||||
Class<Component> annotationType = Component.class;
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
HasLocalAndMetaComponentAnnotation.class, Transactional.class, annotationType, Order.class);
|
||||
HasLocalAndMetaComponentAnnotation.class, Transactional.class, annotationType, Order.class);
|
||||
assertEquals(HasLocalAndMetaComponentAnnotation.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(annotationType, descriptor.getAnnotationType());
|
||||
assertNull(descriptor.getComposedAnnotation());
|
||||
|
|
@ -360,45 +359,45 @@ public class MetaAnnotationUtilsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findAnnotationDescriptorForTypesWithMetaComponentAnnotation() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithMetaComponentAnnotation() {
|
||||
Class<HasMetaComponentAnnotation> startClass = HasMetaComponentAnnotation.class;
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(startClass, "meta1", Meta1.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithDefaultAttributes() {
|
||||
Class<?> startClass = MetaConfigWithDefaultAttributesTestCase.class;
|
||||
Class<ContextConfiguration> annotationType = ContextConfiguration.class;
|
||||
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
|
||||
ContextConfiguration.class, Order.class, Transactional.class);
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass,
|
||||
Service.class, ContextConfiguration.class, Order.class, Transactional.class);
|
||||
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(startClass, descriptor.getRootDeclaringClass());
|
||||
assertEquals(annotationType, descriptor.getAnnotationType());
|
||||
assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
|
||||
assertArrayEquals(new Class[] { MetaConfig.DevConfig.class, MetaConfig.ProductionConfig.class },
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
assertArrayEquals(new Class<?>[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
|
||||
assertArrayEquals(new Class<?>[] {MetaConfig.DevConfig.class, MetaConfig.ProductionConfig.class},
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
assertNotNull(descriptor.getComposedAnnotation());
|
||||
assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() throws Exception {
|
||||
public void findAnnotationDescriptorForTypesWithMetaAnnotationWithOverriddenAttributes() {
|
||||
Class<?> startClass = MetaConfigWithOverriddenAttributesTestCase.class;
|
||||
Class<ContextConfiguration> annotationType = ContextConfiguration.class;
|
||||
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(startClass, Service.class,
|
||||
ContextConfiguration.class, Order.class, Transactional.class);
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
startClass, Service.class, ContextConfiguration.class, Order.class, Transactional.class);
|
||||
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(startClass, descriptor.getRootDeclaringClass());
|
||||
assertEquals(annotationType, descriptor.getAnnotationType());
|
||||
assertArrayEquals(new Class[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
|
||||
assertArrayEquals(new Class[] { MetaAnnotationUtilsTests.class },
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
assertArrayEquals(new Class<?>[] {}, ((ContextConfiguration) descriptor.getAnnotation()).value());
|
||||
assertArrayEquals(new Class<?>[] {MetaAnnotationUtilsTests.class},
|
||||
descriptor.getAnnotationAttributes().getClassArray("classes"));
|
||||
assertNotNull(descriptor.getComposedAnnotation());
|
||||
assertEquals(MetaConfig.class, descriptor.getComposedAnnotationType());
|
||||
}
|
||||
|
|
@ -412,13 +411,11 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesForClassWithMetaAnnotatedInterface() {
|
||||
Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class,
|
||||
Component.class);
|
||||
Component rawAnnotation = AnnotationUtils.findAnnotation(ClassWithMetaAnnotatedInterface.class, Component.class);
|
||||
|
||||
UntypedAnnotationDescriptor descriptor;
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
ClassWithMetaAnnotatedInterface.class, Service.class, Component.class, Order.class, Transactional.class);
|
||||
|
||||
descriptor = findAnnotationDescriptorForTypes(ClassWithMetaAnnotatedInterface.class, Service.class,
|
||||
Component.class, Order.class, Transactional.class);
|
||||
assertNotNull(descriptor);
|
||||
assertEquals(ClassWithMetaAnnotatedInterface.class, descriptor.getRootDeclaringClass());
|
||||
assertEquals(Meta1.class, descriptor.getDeclaringClass());
|
||||
|
|
@ -435,8 +432,8 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
public void findAnnotationDescriptorForTypesForSubClassWithLocalMetaAnnotationAndMetaAnnotatedInterface() {
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
SubClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class,
|
||||
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2", Meta2.class);
|
||||
SubClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class,
|
||||
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, "meta2", Meta2.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -445,8 +442,8 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
public void findAnnotationDescriptorForTypesOnMetaMetaAnnotatedClass() {
|
||||
Class<MetaMetaAnnotatedClass> startClass = MetaMetaAnnotatedClass.class;
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(startClass, startClass, Meta2.class, "meta2",
|
||||
MetaMeta.class);
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
startClass, startClass, Meta2.class, "meta2", MetaMeta.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -455,8 +452,8 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
public void findAnnotationDescriptorForTypesOnMetaMetaMetaAnnotatedClass() {
|
||||
Class<MetaMetaMetaAnnotatedClass> startClass = MetaMetaMetaAnnotatedClass.class;
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(startClass, startClass, Meta2.class, "meta2",
|
||||
MetaMetaMeta.class);
|
||||
assertAtComponentOnComposedAnnotationForMultipleCandidateTypes(
|
||||
startClass, startClass, Meta2.class, "meta2", MetaMetaMeta.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -467,8 +464,8 @@ public class MetaAnnotationUtilsTests {
|
|||
public void findAnnotationDescriptorForTypesOnAnnotatedClassWithMissingTargetMetaAnnotation() {
|
||||
// InheritedAnnotationClass is NOT annotated or meta-annotated with @Component,
|
||||
// @Service, or @Order, but it is annotated with @Transactional.
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(InheritedAnnotationClass.class,
|
||||
Service.class, Component.class, Order.class);
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
InheritedAnnotationClass.class, Service.class, Component.class, Order.class);
|
||||
assertNull("Should not find @Component on InheritedAnnotationClass", descriptor);
|
||||
}
|
||||
|
||||
|
|
@ -478,8 +475,8 @@ public class MetaAnnotationUtilsTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAnnotationDescriptorForTypesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(MetaCycleAnnotatedClass.class,
|
||||
Service.class, Component.class, Order.class);
|
||||
UntypedAnnotationDescriptor descriptor = findAnnotationDescriptorForTypes(
|
||||
MetaCycleAnnotatedClass.class, Service.class, Component.class, Order.class);
|
||||
assertNull("Should not find @Component on MetaCycleAnnotatedClass", descriptor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -46,20 +46,21 @@ public class TxNamespaceHandlerTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
this.context = new ClassPathXmlApplicationContext("txNamespaceHandlerTests.xml", getClass());
|
||||
this.getAgeMethod = ITestBean.class.getMethod("getAge", new Class[0]);
|
||||
this.setAgeMethod = ITestBean.class.getMethod("setAge", new Class[] {int.class});
|
||||
this.getAgeMethod = ITestBean.class.getMethod("getAge");
|
||||
this.setAgeMethod = ITestBean.class.getMethod("setAge", int.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void isProxy() throws Exception {
|
||||
public void isProxy() {
|
||||
ITestBean bean = getTestBean();
|
||||
assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeTransactional() throws Exception {
|
||||
public void invokeTransactional() {
|
||||
ITestBean testBean = getTestBean();
|
||||
CallCountingTransactionManager ptm = (CallCountingTransactionManager) context.getBean("transactionManager");
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ public class TxNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
private ITestBean getTestBean() {
|
||||
return (ITestBean)context.getBean("testBean");
|
||||
return (ITestBean) context.getBean("testBean");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -18,6 +18,7 @@ package org.springframework.transaction.interceptor;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
|
|
@ -57,16 +58,11 @@ public abstract class AbstractTransactionAspectTests {
|
|||
protected Method setNameMethod;
|
||||
|
||||
|
||||
public AbstractTransactionAspectTests() {
|
||||
try {
|
||||
// Cache the methods we'll be testing
|
||||
exceptionalMethod = ITestBean.class.getMethod("exceptional", new Class[] { Throwable.class });
|
||||
getNameMethod = ITestBean.class.getMethod("getName", (Class[]) null);
|
||||
setNameMethod = ITestBean.class.getMethod("setName", new Class[] { String.class} );
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new RuntimeException("Shouldn't happen", ex);
|
||||
}
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
exceptionalMethod = ITestBean.class.getMethod("exceptional", Throwable.class);
|
||||
getNameMethod = ITestBean.class.getMethod("getName");
|
||||
setNameMethod = ITestBean.class.getMethod("setName", String.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -43,7 +43,7 @@ public class TransactionAttributeSourceEditorTests {
|
|||
editor.setAsText(null);
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
Method m = Object.class.getMethod("hashCode", (Class[]) null);
|
||||
Method m = Object.class.getMethod("hashCode");
|
||||
assertNull(tas.getTransactionAttribute(m, null));
|
||||
}
|
||||
|
||||
|
|
@ -62,21 +62,21 @@ public class TransactionAttributeSourceEditorTests {
|
|||
"java.lang.Object.not*=PROPAGATION_REQUIRED");
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
checkTransactionProperties(tas, Object.class.getMethod("hashCode", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("hashCode"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("equals", new Class[] { Object.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("equals", Object.class),
|
||||
TransactionDefinition.PROPAGATION_MANDATORY);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait"),
|
||||
TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", new Class[] { long.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", long.class),
|
||||
TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", new Class[] { long.class, int.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", long.class, int.class),
|
||||
TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notify", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notify"),
|
||||
TransactionDefinition.PROPAGATION_SUPPORTS);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notifyAll", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notifyAll"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("toString", (Class[]) null), -1);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("toString"), -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -84,21 +84,21 @@ public class TransactionAttributeSourceEditorTests {
|
|||
editor.setAsText("java.lang.Object.*=PROPAGATION_REQUIRED");
|
||||
TransactionAttributeSource tas = (TransactionAttributeSource) editor.getValue();
|
||||
|
||||
checkTransactionProperties(tas, Object.class.getMethod("hashCode", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("hashCode"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("equals", new Class[] { Object.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("equals", Object.class),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", new Class[] { long.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", long.class),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", new Class[] { long.class, int.class }),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("wait", long.class, int.class),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notify", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notify"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notifyAll", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("notifyAll"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
checkTransactionProperties(tas, Object.class.getMethod("toString", (Class[]) null),
|
||||
checkTransactionProperties(tas, Object.class.getMethod("toString"),
|
||||
TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ public class TransactionAttributeSourceTests {
|
|||
public void matchAlwaysTransactionAttributeSource() throws Exception {
|
||||
MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||
Object.class.getMethod("hashCode", (Class[]) null), null);
|
||||
Object.class.getMethod("hashCode"), null);
|
||||
assertNotNull(ta);
|
||||
assertTrue(TransactionDefinition.PROPAGATION_REQUIRED == ta.getPropagationBehavior());
|
||||
|
||||
tas.setTransactionAttribute(new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_SUPPORTS));
|
||||
ta = tas.getTransactionAttribute(
|
||||
IOException.class.getMethod("getMessage", (Class[]) null), IOException.class);
|
||||
IOException.class.getMethod("getMessage"), IOException.class);
|
||||
assertNotNull(ta);
|
||||
assertTrue(TransactionDefinition.PROPAGATION_SUPPORTS == ta.getPropagationBehavior());
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ public class TransactionAttributeSourceTests {
|
|||
attributes.put("*ashCode", "PROPAGATION_REQUIRED");
|
||||
tas.setProperties(attributes);
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||
Object.class.getMethod("hashCode", (Class[]) null), null);
|
||||
Object.class.getMethod("hashCode"), null);
|
||||
assertNotNull(ta);
|
||||
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public class TransactionAttributeSourceTests {
|
|||
attributes.put("hashCod*", "PROPAGATION_REQUIRED");
|
||||
tas.setProperties(attributes);
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||
Object.class.getMethod("hashCode", (Class[]) null), null);
|
||||
Object.class.getMethod("hashCode"), null);
|
||||
assertNotNull(ta);
|
||||
assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, ta.getPropagationBehavior());
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ public class TransactionAttributeSourceTests {
|
|||
attributes.put("hashCode", "PROPAGATION_MANDATORY");
|
||||
tas.setProperties(attributes);
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||
Object.class.getMethod("hashCode", (Class[]) null), null);
|
||||
Object.class.getMethod("hashCode"), null);
|
||||
assertNotNull(ta);
|
||||
assertEquals(TransactionDefinition.PROPAGATION_MANDATORY, ta.getPropagationBehavior());
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ public class TransactionAttributeSourceTests {
|
|||
attributes.put("", "PROPAGATION_MANDATORY");
|
||||
tas.setProperties(attributes);
|
||||
TransactionAttribute ta = tas.getTransactionAttribute(
|
||||
Object.class.getMethod("hashCode", (Class[]) null), null);
|
||||
Object.class.getMethod("hashCode"), null);
|
||||
assertNull(ta);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -47,6 +47,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
|||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
||||
@Override
|
||||
protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) throws Exception {
|
||||
TransactionInterceptor ti = new TransactionInterceptor();
|
||||
|
|
@ -76,6 +77,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
|||
return pf.getProxy();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A TransactionInterceptor should be serializable if its
|
||||
* PlatformTransactionManager is.
|
||||
|
|
@ -109,7 +111,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
|||
tas2.setProperties(props);
|
||||
|
||||
TransactionInterceptor ti = new TransactionInterceptor();
|
||||
ti.setTransactionAttributeSources(new TransactionAttributeSource[] {tas1, tas2});
|
||||
ti.setTransactionAttributeSources(tas1, tas2);
|
||||
PlatformTransactionManager ptm = new SerializableTransactionManager();
|
||||
ti.setTransactionManager(ptm);
|
||||
ti = (TransactionInterceptor) SerializationTestUtils.serializeAndDeserialize(ti);
|
||||
|
|
@ -255,8 +257,10 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
|||
verify(beanFactory, times(1)).getBean(PlatformTransactionManager.class);
|
||||
}
|
||||
|
||||
|
||||
private TransactionInterceptor createTransactionInterceptor(BeanFactory beanFactory,
|
||||
String transactionManagerName, PlatformTransactionManager transactionManager) {
|
||||
|
||||
TransactionInterceptor ti = new TransactionInterceptor();
|
||||
if (beanFactory != null) {
|
||||
ti.setBeanFactory(beanFactory);
|
||||
|
|
@ -317,6 +321,6 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
|||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -80,7 +80,7 @@ public class SimpleMappingExceptionResolverTests {
|
|||
@Test
|
||||
public void defaultErrorViewDifferentHandlerClass() {
|
||||
exceptionResolver.setDefaultErrorView("default-view");
|
||||
exceptionResolver.setMappedHandlerClasses(new Class[] {String.class});
|
||||
exceptionResolver.setMappedHandlerClasses(String.class);
|
||||
ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException);
|
||||
assertNull(mav);
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ public class SimpleMappingExceptionResolverTests {
|
|||
public void exactExceptionMappingWithHandlerClassSpecified() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("java.lang.Exception", "error");
|
||||
exceptionResolver.setMappedHandlerClasses(new Class[] {String.class});
|
||||
exceptionResolver.setMappedHandlerClasses(String.class);
|
||||
exceptionResolver.setExceptionMappings(props);
|
||||
ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException);
|
||||
assertEquals("error", mav.getViewName());
|
||||
|
|
@ -171,7 +171,7 @@ public class SimpleMappingExceptionResolverTests {
|
|||
public void exactExceptionMappingWithHandlerInterfaceSpecified() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("java.lang.Exception", "error");
|
||||
exceptionResolver.setMappedHandlerClasses(new Class[] {Comparable.class});
|
||||
exceptionResolver.setMappedHandlerClasses(Comparable.class);
|
||||
exceptionResolver.setExceptionMappings(props);
|
||||
ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException);
|
||||
assertEquals("error", mav.getViewName());
|
||||
|
|
@ -191,7 +191,7 @@ public class SimpleMappingExceptionResolverTests {
|
|||
public void simpleExceptionMappingWithHandlerClassSpecifiedButWrongHandler() {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("Exception", "error");
|
||||
exceptionResolver.setMappedHandlerClasses(new Class[] {String.class});
|
||||
exceptionResolver.setMappedHandlerClasses(String.class);
|
||||
exceptionResolver.setExceptionMappings(props);
|
||||
ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException);
|
||||
assertNull(mav);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
|
|
@ -44,6 +42,9 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.ControllerAdviceBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RequestResponseBodyAdviceChain}.
|
||||
*
|
||||
|
|
@ -80,7 +81,6 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void requestBodyAdvice() throws IOException {
|
||||
|
||||
RequestBodyAdvice requestAdvice = Mockito.mock(RequestBodyAdvice.class);
|
||||
ResponseBodyAdvice<String> responseAdvice = Mockito.mock(ResponseBodyAdvice.class);
|
||||
List<Object> advice = Arrays.asList(requestAdvice, responseAdvice);
|
||||
|
|
@ -104,7 +104,6 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void responseBodyAdvice() {
|
||||
|
||||
RequestBodyAdvice requestAdvice = Mockito.mock(RequestBodyAdvice.class);
|
||||
ResponseBodyAdvice<String> responseAdvice = Mockito.mock(ResponseBodyAdvice.class);
|
||||
List<Object> advice = Arrays.asList(requestAdvice, responseAdvice);
|
||||
|
|
@ -123,9 +122,8 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
|
||||
@Test
|
||||
public void controllerAdvice() {
|
||||
|
||||
Object adviceBean = new ControllerAdviceBean(new MyControllerAdvice());
|
||||
RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Arrays.asList(adviceBean));
|
||||
RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));
|
||||
|
||||
String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
|
||||
this.converterType, this.request, this.response);
|
||||
|
|
@ -135,9 +133,8 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
|
||||
@Test
|
||||
public void controllerAdviceNotApplicable() {
|
||||
|
||||
Object adviceBean = new ControllerAdviceBean(new TargetedControllerAdvice());
|
||||
RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Arrays.asList(adviceBean));
|
||||
RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));
|
||||
|
||||
String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
|
||||
this.converterType, this.request, this.response);
|
||||
|
|
@ -164,6 +161,7 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@ControllerAdvice(annotations = Controller.class)
|
||||
private static class TargetedControllerAdvice implements ResponseBodyAdvice<String> {
|
||||
|
||||
|
|
@ -182,6 +180,7 @@ public class RequestResponseBodyAdviceChainTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ResponseBody
|
||||
public String handle(String body) {
|
||||
|
|
|
|||
|
|
@ -1089,7 +1089,7 @@ expression string.
|
|||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
|
||||
context.registerFunction("reverseString",
|
||||
StringUtils.class.getDeclaredMethod("reverseString", new Class[] { String.class }));
|
||||
StringUtils.class.getDeclaredMethod("reverseString", String.class));
|
||||
|
||||
String helloWorldReversed = parser.parseExpression(
|
||||
"#reverseString('hello')").getValue(context, String.class);
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ This is recommended for applications that use Java-based Spring configuration:
|
|||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
return new Class[] { MyWebConfig.class };
|
||||
return new Class<?>[] { MyWebConfig.class };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue