Skip to content

Commit 564c108

Browse files
committed
add more test
1 parent 756531a commit 564c108

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/test/java/org/mybatis/spring/filter/xml/XmlScanFilterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ void testAnnoScanFilter() {
4949
closeContext();
5050
}
5151

52+
@Test
53+
void testAnnoScanWithPlaceHolderFilter() {
54+
// exclude mappers which has @AnnoTypeFilter
55+
System.getProperties().put("annoFilter","org.mybatis.spring.filter.customfilter.AnnoTypeFilter");
56+
startContext("org/mybatis/spring/filter/xml/appContextPlaceHolder.xml");
57+
assertThat(applicationContext.containsBean("mapperWithAnnoFilter")).isFalse();
58+
assertThat(applicationContext.containsBean("dataSource1Mapper")).isTrue();
59+
assertThat(applicationContext.containsBean("commonDataSourceMapper")).isTrue();
60+
closeContext();
61+
}
62+
5263
@Test
5364
void testAssignScanFilter() {
5465
// exclude mappers which can assignable to ExcludeMaker
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2010-2023 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<!--
20+
<mybatis:scan> with new property exclude-filter
21+
-->
22+
<beans xmlns="http://www.springframework.org/schema/beans"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"
25+
xmlns:context="http://www.springframework.org/schema/context"
26+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
27+
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
28+
29+
<!-- in-memory database and a datasource -->
30+
<jdbc:embedded-database id="dataSource">
31+
<jdbc:script location="classpath:org/mybatis/spring/batch/db/database-schema.sql"/>
32+
<jdbc:script location="classpath:org/mybatis/spring/batch/db/database-test-data.sql"/>
33+
</jdbc:embedded-database>
34+
35+
36+
<!-- simplest possible SqlSessionFactory configuration -->
37+
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
38+
<property name="dataSource" ref="dataSource"/>
39+
</bean>
40+
41+
42+
<mybatis:scan base-package="org.mybatis.spring.filter.datasource">
43+
<mybatis:exclude-filter type="annotation"
44+
expression="${annoFilter}"/>
45+
</mybatis:scan>
46+
47+
</beans>

0 commit comments

Comments
 (0)