java - 在 Mule 中触发模拟 quartz 端点

标签 java mocking mule quartz-scheduler

我是 Mule 新手,我不知道如何在 Mule 中从 Java 触发 Quartz 端点,尤其是在单元测试的上下文中这样做时。

首先,Mule 中 Quartz 的 API 位于哪里?我在 Mule 网站上找不到这个。然而,在Quartz网站上,我发现了“http://quartz-scheduler.org/api/2.1.0/”,这似乎是通用的Quartz API。这个 API 和 Mule 使用的 API 有区别吗?如果没有,在我在 "./MuleStudio_3.4.0/plugins/org.mule.tooling.server.3.4.0.ee_3.4.0.201312031922/mule/mule/mule-transport-quartz- 添加 jar 文件后3.4.0.jar” 添加到我的构建路径中,Mule Studio 无法解析“org.quartz”,它是 Quartz API 的核心包。如果有差异,我需要了解 Mule 使用的 Quartz API。

下面是我尝试测试的 XML:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/2.0/mule-mongo.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<quartz:connector name="QuartzConnName" validateConnections="true" doc:name="Quartz"/>
<flow name="flow_name" doc:name="flow_name">
<quartz:inbound-endpoint jobName="QuartzJobName" cronExpression="${cron.start}" repeatInterval="0" responseTimeout="10000" connector-ref="QuartzConnName" doc:name="Scheduler">
            <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
</flow>
</mule>

内部Mule服务器版本是3.4,Mule Studio版本是3.4.0。

最佳答案

我真的看不出测试 Quartz 端点的值(value),除非你在 MuleSoft 开发这种传输。您应该仅测试您自己的流程和组件。

如果您只想在FunctionalTestCase @Test方法中使用Quartz入站调度程序触发流程,您可以使用一些虚拟消息直接调用该流程:

Flow flow = (Flow) getFlowConstruct("myFlow1");
MuleEvent event = getTestEvent("", flow);
MuleEvent result = flow.process(event);
String returnData = result.getMessage().getPayloadAsString();

关于java - 在 Mule 中触发模拟 quartz 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21893666/

相关文章:

java - ReadWriteLock 写锁饱和

python - Django 模拟未按预期工作

python - MagicMock 对象可以迭代吗?

java - 骡子 ESB 3.4.0 CE : Redeliver message through TCP Endpoint upon Socket Exception

java - 在 DataWeave 1.0 中将字符串转换为数字时如何避免指数

java - 在 scrollview 和 viewpager 之间触摸

java - 将 BKS 与 keytool 一起使用导致无法从回复建立链

java - GlassFish v3 Prelude - 管理问题

java - 如何使用 JMockit 模拟 DAO 层?

java - Mule ESB - 集成测试 - REST 端点 - 使用 MuleClient