List of usage examples for org.springframework.batch.core.jsr.configuration.xml JsrBeanDefinitionDocumentReader initProperties
protected void initProperties(Element root)
From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReaderTests.java
@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")); }
From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReaderTests.java
@Test public void testJobParametersResolution() { Properties jobParameters = new Properties(); jobParameters.setProperty("jobParameter1", "myfile.txt"); jobParameters.setProperty("jobParameter2", "#{jobProperties['jobProperty2']}"); jobParameters.setProperty("jobParameter3", "#{jobParameters['jobParameter1']}"); @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();/*from w w w . java2 s.com*/ Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"); JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext); documentReader.initProperties(document.getDocumentElement()); Properties resolvedParameters = documentReader.getJobParameters(); assertNotNull(resolvedParameters); assertTrue("Wrong number of job parameters", resolvedParameters.size() == 3); assertEquals("myfile.txt", resolvedParameters.getProperty("jobParameter1")); assertEquals("jobProperty1Value", resolvedParameters.getProperty("jobParameter2")); assertEquals("myfile.txt", resolvedParameters.getProperty("jobParameter3")); }
From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReaderTests.java
@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();/* w w w .j ava2 s . c o m*/ 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")); }