@BeforeClass
コールバックは arquillian テストでは機能しないため、@PostConstruct
テストのコールバックでいくつかのフィールドを初期化しようとしました。展開にはがあり、注釈と引数なしのコンストラクターbeans.xml
も追加しようとしましたが、効果はありません。@Startup
CDI は機能しており、テストの他のフィールドに対してすべてのインジェクションが実行されていますが、@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");
}