Skip to content

Commit c539537

Browse files
bdemersbmarwell
authored andcommitted
Add basic tests to assert no whitespace in spring.factories fiels
1 parent 5f367c3 commit c539537

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.apache.shiro.spring.boot.autoconfigure
2+
3+
import org.junit.Test
4+
5+
import static org.hamcrest.MatcherAssert.assertThat
6+
import static org.hamcrest.Matchers.matchesPattern
7+
import static org.hamcrest.Matchers.not
8+
9+
class SpringFactoriesTest {
10+
11+
@Test
12+
void springFactoriesConfigContainsNoWhitespace() {
13+
Properties props = new Properties()
14+
props.load(new FileReader("src/main/resources/META-INF/spring.factories"))
15+
assertNoWhitespaceInEntries(props)
16+
}
17+
18+
static private assertNoWhitespaceInEntries(Properties props) {
19+
props.each{ key, val ->
20+
assertThat "Property [${key}] contains whitespace",
21+
props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*"))
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.apache.shiro.spring.boot.autoconfigure.web
2+
3+
import org.junit.Test
4+
5+
import static org.hamcrest.MatcherAssert.assertThat
6+
import static org.hamcrest.Matchers.matchesPattern
7+
import static org.hamcrest.Matchers.not
8+
9+
class WebSpringFactoriesTest {
10+
11+
@Test
12+
void springFactoriesConfigContainsNoWhitespace() {
13+
Properties props = new Properties()
14+
props.load(new FileReader("src/main/resources/META-INF/spring.factories"))
15+
assertNoWhitespaceInEntries(props)
16+
}
17+
18+
static private assertNoWhitespaceInEntries(Properties props) {
19+
props.each{ key, val ->
20+
assertThat "Property [${key}] contains whitespace",
21+
props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*"))
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)