Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
7f5e60e7
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,发现更多精彩内容 >>
提交
7f5e60e7
编写于
12月 13, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moving unit tests from .testsuite -> .aop
上级
84a4fe6d
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
133 addition
and
36 deletion
+133
-36
org.springframework.aop/src/test/java/org/springframework/aop/interceptor/SideEffectBean.java
...a/org/springframework/aop/interceptor/SideEffectBean.java
+40
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java
...amework/aop/target/CommonsPoolTargetSourceProxyTests.java
+9
-6
org.springframework.aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
...ngframework/aop/target/HotSwappableTargetSourceTests.java
+14
-6
org.springframework.aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java
...ngframework/aop/target/LazyCreationTargetSourceTests.java
+6
-3
org.springframework.aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
...springframework/aop/target/LazyInitTargetSourceTests.java
+10
-5
org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
...framework/aop/target/PrototypeBasedTargetSourceTests.java
+5
-2
org.springframework.aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
...pringframework/aop/target/PrototypeTargetSourceTests.java
+8
-3
org.springframework.aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
...ingframework/aop/target/ThreadLocalTargetSourceTests.java
+13
-4
org.springframework.aop/src/test/java/org/springframework/aop/target/commonsPoolProxyTests.xml
.../org/springframework/aop/target/commonsPoolProxyTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/commonsPoolTests.xml
.../java/org/springframework/aop/target/commonsPoolTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/customLazyInitTarget.xml
...a/org/springframework/aop/target/customLazyInitTarget.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java
...work/aop/target/dynamic/RefreshableTargetSourceTests.java
+9
-2
org.springframework.aop/src/test/java/org/springframework/aop/target/hotSwapTests.xml
...test/java/org/springframework/aop/target/hotSwapTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/lazyInitFactoryBean.xml
...va/org/springframework/aop/target/lazyInitFactoryBean.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/lazyInitSingletonTests.xml
...org/springframework/aop/target/lazyInitSingletonTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/prototypeTests.xml
...st/java/org/springframework/aop/target/prototypeTests.xml
+0
-0
org.springframework.aop/src/test/java/org/springframework/aop/target/threadLocalTests.xml
.../java/org/springframework/aop/target/threadLocalTests.xml
+0
-0
org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java
...ingframework/aop/target/CommonsPoolTargetSourceTests.java
+19
-5
未找到文件。
org.springframework.aop/src/test/java/org/springframework/aop/interceptor/SideEffectBean.java
0 → 100644
浏览文件 @
7f5e60e7
/*
* 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
;
/**
* Bean that changes state on a business invocation, so that
* we can check whether it's been invoked
* @author Rod Johnson
*/
public
class
SideEffectBean
{
private
int
count
;
public
void
setCount
(
int
count
)
{
this
.
count
=
count
;
}
public
int
getCount
()
{
return
this
.
count
;
}
public
void
doWork
()
{
++
count
;
}
}
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,20 +16,23 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCas
e
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.
springframework.beans.factory.xml.XmlBeanDefinitionReader
;
import
org.springframework.
beans.factory.support.DefaultListableBeanFactory
;
import
static
org
.
junit
.
Assert
.
assertTru
e
;
import
org.
junit.Test
;
import
org.springframework.
aop.support.AopUtils
;
import
org.springframework.beans.ITestBean
;
import
org.springframework.beans.factory.support.DefaultListableBeanFactory
;
import
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.aop.support.AopUtils
;
/**
* @author Rob Harrop
* @author Chris Beams
* @since 2.0
*/
public
class
CommonsPoolTargetSourceProxyTests
extends
TestCase
{
public
class
CommonsPoolTargetSourceProxyTests
{
@Test
public
void
testProxy
()
throws
Exception
{
DefaultListableBeanFactory
beanFactory
=
new
DefaultListableBeanFactory
();
XmlBeanDefinitionReader
reader
=
new
XmlBeanDefinitionReader
(
beanFactory
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,8 +16,11 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.After
;
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.SerializableNopInterceptor
;
...
...
@@ -31,22 +34,25 @@ import org.springframework.util.SerializationTestUtils;
/**
* @author Rod Johnson
* @author Chris Beams
*/
public
class
HotSwappableTargetSourceTests
extends
TestCase
{
public
class
HotSwappableTargetSourceTests
{
/** Initial count value set in bean factory XML */
private
static
final
int
INITIAL_COUNT
=
10
;
private
XmlBeanFactory
beanFactory
;
protected
void
setUp
()
throws
Exception
{
@Before
public
void
setUp
()
throws
Exception
{
this
.
beanFactory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"hotSwapTests.xml"
,
getClass
()));
}
/**
* We must simulate container shutdown, which should clear threads.
*/
protected
void
tearDown
()
{
@After
public
void
tearDown
()
{
// Will call pool.close()
this
.
beanFactory
.
destroySingletons
();
}
...
...
@@ -55,8 +61,8 @@ public class HotSwappableTargetSourceTests extends TestCase {
* Check it works like a normal invoker
*
*/
@Test
public
void
testBasicFunctionality
()
{
SideEffectBean
target1
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"target1"
);
SideEffectBean
proxied
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"swappable"
);
assertEquals
(
INITIAL_COUNT
,
proxied
.
getCount
()
);
proxied
.
doWork
();
...
...
@@ -67,12 +73,12 @@ public class HotSwappableTargetSourceTests extends TestCase {
assertEquals
(
INITIAL_COUNT
+
2
,
proxied
.
getCount
()
);
}
@Test
public
void
testValidSwaps
()
{
SideEffectBean
target1
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"target1"
);
SideEffectBean
target2
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"target2"
);
SideEffectBean
proxied
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"swappable"
);
// assertEquals(target1, ((Advised) proxied).getTarget());
assertEquals
(
target1
.
getCount
(),
proxied
.
getCount
()
);
proxied
.
doWork
();
assertEquals
(
INITIAL_COUNT
+
1
,
proxied
.
getCount
()
);
...
...
@@ -117,6 +123,7 @@ public class HotSwappableTargetSourceTests extends TestCase {
return
aopex
;
}
@Test
public
void
testRejectsSwapToNull
()
{
IllegalArgumentException
ex
=
testRejectsSwapToInvalidValue
(
null
);
assertTrue
(
ex
.
getMessage
().
indexOf
(
"null"
)
!=
-
1
);
...
...
@@ -126,6 +133,7 @@ public class HotSwappableTargetSourceTests extends TestCase {
// how to decide what's valid?
@Test
public
void
testSerialization
()
throws
Exception
{
SerializablePerson
sp1
=
new
SerializablePerson
();
sp1
.
setName
(
"Tony"
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,23 +16,26 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Test
;
import
org.springframework.aop.TargetSource
;
import
org.springframework.aop.framework.ProxyFactory
;
/**
* @author Rob Harrop
* @author Juergen Hoeller
* @author Chris Beams
*/
public
class
LazyCreationTargetSourceTests
extends
TestCase
{
public
class
LazyCreationTargetSourceTests
{
@Test
public
void
testCreateLazy
()
{
TargetSource
targetSource
=
new
AbstractLazyCreationTargetSource
()
{
protected
Object
createObject
()
{
return
new
InitCountingBean
();
}
public
Class
getTargetClass
()
{
public
Class
<?>
getTargetClass
()
{
return
InitCountingBean
.
class
;
}
};
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,10 +16,11 @@
package
org.springframework.aop.target
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.*
;
import
j
unit.framework.TestCase
;
import
j
ava.util.Set
;
import
org.junit.Test
;
import
org.springframework.beans.ITestBean
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
import
org.springframework.core.io.ClassPathResource
;
...
...
@@ -27,10 +28,12 @@ import org.springframework.core.io.ClassPathResource;
/**
* @author Juergen Hoeller
* @author Rob Harrop
* @author Chris Beams
* @since 07.01.2005
*/
public
class
LazyInitTargetSourceTests
extends
TestCase
{
public
class
LazyInitTargetSourceTests
{
@Test
public
void
testLazyInitSingletonTargetSource
()
{
XmlBeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"lazyInitSingletonTests.xml"
,
getClass
()));
bf
.
preInstantiateSingletons
();
...
...
@@ -41,6 +44,7 @@ public class LazyInitTargetSourceTests extends TestCase {
assertTrue
(
bf
.
containsSingleton
(
"target"
));
}
@Test
public
void
testCustomLazyInitSingletonTargetSource
()
{
XmlBeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"customLazyInitTarget.xml"
,
getClass
()));
bf
.
preInstantiateSingletons
();
...
...
@@ -51,16 +55,17 @@ public class LazyInitTargetSourceTests extends TestCase {
assertTrue
(
bf
.
containsSingleton
(
"target"
));
}
@Test
public
void
testLazyInitFactoryBeanTargetSource
()
{
XmlBeanFactory
bf
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"lazyInitFactoryBean.xml"
,
getClass
()));
bf
.
preInstantiateSingletons
();
Set
set1
=
(
Set
)
bf
.
getBean
(
"proxy1"
);
Set
<?>
set1
=
(
Set
<?>
)
bf
.
getBean
(
"proxy1"
);
assertFalse
(
bf
.
containsSingleton
(
"target1"
));
assertTrue
(
set1
.
contains
(
"10"
));
assertTrue
(
bf
.
containsSingleton
(
"target1"
));
Set
set2
=
(
Set
)
bf
.
getBean
(
"proxy2"
);
Set
<?>
set2
=
(
Set
<?>
)
bf
.
getBean
(
"proxy2"
);
assertFalse
(
bf
.
containsSingleton
(
"target2"
));
assertTrue
(
set2
.
contains
(
"20"
));
assertTrue
(
bf
.
containsSingleton
(
"target2"
));
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,8 +16,9 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Test
;
import
org.springframework.aop.TargetSource
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.beans.SerializablePerson
;
...
...
@@ -31,9 +32,11 @@ import org.springframework.util.SerializationTestUtils;
* and not subclasses.
*
* @author Rod Johnson
* @author Chris Beams
*/
public
class
PrototypeBasedTargetSourceTests
extends
TestCase
{
public
class
PrototypeBasedTargetSourceTests
{
@Test
public
void
testSerializability
()
throws
Exception
{
MutablePropertyValues
tsPvs
=
new
MutablePropertyValues
();
tsPvs
.
addPropertyValue
(
"targetBeanName"
,
"person"
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,8 +16,10 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.aop.interceptor.SideEffectBean
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
...
...
@@ -25,15 +27,17 @@ import org.springframework.core.io.ClassPathResource;
/**
* @author Rod Johnson
* @author Chris Beams
*/
public
class
PrototypeTargetSourceTests
extends
TestCase
{
public
class
PrototypeTargetSourceTests
{
/** Initial count value set in bean factory XML */
private
static
final
int
INITIAL_COUNT
=
10
;
private
BeanFactory
beanFactory
;
protected
void
setUp
()
throws
Exception
{
@Before
public
void
setUp
()
throws
Exception
{
this
.
beanFactory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"prototypeTests.xml"
,
getClass
()));
}
...
...
@@ -42,6 +46,7 @@ public class PrototypeTargetSourceTests extends TestCase {
* in no change to visible state, as a new instance is used.
* With the singleton, there will be change.
*/
@Test
public
void
testPrototypeAndSingletonBehaveDifferently
()
{
SideEffectBean
singleton
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"singleton"
);
assertEquals
(
INITIAL_COUNT
,
singleton
.
getCount
()
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,8 +16,10 @@
package
org.springframework.aop.target
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.aop.interceptor.SideEffectBean
;
import
org.springframework.beans.ITestBean
;
import
org.springframework.beans.factory.xml.XmlBeanFactory
;
...
...
@@ -25,15 +27,17 @@ import org.springframework.core.io.ClassPathResource;
/**
* @author Rod Johnson
* @author Chris Beams
*/
public
class
ThreadLocalTargetSourceTests
extends
TestCase
{
public
class
ThreadLocalTargetSourceTests
{
/** Initial count value set in bean factory XML */
private
static
final
int
INITIAL_COUNT
=
10
;
private
XmlBeanFactory
beanFactory
;
protected
void
setUp
()
throws
Exception
{
@Before
public
void
setUp
()
throws
Exception
{
this
.
beanFactory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"threadLocalTests.xml"
,
getClass
()));
}
...
...
@@ -49,6 +53,7 @@ public class ThreadLocalTargetSourceTests extends TestCase {
* managing objects of different types without them interfering
* with one another.
*/
@Test
public
void
testUseDifferentManagedInstancesInSameThread
()
{
SideEffectBean
apartment
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"apartment"
);
assertEquals
(
INITIAL_COUNT
,
apartment
.
getCount
()
);
...
...
@@ -60,6 +65,7 @@ public class ThreadLocalTargetSourceTests extends TestCase {
assertEquals
(
"Kerry"
,
test
.
getSpouse
().
getName
());
}
@Test
public
void
testReuseInSameThread
()
{
SideEffectBean
apartment
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"apartment"
);
assertEquals
(
INITIAL_COUNT
,
apartment
.
getCount
()
);
...
...
@@ -73,6 +79,7 @@ public class ThreadLocalTargetSourceTests extends TestCase {
/**
* Relies on introduction.
*/
@Test
public
void
testCanGetStatsViaMixin
()
{
ThreadLocalTargetSourceStats
stats
=
(
ThreadLocalTargetSourceStats
)
beanFactory
.
getBean
(
"apartment"
);
// +1 because creating target for stats call counts
...
...
@@ -90,6 +97,7 @@ public class ThreadLocalTargetSourceTests extends TestCase {
assertEquals
(
1
,
stats
.
getObjectCount
());
}
@Test
public
void
testNewThreadHasOwnInstance
()
throws
InterruptedException
{
SideEffectBean
apartment
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"apartment"
);
assertEquals
(
INITIAL_COUNT
,
apartment
.
getCount
()
);
...
...
@@ -128,11 +136,12 @@ public class ThreadLocalTargetSourceTests extends TestCase {
/**
* Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE
*/
@Test
public
void
testReuseDestroyedTarget
()
{
ThreadLocalTargetSource
source
=
(
ThreadLocalTargetSource
)
this
.
beanFactory
.
getBean
(
"threadLocalTs"
);
// try first time
Object
o
=
source
.
getTarget
();
source
.
getTarget
();
source
.
destroy
();
// try second time
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/commonsPoolProxyTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/commonsPoolProxyTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/commonsPoolTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/commonsPoolTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/customLazyInitTarget.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/customLazyInitTarget.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,16 +16,20 @@
package
org.springframework.aop.target.dynamic
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
/**
* @author Rob Harrop
* @author Chris Beams
*/
public
class
RefreshableTargetSourceTests
extends
TestCase
{
public
class
RefreshableTargetSourceTests
{
/**
* Test what happens when checking for refresh but not refreshing object.
*/
@Test
public
void
testRefreshCheckWithNonRefresh
()
throws
Exception
{
CountingRefreshableTargetSource
ts
=
new
CountingRefreshableTargetSource
();
ts
.
setRefreshCheckDelay
(
0
);
...
...
@@ -41,6 +45,7 @@ public class RefreshableTargetSourceTests extends TestCase {
/**
* Test what happens when checking for refresh and refresh occurs.
*/
@Test
public
void
testRefreshCheckWithRefresh
()
throws
Exception
{
CountingRefreshableTargetSource
ts
=
new
CountingRefreshableTargetSource
(
true
);
ts
.
setRefreshCheckDelay
(
0
);
...
...
@@ -56,6 +61,7 @@ public class RefreshableTargetSourceTests extends TestCase {
/**
* Test what happens when no refresh occurs.
*/
@Test
public
void
testWithNoRefreshCheck
()
throws
Exception
{
CountingRefreshableTargetSource
ts
=
new
CountingRefreshableTargetSource
(
true
);
ts
.
setRefreshCheckDelay
(-
1
);
...
...
@@ -67,6 +73,7 @@ public class RefreshableTargetSourceTests extends TestCase {
assertSame
(
"Objects should be the same - refresh check delay not elapsed"
,
a
,
b
);
}
@Test
public
void
testRefreshOverTime
()
throws
Exception
{
CountingRefreshableTargetSource
ts
=
new
CountingRefreshableTargetSource
(
true
);
ts
.
setRefreshCheckDelay
(
100
);
...
...
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/hotSwapTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/hotSwapTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/lazyInitFactoryBean.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/lazyInitFactoryBean.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/lazyInitSingletonTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/lazyInitSingletonTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/prototypeTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/prototypeTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.
testsuite
/src/test/java/org/springframework/aop/target/threadLocalTests.xml
→
org.springframework.
aop
/src/test/java/org/springframework/aop/target/threadLocalTests.xml
浏览文件 @
7f5e60e7
文件已移动
org.springframework.testsuite/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceTests.java
浏览文件 @
7f5e60e7
...
...
@@ -16,11 +16,14 @@
package
org.springframework.aop.target
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.NoSuchElementException
;
import
junit.framework.TestCase
;
import
org.apache.commons.pool.impl.GenericObjectPool
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.aop.framework.Advised
;
import
org.springframework.aop.interceptor.SideEffectBean
;
import
org.springframework.beans.Person
;
...
...
@@ -37,8 +40,9 @@ import org.springframework.util.SerializationTestUtils;
*
* @author Rod Johnson
* @author Rob Harrop
* @author Chris Beams
*/
public
class
CommonsPoolTargetSourceTests
extends
TestCase
{
public
class
CommonsPoolTargetSourceTests
{
/**
* Initial count value set in bean factory XML
...
...
@@ -47,14 +51,16 @@ public class CommonsPoolTargetSourceTests extends TestCase {
private
XmlBeanFactory
beanFactory
;
protected
void
setUp
()
throws
Exception
{
@Before
public
void
setUp
()
throws
Exception
{
this
.
beanFactory
=
new
XmlBeanFactory
(
new
ClassPathResource
(
"commonsPoolTests.xml"
,
getClass
()));
}
/**
* We must simulate container shutdown, which should clear threads.
*/
protected
void
tearDown
()
{
@After
public
void
tearDown
()
{
// Will call pool.close()
this
.
beanFactory
.
destroySingletons
();
}
...
...
@@ -72,14 +78,17 @@ public class CommonsPoolTargetSourceTests extends TestCase {
//assertEquals(INITIAL_COUNT + 1, apartment.getCount() );
}
@Test
public
void
testFunctionality
()
{
testFunctionality
(
"pooled"
);
}
@Test
public
void
testFunctionalityWithNoInterceptors
()
{
testFunctionality
(
"pooledNoInterceptors"
);
}
@Test
public
void
testConfigMixin
()
{
SideEffectBean
pooled
=
(
SideEffectBean
)
beanFactory
.
getBean
(
"pooledWithMixin"
);
assertEquals
(
INITIAL_COUNT
,
pooled
.
getCount
());
...
...
@@ -94,6 +103,7 @@ public class CommonsPoolTargetSourceTests extends TestCase {
assertEquals
(
25
,
conf
.
getMaxSize
());
}
@Test
public
void
testTargetSourceSerializableWithoutConfigMixin
()
throws
Exception
{
CommonsPoolTargetSource
cpts
=
(
CommonsPoolTargetSource
)
beanFactory
.
getBean
(
"personPoolTargetSource"
);
...
...
@@ -102,6 +112,7 @@ public class CommonsPoolTargetSourceTests extends TestCase {
}
@Test
public
void
testProxySerializableWithoutConfigMixin
()
throws
Exception
{
Person
pooled
=
(
Person
)
beanFactory
.
getBean
(
"pooledPerson"
);
...
...
@@ -115,6 +126,7 @@ public class CommonsPoolTargetSourceTests extends TestCase {
assertEquals
(
25
,
serialized
.
getAge
());
}
@Test
public
void
testHitMaxSize
()
throws
Exception
{
int
maxSize
=
10
;
...
...
@@ -150,6 +162,7 @@ public class CommonsPoolTargetSourceTests extends TestCase {
}
}
@Test
public
void
testHitMaxSizeLoadedFromContext
()
throws
Exception
{
Advised
person
=
(
Advised
)
beanFactory
.
getBean
(
"maxSizePooledPerson"
);
CommonsPoolTargetSource
targetSource
=
(
CommonsPoolTargetSource
)
person
.
getTargetSource
();
...
...
@@ -182,6 +195,7 @@ public class CommonsPoolTargetSourceTests extends TestCase {
}
}
@Test
public
void
testSetWhenExhaustedAction
()
{
CommonsPoolTargetSource
targetSource
=
new
CommonsPoolTargetSource
();
targetSource
.
setWhenExhaustedActionName
(
"WHEN_EXHAUSTED_BLOCK"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录