奇妙な主題は質問自体を続けます:)春のアプリケーションコンテキストから春のテストクラスに到達する方法はありますか? 質問の詳細は、コメント ブロックとして「SimpleDaoHandler」クラスに隠されています :)
テスト クラス:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/applicationContext-core.xml")
public class DbFuntionTests {
@TestAnnotation
private UserSessionDao userSessionDao;
@Test
public void testOracleTimestamp() throws Exception {
userSessionDao.findAll();
}
}
スプリング コンテキストの初期化後のハンドラー クラス:
@Component
public class SimpleDaoHandler implements ApplicationContextAware, InitializingBean {
private ApplicationContext applicationContext;
private static Logger logger = Logger.getLogger(SimpleDaoHandler.class);
@Override
public void afterPropertiesSet() throws Exception {
//I have the application context now, via method "setApplicationContext"
// and need to get test class object to get the
// annotated field "TestAnnotation" because I also need to set this
// field with my business logic, using reflection.
// Problem is; test class object is not included in the
// "applicationContext" as a bean and I don't know how to access my
//test class which is already starting the spring context initialization.
//I need to get that test class object.
}
@Override
public void setApplicationContext(final ApplicationContext applicationContext)
throws BeansException {
this.applicationContext = applicationContext;
}
どんな手掛かり?