List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:example.HibernateExampleAppConfigTest.java
@Before public void init() { context = new AnnotationConfigApplicationContext(HibernateExampleAppConfig.class); service = context.getBean(DeptService.BEAN_NAME, DeptService.class); dao = context.getBean(DeptDao.BEAN_NAME, DeptDao.class); }
From source file:com.oreilly.springdata.jpa.ApplicationConfigTest.java
@Test public void bootstrapAppFromJavaConfig() { ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class); assertThat(context, is(notNullValue())); assertThat(context.getBean(CustomerRepository.class), is(notNullValue())); }
From source file:net.codestory.http.injection.SpringAdapterTest.java
@Test public void inject_spring_bean_with_context() { ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class); SpringAdapter adapter = new SpringAdapter(context); Human human = adapter.get(Human.class); assertThat(human.name).isEqualTo("JL"); assertThat(human.age).isEqualTo(42); }
From source file:serviceTests.CountEmployeesTestNGTest.java
@BeforeClass public static void setUpClass() throws Exception { ctx = new AnnotationConfigApplicationContext(ConnectionConfig.class); counter = new CountEmployees(); cashierRepo = ctx.getBean(CashierRepository.class); doctorRepo = ctx.getBean(DoctorRepository.class); iTSupportRepo = ctx.getBean(ITSupportRepository.class); packerRepo = ctx.getBean(PackerRepository.class); staffMemberRepo = ctx.getBean(StaffMemberRepository.class); storeManagerRepo = ctx.getBean(StoreManagerRepository.class); cashierRepo.deleteAll();/*from w w w . j a v a 2 s . c o m*/ doctorRepo.deleteAll(); iTSupportRepo.deleteAll(); packerRepo.deleteAll(); staffMemberRepo.deleteAll(); storeManagerRepo.deleteAll(); StoreManager storeManager = new StoreManager.Builder().id(0).name("Kurt").Surname("Davids") .position("StoreManager").age(22).contactNumber("0800223450").build(); StaffMember staffMember = new StaffMember.Builder().id(0).name("Colijn").Surname("Hahndiek") .position("StaffMember").age(22).contactNumber("0800123450").build(); Packer packer = new Packer.Builder().id(0).name("Robyn").Surname("Davids").position("Packer").age(22) .contactNumber("0800123459").build(); ITSupport iTSupport = new ITSupport.Builder().id(0).name("Wesley").surname("De Wet").position("ITSupport") .age(22).contactNumber("0800123458").build(); Doctor doctor = new Doctor.Builder().id(0).name("Taswell").Surname("Salie").position("Doctor").age(22) .contactNumber("0800123457").build(); Cashier cashier = new Cashier.Builder().id(0).name("Alexander").surname("Daniels").position("Cashier") .age(22).contactNumber("0800123456").build(); cashierRepo.save(cashier); doctorRepo.save(doctor); iTSupportRepo.save(iTSupport); packerRepo.save(packer); staffMemberRepo.save(staffMember); storeManagerRepo.save(storeManager); }
From source file:com.oreilly.springdata.gemfire.ApplicationConfigTest.java
@Test public void bootstrapAppFromJavaConfig() { ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class); assertThat(context, is(notNullValue())); }
From source file:gov.samhsa.ds4p.cms.consent.mongodb.test.ApplicationConfigTest.java
@Test public void bootstrapAppFromJavaConfig() { ApplicationContext context = new AnnotationConfigApplicationContext(MongoApplicationConfig.class); assertThat(context, is(notNullValue())); assertThat(context.getBean(PersonRepository.class), is(notNullValue())); }
From source file:coreexample.MockitoTest.java
@Before public void init() { MockitoAnnotations.initMocks(this); context = new AnnotationConfigApplicationContext(MockitoExampleAppConfig.class); when(exampleDao.getExampleName()).thenReturn("bbb"); when(example2Dao.getName()).thenReturn("ddd"); }
From source file:com.github.jmnarloch.spring.jaxrs.client.cxf.CxfClientConfigurationTest.java
/** * Tests the registration of the proxy factory in application context. *///from w ww .j a v a 2 s.co m @Test public void shouldRegisterClientProxyFactory() { // given final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( CxfClientConfiguration.class); // when JaxRsClientProxyFactory factory = context.getBean(JaxRsClientProxyFactory.class); // then assertNotNull(factory); assertTrue(CxfClientProxyFactory.class.equals(factory.getClass())); }
From source file:example.JpaExampleAppConfigTest.java
@Before public void init() { context = new AnnotationConfigApplicationContext(JpaExampleAppConfig.class); Application.setApplicationContext(context); service = context.getBean(DeptService.BEAN_NAME, DeptService.class); dao = context.getBean(DeptDao.BEAN_NAME, DeptDao.class); }
From source file:fr.xebia.extras.selma.it.inject.CustomMapperUsingSpringIoCWithServiceNameIT.java
@Test public void given_mapper_name_as_selma_mapper_should_retrieve_it() throws IllegalAccessException, InstantiationException, ClassNotFoundException { ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class); AddressMapperWithName addressMapperByName = (AddressMapperWithName) context.getBean("addressSelmaMapper"); Assert.assertNotNull(addressMapperByName); AddressMapperWithName addressMapper = context.getBean(AddressMapperWithName.class); Assert.assertEquals(addressMapper, addressMapperByName); }