Example usage for org.springframework.batch.core.jsr.configuration.xml JsrBeanDefinitionDocumentReader getJobProperties

List of usage examples for org.springframework.batch.core.jsr.configuration.xml JsrBeanDefinitionDocumentReader getJobProperties

Introduction

In this page you can find the example usage for org.springframework.batch.core.jsr.configuration.xml JsrBeanDefinitionDocumentReader getJobProperties.

Prototype

protected Properties getJobProperties() 

Source Link

Usage

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 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();//from  w ww.  j  a  va 2s  .  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"));
}