2013-11-27 50 views
1

請幫我解決這個問題。我開發了我的騾子流(3.4版)。當我運行JUnit測試用例時,Flow運行正常,直到Data Mapper消息處理器。在達到dataMapper流後拋出錯誤,如.grf doesnot exits。但是當我在Mule服務器上運行相同的流程時能夠成功獲得響應。只有在運行JUnit TestCase時纔會發生問題。 觀察:當我們碰到JUit TestCase時,DataMapper位置在類路徑中無法識別。請找我的完整的錯誤Mule 3.4 -JUnit TestCase故障轉移騾子DataMapper MessageProcessor ESB


錯誤[線程0] [org.mule.exception.CatchMessagingExceptionStrategy] - 消息:com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException:數據映射圖C:\ Documents and Settings \ UserID \ Desktop \ Mule-Project \ MuleProject \ Transformation_InputRequest.grf不存在(java.lang.RuntimeException)。消息有效載荷的類型爲:字符串

代碼:MULE ERROR -2 異常堆棧是: 1.數據映射圖C:\ Documents和Settings \用戶ID \桌面\ MuleProject \ MuleProject \ Transformation_InputRequest.grf確實不存在(com.mulesoft.mule.module.datamapper.api.exception.DataMapperCreationException) com.mulesoft.mule.module.datamapper.clover.impl.graphfactory.AppHomeCloverGraphFactoryImpl:52(空)


我已經觀察到 - 這個問題有關JIRA提出:https://www.mulesoft.org/jira/browse/STUDIO-3400但它似乎是開放狀態。 我無法繼續執行其他成功和失敗場景的Junit TestCase,因爲我在主流程中有dataMapper。 有什麼辦法可以解決這個問題以進一步進行。請建議。 在此先感謝。

回答

4

嘗試添加以下到您的測試類:

@Override 
protected Properties getStartUpProperties() { 
    Properties properties = new Properties(super.getStartUpProperties()); 
    properties.put(MuleProperties.APP_HOME_DIRECTORY_PROPERTY, new File("mappings").getAbsolutePath()); 
    return properties; 
} 
+0

謝謝@Seba。它工作正常。我在上面的代碼中做了一些修改。我在代碼段之間添加了文件讀取邏輯,以便從Data Mapper錯誤中解脫出來。 – star

1

我知道這是像2歲。我有這個相同的問題,上面的解決方案確實有效。但是可以避免使用額外的代碼。我發現問題是我的目錄路徑中的空間。嘗試將您的項目從 C:\Documents and Settings\UserID\Desktop\Mule-Project\MuleProject\Transformation_InputRequest.grf 更改爲C:\Projects或任何其他路徑名稱中沒有空格的目錄。