MUnits 失败 "An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config"

MUnits fails with "An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config"

我正在使用 Anypoint 生成的连接器从我的主 Mule API 调用其他 api。 虽然 运行 通过模拟连接器并使用 munit:store 将有效负载存储到密钥并从密钥中检索以进行验证,但我收到了此错误。

An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config

有人可以解释是什么导致了这个问题吗?

这是完整的错误:

INFO  2021-03-10 20:31:36,919 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: {} Waiting for client connection 
INFO  2021-03-10 20:31:36,919 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: {} Client connection received from view-localhost - true
INFO  2021-03-10 20:31:37,082 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.DynamicConfigurationProvider-Logging_Config_in_Error_Handlers
INFO  2021-03-10 20:31:37,085 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.DynamicConfigurationProvider-Logging_Config_in_Error_Handlers
INFO  2021-03-10 20:31:37,089 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-system-api-httpreq-config-System_API_Config
INFO  2021-03-10 20:31:37,090 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-system-api-httpreq-config-System_API_Config
INFO  2021-03-10 20:31:37,093 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Stopping Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-Snowflake_E2E_Database_Config
INFO  2021-03-10 20:31:37,093 [munit.01] org.mule.runtime.core.privileged.lifecycle.AbstractLifecycleManager: {} Disposing Bean: org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter-Snowflake_E2E_Database_Config
org.mule.runtime.api.exception.MuleRuntimeException: org.mule.runtime.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "initialise" on object: org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig$$EnhancerByCGLIB$$edc0e215@748b8fa2
Caused by: org.mule.runtime.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "initialise" on object: org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig$$EnhancerByCGLIB$$edc0e215@748b8fa2
Caused by: java.lang.IllegalArgumentException: An Object Store was already defined for name token-manager-store-tokenManagerConfig-System_API_Config
       at org.mule.runtime.core.internal.util.store.MuleObjectStoreManager.createObjectStore(MuleObjectStoreManager.java:127)
       at org.mule.extension.oauth2.api.tokenmanager.TokenManagerConfig.initialise(TokenManagerConfig.java:103)
       at org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded(LifecycleUtils.java:56)
       at org.mule.runtime.core.api.util.func.CheckedConsumer.accept(CheckedConsumer.java:19)
       at org.mule.runtime.core.internal.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:115)
       at org.mule.runtime.core.internal.lifecycle.phases.MuleContextInitialisePhase.applyLifecycle(MuleContextInitialisePhase.java:73)
       at org.mule.runtime.config.internal.SpringRegistryLifecycleManager$SpringContextInitialisePhase.applyLifecycle(SpringRegistryLifecycleManager.java:128)
       at org.mule.runtime.core.internal.lifecycle.RegistryLifecycleManager.doApplyLifecycle(RegistryLifecycleManager.java:175)
       at org.mule.runtime.core.internal.lifecycle.RegistryLifecycleManager.applyPhase(RegistryLifecycleManager.java:146)
       at org.mule.runtime.config.internal.SpringRegistry.applyLifecycle(SpringRegistry.java:289)
       at org.mule.runtime.core.internal.registry.MuleRegistryHelper.applyLifecycle(MuleRegistryHelper.java:339)
       at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:285)
       at org.mule.runtime.config.internal.LazyMuleArtifactContext.lambda$applyLifecycle(LazyMuleArtifactContext.java:248)
       at org.mule.runtime.core.internal.context.DefaultMuleContext.withLifecycleLock(DefaultMuleContext.java:531)
       at org.mule.runtime.config.internal.LazyMuleArtifactContext.applyLifecycle(LazyMuleArtifactContext.java:246)
       at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:327)
       at org.mule.runtime.config.internal.LazyMuleArtifactContext.initializeComponents(LazyMuleArtifactContext.java:315)
       at org.mule.munit.runner.config.TestComponentLocator.initializeComponents(TestComponentLocator.java:63)
       at org.mule.munit.runner.model.builders.SuiteBuilder.build(SuiteBuilder.java:78)
       at org.mule.munit.runner.remote.api.server.RunMessageHandler.buildSuite(RunMessageHandler.java:108)
       at org.mule.munit.runner.remote.api.server.RunMessageHandler.parseSuiteMessage(RunMessageHandler.java:94)
       at org.mule.munit.runner.remote.api.server.RunMessageHandler.parseAndRun(RunMessageHandler.java:81)
       at org.mule.munit.runner.remote.api.server.RunMessageHandler.handle(RunMessageHandler.java:75)
       at org.mule.munit.runner.remote.api.server.RunnerServer.handleClientMessage(RunnerServer.java:145)
       at org.mule.munit.runner.remote.api.server.RunnerServer.run(RunnerServer.java:91)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
       at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)

更新:这里是 Munit 测试和生成的连接器 api 模块 xml 文件的一些屏幕截图。基本上,我试图使用 munit-tools:store 将传递给连接器的有效负载(通过 t运行sform 消息传递)存储在对象存储密钥中。生成的连接器端点有如下所示的部分输出

我正在获取存储在此变量中的值并将其存储到此 munit-tools:store 键中,如下所示。

如果我 运行 我的 Munit 测试套件一次一个,我就不会遇到这个问题。但是,当 运行 全部放在一起时,它失败了。

现在查看生成的连接器模块的屏幕截图 xml。

错误可能是由于第 38 行和第 54 行中的 oauth 配置引起的。我相信在模拟之前的连接器上发生了 Oauth 调用,并且它正在将令牌值存储到显示的每个测试套件的令牌管理器配置。由于它已经为给定的令牌配置创建并存储了一些值,因此它不允许第二次创建对象库。但有一件事是肯定的,我们无法编辑任何生成的连接器 xmls.


下面是生成的 xml 和 munit 测试用例在工作室中的样子。抱歉,我不能在这里粘贴源代码。

我们在项目中遇到了类似的问题。这是由 Oauth 模块引起的。将 oauth 模块升级到 1.1.15 解决了问题:

    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-oauth-module</artifactId>
        <version>1.1.15</version>
        <classifier>mule-plugin</classifier>
    </dependency>