Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
希川
container-mini
提交
853bbdd5
C
container-mini
项目概览
希川
/
container-mini
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
container-mini
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
853bbdd5
编写于
11月 09, 2021
作者:
希川
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<feat>: 自动扫描 Bean 对象, 单元测试补充
上级
7ca6c526
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
0 deletion
+72
-0
src/test/java/cn/noexception/test/AopTest.java
src/test/java/cn/noexception/test/AopTest.java
+26
-0
src/test/java/cn/noexception/test/bean/impl/UserService.java
src/test/java/cn/noexception/test/bean/impl/UserService.java
+18
-0
src/test/resources/spring-property.xml
src/test/resources/spring-property.xml
+17
-0
src/test/resources/spring-scan.xml
src/test/resources/spring-scan.xml
+10
-0
src/test/resources/token.properties
src/test/resources/token.properties
+1
-0
未找到文件。
src/test/java/cn/noexception/test/AopTest.java
浏览文件 @
853bbdd5
...
...
@@ -9,6 +9,7 @@ import cn.noexception.container.aop.aspectj.AspectJExpressionPointcutAdvisor;
import
cn.noexception.container.aop.framework.ProxyFactory
;
import
cn.noexception.container.aop.framework.ReflectiveMethodInvocation
;
import
cn.noexception.container.aop.framework.adapter.MethodBeforeAdviceInterceptor
;
import
cn.noexception.container.context.support.ClassPathXmlApplicationContext
;
import
cn.noexception.test.bean.IUserService
;
import
cn.noexception.test.bean.UserServiceBeforeAdvice
;
import
cn.noexception.test.bean.UserServiceInterceptor
;
...
...
@@ -101,4 +102,29 @@ public class AopTest {
String
result
=
proxy
.
queryUserInfo
();
System
.
out
.
println
(
"测试结果:"
+
result
);
}
@Test
public
void
test_property
()
{
ClassPathXmlApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
"classpath:spring-property.xml"
);
IUserService
userService
=
applicationContext
.
getBean
(
"userService"
,
IUserService
.
class
);
System
.
out
.
println
(
"测试结果: "
+
userService
);
}
@Test
public
void
test_scan
()
{
ClassPathXmlApplicationContext
applicationContext
=
new
ClassPathXmlApplicationContext
(
"classpath:spring-scan.xml"
);
IUserService
userService
=
applicationContext
.
getBean
(
"userService"
,
IUserService
.
class
);
System
.
out
.
println
(
"测试结果:"
+
userService
.
queryUserInfo
());
}
}
src/test/java/cn/noexception/test/bean/impl/UserService.java
浏览文件 @
853bbdd5
package
cn.noexception.test.bean.impl
;
import
cn.noexception.container.factory.stereotype.Cube
;
import
cn.noexception.test.bean.IUserService
;
import
java.util.Random
;
...
...
@@ -10,7 +11,11 @@ import java.util.Random;
* @author 吕滔
* @Date 2021/11/3 17:01
*/
@Cube
(
"userService"
)
public
class
UserService
implements
IUserService
{
private
String
token
;
@Override
public
String
queryUserInfo
()
{
try
{
...
...
@@ -31,4 +36,17 @@ public class UserService implements IUserService {
return
"注册用户:"
+
userName
+
" success! "
;
}
@Override
public
String
toString
()
{
return
"UserService#token = { "
+
token
+
" }"
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
}
src/test/resources/spring-property.xml
0 → 100644
浏览文件 @
853bbdd5
<?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:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context"
>
<bean
class=
"cn.noexception.container.factory.PropertyPlaceholderConfigurer"
>
<property
name=
"location"
value=
"classpath:token.properties"
/>
</bean>
<bean
id=
"userService"
class=
"cn.noexception.test.bean.impl.UserService"
>
<property
name=
"token"
value=
"${token}"
/>
</bean>
</beans>
\ No newline at end of file
src/test/resources/spring-scan.xml
0 → 100644
浏览文件 @
853bbdd5
<?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:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context"
>
<context:component-scan
base-package=
"cn.noexception.test.bean"
/>
</beans>
\ No newline at end of file
src/test/resources/token.properties
0 → 100644
浏览文件 @
853bbdd5
token
=
RejDlI78hu223Opo983Ds
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录