-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the same configuration library for tests as Java SDK (#14)
- Loading branch information
Showing
7 changed files
with
67 additions
and
74 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
package com.pubnub.api | ||
|
||
import dev.nohus.autokonfig.AutoKonfig | ||
import dev.nohus.autokonfig.types.StringSetting | ||
import dev.nohus.autokonfig.withEnvironmentVariables | ||
import dev.nohus.autokonfig.withResourceConfig | ||
import org.aeonbits.owner.Config | ||
import org.aeonbits.owner.ConfigFactory | ||
|
||
object Keys { | ||
private fun AutoKonfig.withSafeResourceConfig(resource: String) = apply { | ||
try { | ||
withResourceConfig(resource) | ||
} catch (e: Exception) { | ||
} | ||
} | ||
@Config.Sources("file:test.properties") | ||
interface KeysConfig : Config { | ||
@get:Config.Key("subKey") | ||
val subscribeKey: String | ||
|
||
private val config = AutoKonfig() | ||
.withSafeResourceConfig("config.properties") | ||
.withEnvironmentVariables() | ||
@get:Config.Key("pubKey") | ||
val publishKey: String | ||
|
||
val pubKey by config.StringSetting() | ||
val subKey by config.StringSetting() | ||
val pamPubKey by config.StringSetting() | ||
val pamSubKey by config.StringSetting() | ||
val pamSecKey by config.StringSetting() | ||
@get:Config.Key("pamSubKey") | ||
val pamSubKey: String | ||
|
||
@get:Config.Key("pamPubKey") | ||
val pamPubKey: String | ||
|
||
@get:Config.Key("pamSecKey") | ||
val pamSecKey: String | ||
} | ||
|
||
val Keys: KeysConfig = ConfigFactory.create(KeysConfig::class.java, System.getenv()) |
53 changes: 28 additions & 25 deletions
53
src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt
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 |
---|---|---|
@@ -1,28 +1,31 @@ | ||
package com.pubnub.contract | ||
|
||
import dev.nohus.autokonfig.AutoKonfig | ||
import dev.nohus.autokonfig.types.BooleanSetting | ||
import dev.nohus.autokonfig.types.StringSetting | ||
import dev.nohus.autokonfig.withEnvironmentVariables | ||
import dev.nohus.autokonfig.withResourceConfig | ||
|
||
object ContractTestConfig { | ||
private fun AutoKonfig.withSafeResourceConfig(resource: String) = apply { | ||
try { | ||
withResourceConfig(resource) | ||
} catch (e: Exception) { | ||
} | ||
} | ||
|
||
private val config = AutoKonfig() | ||
.withSafeResourceConfig("config.properties") | ||
.withEnvironmentVariables() | ||
|
||
val pamSubKey by config.StringSetting() | ||
val pamPubKey by config.StringSetting() | ||
val pamSecKey by config.StringSetting() | ||
val pubKey by config.StringSetting() | ||
val subKey by config.StringSetting() | ||
val serverHostPort by config.StringSetting() | ||
val serverMock by config.BooleanSetting(true) | ||
import org.aeonbits.owner.Config | ||
import org.aeonbits.owner.ConfigFactory | ||
|
||
@Config.Sources("file:test.properties") | ||
interface ContractTestKeysConfig : Config { | ||
@get:Config.Key("subKey") | ||
val subKey: String | ||
|
||
@get:Config.Key("pubKey") | ||
val pubKey: String | ||
|
||
@get:Config.Key("pamSubKey") | ||
val pamSubKey: String | ||
|
||
@get:Config.Key("pamPubKey") | ||
val pamPubKey: String | ||
|
||
@get:Config.Key("pamSecKey") | ||
val pamSecKey: String | ||
|
||
@get:Config.Key("serverHostPort") | ||
val serverHostPort: String | ||
|
||
@get:Config.Key("serverMock") | ||
@get:Config.DefaultValue("true") | ||
val serverMock: Boolean | ||
} | ||
|
||
val ContractTestConfig: ContractTestKeysConfig = ConfigFactory.create(ContractTestKeysConfig::class.java, System.getenv()) |
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 |
---|---|---|
@@ -1,25 +1,24 @@ | ||
package com.pubnub.api | ||
|
||
import dev.nohus.autokonfig.AutoKonfig | ||
import dev.nohus.autokonfig.types.StringSetting | ||
import dev.nohus.autokonfig.withEnvironmentVariables | ||
import dev.nohus.autokonfig.withResourceConfig | ||
import org.aeonbits.owner.Config | ||
import org.aeonbits.owner.ConfigFactory | ||
|
||
object Keys { | ||
private fun AutoKonfig.withSafeResourceConfig(resource: String) = apply { | ||
try { | ||
withResourceConfig(resource) | ||
} catch (e: Exception) { | ||
} | ||
} | ||
@Config.Sources("file:test.properties") | ||
interface KeysConfig : Config { | ||
@get:Config.Key("subKey") | ||
val subKey: String | ||
|
||
private val config = AutoKonfig() | ||
.withSafeResourceConfig("config.properties") | ||
.withEnvironmentVariables() | ||
@get:Config.Key("pubKey") | ||
val pubKey: String | ||
|
||
val pubKey by config.StringSetting() | ||
val subKey by config.StringSetting() | ||
val pamPubKey by config.StringSetting() | ||
val pamSubKey by config.StringSetting() | ||
val pamSecKey by config.StringSetting() | ||
@get:Config.Key("pamSubKey") | ||
val pamSubKey: String | ||
|
||
@get:Config.Key("pamPubKey") | ||
val pamPubKey: String | ||
|
||
@get:Config.Key("pamSecKey") | ||
val pamSecKey: String | ||
} | ||
|
||
val Keys: KeysConfig = ConfigFactory.create(KeysConfig::class.java, System.getenv()) |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/test/resources/config-example.properties → test-example.properties
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