Spring Webflow フロー内で使用される Spring Bean をモックするための明確なガイドラインがあります。フローはデフォルトで暗黙的にフローから Spring Bean を参照でき、AbstractXmlFlowExecutionTests ベース テスト クラスにはこれらの Bean をモックするためにオーバーライドするメソッドがあります。
テスト対象のフローでフロー変数の @Autowired フィールドをモックする同様の手段が見つかりません。私が何を意味するかを理解するには、次の基本的なセットアップを参照してください。
テスト中の流れ:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
parent="commons">
<var name="consumerBean" class="com.mycompany.ConsumerBean" />
<!-- etc.. -->
@Autowired フィールドを持つ Bean:
public class ConsumerBean implements Serializable {
@Autowired
transient CustomerService userService;
//Etc..
私の質問は、「userService」のモックを「consumerBean」フロー変数に提供/構成するにはどうすればよいですか?