public void testSplitMessageWithHeader2() throws Exception { LineCountSplitter s = new LineCountSplitter(); s.setKeepHeaderLines(2); s.setSplitOnLine(10); s.setIgnoreBlankLines(true); final String HEADER_LINE_1 = "HEADER LINE 1"; final String HEADER_LINE_2 = "HEADER LINE 2"; List<AdaptrisMessage> result = toList( s.splitMessage( createLineCountMessageInputWithHeader( new String[] {HEADER_LINE_1, HEADER_LINE_2}))); assertEquals("5 split messages", 5, result.size()); for (AdaptrisMessage m : result) { try (Reader reader = m.getReader()) { List<String> lines = IOUtils.readLines(reader); assertEquals("12 lines per message", 12, lines.size()); assertEquals("Must be header line 1", HEADER_LINE_1, lines.get(0)); assertEquals("Must be header line 2", HEADER_LINE_2, lines.get(1)); for (int i = 2; i < 12; i++) { assertEquals("Must be regular line", LINE, lines.get(i)); } } } }
public void testSplitMessageWithHeader1() throws Exception { LineCountSplitter s = new LineCountSplitter(); s.setKeepHeaderLines(1); s.setSplitOnLine(1); s.setIgnoreBlankLines(true); final String HEADER_TEXT = "HEADER LINE 1"; List<AdaptrisMessage> result = toList(s.splitMessage(createLineCountMessageInputWithHeader(new String[] {HEADER_TEXT}))); assertEquals("50 split messages", 50, result.size()); for (AdaptrisMessage m : result) { List<String> lines = IOUtils.readLines(m.getReader()); assertEquals("2 lines per message", 2, lines.size()); assertEquals("Must be header line", HEADER_TEXT, lines.get(0)); assertEquals("Must be regular line", LINE, lines.get(1)); } }
public void testSingleLineSplit() throws Exception { LineCountSplitter s = new LineCountSplitter(); s.setSplitOnLine(1); List<AdaptrisMessage> msgs = toList(s.splitMessage(msg)); assertEquals("100 split messages", 100, msgs.size()); }