質問はそれほど明確ではないかもしれませんが、例を挙げれば、私はそれを明らかにすると思います。私のプロジェクトには、統合テストとシナリオテストの2種類のテストがあります。どちらもデータソースが必要です(カスタムメイドのpropertyplaceholderを使用)。
統合テストケースのコンテキストでは、次のように、データソースとプレースホルダーのみを定義します。
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>
<bean id="propertyResolver" class="com.cegeka.bibliothouris.test.MultiThreadedPropertyResolver">
<property name="location"><value>classpath:testContext.properties</value></property>
</bean>
私のシナリオテストケースコンテキストでは、これらのオブジェクトも(他のものと一緒に)必要ですが、シナリオコンテキストに統合コンテキストを作成したいので、ある種の継承が必要です。
私はすでにclassPathApplicationContext
シナリオテストケースでそれを試しました(一度trueでlazy-initを使用)、次のようになります:
<bean class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>classpath:overridingTestContext.xml</value>
</list>
</constructor-arg>
</bean>
dataSource
しかし、彼はシナリオコンテキストでを作成しません。これはグーグルするのが非常に難しい問題です、それで私はここでそれを尋ねています。私は誰かが解決策を持っていることを願っています。