@BeforeClassコールバックは arquillian テストでは機能しないため、@PostConstructテストのコールバックでいくつかのフィールドを初期化しようとしました。展開にはがあり、注釈と引数なしのコンストラクターbeans.xmlも追加しようとしましたが、効果はありません。@StartupCDI は機能しており、テストの他のフィールドに対してすべてのインジェクションが実行されていますが、@PostConstruct呼び出されていません。何か不足していますか?
で使用Arquillian 1.0.0.FinalしていJBoss 7.1.1.Finalます。回避策を探しているわけではありません-@Beforeコールバックを使用できます。しかし、すべてのテストで一度だけ値を初期化する必要があるため、これは明らかに最適ではありません。さらに重要なことに、観察された動作は、私の CDI の理解と矛盾しているようです。
これが私のテストの要点です:
@RunWith(Arquillian.class)
public class UploadResetterTest {
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap
.create(WebArchive.class, "uploadResetTest.war")
.addPackages(true, "my.package")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
Map<String, String> predicates = new HashMap<String, String>();
@Inject
Logger log;
@PostConstruct
public void postConstruct() {
log.info("postconstruct");
// here I am trying to fill the map
predicates.put("type", UploadTypes.TALLY.toString());
}
@Test
public void testResetTallies() throws Exception {
// here the map is still empty
predicates.get("type");
}