A Spring test util for resolving property placeholders to free random ports.
Add to build.gradle.kts
testCompile 'se.svt.oss:random-port-initializer:X.Y.Z
When the RandomPortInitializer is applied to the application context, any property placeholders
starting with prefix random-port.
will be resolved to a random free port. If the same
property placeholder appears in multiple places, the same port will be assigned everywhere.
Example on usage in test
@ContextConfiguration(classes = arrayOf(MyTestConfiguration::class),
initializers = arrayOf(RandomPortInitializer::class))
class SomeIntegrationTest {
@Value("\${random-port.port1}")
var myRandomPort: Int = 0
@Test
fun blabla....
}
./gradlew test
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
General instructions for contributing CONTRIBUTING.
This software is released under the:
Copyright 2018 Sveriges Television AB
Gustav Grusell https://github.com/grusell