Skip to content

Latest commit

 

History

History
66 lines (39 loc) · 1.58 KB

README.md

File metadata and controls

66 lines (39 loc) · 1.58 KB

Random Port Initializer

REUSE status GitHub tag (latest SemVer) License

What is it?

A Spring test util for resolving property placeholders to free random ports.

Usage

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....
}

How to test the software

./gradlew test

Getting help

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

Getting involved

General instructions for contributing CONTRIBUTING.

License

This software is released under the:

Apache License 2.0

Copyright 2018 Sveriges Television AB

Primary Maintainer

Gustav Grusell https://github.com/grusell