jimm.datavision.test
Class CharSepTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by jimm.datavision.test.CharSepTest
All Implemented Interfaces:
junit.framework.Test

public class CharSepTest
extends junit.framework.TestCase

Reads a report from an XML file, runs it, and verifies the output. Uses a CharSepSource data source and the CharSepLE layout engine to produce a tab-delimited output file.

These tests are tightly coupled with the contents of the files charsep.xml and charsep_data.csv.

Author:
Jim Menard, jimm@io.com

Field Summary
protected static java.lang.String DATA_FILE
           
protected static java.lang.String DATA_FILE_WITH_SHORT_LINES
           
protected  CharSepSource dataSource
           
protected  java.text.DecimalFormat dollarFormatter
           
protected static java.lang.String EMPTY_DATA_FILE
           
protected static java.io.File EXAMPLE_REPORT
           
protected  java.text.DecimalFormat lastColFormatter
           
protected  int officeRowNumber
           
protected static java.lang.String[] OFFICES
           
protected static java.io.File OUT_FILE
           
protected  int postDateRowNumber
           
protected  Report report
           
protected static java.lang.String REPORT_DATE_FORMAT
           
protected static java.lang.String REPORT_TITLE
           
protected  int reportRowNumber
           
protected  java.text.SimpleDateFormat titleDateFormatter
           
 
Constructor Summary
CharSepTest(java.lang.String name)
           
 
Method Summary
protected  int checkDetailLine(java.lang.String line)
          Checks the format of a detail line and returns the integer id found at the beginning of line.
protected  int checkOfficeGroup(java.io.BufferedReader in, java.lang.String officeName)
          Checks a group (header plus detail lines) and returns the total of the dollar amounts in the group.
protected  java.lang.Object checkPostDateGroup(java.io.BufferedReader in)
          Checks a subgroup (header plus detail lines) and returns the total of the dollar amounts in the group.
protected  void expectHeaders(java.io.BufferedReader in)
           
static void main(java.lang.String[] args)
           
 void setUp()
           
static junit.framework.Test suite()
           
 void tearDown()
           
 void testColumnInfo()
           
 void testEmptyFile()
           
 void testNoRecords()
           
 void testReportRun()
           
 void testShortInputLines()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXAMPLE_REPORT

protected static final java.io.File EXAMPLE_REPORT

DATA_FILE

protected static final java.lang.String DATA_FILE

EMPTY_DATA_FILE

protected static final java.lang.String EMPTY_DATA_FILE

DATA_FILE_WITH_SHORT_LINES

protected static final java.lang.String DATA_FILE_WITH_SHORT_LINES

OUT_FILE

protected static final java.io.File OUT_FILE

REPORT_DATE_FORMAT

protected static final java.lang.String REPORT_DATE_FORMAT
See Also:
Constant Field Values

OFFICES

protected static final java.lang.String[] OFFICES

REPORT_TITLE

protected static final java.lang.String REPORT_TITLE
See Also:
Constant Field Values

report

protected Report report

dataSource

protected CharSepSource dataSource

dollarFormatter

protected java.text.DecimalFormat dollarFormatter

lastColFormatter

protected java.text.DecimalFormat lastColFormatter

titleDateFormatter

protected java.text.SimpleDateFormat titleDateFormatter

reportRowNumber

protected int reportRowNumber

officeRowNumber

protected int officeRowNumber

postDateRowNumber

protected int postDateRowNumber
Constructor Detail

CharSepTest

public CharSepTest(java.lang.String name)
Method Detail

suite

public static junit.framework.Test suite()

setUp

public void setUp()
           throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

tearDown

public void tearDown()
Overrides:
tearDown in class junit.framework.TestCase

testColumnInfo

public void testColumnInfo()

testReportRun

public void testReportRun()
                   throws java.io.IOException,
                          java.io.FileNotFoundException
Throws:
java.io.IOException
java.io.FileNotFoundException

expectHeaders

protected void expectHeaders(java.io.BufferedReader in)
                      throws java.io.IOException
Throws:
java.io.IOException

checkOfficeGroup

protected int checkOfficeGroup(java.io.BufferedReader in,
                               java.lang.String officeName)
                        throws java.io.IOException
Checks a group (header plus detail lines) and returns the total of the dollar amounts in the group.

Parameters:
in - the input reader
officeName - the group name
Returns:
the total dollar amount in the group
Throws:
java.io.IOException

checkPostDateGroup

protected java.lang.Object checkPostDateGroup(java.io.BufferedReader in)
                                       throws java.io.IOException
Checks a subgroup (header plus detail lines) and returns the total of the dollar amounts in the group. If the next report section is not a subgroup, it will be a group total line; we return the line

Parameters:
in - the input reader
Returns:
either an Integer containing the total or the next line read from the report
Throws:
java.io.IOException

checkDetailLine

protected int checkDetailLine(java.lang.String line)
Checks the format of a detail line and returns the integer id found at the beginning of line. This is the same as the dollar amount.

Parameters:
line - a detail line
Returns:
the id number

testNoRecords

public void testNoRecords()

testEmptyFile

public void testEmptyFile()

testShortInputLines

public void testShortInputLines()

main

public static void main(java.lang.String[] args)