List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:com.nkosy.designpatterns.creational.prototypepattern.PrototypePatternTest.java
@BeforeMethod public void setUpMethod() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); obj = (Prototype) ctx.getBean("prototypePattern"); }
From source file:fr.xebia.extras.selma.it.inject.CustomMapperUsingSpringIoCIT.java
@Test public void given_custom_as_selma_mapper_should_map_bean_with_it() throws IllegalAccessException, InstantiationException, ClassNotFoundException { ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class); AddressMapper addressMapper = context.getBean(AddressMapper.class); AddressIn addressIn = new AddressIn(); addressIn.setCity(new CityIn()); addressIn.getCity().setCapital(true); addressIn.getCity().setName("Paris"); addressIn.getCity().setPopulation(3 * 1000 * 1000); addressIn.setPrincipal(true);/*from w w w. j av a 2 s .c o m*/ addressIn.setNumber(55); addressIn.setStreet("rue de la truanderie"); addressIn.setExtras(Arrays.asList("titi", "toto")); AddressOut res = addressMapper.asAddressOut(addressIn); Assert.assertNotNull(res); Assert.assertEquals(addressIn.getStreet(), res.getStreet()); Assert.assertEquals(addressIn.getNumber(), res.getNumber()); Assert.assertNull(res.getExtras()); Assert.assertEquals(addressIn.getCity().getName() + CustomImmutableMapper.IMMUTABLY_MAPPED, res.getCity().getName()); Assert.assertEquals(addressIn.getCity().getPopulation() + CustomImmutableMapper.POPULATION_INC, res.getCity().getPopulation()); Assert.assertEquals(addressIn.getCity().isCapital(), res.getCity().isCapital()); }
From source file:com.karriem.tp2.immutable_domain_model_assignment.DomainTest.EmployeesTest.DoctorNGTest.java
@BeforeClass public static void setUpClass() throws Exception { ctx = new AnnotationConfigApplicationContext(DoctorConfig.class); service = (DoctorService) ctx.getBean("createDoc"); }
From source file:net.maritimecloud.portal.application.ApplicationServiceTest.java
/** * Factory method that creates a new Application Context. Override this method to provide your own application context * <p>/* w w w . ja v a 2 s . c o m*/ * @return the created application context */ protected ApplicationContext createApplicationContext() { return new AnnotationConfigApplicationContext(ApplicationTestConfig.class); }
From source file:integrationtest.registration.SpringContextRegistrationTest.java
@Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); springContext = new AnnotationConfigApplicationContext("integrationtest.registration.context"); underTest = new OsgiApplicationContext(springContext); underTest.start(bundleContext);/*from w w w. j av a 2s. co m*/ }
From source file:com.nkosy.designpatterns.creational.factorymethod.test.FactoryMethodTest.java
@BeforeMethod public void setUpMethod() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); obj = (AnimalFactory) ctx.getBean("factorymethod"); }
From source file:com.tchouyangoko.humain.domain.repository.CountriesRepositoryTest.java
@BeforeClass public static void setUpClass() throws Exception { ctx = new AnnotationConfigApplicationContext(ConnectionConfig.class); ctx = new AnnotationConfigApplicationContext(ConnectionConfig.class); }
From source file:org.apache.nutch.storage.local.TestLocalStorage.java
@Before public void setUp() { springContext = new AnnotationConfigApplicationContext(SpringConfiguration.class); // ServerInstanceService serverInstanceService = springContext.getBean(ServerInstanceService.class); }
From source file:com.github.qwazer.markdown.confluence.gradle.plugin.ConfluenceGradleTask.java
@TaskAction public void confluence() throws NoSuchAlgorithmException, KeyManagementException, IOException { final AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext( SpringConfig.class); final MainService mainService = annotationConfigApplicationContext.getBean(MainService.class); final ConfluenceConfig confluenceConfig = getProject().getExtensions().findByType(ConfluenceConfig.class); validate(confluenceConfig);// w ww.j a va2 s .c om if (confluenceConfig.isSslTrustAll()) { sslTrustAll(); } mainService.processAll(confluenceConfig); annotationConfigApplicationContext.close(); }
From source file:com.avanza.astrix.integration.tests.GsBinderIntegrationTest.java
@Test public void usesQualifierToIdentifyWhatEmbeddedSpaceToUse() throws Exception { applicationContext = new AnnotationConfigApplicationContext(AppWithTwoEmbeddedSpaces.class); GsBinder gsBinder = new GsBinder(); gsBinder.setConfig(DynamicConfig.create(config)); config.set(AstrixSettings.GIGA_SPACE_BEAN_NAME, "gigaSpace"); GigaSpace gigaSpace = gsBinder.getEmbeddedSpace(applicationContext); GigaSpace expected = applicationContext.getBean("gigaSpace", GigaSpace.class); assertSame("Expected embedded space to be defined by GIGA_SPACE_BEAN_NAME prpoerty", expected, gigaSpace); }