diff --git a/core/api/src/main/java/io/gatehill/imposter/config/LoadedConfig.kt b/core/api/src/main/java/io/gatehill/imposter/config/LoadedConfig.kt
index c06ca9735..f6930a2d0 100644
--- a/core/api/src/main/java/io/gatehill/imposter/config/LoadedConfig.kt
+++ b/core/api/src/main/java/io/gatehill/imposter/config/LoadedConfig.kt
@@ -46,8 +46,14 @@ package io.gatehill.imposter.config
/**
* Holds a loaded configuration and its reference.
*/
-data class LoadedConfig(
- val ref: ConfigReference,
- val serialised: String,
- val plugin: String,
-)
+interface LoadedConfig {
+ val ref: ConfigReference
+ val serialised: String
+ val plugin: String
+}
+
+data class LoadedConfigImpl(
+ override val ref: ConfigReference,
+ override val serialised: String,
+ override val plugin: String,
+) : LoadedConfig
diff --git a/core/config/build.gradle b/core/config/build.gradle
index 0329dcb81..85ee43df8 100644
--- a/core/config/build.gradle
+++ b/core/config/build.gradle
@@ -14,11 +14,6 @@ dependencies {
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$version_jackson"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$version_jackson"
- implementation "com.esotericsoftware:kryo:5.6.0"
-
-// implementation "de.ruedigermoeller:fst:2.56"
- implementation "de.ruedigermoeller:fst:3.0.1"
-
// test
testImplementation "junit:junit:$version_junit"
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: version_hamcrest
diff --git a/core/config/src/main/java/io/gatehill/imposter/config/loader/ConfigLoader.kt b/core/config/src/main/java/io/gatehill/imposter/config/loader/ConfigLoader.kt
new file mode 100644
index 000000000..ccdf53a57
--- /dev/null
+++ b/core/config/src/main/java/io/gatehill/imposter/config/loader/ConfigLoader.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2024.
+ *
+ * This file is part of Imposter.
+ *
+ * "Commons Clause" License Condition v1.0
+ *
+ * The Software is provided to you by the Licensor under the License, as
+ * defined below, subject to the following condition.
+ *
+ * Without limiting other conditions in the License, the grant of rights
+ * under the License will not include, and the License does not grant to
+ * you, the right to Sell the Software.
+ *
+ * For purposes of the foregoing, "Sell" means practicing any or all of
+ * the rights granted to you under the License to provide to third parties,
+ * for a fee or other consideration (including without limitation fees for
+ * hosting or consulting/support services related to the Software), a
+ * product or service whose value derives, entirely or substantially, from
+ * the functionality of the Software. Any license notice or attribution
+ * required by the License must also include this Commons Clause License
+ * Condition notice.
+ *
+ * Software: Imposter
+ *
+ * License: GNU Lesser General Public License version 3
+ *
+ * Licensor: Peter Cornish
+ *
+ * Imposter is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Imposter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Imposter. If not, see .
+ */
+
+package io.gatehill.imposter.config.loader
+
+import io.gatehill.imposter.config.ConfigReference
+import io.gatehill.imposter.config.LoadedConfig
+import io.gatehill.imposter.plugin.config.BasicPluginConfig
+import java.io.File
+
+/**
+ * Reads configuration files and deserialises them to plugin configuration instances.
+ *
+ * @author Pete Cornish
+ */
+interface ConfigLoader {
+ fun readPluginConfig(configRef: ConfigReference): C
+ fun loadConfig(configFile: File, loadedConfig: C, configClass: Class): T
+}
diff --git a/core/config/src/main/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImpl.kt b/core/config/src/main/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImpl.kt
new file mode 100644
index 000000000..564604d01
--- /dev/null
+++ b/core/config/src/main/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImpl.kt
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2024.
+ *
+ * This file is part of Imposter.
+ *
+ * "Commons Clause" License Condition v1.0
+ *
+ * The Software is provided to you by the Licensor under the License, as
+ * defined below, subject to the following condition.
+ *
+ * Without limiting other conditions in the License, the grant of rights
+ * under the License will not include, and the License does not grant to
+ * you, the right to Sell the Software.
+ *
+ * For purposes of the foregoing, "Sell" means practicing any or all of
+ * the rights granted to you under the License to provide to third parties,
+ * for a fee or other consideration (including without limitation fees for
+ * hosting or consulting/support services related to the Software), a
+ * product or service whose value derives, entirely or substantially, from
+ * the functionality of the Software. Any license notice or attribution
+ * required by the License must also include this Commons Clause License
+ * Condition notice.
+ *
+ * Software: Imposter
+ *
+ * License: GNU Lesser General Public License version 3
+ *
+ * Licensor: Peter Cornish
+ *
+ * Imposter is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Imposter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Imposter. If not, see .
+ */
+
+package io.gatehill.imposter.config.loader
+
+import com.fasterxml.jackson.databind.JsonMappingException
+import io.gatehill.imposter.config.ConfigReference
+import io.gatehill.imposter.config.LoadedConfig
+import io.gatehill.imposter.config.LoadedConfigImpl
+import io.gatehill.imposter.config.expression.EnvEvaluator
+import io.gatehill.imposter.config.expression.SystemEvaluator
+import io.gatehill.imposter.config.model.LightweightConfig
+import io.gatehill.imposter.config.util.ConfigUtil
+import io.gatehill.imposter.config.util.EnvVars
+import io.gatehill.imposter.expression.eval.ExpressionEvaluator
+import io.gatehill.imposter.expression.util.ExpressionUtil
+import io.gatehill.imposter.plugin.config.BasicPluginConfig
+import java.io.File
+import java.io.IOException
+
+/**
+ * YAML (and JSON) implementation of a configuration loader.
+ *
+ * @author Pete Cornish
+ */
+class YamlConfigLoaderImpl : ConfigLoader {
+ private var expressionEvaluators: Map> = emptyMap()
+
+ init {
+ initInterpolators(EnvVars.getEnv())
+ }
+
+ fun initInterpolators(environment: Map) {
+ // reset the environment used by the expression evaluator
+ expressionEvaluators = mapOf(
+ "env" to EnvEvaluator(environment),
+ "system" to SystemEvaluator,
+ )
+ }
+
+ /**
+ * Reads the contents of the configuration file, performing necessary string substitutions.
+ *
+ * @param configRef the configuration reference
+ * @return the loaded configuration
+ */
+ override fun readPluginConfig(configRef: ConfigReference): LoadedConfig {
+ val configFile = configRef.file
+ try {
+ val rawContents = configFile.readText()
+ val parsedContents = ExpressionUtil.eval(rawContents, expressionEvaluators, nullifyUnsupported = false)
+
+ val config = ConfigUtil.lookupMapper(configFile).readValue(parsedContents, LightweightConfig::class.java)
+ config.plugin
+ ?: throw IllegalStateException("No plugin specified in configuration file: $configFile")
+
+ return LoadedConfigImpl(configRef, parsedContents, config.plugin)
+
+ } catch (e: JsonMappingException) {
+ throw RuntimeException("Error reading configuration file: " + configFile.absolutePath + ", reason: ${e.message}")
+ } catch (e: IOException) {
+ throw RuntimeException("Error reading configuration file: " + configFile.absolutePath, e)
+ }
+ }
+
+ override fun loadConfig(configFile: File, loadedConfig: LoadedConfig, configClass: Class): T =
+ ConfigUtil.lookupMapper(configFile).readValue(loadedConfig.serialised, configClass)!!
+}
diff --git a/core/config/src/main/java/io/gatehill/imposter/config/util/BinarySerialisationUtil.kt b/core/config/src/main/java/io/gatehill/imposter/config/util/BinarySerialisationUtil.kt
deleted file mode 100644
index 65eb544ea..000000000
--- a/core/config/src/main/java/io/gatehill/imposter/config/util/BinarySerialisationUtil.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-package io.gatehill.imposter.config.util
-
-import com.esotericsoftware.kryo.Kryo
-import com.esotericsoftware.kryo.io.Input
-import com.esotericsoftware.kryo.io.Output
-import org.nustaq.serialization.FSTConfiguration
-import java.io.ByteArrayInputStream
-import java.io.ByteArrayOutputStream
-import java.io.File
-import java.io.ObjectInputStream
-import java.io.ObjectOutputStream
-
-object BinarySerialisationUtil {
- private val kryo = Kryo().apply {
- isRegistrationRequired = false
- references = true
- }
-
- private val conf: FSTConfiguration by lazy { FSTConfiguration.createDefaultConfiguration() }
-
- fun serialise(obj: Any, filePath: String) = serialiseKryo(obj, filePath)
- fun deserialise(filePath: String) = deserialiseKryo(filePath)
-
- /**
- * Serialises an object to a file using FST.
- */
- fun serialiseFst(obj: Any, filePath: String) {
- File(filePath).outputStream().use {
- val output = conf.asByteArray(obj)
- it.write(output)
- }
- }
-
- /**
- * Deserialises an object from a file using FST.
- */
- fun deserialiseFst(filePath: String): T {
- return File(filePath).inputStream().use {
- conf.asObject(it.readAllBytes()) as T
- }
- }
-
- /**
- * Serialises an object to a file using Kryo.
- */
- fun serialiseKryo(obj: Any, filePath: String) {
- File(filePath).outputStream().use {
- val output = Output(it)
- kryo.writeClassAndObject(output, obj)
- output.close()
- }
- }
-
- /**
- * Deserialises an object from a file using Kryo.
- */
- fun deserialiseKryo(filePath: String): T {
- return File(filePath).inputStream().use {
- val input = Input(it)
- val obj = kryo.readClassAndObject(input) as T
- input.close()
- obj
- }
- }
-
- fun serialiseJOS(obj: Any, filePath: String) {
- ByteArrayOutputStream().use { byteArrayOutputStream ->
- ObjectOutputStream(byteArrayOutputStream).use { objectOutputStream ->
- objectOutputStream.writeObject(obj)
- java.io.File(filePath).writeBytes(byteArrayOutputStream.toByteArray())
- }
- }
- }
-
- fun deserialiseJOS(filePath: String): T {
- val bytes = java.io.File(filePath).readBytes()
- return ByteArrayInputStream(bytes).use { byteArrayInputStream ->
- ObjectInputStream(byteArrayInputStream).use { objectInputStream ->
- objectInputStream.readObject()
- }
- } as T
- }
-}
diff --git a/core/config/src/main/java/io/gatehill/imposter/config/util/ConfigUtil.kt b/core/config/src/main/java/io/gatehill/imposter/config/util/ConfigUtil.kt
index bb8d4bdf7..440f7d01e 100644
--- a/core/config/src/main/java/io/gatehill/imposter/config/util/ConfigUtil.kt
+++ b/core/config/src/main/java/io/gatehill/imposter/config/util/ConfigUtil.kt
@@ -47,12 +47,9 @@ import com.fasterxml.jackson.databind.ObjectMapper
import io.gatehill.imposter.ImposterConfig
import io.gatehill.imposter.config.ConfigReference
import io.gatehill.imposter.config.LoadedConfig
-import io.gatehill.imposter.config.expression.EnvEvaluator
-import io.gatehill.imposter.config.expression.SystemEvaluator
-import io.gatehill.imposter.config.model.LightweightConfig
+import io.gatehill.imposter.config.loader.ConfigLoader
+import io.gatehill.imposter.config.loader.YamlConfigLoaderImpl
import io.gatehill.imposter.config.resolver.ConfigResolver
-import io.gatehill.imposter.expression.eval.ExpressionEvaluator
-import io.gatehill.imposter.expression.util.ExpressionUtil
import io.gatehill.imposter.plugin.PluginManager
import io.gatehill.imposter.plugin.config.BasicPluginConfig
import io.gatehill.imposter.plugin.config.InterceptorsHolder
@@ -84,14 +81,12 @@ object ConfigUtil {
"yml" to MapUtil.YAML_MAPPER
)
- private val scanRecursiveConfig
+ val scanRecursiveConfig
get() = EnvVars.getEnv("IMPOSTER_CONFIG_SCAN_RECURSIVE")?.toBoolean() == true
private val autoBasePath
get() = EnvVars.getEnv("IMPOSTER_AUTO_BASE_PATH")?.toBoolean() == true
- private var expressionEvaluators: Map> = emptyMap()
-
private val defaultIgnoreList: List by lazy {
ConfigUtil::class.java.getResourceAsStream("/$IGNORE_FILE_NAME")?.use {
parseExclusionsFile(it.reader().readLines())
@@ -101,7 +96,9 @@ object ConfigUtil {
}
}
- val configResolvers: Set
+ private val configResolvers: Set
+
+ private val configLoader: ConfigLoader
/**
* Controls whether errors encountered during configuration parsing
@@ -116,7 +113,7 @@ object ConfigUtil {
init {
configResolvers = registerResolvers()
- initInterpolators(EnvVars.getEnv())
+ configLoader = getLoader()
}
private fun registerResolvers(): Set {
@@ -132,20 +129,28 @@ object ConfigUtil {
}.toSet()
}
+ private fun getLoader(): ConfigLoader {
+ val loaderName = EnvVars.getEnv("IMPOSTER_CONFIG_LOADER") ?: "yaml"
+ LOGGER.trace("Using config loader: $loaderName")
+
+ return when (loaderName) {
+ "yaml" -> YamlConfigLoaderImpl()
+ "kryo" -> {
+ @Suppress("UNCHECKED_CAST")
+ Class.forName("io.gatehill.imposter.config.loader.kryo.KryoConfigLoader")
+ .getDeclaredConstructor()
+ .newInstance() as ConfigLoader
+ }
+ else -> throw IllegalStateException("Invalid configuration loader: $loaderName")
+ }
+ }
+
/**
* Parses the `IMPOSTER_CONFIG_DIR` environment variable for a list of configuration directories.
*/
fun parseConfigDirEnvVar(): Array =
EnvVars.getEnv("IMPOSTER_CONFIG_DIR")?.splitOnCommaAndTrim()?.toTypedArray() ?: emptyArray()
- fun initInterpolators(environment: Map) {
- // reset the environment used by the expression evaluator
- expressionEvaluators = mapOf(
- "env" to EnvEvaluator(environment),
- "system" to SystemEvaluator,
- )
- }
-
/**
* Resolves configuration directories to local paths, then
* discovers configuration files. File discovery is optionally
@@ -196,7 +201,7 @@ object ConfigUtil {
configCount++
// load to determine plugin
- val config = readPluginConfig(configFile)
+ val config = configLoader.readPluginConfig(configFile)
val pluginClass = pluginManager.determinePluginClass(config.plugin)
val pluginConfigs = allPluginConfigs.getOrPut(pluginClass) { mutableListOf() }
@@ -254,31 +259,6 @@ object ConfigUtil {
return CONFIG_FILE_MAPPERS.keys.any { extension -> name.endsWith("$CONFIG_FILE_SUFFIX.$extension") }
}
- /**
- * Reads the contents of the configuration file, performing necessary string substitutions.
- *
- * @param configRef the configuration reference
- * @return the loaded configuration
- */
- internal fun readPluginConfig(configRef: ConfigReference): LoadedConfig {
- val configFile = configRef.file
- try {
- val rawContents = configFile.readText()
- val parsedContents = ExpressionUtil.eval(rawContents, expressionEvaluators, nullifyUnsupported = false)
-
- val config = lookupMapper(configFile).readValue(parsedContents, LightweightConfig::class.java)
- config.plugin
- ?: throw IllegalStateException("No plugin specified in configuration file: $configFile")
-
- return LoadedConfig(configRef, parsedContents, config.plugin)
-
- } catch (e: JsonMappingException) {
- throw RuntimeException("Error reading configuration file: " + configFile.absolutePath + ", reason: ${e.message}")
- } catch (e: IOException) {
- throw RuntimeException("Error reading configuration file: " + configFile.absolutePath, e)
- }
- }
-
/**
* Converts the raw configuration into a typed configuration object.
*
@@ -294,7 +274,7 @@ object ConfigUtil {
): T {
val configFile = loadedConfig.ref.file
try {
- var config = lookupMapper(configFile).readValue(loadedConfig.serialised, configClass)!!
+ val config: T = configLoader.loadConfig(configFile, loadedConfig, configClass)
check(config.plugin != null) { "No plugin specified in configuration file: $configFile" }
@@ -339,12 +319,6 @@ object ConfigUtil {
}
}
- BinarySerialisationUtil.serialise(config, "/tmp/config.bin")
- println("serialised config")
-
- config = BinarySerialisationUtil.deserialise("/tmp/config.bin")
- println("deserialised config")
-
// always set after deserialisation
config.dir = configFile.parentFile
@@ -363,7 +337,7 @@ object ConfigUtil {
* @param configFile the configuration file
* @return the mapper
*/
- private fun lookupMapper(configFile: File): ObjectMapper {
+ internal fun lookupMapper(configFile: File): ObjectMapper {
val extension = configFile.name.substringAfterLast(".")
return CONFIG_FILE_MAPPERS[extension]
?: throw IllegalStateException("Unable to locate mapper for config file: $configFile")
diff --git a/core/config/src/test/java/io/gatehill/imposter/config/ConfigUtilTest.kt b/core/config/src/test/java/io/gatehill/imposter/config/ConfigUtilTest.kt
index 167ea8033..e8f3549ef 100644
--- a/core/config/src/test/java/io/gatehill/imposter/config/ConfigUtilTest.kt
+++ b/core/config/src/test/java/io/gatehill/imposter/config/ConfigUtilTest.kt
@@ -43,17 +43,16 @@
package io.gatehill.imposter.config
import io.gatehill.imposter.ImposterConfig
+import io.gatehill.imposter.config.loader.YamlConfigLoaderImpl
import io.gatehill.imposter.config.support.BasePathSupportingPluginConfig
import io.gatehill.imposter.config.util.ConfigUtil
import io.gatehill.imposter.config.util.EnvVars
import io.gatehill.imposter.http.HttpMethod
import org.hamcrest.MatcherAssert.assertThat
-import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.not
import org.hamcrest.Matchers.nullValue
import org.hamcrest.Matchers.startsWith
-import org.junit.AfterClass
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
@@ -66,34 +65,6 @@ import java.io.File
* @author Pete Cornish
*/
class ConfigUtilTest {
- companion object {
- @AfterClass
- @JvmStatic
- fun afterClass() {
- ConfigHolder.config.listenPort = 0
- }
- }
-
- @Test
- fun testReadInterpolatedPluginConfig() {
- ConfigHolder.config.listenPort = 9090
-
- // override environment variables in string interpolators
- val environment: Map = mapOf(
- "EXAMPLE_PLUGIN" to "example-plugin"
- )
- ConfigUtil.initInterpolators(environment)
-
- val configFile = File(ConfigUtilTest::class.java.getResource("/interpolated/test-config.yaml").toURI())
- val configRef = ConfigReference(
- file = configFile,
- configRoot = configFile.parentFile,
- )
- val loadedConfig = ConfigUtil.readPluginConfig(configRef)
- assertEquals("example-plugin", loadedConfig.plugin)
- assertThat(loadedConfig.serialised, containsString("port 9090"))
- }
-
/**
* All config files within the config dir and its subdirectories should be returned.
*/
@@ -163,7 +134,8 @@ class ConfigUtilTest {
file = configFile,
configRoot = configFile.parentFile,
)
- val loadedConfig = ConfigUtil.readPluginConfig(configRef)
+ val loader = YamlConfigLoaderImpl()
+ val loadedConfig = loader.readPluginConfig(configRef)
val config = ConfigUtil.loadPluginConfig(
ImposterConfig(),
loadedConfig,
@@ -201,7 +173,8 @@ class ConfigUtilTest {
file = configFile,
configRoot = configFile.parentFile,
)
- val loadedConfig = ConfigUtil.readPluginConfig(configRef)
+ val loader = YamlConfigLoaderImpl()
+ val loadedConfig = loader.readPluginConfig(configRef)
val config = ConfigUtil.loadPluginConfig(
ImposterConfig(),
loadedConfig,
@@ -236,5 +209,5 @@ class ConfigUtilTest {
}
private fun buildLoadedConfig(configRef: ConfigReference, configFile: File) =
- LoadedConfig(configRef, configFile.readText(), "io.gatehill.imposter.core.test.ExamplePluginImpl")
+ LoadedConfigImpl(configRef, configFile.readText(), "io.gatehill.imposter.core.test.ExamplePluginImpl")
}
diff --git a/core/config/src/test/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImplTest.kt b/core/config/src/test/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImplTest.kt
new file mode 100644
index 000000000..5df17c069
--- /dev/null
+++ b/core/config/src/test/java/io/gatehill/imposter/config/loader/YamlConfigLoaderImplTest.kt
@@ -0,0 +1,56 @@
+package io.gatehill.imposter.config.loader
+
+import io.gatehill.imposter.config.ConfigHolder
+import io.gatehill.imposter.config.ConfigReference
+import io.gatehill.imposter.config.ConfigUtilTest
+import org.hamcrest.MatcherAssert
+import org.hamcrest.Matchers
+import org.junit.AfterClass
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import java.io.File
+
+/**
+ * Tests for [YamlConfigLoaderImpl].
+ *
+ * @author Pete Cornish
+ */
+class YamlConfigLoaderImplTest {
+ companion object {
+ @AfterClass
+ @JvmStatic
+ fun afterClass() {
+ ConfigHolder.config.listenPort = 0
+ }
+ }
+
+ @Test
+ fun testReadInterpolatedPluginConfig() {
+ ConfigHolder.config.listenPort = 9090
+
+ // override environment variables in string interpolators
+ val environment: Map = mapOf(
+ "EXAMPLE_PLUGIN" to "example-plugin"
+ )
+
+ val loader = YamlConfigLoaderImpl()
+ loader.initInterpolators(environment)
+
+ val configFile = File(ConfigUtilTest::class.java.getResource("/interpolated/test-config.yaml").toURI())
+ val configRef = ConfigReference(
+ file = configFile,
+ configRoot = configFile.parentFile,
+ )
+ val loadedConfig = loader.readPluginConfig(configRef)
+ assertEquals("example-plugin", loadedConfig.plugin)
+ MatcherAssert.assertThat(loadedConfig.serialised, Matchers.containsString("port 9090"))
+ }
+
+ @Test
+ fun readPluginConfig() {
+ }
+
+ @Test
+ fun loadConfig() {
+ }
+}
diff --git a/mock/wiremock/src/main/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginImpl.kt b/mock/wiremock/src/main/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginImpl.kt
index 352eda83c..bd8df52ba 100644
--- a/mock/wiremock/src/main/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginImpl.kt
+++ b/mock/wiremock/src/main/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginImpl.kt
@@ -45,6 +45,7 @@ package io.gatehill.imposter.plugin.wiremock
import io.gatehill.imposter.ImposterConfig
import io.gatehill.imposter.config.ConfigReference
import io.gatehill.imposter.config.LoadedConfig
+import io.gatehill.imposter.config.LoadedConfigImpl
import io.gatehill.imposter.config.util.EnvVars
import io.gatehill.imposter.http.HttpMethod
import io.gatehill.imposter.plugin.PluginInfo
@@ -126,7 +127,7 @@ class WiremockPluginImpl @Inject constructor(
configFiles += writeConfig(localConfigDir, 0, converted.flatten())
}
logger.debug("Wrote converted wiremock mapping file(s) to $localConfigDir")
- return configFiles.map { LoadedConfig(ConfigReference(it, mappingsFile.ref.configRoot), mappingsFile.serialised, mappingsFile.plugin) }
+ return configFiles.map { LoadedConfigImpl(ConfigReference(it, mappingsFile.ref.configRoot), mappingsFile.serialised, mappingsFile.plugin) }
}
}
logger.warn("No wiremock mapping files found in $sourceDir")
diff --git a/mock/wiremock/src/test/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginTest.kt b/mock/wiremock/src/test/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginTest.kt
index 15f5f3b8d..d621ea4f8 100644
--- a/mock/wiremock/src/test/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginTest.kt
+++ b/mock/wiremock/src/test/java/io/gatehill/imposter/plugin/wiremock/WiremockPluginTest.kt
@@ -45,7 +45,7 @@ package io.gatehill.imposter.plugin.wiremock
import io.gatehill.imposter.ImposterConfig
import io.gatehill.imposter.config.ConfigReference
-import io.gatehill.imposter.config.LoadedConfig
+import io.gatehill.imposter.config.LoadedConfigImpl
import io.gatehill.imposter.config.util.EnvVars
import io.gatehill.imposter.service.HandlerService
import io.gatehill.imposter.service.ResponseFileService
@@ -159,7 +159,7 @@ class WiremockPluginTest {
file = File(mappingsDir, "imposter-config.yaml"),
configRoot = mappingsDir
)
- val loadedConfig = LoadedConfig(configRef, configRef.file.readText(), "wiremock")
+ val loadedConfig = LoadedConfigImpl(configRef, configRef.file.readText(), "wiremock")
val loadedConfigs = wiremock.convert(loadedConfig)
assertThat(loadedConfigs, hasSize(expectedConfigFiles))