-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-test-clients' of https://github.com/FINTprosjektet/…
…fint-provider into fix-test-clients
- Loading branch information
Showing
8 changed files
with
91 additions
and
19 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/test/groovy/no/fint/provider/events/testmode/TestModeDisabledSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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.Specification | ||
|
||
@SpringBootTest | ||
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 | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/groovy/no/fint/provider/events/testmode/TestModeSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package no.fint.provider.events.testmode | ||
|
||
import no.fint.provider.events.Application | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.context.embedded.LocalServerPort | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.web.client.TestRestTemplate | ||
import org.springframework.test.context.ActiveProfiles | ||
import spock.lang.Requires | ||
import spock.lang.Specification | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = Application) | ||
@ActiveProfiles('local') | ||
@Requires({ env.INTEGRATION }) | ||
class TestModeSpec extends Specification { | ||
|
||
@LocalServerPort | ||
private int port | ||
|
||
@Value('${server.context-path:/}') | ||
private String contextPath | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate | ||
|
||
def 'Loopback events'() { | ||
when: | ||
TimeUnit.SECONDS.sleep(10) | ||
def response1 = restTemplate.postForEntity('http://localhost:{port}/{context}/test-mode-consumer?numberOfEvents={events}', null, Void, port, contextPath, 10) | ||
|
||
then: | ||
response1.statusCode.is2xxSuccessful() | ||
|
||
when: | ||
TimeUnit.SECONDS.sleep(10) | ||
def response2 = restTemplate.getForEntity('http://localhost:{port}/{context}/test-mode-consumer', Map, port, contextPath) | ||
|
||
then: | ||
response2.statusCode.is2xxSuccessful() | ||
response2.body['numberOfEvents'] == 10 | ||
} | ||
} |