Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
32bea88e
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
32bea88e
编写于
12月 13, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moving unit tests from .testsuite -> .aop
上级
e3ec177a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
216 addition
and
62 deletion
+216
-62
org.springframework.aop/src/test/java/org/springframework/aop/interceptor/SerializableNopInterceptor.java
...framework/aop/interceptor/SerializableNopInterceptor.java
+45
-0
org.springframework.aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java
...va/org/springframework/aop/support/ClassFiltersTests.java
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java
...k/aop/support/DelegatingIntroductionInterceptorTests.java
+35
-44
org.springframework.aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
.../org/springframework/aop/support/MethodMatchersTests.java
+11
-4
org.springframework.aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
...ngframework/aop/support/NameMatchMethodPointcutTests.java
+13
-8
org.springframework.aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
.../support/RegexpMethodPointcutAdvisorIntegrationTests.java
+12
-6
org.springframework.aop/src/test/java/org/springframework/aop/support/regexpSetterTests.xml
...ava/org/springframework/aop/support/regexpSetterTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/beans/Person.java
...k.aop/src/test/java/org/springframework/beans/Person.java
+36
-0
org.springframework.aop/src/test/java/org/springframework/beans/SerializablePerson.java
...st/java/org/springframework/beans/SerializablePerson.java
+64
-0
未找到文件。
org.springframework.aop/src/test/java/org/springframework/aop/interceptor/SerializableNopInterceptor.java
0 → 100644
浏览文件 @
32bea88e
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.aop.interceptor
;
import
java.io.Serializable
;
/**
* Subclass of NopInterceptor that is serializable and
* can be used to test proxy serialization.
*
* @author Rod Johnson
*/
public
class
SerializableNopInterceptor
extends
NopInterceptor
implements
Serializable
{
/**
* We must override this field and the related methods as
* otherwise count won't be serialized from the non-serializable
* NopInterceptor superclass.
*/
private
int
count
;
public
int
getCount
()
{
return
this
.
count
;
}
protected
void
increment
()
{
++
count
;
}
}
\ No newline at end of file
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/ClassFiltersTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/ClassFiltersTests.java
浏览文件 @
32bea88e
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java
浏览文件 @
32bea88e
...
...
@@ -16,12 +16,13 @@
package
org.springframework.aop.support
;
import
static
org
.
easymock
.
EasyMock
.*;
import
static
org
.
junit
.
Assert
.*;
import
java.io.Serializable
;
import
junit.framework.TestCase
;
import
org.aopalliance.intercept.MethodInterceptor
;
import
org.easymock.MockControl
;
import
org.junit.Test
;
import
org.springframework.aop.IntroductionAdvisor
;
import
org.springframework.aop.IntroductionInterceptor
;
import
org.springframework.aop.framework.ProxyFactory
;
...
...
@@ -37,71 +38,65 @@ import org.springframework.util.SerializationTestUtils;
/**
* @author Rod Johnson
* @author Chris Beams
* @since 13.05.2003
*/
public
class
DelegatingIntroductionInterceptorTests
extends
TestCase
{
public
class
DelegatingIntroductionInterceptorTests
{
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testNullTarget
()
throws
Exception
{
try
{
IntroductionInterceptor
ii
=
new
DelegatingIntroductionInterceptor
(
null
);
fail
(
"Shouldn't accept null target"
);
}
catch
(
IllegalArgumentException
ex
)
{
// OK
}
// Shouldn't accept null target
new
DelegatingIntroductionInterceptor
(
null
);
}
@Test
public
void
testIntroductionInterceptorWithDelegation
()
throws
Exception
{
TestBean
raw
=
new
TestBean
();
assertTrue
(!
(
raw
instanceof
TimeStamped
));
ProxyFactory
factory
=
new
ProxyFactory
(
raw
);
MockControl
tsControl
=
MockControl
.
createControl
(
TimeStamped
.
class
);
TimeStamped
ts
=
(
TimeStamped
)
tsControl
.
getMock
();
ts
.
getTimeStamp
();
TimeStamped
ts
=
createMock
(
TimeStamped
.
class
);
long
timestamp
=
111L
;
tsControl
.
setReturnValue
(
timestamp
,
1
);
tsControl
.
replay
(
);
expect
(
ts
.
getTimeStamp
()).
andReturn
(
timestamp
);
replay
(
ts
);
factory
.
addAdvisor
(
0
,
new
DefaultIntroductionAdvisor
(
new
DelegatingIntroductionInterceptor
(
ts
)));
TimeStamped
tsp
=
(
TimeStamped
)
factory
.
getProxy
();
assertTrue
(
tsp
.
getTimeStamp
()
==
timestamp
);
tsControl
.
verify
(
);
verify
(
ts
);
}
@Test
public
void
testIntroductionInterceptorWithInterfaceHierarchy
()
throws
Exception
{
TestBean
raw
=
new
TestBean
();
assertTrue
(!
(
raw
instanceof
SubTimeStamped
));
ProxyFactory
factory
=
new
ProxyFactory
(
raw
);
MockControl
tsControl
=
MockControl
.
createControl
(
SubTimeStamped
.
class
);
SubTimeStamped
ts
=
(
SubTimeStamped
)
tsControl
.
getMock
();
ts
.
getTimeStamp
();
TimeStamped
ts
=
createMock
(
SubTimeStamped
.
class
);
long
timestamp
=
111L
;
tsControl
.
setReturnValue
(
timestamp
,
1
);
tsControl
.
replay
(
);
expect
(
ts
.
getTimeStamp
()).
andReturn
(
timestamp
);
replay
(
ts
);
factory
.
addAdvisor
(
0
,
new
DefaultIntroductionAdvisor
(
new
DelegatingIntroductionInterceptor
(
ts
),
SubTimeStamped
.
class
));
SubTimeStamped
tsp
=
(
SubTimeStamped
)
factory
.
getProxy
();
assertTrue
(
tsp
.
getTimeStamp
()
==
timestamp
);
tsControl
.
verify
(
);
verify
(
ts
);
}
@Test
public
void
testIntroductionInterceptorWithSuperInterface
()
throws
Exception
{
TestBean
raw
=
new
TestBean
();
assertTrue
(!
(
raw
instanceof
TimeStamped
));
ProxyFactory
factory
=
new
ProxyFactory
(
raw
);
MockControl
tsControl
=
MockControl
.
createControl
(
SubTimeStamped
.
class
);
SubTimeStamped
ts
=
(
SubTimeStamped
)
tsControl
.
getMock
();
ts
.
getTimeStamp
();
TimeStamped
ts
=
createMock
(
SubTimeStamped
.
class
);
long
timestamp
=
111L
;
tsControl
.
setReturnValue
(
timestamp
,
1
);
tsControl
.
replay
(
);
expect
(
ts
.
getTimeStamp
()).
andReturn
(
timestamp
);
replay
(
ts
);
factory
.
addAdvisor
(
0
,
new
DefaultIntroductionAdvisor
(
new
DelegatingIntroductionInterceptor
(
ts
),
TimeStamped
.
class
));
...
...
@@ -109,9 +104,10 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
assertTrue
(!(
tsp
instanceof
SubTimeStamped
));
assertTrue
(
tsp
.
getTimeStamp
()
==
timestamp
);
tsControl
.
verify
(
);
verify
(
ts
);
}
@Test
public
void
testAutomaticInterfaceRecognitionInDelegate
()
throws
Exception
{
final
long
t
=
1001L
;
class
Tester
implements
TimeStamped
,
ITester
{
...
...
@@ -139,8 +135,10 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
}
@Test
public
void
testAutomaticInterfaceRecognitionInSubclass
()
throws
Exception
{
final
long
t
=
1001L
;
@SuppressWarnings
(
"serial"
)
class
TestII
extends
DelegatingIntroductionInterceptor
implements
TimeStamped
,
ITester
{
public
void
foo
()
throws
Exception
{
}
...
...
@@ -180,6 +178,8 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
assertTrue
(!(
o
instanceof
TimeStamped
));
}
@SuppressWarnings
(
"serial"
)
@Test
public
void
testIntroductionInterceptorDoesntReplaceToString
()
throws
Exception
{
TestBean
raw
=
new
TestBean
();
assertTrue
(!
(
raw
instanceof
TimeStamped
));
...
...
@@ -199,6 +199,7 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
assertEquals
(
raw
.
toString
(),
tsp
.
toString
());
}
@Test
public
void
testDelegateReturnsThisIsMassagedToReturnProxy
()
{
NestedTestBean
target
=
new
NestedTestBean
();
String
company
=
"Interface21"
;
...
...
@@ -218,6 +219,7 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
assertTrue
(
"Introduced method returning delegate returns proxy"
,
AopUtils
.
isAopProxy
(
introduction
.
getSpouse
()));
}
@Test
public
void
testSerializableDelegatingIntroductionInterceptorSerializable
()
throws
Exception
{
SerializablePerson
serializableTarget
=
new
SerializablePerson
();
String
name
=
"Tony"
;
...
...
@@ -241,23 +243,11 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
assertEquals
(
time
,
((
TimeStamped
)
p1
).
getTimeStamp
());
}
// public void testDelegatingIntroductionInterceptorDoesntMakeNonserializableSerializable() throws Exception {
// // Target is NOT serialiable
// TestBean raw = new TestBean();
// ProxyFactory factory = new ProxyFactory(raw);
// factory.addInterface(Person.class);
// long time = 1000;
// TimeStamped ts = new SerializableTimeStamped(time);
//
// factory.addAdvisor(new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
// Object proxy = factory.getProxy();
//
// assertFalse(proxy instanceof Serializable);
// }
// Test when target implements the interface: should get interceptor by preference.
@Test
public
void
testIntroductionMasksTargetImplementation
()
throws
Exception
{
final
long
t
=
1001L
;
@SuppressWarnings
(
"serial"
)
class
TestII
extends
DelegatingIntroductionInterceptor
implements
TimeStamped
{
public
long
getTimeStamp
()
{
return
t
;
...
...
@@ -278,6 +268,7 @@ public class DelegatingIntroductionInterceptorTests extends TestCase {
}
@SuppressWarnings
(
"serial"
)
private
static
class
SerializableTimeStamped
implements
TimeStamped
,
Serializable
{
private
final
long
ts
;
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/MethodMatchersTests.java
浏览文件 @
32bea88e
...
...
@@ -16,10 +16,11 @@
package
org.springframework.aop.support
;
import
java.lang.reflect.Method
;
import
static
org
.
junit
.
Assert
.*
;
import
j
unit.framework.TestCase
;
import
j
ava.lang.reflect.Method
;
import
org.junit.Test
;
import
org.springframework.aop.MethodMatcher
;
import
org.springframework.beans.IOther
;
import
org.springframework.beans.ITestBean
;
...
...
@@ -27,9 +28,10 @@ import org.springframework.beans.TestBean;
import
org.springframework.util.SerializationTestUtils
;
/**
* $Id: MethodMatchersTests.java,v 1.7 2005/03/25 09:28:18 jhoeller Exp $
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
MethodMatchersTests
extends
TestCase
{
public
class
MethodMatchersTests
{
private
final
Method
EXCEPTION_GETMESSAGE
;
...
...
@@ -46,16 +48,19 @@ public class MethodMatchersTests extends TestCase {
IOTHER_ABSQUATULATE
=
IOther
.
class
.
getMethod
(
"absquatulate"
,
(
Class
[])
null
);
}
@Test
public
void
testDefaultMatchesAll
()
throws
Exception
{
MethodMatcher
defaultMm
=
MethodMatcher
.
TRUE
;
assertTrue
(
defaultMm
.
matches
(
EXCEPTION_GETMESSAGE
,
Exception
.
class
));
assertTrue
(
defaultMm
.
matches
(
ITESTBEAN_SETAGE
,
TestBean
.
class
));
}
@Test
public
void
testMethodMatcherTrueSerializable
()
throws
Exception
{
assertSame
(
SerializationTestUtils
.
serializeAndDeserialize
(
MethodMatcher
.
TRUE
),
MethodMatcher
.
TRUE
);
}
@Test
public
void
testSingle
()
throws
Exception
{
MethodMatcher
defaultMm
=
MethodMatcher
.
TRUE
;
assertTrue
(
defaultMm
.
matches
(
EXCEPTION_GETMESSAGE
,
Exception
.
class
));
...
...
@@ -67,6 +72,7 @@ public class MethodMatchersTests extends TestCase {
}
@Test
public
void
testDynamicAndStaticMethodMatcherIntersection
()
throws
Exception
{
MethodMatcher
mm1
=
MethodMatcher
.
TRUE
;
MethodMatcher
mm2
=
new
TestDynamicMethodMatcherWhichMatches
();
...
...
@@ -81,6 +87,7 @@ public class MethodMatchersTests extends TestCase {
assertFalse
(
"3 - not Matched setAge method"
,
intersection
.
matches
(
ITESTBEAN_SETAGE
,
TestBean
.
class
,
new
Object
[]
{
new
Integer
(
5
)
}));
}
@Test
public
void
testStaticMethodMatcherUnion
()
throws
Exception
{
MethodMatcher
getterMatcher
=
new
StartsWithMatcher
(
"get"
);
MethodMatcher
setterMatcher
=
new
StartsWithMatcher
(
"set"
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java
浏览文件 @
32bea88e
...
...
@@ -16,8 +16,10 @@
package
org.springframework.aop.support
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.aop.framework.Advised
;
import
org.springframework.aop.framework.ProxyFactory
;
import
org.springframework.aop.interceptor.NopInterceptor
;
...
...
@@ -27,10 +29,10 @@ import org.springframework.beans.SerializablePerson;
import
org.springframework.util.SerializationTestUtils
;
/**
*
* @author Rod Johnson
* @author Chris Beams
*/
public
class
NameMatchMethodPointcutTests
extends
TestCase
{
public
class
NameMatchMethodPointcutTests
{
protected
NameMatchMethodPointcut
pc
;
...
...
@@ -38,15 +40,12 @@ public class NameMatchMethodPointcutTests extends TestCase {
protected
SerializableNopInterceptor
nop
;
public
NameMatchMethodPointcutTests
(
String
s
)
{
super
(
s
);
}
/**
* Create an empty pointcut, populating instance variables.
* @see junit.framework.TestCase#setUp()
*/
protected
void
setUp
()
{
@Before
public
void
setUp
()
{
ProxyFactory
pf
=
new
ProxyFactory
(
new
SerializablePerson
());
nop
=
new
SerializableNopInterceptor
();
pc
=
new
NameMatchMethodPointcut
();
...
...
@@ -54,6 +53,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
proxied
=
(
Person
)
pf
.
getProxy
();
}
@Test
public
void
testMatchingOnly
()
{
// Can't do exact matching through isMatch
assertTrue
(
pc
.
isMatch
(
"echo"
,
"ech*"
));
...
...
@@ -64,6 +64,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
assertTrue
(
pc
.
isMatch
(
"testing"
,
"*ing"
));
}
@Test
public
void
testEmpty
()
throws
Throwable
{
assertEquals
(
0
,
nop
.
getCount
());
proxied
.
getName
();
...
...
@@ -73,6 +74,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
}
@Test
public
void
testMatchOneMethod
()
throws
Throwable
{
pc
.
addMethodName
(
"echo"
);
pc
.
addMethodName
(
"set*"
);
...
...
@@ -90,6 +92,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
assertEquals
(
3
,
nop
.
getCount
());
}
@Test
public
void
testSets
()
throws
Throwable
{
pc
.
setMappedNames
(
new
String
[]
{
"set*"
,
"echo"
});
assertEquals
(
0
,
nop
.
getCount
());
...
...
@@ -100,6 +103,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
assertEquals
(
2
,
nop
.
getCount
());
}
@Test
public
void
testSerializable
()
throws
Throwable
{
testSets
();
// Count is now 2
...
...
@@ -111,6 +115,7 @@ public class NameMatchMethodPointcutTests extends TestCase {
assertEquals
(
3
,
nop2
.
getCount
());
}
@Test
public
void
testEqualsAndHashCode
()
throws
Exception
{
NameMatchMethodPointcut
pc1
=
new
NameMatchMethodPointcut
();
NameMatchMethodPointcut
pc2
=
new
NameMatchMethodPointcut
();
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
浏览文件 @
32bea88e
...
...
@@ -16,8 +16,9 @@
package
org.springframework.aop.support
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.springframework.aop.framework.Advised
;
import
org.springframework.aop.interceptor.NopInterceptor
;
import
org.springframework.aop.interceptor.SerializableNopInterceptor
;
...
...
@@ -25,16 +26,19 @@ import org.springframework.beans.ITestBean;
import
org.springframework.beans.Person
;
import
org.springframework.beans.TestBean
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.util.SerializationTestUtils
;
/**
* @author Rod Johnson
* @author Chris Beams
*/
public
class
RegexpMethodPointcutAdvisorIntegrationTests
extends
TestCase
{
public
class
RegexpMethodPointcutAdvisorIntegrationTests
{
@Test
public
void
testSinglePattern
()
throws
Throwable
{
BeanFactory
bf
=
new
ClassPathXmlApplicationContext
(
"org/springframework/aop/support/regexpSetterTests.xml"
);
BeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"regexpSetterTests.xml"
,
getClass
())
);
ITestBean
advised
=
(
ITestBean
)
bf
.
getBean
(
"settersAdvised"
);
// Interceptor behind regexp advisor
NopInterceptor
nop
=
(
NopInterceptor
)
bf
.
getBean
(
"nopInterceptor"
);
...
...
@@ -50,8 +54,9 @@ public class RegexpMethodPointcutAdvisorIntegrationTests extends TestCase {
assertEquals
(
1
,
nop
.
getCount
());
}
@Test
public
void
testMultiplePatterns
()
throws
Throwable
{
BeanFactory
bf
=
new
ClassPathXmlApplicationContext
(
"org/springframework/aop/support/regexpSetterTests.xml"
);
BeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"regexpSetterTests.xml"
,
getClass
())
);
// This is a CGLIB proxy, so we can proxy it to the target class
TestBean
advised
=
(
TestBean
)
bf
.
getBean
(
"settersAndAbsquatulateAdvised"
);
// Interceptor behind regexp advisor
...
...
@@ -72,8 +77,9 @@ public class RegexpMethodPointcutAdvisorIntegrationTests extends TestCase {
assertEquals
(
2
,
nop
.
getCount
());
}
@Test
public
void
testSerialization
()
throws
Throwable
{
BeanFactory
bf
=
new
ClassPathXmlApplicationContext
(
"org/springframework/aop/support/regexpSetterTests.xml"
);
BeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"regexpSetterTests.xml"
,
getClass
())
);
// This is a CGLIB proxy, so we can proxy it to the target class
Person
p
=
(
Person
)
bf
.
getBean
(
"serializableSettersAdvised"
);
// Interceptor behind regexp advisor
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/support/regexpSetterTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/support/regexpSetterTests.xml
浏览文件 @
32bea88e
文件已移动
org.springframework.aop/src/test/java/org/springframework/beans/Person.java
0 → 100644
浏览文件 @
32bea88e
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.beans
;
/**
*
* @author Rod Johnson
*/
public
interface
Person
{
String
getName
();
void
setName
(
String
name
);
int
getAge
();
void
setAge
(
int
i
);
/**
* Test for non-property method matching.
* If the parameter is a Throwable, it will be thrown rather than
* returned.
*/
Object
echo
(
Object
o
)
throws
Throwable
;
}
\ No newline at end of file
org.springframework.aop/src/test/java/org/springframework/beans/SerializablePerson.java
0 → 100644
浏览文件 @
32bea88e
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.beans
;
import
java.io.Serializable
;
import
org.springframework.util.ObjectUtils
;
/**
* Serializable implementation of the Person interface.
*
* @author Rod Johnson
*/
public
class
SerializablePerson
implements
Person
,
Serializable
{
private
String
name
;
private
int
age
;
public
int
getAge
()
{
return
age
;
}
public
void
setAge
(
int
age
)
{
this
.
age
=
age
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Object
echo
(
Object
o
)
throws
Throwable
{
if
(
o
instanceof
Throwable
)
{
throw
(
Throwable
)
o
;
}
return
o
;
}
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
SerializablePerson
))
{
return
false
;
}
SerializablePerson
p
=
(
SerializablePerson
)
other
;
return
p
.
age
==
age
&&
ObjectUtils
.
nullSafeEquals
(
name
,
p
.
name
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录