CountDownLatch を使用しているクラス用の junit を作成しようとしていますが、jmockit ライブラリを使用して junit テストを行っています。
public class MappedData {
private static final AtomicReference<Map<String, Map<Integer, String>>> mapped1 = new AtomicReference<Map<String, Map<Integer, String>>>();
private static final AtomicReference<Map<String, Map<Integer, String>>> mapped2 = new AtomicReference<Map<String, Map<Integer, String>>>();
private static final CountDownLatch firstSet = new CountDownLatch(1);
public static Map<String, Map<Integer, String>> getMapped1Table() {
try {
firstSet.await();
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
return mapped1.get();
}
public static Map<String, Map<Integer, String>> getMapped2Table() {
try {
firstSet.await();
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
return mapped2.get();
}
}
getMapped1Table
andメソッドでそれを確認する最も簡単な方法は何ですか-そのシナリオもカバーできるgetMapped2Table
ようにをスローできます。InterruptedException
これらの 2 つの方法を調べると、カバーできない catch ブロックがあります。
MappedData.getMapped1Table()
上記の2つのメソッドがスローされていることを確認する方法はありInterruptedException
ますか?
アップデート:-
私がやろうとしているのは、junit テスト中に firstSet.await() を取得して InterruptedException をスローする方法です。