I am using the below piece of code for JUnit test of my Spring maven application
private static BeanFactory servicefactory = null;
private static BookingProcessService bookingProcessService;
@BeforeClass
public static void setUpBeforeClass() throws Exception{
try{
String[] configFiles = {"applicationcontext-Service.xml","applicationcontext-Hibernate.xml","applicationContext-dao.xml"};
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(configFiles);
servicefactory = (BeanFactory) appContext;
bookingProcessService = (BookingProcessService) servicefactory.getBean("bookingProcessService");
}catch (Exception e){
e.printStackTrace();
}
}
While building my project using maven, I am getting some errors.The bean named bookingProcessBusiness is not creating may be because the spring configuartion files are not properly loaded.
Can somebody please help me?
Please provide exact exception you are getting
Yes, the exception that you are swallowing instead of throwing further and letting JUnit know something is wrong. Don’t do this:
Why won’t you use built-in Spring support for integration testing?
No glue code, no
statics.