Skip to content

Commit

Permalink
added testmode conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlehansen committed Oct 27, 2018
1 parent d04b45c commit d02fe76
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package no.fint.provider.events.testmode

class TestModeConditional {

static Boolean integrationTest() {
def value = System.getenv('SPRING_PROFILES_ACTIVE') ?: System.getProperty('spring.profiles.active')
return (value?.toLowerCase() == 'integration')
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package no.fint.provider.events.testmode

import no.fint.provider.events.testmode.adapter.TestModeAdapter
import no.fint.provider.events.testmode.consumer.TestModeController
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.IgnoreIf
import spock.lang.Specification

@SpringBootTest
@IgnoreIf({ TestModeConditional.integrationTest() })
class TestModeDisabledSpec extends Specification {

@Autowired(required = false)
private TestModeController controller

@Autowired(required = false)
private TestModeAdapter adapter

def "Test mode components are disabled by default"() {
expect:
!controller
!adapter
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import spock.lang.Specification
import java.util.concurrent.TimeUnit

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = Application)
@Requires({ Boolean.valueOf(sys['fint.provider.test-mode']) })
@Requires({ TestModeConditional.integrationTest() })
class TestModeSpec extends Specification {

@LocalServerPort
Expand Down

0 comments on commit d02fe76

Please sign in to comment.