@Test public void testChildContextOverridesBeanPostProcessor() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/2jobs.xml") }; @SuppressWarnings("resource") ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "/org/springframework/batch/core/launch/support/test-environment-with-registry-and-auto-register.xml"); registrar.setApplicationContext(applicationContext); setUpApplicationContextFactories(jobPaths, applicationContext); registrar.start(); assertEquals(2, registry.getJobNames().size()); }
@Test public void testNoJobFound() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/test-environment.xml") }; @SuppressWarnings("resource") GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.refresh(); setUpApplicationContextFactories(jobPaths, applicationContext); registrar.setApplicationContext(applicationContext); registrar.start(); }
@Test public void testDuplicateJobsInFile() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource( "org/springframework/batch/core/launch/support/2jobs.xml") }; @SuppressWarnings("resource") GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.refresh(); setUpApplicationContextFactories(jobPaths, applicationContext); registrar.setApplicationContext(applicationContext); registrar.start(); assertEquals(2, registry.getJobNames().size()); }
@Test public void testLocateJob() throws Exception { Resource[] jobPaths = new Resource[] { new ClassPathResource("org/springframework/batch/core/launch/support/job.xml"), new ClassPathResource("org/springframework/batch/core/launch/support/job2.xml") }; @SuppressWarnings("resource") GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.refresh(); setUpApplicationContextFactories(jobPaths, applicationContext); registrar.setApplicationContext(applicationContext); registrar.start(); Collection<String> names = registry.getJobNames(); assertEquals(2, names.size()); assertTrue(names.contains("test-job")); assertTrue(names.contains("test-job2")); Job job = registry.getJob("test-job"); assertEquals("test-job", job.getName()); job = registry.getJob("test-job2"); assertEquals("test-job2", job.getName()); }