Maven 3.0.3、JUnit 4.8.1、および Java 1.6 を使用しています。私はJUnitテストファイルにこれを持っています...
@Before
public void loadTestProps() throws IOException, GeneralSecurityException {
final InputStream in = getClass().getClassLoader().getResourceAsStream("test.properties");
testProps = new Properties();
testProps.load(in);
「test.properties」が取得されていません (入力ストリーム オブジェクトが null です)。私のプロジェクト構造は次のとおりです。
親 + --- pom.xml
+ --- war モジュール
+ ------ pom.xml
+ ------ src/test/java/JUnit ファイル
+ ------ src/test/ resources/test.properties
+ --- ear モジュール
+ ------- pom.xml
テストは WAR ファイルのみに関連するため、WAR モジュール内に「src/test/resources」ディレクトリを保持したいと考えています。「test.properties」を見つけるために上記のJavaを書き直す方法はありますか、それともWARモジュールからファイルを移動する必要がありますか?