List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext close
@Override public void close()
From source file:ch.ralscha.extdirectspring.util.MethodInfoCacheTest.java
@Test(expected = NullPointerException.class) public void testExistingWithouEdsAnnotation() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { MethodInfoCache methodInfoCache = new MethodInfoCache(); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/testApplicationContextB.xml"); MethodInfo info = methodInfoCache.get("springManagedBean", "methodA"); ExtDirectSpringUtil.invoke(context, "springManagedBean", info, null); context.close(); }
From source file:org.echocat.jemoni.carbon.spring.CarbonPropertyEditorRegistrarUnitTest.java
@Test public void test() throws Exception { final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "registerPropertyEditorsTestBeans.xml", CarbonPropertyEditorRegistrarUnitTest.class); try {/*w w w. j a v a 2 s . co m*/ final Jmx2CarbonBridge bridge = context.getBean("bridge", Jmx2CarbonBridge.class); assertThat(bridge.getConfiguration(), is(createReferenceRules())); } finally { context.close(); } }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.LoadConfigurationFactoryBeanTests.java
@Test public void testListValuesToColumns() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "LoadConfigurationFactoryBeanTests1.xml"); LoadConfigurationFactoryBean factoryBean = context.getBean("&greenplumLoadConfiguration", LoadConfigurationFactoryBean.class); assertThat(factoryBean.getUpdateColumns().size(), is(2)); assertThat(factoryBean.getMatchColumns().size(), is(2)); context.close(); }
From source file:org.alfresco.bm.mongo.MongoFactoriesTest.java
@Test public void testSpringEnabled() throws Exception { // Get a DB running MongoDBForTestsFactory mockDBFactory = new MongoDBForTestsFactory(); try {/* w w w . j a v a2 s . c om*/ String uriWithDB = mockDBFactory.getMongoURI(); int idx = uriWithDB.lastIndexOf("/"); String uriWithoutDB = uriWithDB.substring(0, idx); System.setProperty("mongo.uri.test", uriWithoutDB); // Count threads int threadCount = Thread.activeCount(); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext( "test-MongoFactoriesTest-context.xml"); Assert.assertTrue(Thread.activeCount() > threadCount); // Get the DB ctx.close(); Assert.assertEquals("Not all threads killed", threadCount, Thread.activeCount()); } finally { mockDBFactory.destroy(); } }
From source file:com.ryantenney.metrics.spring.DefaultRegistryTest.java
@Test public void testDefaultRegistries() { ClassPathXmlApplicationContext ctx = null; try {// ww w .j av a 2 s . c om ctx = new ClassPathXmlApplicationContext("classpath:default-registries.xml"); Assert.assertNotNull("Should be a MetricRegistry.", ctx.getBean(MetricRegistry.class)); Assert.assertNotNull("Should be HealthCheckRegistry.", ctx.getBean(HealthCheckRegistry.class)); } finally { if (ctx != null) { ctx.close(); } } }
From source file:de.uniwue.dmir.heatmap.PointSpringTest.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void testHeatmap() throws IOException { System.setProperty("configDir", "classpath:spring/example/points/config"); System.setProperty("workDir", "out/points/work-jar"); // System.setProperty("spring.profiles.active", "minmax"); // System.setProperty("min", "2013-06-01 00:00:00"); // System.setProperty("max", "2013-07-01 00:00:00"); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[] { "spring/example/points/config/config.xml" }, false); appContext.refresh();/*from w w w . j ava 2 s . co m*/ IHeatmap heatmap = appContext.getBean(HEATMAP_BEAN, IHeatmap.class); ITileProcessor tileProcessor = appContext.getBean(WRITER_BEAN, ITileProcessor.class); heatmap.processTiles(tileProcessor); appContext.close(); }
From source file:ch.ralscha.extdirectspring.util.MethodInfoCacheTest.java
@Test(expected = NoSuchBeanDefinitionException.class) public void testNonExistingBeanAndMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/testApplicationContextB.xml"); MethodInfoCache methodInfoCache = context.getBean(MethodInfoCache.class); MethodInfo info = methodInfoCache.get("springManagedBeanA", "methodA"); ExtDirectSpringUtil.invoke(context, "springManagedBeanA", info, null); context.close(); }
From source file:com.ryantenney.metrics.spring.SharedRegistryTest.java
@Test public void testDefaultRegistries() { ClassPathXmlApplicationContext ctx = null; try {/*from w w w . ja v a 2 s . co m*/ MetricRegistry instance = new MetricRegistry(); SharedMetricRegistries.add("SomeSharedRegistry", instance); ctx = new ClassPathXmlApplicationContext("classpath:shared-registry.xml"); Assert.assertSame("Should be the same MetricRegistry", instance, ctx.getBean(MetricRegistry.class)); } finally { if (ctx != null) { ctx.close(); } } }
From source file:net.sf.jdbcwrappers.spring.SpringTest.java
@Test public void test() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "net/sf/jdbcwrappers/spring/beans.xml"); try {/*from ww w . ja va 2 s. c om*/ DataSource ds = (DataSource) context.getBean("dataSource"); assertTrue(Proxy.getInvocationHandler(ds) instanceof TrimmingDelegateInvocationHandler); // Attempt to get a connection ds.getConnection().close(); } finally { context.close(); } }
From source file:com.chevres.rss.worker.controller.WorkerController.java
@Scheduled(cron = "0 0/10 * * * ?") public void refreshFeedsScheduled() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml"); FeedDAO feedDAO = context.getBean(FeedDAO.class); ArticleDAO articleDAO = context.getBean(ArticleDAO.class); ArticleStateDAO articleStateDAO = context.getBean(ArticleStateDAO.class); FeedUpdater feedUpdater = new FeedUpdater(feedDAO, articleDAO, articleStateDAO); feedUpdater.updateAll();//ww w .j a v a 2 s. com context.close(); }