@@ -26,7 +26,6 @@ import javasabr.mqtt.test.support.UnitSpecification
2626import javasabr.rlib.collections.array.Array
2727
2828import java.nio.file.Files
29- import java.nio.file.NoSuchFileException
3029import java.nio.file.Path
3130import java.util.concurrent.CompletionException
3231
@@ -39,31 +38,22 @@ class AclRulesLoaderTest extends UnitSpecification {
3938
4039 def " should load test Groovy DSL config" () {
4140 given :
42- def ruleFile = TestRulesGenerator . generate(100 )
41+ def aclConfigFile = TestRulesGenerator . generate(100 )
42+ def aclConfigInputStream = new FileInputStream (aclConfigFile)
4343 when :
44- def load = AclRulesLoader . load(new FileInputStream (ruleFile) )
44+ def load = AclRulesLoader . load(aclConfigInputStream )
4545 then :
4646 load. get(SUBSCRIBE ). size() == 50
4747 load. get(PUBLISH ). size() == 50
48- ruleFile. delete()
49- }
50-
51- def " should throw exception if config not exists" (String configPath) {
52- when :
53- AclRulesLoader . load(Files . newInputStream(Path . of(configPath)))
54- then :
55- def exception = thrown(NoSuchFileException )
56- exception. message == configPath
57- where :
58- configPath | _
59- " not/existed/path" | _
48+ aclConfigFile. delete()
6049 }
6150
6251 def " should work fine with only publish rules" () {
6352 given :
6453 def onlyPublishRulesAclPath = getAbsolutePath(" acl/config/acl-publish-only.gacl" )
54+ def aclConfigInputStream = Files . newInputStream(Path . of(onlyPublishRulesAclPath))
6555 when :
66- def ruleMap = AclRulesLoader . load(Files . newInputStream( Path . of(onlyPublishRulesAclPath)) )
56+ def ruleMap = AclRulesLoader . load(aclConfigInputStream )
6757 then :
6858 noExceptionThrown()
6959 ! ruleMap. get(PUBLISH ). isEmpty()
@@ -73,8 +63,9 @@ class AclRulesLoaderTest extends UnitSpecification {
7363 def " should throw exception if config is invalid" (String invalidAclFileName, String errorMessage, Class<? extends Exception > exceptionClass) {
7464 given :
7565 def invalidAclPath = getAbsolutePath(" acl/config/invalid/${ invalidAclFileName} " )
66+ def aclConfigInputStream = Files . newInputStream(Path . of(invalidAclPath))
7667 when :
77- AclRulesLoader . load(Files . newInputStream( Path . of(invalidAclPath)) )
68+ AclRulesLoader . load(aclConfigInputStream )
7869 then :
7970 def exception = thrown CompletionException
8071 exceptionClass. isInstance exception. cause
0 commit comments