Skip to content

Commit

Permalink
Add basic tests to assert no whitespace in spring.factories fiels
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemers authored and bmarwell committed Nov 22, 2020
1 parent 5f367c3 commit c539537
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.apache.shiro.spring.boot.autoconfigure

import org.junit.Test

import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.Matchers.matchesPattern
import static org.hamcrest.Matchers.not

class SpringFactoriesTest {

@Test
void springFactoriesConfigContainsNoWhitespace() {
Properties props = new Properties()
props.load(new FileReader("src/main/resources/META-INF/spring.factories"))
assertNoWhitespaceInEntries(props)
}

static private assertNoWhitespaceInEntries(Properties props) {
props.each{ key, val ->
assertThat "Property [${key}] contains whitespace",
props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.apache.shiro.spring.boot.autoconfigure.web

import org.junit.Test

import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.Matchers.matchesPattern
import static org.hamcrest.Matchers.not

class WebSpringFactoriesTest {

@Test
void springFactoriesConfigContainsNoWhitespace() {
Properties props = new Properties()
props.load(new FileReader("src/main/resources/META-INF/spring.factories"))
assertNoWhitespaceInEntries(props)
}

static private assertNoWhitespaceInEntries(Properties props) {
props.each{ key, val ->
assertThat "Property [${key}] contains whitespace",
props.get("org.springframework.boot.autoconfigure.EnableAutoConfiguration"), not(matchesPattern(".*\\s.*"))
}
}
}

0 comments on commit c539537

Please sign in to comment.