jimm.datavision.test
Class ReportRunTest

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

public class ReportRunTest
extends junit.framework.TestCase

Reads a report from an XML file, runs it, and verifies the output. Uses the {}@link CharSepLE} layout engine to produce a tab-delimited output file.

These tests are tightly coupled with the contents of the files test.xml and test_parameters.xml and the data generated by the MockDataSource.

Author:
Jim Menard, jimm@io.com

Field Summary
protected  java.text.DecimalFormat dollarFormatter
           
protected static java.io.File EXAMPLE_REPORT
           
protected  java.text.DecimalFormat lastColFormatter
           
protected  int officeRowNumber
           
(package private) static java.lang.String[] OFFICES
           
protected static java.io.File OUT_FILE
           
protected static java.io.File PARAM_INPUT_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 static java.lang.String STRING_PARAM_VALUE
           
protected  java.text.SimpleDateFormat titleDateFormatter
           
 
Constructor Summary
ReportRunTest(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 testNoRecords()
           
 void testParamInWhereClause()
           
 void testReportRun()
           
 void testUseReportValue()
           
 
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

PARAM_INPUT_FILE

protected static final java.io.File PARAM_INPUT_FILE

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

static final java.lang.String[] OFFICES

STRING_PARAM_VALUE

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

REPORT_TITLE

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

report

protected Report report

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

ReportRunTest

public ReportRunTest(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

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

testParamInWhereClause

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

testNoRecords

public void testNoRecords()

testUseReportValue

public void testUseReportValue()
                        throws java.lang.Exception
Throws:
java.lang.Exception

main

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