parent
c926ec477a
commit
1932a9d729
|
@ -1,6 +1,5 @@
|
|||
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,27 +28,21 @@ public class NopInterceptor implements MethodInterceptor {
|
|||
|
||||
private int count;
|
||||
|
||||
/**
|
||||
* @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
increment();
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
protected void increment() {
|
||||
this.count++;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
protected void increment() {
|
||||
++count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
@ -62,5 +55,9 @@ public class NopInterceptor implements MethodInterceptor {
|
|||
return this.count == ((NopInterceptor) other).count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return NopInterceptor.class.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,22 +28,10 @@ import org.springframework.util.ObjectUtils;
|
|||
@SuppressWarnings("serial")
|
||||
public class SerializablePerson implements Person, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -55,6 +43,16 @@ public class SerializablePerson implements Person, Serializable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object echo(Object o) throws Throwable {
|
||||
if (o instanceof Throwable) {
|
||||
|
@ -63,10 +61,6 @@ public class SerializablePerson implements Person, Serializable {
|
|||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
@ -77,4 +71,9 @@ public class SerializablePerson implements Person, Serializable {
|
|||
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return SerializablePerson.class.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -223,7 +223,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
|||
|
||||
@Override
|
||||
public ITestBean[] getSpouses() {
|
||||
return (spouse != null ? new ITestBean[]{spouse} : null);
|
||||
return (spouse != null ? new ITestBean[] {spouse} : null);
|
||||
}
|
||||
|
||||
public String getTouchy() {
|
||||
|
|
|
@ -124,6 +124,7 @@ public class AsyncExecutionTests {
|
|||
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
|
||||
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
|
||||
context.refresh();
|
||||
|
||||
SimpleInterface asyncTest = context.getBean("asyncTest", SimpleInterface.class);
|
||||
asyncTest.doNothing(5);
|
||||
asyncTest.doSomething(10);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,6 @@ import static org.junit.Assert.*;
|
|||
/**
|
||||
* @author Keith Donald
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class ToStringCreatorTests {
|
||||
|
||||
private SomeObject s1, s2, s3;
|
||||
|
@ -63,20 +62,20 @@ public class ToStringCreatorTests {
|
|||
|
||||
@Test
|
||||
public void defaultStyleMap() {
|
||||
final Map map = getMap();
|
||||
final Map<String, String> map = getMap();
|
||||
Object stringy = new Object() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("familyFavoriteSport", map).toString();
|
||||
}
|
||||
};
|
||||
assertEquals("[ToStringCreatorTests.4@" + ObjectUtils.getIdentityHexString(stringy)
|
||||
+ " familyFavoriteSport = map['Keri' -> 'Softball', 'Scot' -> 'Fishing', 'Keith' -> 'Flag Football']]",
|
||||
assertEquals("[ToStringCreatorTests.4@" + ObjectUtils.getIdentityHexString(stringy) +
|
||||
" familyFavoriteSport = map['Keri' -> 'Softball', 'Scot' -> 'Fishing', 'Keith' -> 'Flag Football']]",
|
||||
stringy.toString());
|
||||
}
|
||||
|
||||
private Map getMap() {
|
||||
Map map = new LinkedHashMap(3);
|
||||
private Map<String, String> getMap() {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("Keri", "Softball");
|
||||
map.put("Scot", "Fishing");
|
||||
map.put("Keith", "Flag Football");
|
||||
|
@ -85,22 +84,22 @@ public class ToStringCreatorTests {
|
|||
|
||||
@Test
|
||||
public void defaultStyleArray() {
|
||||
SomeObject[] array = new SomeObject[] { s1, s2, s3 };
|
||||
SomeObject[] array = new SomeObject[] {s1, s2, s3};
|
||||
String str = new ToStringCreator(array).toString();
|
||||
assertEquals("[@" + ObjectUtils.getIdentityHexString(array)
|
||||
+ " array<ToStringCreatorTests.SomeObject>[A, B, C]]", str);
|
||||
assertEquals("[@" + ObjectUtils.getIdentityHexString(array) +
|
||||
" array<ToStringCreatorTests.SomeObject>[A, B, C]]", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitiveArrays() {
|
||||
int[] integers = new int[] { 0, 1, 2, 3, 4 };
|
||||
int[] integers = new int[] {0, 1, 2, 3, 4};
|
||||
String str = new ToStringCreator(integers).toString();
|
||||
assertEquals("[@" + ObjectUtils.getIdentityHexString(integers) + " array<Integer>[0, 1, 2, 3, 4]]", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendList() {
|
||||
List list = new ArrayList();
|
||||
List<SomeObject> list = new ArrayList<>();
|
||||
list.add(s1);
|
||||
list.add(s2);
|
||||
list.add(s3);
|
||||
|
@ -111,28 +110,26 @@ public class ToStringCreatorTests {
|
|||
|
||||
@Test
|
||||
public void appendSet() {
|
||||
Set set = new LinkedHashSet<>(3);
|
||||
Set<SomeObject> set = new LinkedHashSet<>();
|
||||
set.add(s1);
|
||||
set.add(s2);
|
||||
set.add(s3);
|
||||
String str = new ToStringCreator(this).append("myLetters", set).toString();
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myLetters = set[A, B, C]]",
|
||||
str);
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myLetters = set[A, B, C]]", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendClass() {
|
||||
String str = new ToStringCreator(this).append("myClass", this.getClass()).toString();
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this)
|
||||
+ " myClass = ToStringCreatorTests]", str);
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) +
|
||||
" myClass = ToStringCreatorTests]", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendMethod() throws Exception {
|
||||
String str = new ToStringCreator(this).append("myMethod", this.getClass().getMethod("appendMethod"))
|
||||
.toString();
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this)
|
||||
+ " myMethod = appendMethod@ToStringCreatorTests]", str);
|
||||
String str = new ToStringCreator(this).append("myMethod", this.getClass().getMethod("appendMethod")).toString();
|
||||
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) +
|
||||
" myMethod = appendMethod@ToStringCreatorTests]", str);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -79,7 +79,7 @@ public class MethodInvokerTests {
|
|||
MethodInvoker methodInvoker = new MethodInvoker();
|
||||
methodInvoker.setTargetObject(new Greeter());
|
||||
methodInvoker.setTargetMethod("greet");
|
||||
methodInvoker.setArguments(new Object[] { new String("no match") });
|
||||
methodInvoker.setArguments(new Object[] {"no match"});
|
||||
|
||||
exception.expect(NoSuchMethodException.class);
|
||||
methodInvoker.prepare();
|
||||
|
@ -199,6 +199,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class Greeter {
|
||||
|
||||
|
@ -223,13 +224,17 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private interface Greetable {
|
||||
|
||||
String getGreeting();
|
||||
}
|
||||
|
||||
|
||||
private interface Person extends Greetable {
|
||||
}
|
||||
|
||||
|
||||
private static class Purchaser implements Greetable {
|
||||
|
||||
@Override
|
||||
|
@ -238,6 +243,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Shopper extends Purchaser implements Person {
|
||||
|
||||
@Override
|
||||
|
@ -246,6 +252,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Salesman implements Person {
|
||||
|
||||
@Override
|
||||
|
@ -254,6 +261,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Customer extends Shopper {
|
||||
|
||||
@Override
|
||||
|
@ -262,6 +270,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Regular extends Customer {
|
||||
|
||||
private String name;
|
||||
|
@ -276,6 +285,7 @@ public class MethodInvokerTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class VIP extends Regular {
|
||||
|
||||
public VIP(String name) {
|
||||
|
|
|
@ -29,8 +29,6 @@ import javax.sql.DataSource;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
@ -49,7 +47,7 @@ public class GenericSqlQueryTests {
|
|||
private static final String SELECT_ID_FORENAME_NAMED_PARAMETERS_PARSED =
|
||||
"select id, forename from custmr where id = ? and country = ?";
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
|
@ -61,7 +59,7 @@ public class GenericSqlQueryTests {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
new ClassPathResource("org/springframework/jdbc/object/GenericSqlQueryTests-context.xml"));
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
this.connection = mock(Connection.class);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
|
||||
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.TestDataSourceWrapper"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -83,7 +83,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
public void readXmlRootElementList() throws Exception {
|
||||
String content = "<list><rootElement><type s=\"1\"/></rootElement><rootElement><type s=\"2\"/></rootElement></list>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
|
||||
|
||||
List<RootElement> result = (List<RootElement>) converter.read(rootElementListType, null, inputMessage);
|
||||
|
||||
assertEquals("Invalid result", 2, result.size());
|
||||
|
@ -96,7 +95,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
public void readXmlRootElementSet() throws Exception {
|
||||
String content = "<set><rootElement><type s=\"1\"/></rootElement><rootElement><type s=\"2\"/></rootElement></set>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
|
||||
|
||||
Set<RootElement> result = (Set<RootElement>) converter.read(rootElementSetType, null, inputMessage);
|
||||
|
||||
assertEquals("Invalid result", 2, result.size());
|
||||
|
@ -109,7 +107,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
public void readXmlTypeList() throws Exception {
|
||||
String content = "<list><foo s=\"1\"/><bar s=\"2\"/></list>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
|
||||
|
||||
List<TestType> result = (List<TestType>) converter.read(typeListType, null, inputMessage);
|
||||
|
||||
assertEquals("Invalid result", 2, result.size());
|
||||
|
@ -122,7 +119,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
public void readXmlTypeSet() throws Exception {
|
||||
String content = "<set><foo s=\"1\"/><bar s=\"2\"/></set>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
|
||||
|
||||
Set<TestType> result = (Set<TestType>) converter.read(typeSetType, null, inputMessage);
|
||||
|
||||
assertEquals("Invalid result", 2, result.size());
|
||||
|
@ -133,7 +129,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readXmlRootElementExternalEntityDisabled() throws Exception {
|
||||
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
String content = "<!DOCTYPE root [" +
|
||||
" <!ELEMENT external ANY >\n" +
|
||||
|
@ -142,7 +137,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
|
||||
|
||||
converter = new Jaxb2CollectionHttpMessageConverter<Collection<Object>>() {
|
||||
|
||||
@Override
|
||||
protected XMLInputFactory createXmlInputFactory() {
|
||||
XMLInputFactory inputFactory = super.createXmlInputFactory();
|
||||
|
@ -164,7 +158,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readXmlRootElementExternalEntityEnabled() throws Exception {
|
||||
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
String content = "<!DOCTYPE root [" +
|
||||
" <!ELEMENT external ANY >\n" +
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.accept;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
Loading…
Reference in New Issue