Example usage for org.springframework.batch.item UnexpectedInputException printStackTrace

List of usage examples for org.springframework.batch.item UnexpectedInputException printStackTrace

Introduction

In this page you can find the example usage for org.springframework.batch.item UnexpectedInputException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.complexible.stardog.ext.spring.batch.TestSpringBatch.java

/**
 * Unit test for SnarlREader/* www. j av a 2  s. c om*/
 * 
 * Note: The below code is not idiomatic for Stardog Spring Batch developer.  The SnarlItemReader
 * would be configured in a Spring bean definition file, and then orchestrated by Spring Batch
 * The below test validates the behavior of the ItemReader interface and integration of the 
 * SnarlTemplate and DataSource classes
 * 
 * Test method for {@link com.complexible.stardog.ext.spring.batch.SnarlItemReader#read()}.
 */
@Test
public void testRead() {
    String sparql = "SELECT ?a ?b WHERE { ?a ?predicate ?b } LIMIT 2";
    SnarlItemReader<String> reader = new SnarlItemReader<String>();
    reader.setDataSource(dataSource);
    reader.setRowMapper(new RowMapper<String>() {
        @Override
        public String mapRow(BindingSet bindingSet) {
            return (bindingSet.getValue("a").stringValue() + ":" + bindingSet.getValue("b").stringValue());
        }
    });
    reader.setQuery(sparql);

    try {
        reader.afterPropertiesSet();
        String resultOne = reader.read();
        String resultTwo = reader.read();
        String resultThree = reader.read();
        assertNotNull(resultOne);
        assertNotNull(resultTwo);
        assertNull(resultThree);
    } catch (UnexpectedInputException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NonTransientResourceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}