【问题标题】:Asserting SMTP connector attributes in a flow在流中断言 SMTP 连接器属性
【发布时间】:2014-12-05 18:41:33
【问题描述】:

我有一个以 SMTP 端点结束的子流。 我已经使用 MUnit 模拟了 smtp:outbound-endpoint,以验证在给定流输入的情况下是否按预期指定了属性。

但我无法验证的一件事是内容类型/mime 类型。此属性在关联的连接器上设置。但似乎不可能将连接器模拟为消息处理器。

如何验证 smtp:connector 上的 mimeType 是否设置为某个值?

例如(下),如果我的 xml 有一个无效的名称来配置下面的 contentType,我怎么能写一个测试来防止它:

<smtp:connector name="smtpConnector"  doc:name="SMTP" contentType="#[flowVars.someInvalidName]"/>

【问题讨论】:

    标签: java unit-testing mule


    【解决方案1】:

    你可以使用:

    String contentTypeInbound = message.getProperty("content-type", PropertyScope.INBOUND);
    MimeType mt = new MimeType(contentTypeInbound);
    String mimeType = mt.getPrimaryType() + "/" + mt.getSubType();
    assertEquals(expectedMimeType, mimeType);
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2017-11-02
      • 2012-02-18
      • 2018-09-21
      • 2017-12-23
      • 1970-01-01
      • 2020-05-20
      • 2014-09-06
      • 2016-06-21
      • 2021-12-16
      相关资源
      最近更新 更多