@Test public void testGetJobProperties() { Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"); @SuppressWarnings("resource") JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(); JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext); documentReader.initProperties(document.getDocumentElement()); Properties documentJobProperties = documentReader.getJobProperties(); assertNotNull(documentJobProperties); assertTrue("Wrong number of job properties", documentJobProperties.size() == 3); assertEquals("jobProperty1Value", documentJobProperties.getProperty("jobProperty1")); assertEquals("jobProperty1Value", documentJobProperties.getProperty("jobProperty2")); assertEquals("", documentJobProperties.getProperty("jobProperty3")); }
@Test public void testJobPropertyResolution() { Properties jobParameters = new Properties(); jobParameters.setProperty("file.name", "myfile.txt"); @SuppressWarnings("resource") JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(jobParameters); applicationContext.setValidating(false); applicationContext.load(new ClassPathResource("jsrBaseContext.xml"), new ClassPathResource("/META-INF/batch.xml"), new ClassPathResource("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml")); applicationContext.refresh(); Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"); JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext); documentReader.initProperties(document.getDocumentElement()); Properties resolvedProperties = documentReader.getJobProperties(); assertNotNull(resolvedProperties); assertTrue("Wrong number of job properties", resolvedProperties.size() == 3); assertEquals("jobProperty1Value", resolvedProperties.getProperty("jobProperty1")); assertEquals("jobProperty1Value", resolvedProperties.getProperty("jobProperty2")); assertEquals("myfile.txt", resolvedProperties.getProperty("jobProperty3")); }