@Test public void testRootContext() throws Exception { GenericXmlApplicationContext context = new GenericXmlApplicationContext( new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml")); context.close(); }
public static void main(String[] args) { GenericXmlApplicationContext ctx = null; ctx = new GenericXmlApplicationContext("spring/beans_dao.xml"); CityMapper cityMapper = ctx.getBean(CityMapper.class); // List<City> list = cityMapper.selectAll(); List<City> list = cityMapper.selectByCountryCode("KOR"); list.forEach( new Consumer<City>() { @Override public void accept(City c) { log.info(c.getCountryCode() + "\t" + c.getName()); } }); // for(City c : list){ // // log.info(c.getCountryCode()); // // } ctx.close(); }
@Test public void testWorkflow() throws Exception { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("/org/springframework/data/hadoop/batch/in-do-out.xml"); ctx.registerShutdownHook(); FileSystem fs = FileSystem.get(ctx.getBean(Configuration.class)); System.out.println("FS is " + fs.getClass().getName()); HdfsResourceLoader hrl = ctx.getBean(HdfsResourceLoader.class); Resource resource = hrl.getResource("/ide-test/output/word/"); assertTrue(ctx.isPrototype("script-tasklet")); fs.delete(new Path(resource.getURI().toString()), true); JobsTrigger.startJobs(ctx); Path p = new Path("/ide-test/output/word/"); Job job = (Job) ctx.getBean("mr-job"); Configuration c = job.getConfiguration(); FileSystem fs2 = p.getFileSystem(c); System.out.println("FS is " + fs2.getClass().getName()); fs2.exists(p); ctx.close(); }
@Test public void testWorkflowNS() throws Exception { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("/org/springframework/data/hadoop/batch/in-do-out-ns.xml"); ctx.registerShutdownHook(); FileSystem fs = FileSystem.get(ctx.getBean(Configuration.class)); fs.delete(new Path("/ide-test/output/word/"), true); assertTrue(ctx.isPrototype("hadoop-tasklet")); JobsTrigger.startJobs(ctx); ctx.close(); }
@After public void close() { if (context != null) { context.close(); } }