Examples of DelimitedLineTokenizer


Examples of batch.internal.support.DelimitedLineTokenizer

import junit.framework.TestCase;

public class DelimitedLineTokenizerTests extends TestCase {

  public void testDelimitedLineTokenizer() {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("a,b,c");
    assertEquals(3, line.length);
  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    String[] line = tokenizer.tokenize("a,b,c");
    assertEquals(3, line.length);
  }

  public void testDelimitedLineTokenizerChar() {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(' ');
    String[] line = tokenizer.tokenize("a b c");
    assertEquals(3, line.length);
  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    String[] line = tokenizer.tokenize("a b c");
    assertEquals(3, line.length);
  }

  public void testTokenizeWithQuotes() {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("a,b,\"c\"");
    assertEquals(3, line.length);
    assertEquals("c", line[2]);
  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    assertEquals(3, line.length);
    assertEquals("c", line[2]);
  }

  public void testTokenizeWithDelimiterAtEnd() {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("a,b,c,");
    assertEquals(4, line.length);
    assertEquals("c", line[2]);
    assertEquals("", line[3]);
  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    assertEquals("c", line[2]);
    assertEquals("", line[3]);
  }

  public void testEmptyLine() throws Exception {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("");
    assertEquals(0, line.length);
    line = tokenizer.tokenize("  ");
    // whitespace counts as text
    assertEquals(1, line.length);
    line = tokenizer.tokenize(null);
    // null doesn't...
    assertEquals(0, line.length);
  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    // null doesn't...
    assertEquals(0, line.length);
  }

  public void testMultiLineField() throws Exception {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("a,b,c\nrap");
    assertEquals(3, line.length);
    assertEquals("c\nrap", line[2]);

  }
View Full Code Here

Examples of batch.internal.support.DelimitedLineTokenizer

    assertEquals("c\nrap", line[2]);

  }

  public void testMultiLineFieldWithQuotes() throws Exception {
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    String[] line = tokenizer.tokenize("a,b,\"c\nrap\"");
    assertEquals(3, line.length);
    assertEquals("c\nrap", line[2]);

  }
View Full Code Here

Examples of org.springframework.batch.item.file.transform.DelimitedLineTokenizer

  public void testLeads() throws Exception {

    FlatFileItemReader<FieldSet> reader = new FlatFileItemReader<FieldSet>();
    reader.setResource(new ClassPathResource("/data/test.txt"));
    DefaultLineMapper<FieldSet> lineMapper = new DefaultLineMapper<FieldSet>();
    lineMapper.setLineTokenizer(new DelimitedLineTokenizer());
    lineMapper.setFieldSetMapper(new PassThroughFieldSetMapper());
    reader.setLinesToSkip(1);
    final List<String> headers = new ArrayList<String>();
    reader.setSkippedLinesCallback(new LineCallbackHandler() {
      public void handleLine(String line) {
View Full Code Here

Examples of org.springframework.batch.item.file.transform.DelimitedLineTokenizer

    tested.mapLine("foo", 1);
  }
 
  @Test(expected=IllegalArgumentException.class)
  public void testMandatoryMapper() throws Exception {
    tested.setLineTokenizer(new DelimitedLineTokenizer());
    tested.afterPropertiesSet();
    tested.mapLine("foo", 1);
  }
View Full Code Here

Examples of org.springframework.batch.item.file.transform.DelimitedLineTokenizer

  private PatternMatchingCompositeLineMapper<Name> mapper = new PatternMatchingCompositeLineMapper<Name>();

  @Test(expected = IllegalArgumentException.class)
  public void testNoMappers() throws Exception {
    mapper.setTokenizers(Collections.singletonMap("", (LineTokenizer) new DelimitedLineTokenizer()));
    Map<String, FieldSetMapper<Name>> fieldSetMappers = Collections.emptyMap();
    mapper.setFieldSetMappers(fieldSetMappers);
    mapper.afterPropertiesSet();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.