com.meyling.principia.logic.basic
Class PackageTest

java.lang.Object
  |
  +--com.meyling.principia.logic.basic.PackageTest

public class PackageTest
extends Object

General package test.

Version:
$Revision 0.00.50$
Author:
Michael Meyling

Inner Class Summary
private static class PackageTest.TestReader
          Special reader for test files with convenient methods for reading arguments.
 
Field Summary
static String ACTUAL_OUTPUT_FILE_POSTFIX
          output file name postfix
static String END
          marks end of result
static String EXCEPTION_TEST_FILE_PREFIX
          test input file
static String EXPECTED_OUTPUT_FILE_POSTFIX
          expected output file name postfix
static String FAIL
          creation failed
static String FALSE
          false
static String FILE_PATH
          path to test data
static String INPUT_FILE_POSTFIX
          input file name postfix
static String NEXT
          seperates several arguments
static PrintStream out
          output stream
static String RESULT
          seperates result from arguments
static String TEST_FILE_PREFIX
          file name prefix
static String TRUE
          true
 
Constructor Summary
PackageTest()
           
 
Method Summary
private static boolean isEndSeparator(String text)
          Check if text is equal to END.
private static boolean isNextSeparator(String text)
          Check if text is equal to NEXT.
private static boolean isResultSeparator(String text)
          Check if text is equal to RESULT.
private static boolean isSeparator(String text)
          Check if text is equal to any separator: NEXT, RESULT or END.
static void main(String[] argument)
          Runs the following test numbers (or all tests).
static boolean test()
          Run all normal tests in directory FILE_PATH.
static void testArgument(Argument argument, StringBuffer list)
          Performes simple argument tests: is argument equal to itself is argument equal to argument.copy() (both directions) is argument equal to same argument created of list with BasicCreator.readArgument(com.meyling.principia.io.TextInput, com.meyling.principia.io.ParsingTable) (both directions) is argument equal to same argument created of result of BasicCreator.writeArgument(com.meyling.principia.io.Output, com.meyling.principia.argument.Argument) with BasicCreator.readArgument(com.meyling.principia.io.TextInput, com.meyling.principia.io.ParsingTable) (both directions)
static boolean testArgument(String argument)
          Test a single normal test file.
static boolean testCreate(PackageTest.TestReader reader, int startLine)
          Test creation of argument.
static boolean testEquals(PackageTest.TestReader reader, int startLine)
          Test equality of arguments.
static boolean testException()
          Run all exception tests in directory FILE_PATH.
static boolean testExceptionArgument(String argument)
          Test a single exception test file.
static int testFile(String fileName)
          Test this package with a file.
static boolean testReplace1(PackageTest.TestReader reader, int startLine)
          Test simple replacement of arguments.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

FILE_PATH

public static final String FILE_PATH
path to test data

TEST_FILE_PREFIX

public static final String TEST_FILE_PREFIX
file name prefix

INPUT_FILE_POSTFIX

public static final String INPUT_FILE_POSTFIX
input file name postfix

ACTUAL_OUTPUT_FILE_POSTFIX

public static final String ACTUAL_OUTPUT_FILE_POSTFIX
output file name postfix

EXPECTED_OUTPUT_FILE_POSTFIX

public static final String EXPECTED_OUTPUT_FILE_POSTFIX
expected output file name postfix

EXCEPTION_TEST_FILE_PREFIX

public static final String EXCEPTION_TEST_FILE_PREFIX
test input file

NEXT

public static final String NEXT
seperates several arguments

RESULT

public static final String RESULT
seperates result from arguments

END

public static final String END
marks end of result

TRUE

public static final String TRUE
true

FALSE

public static final String FALSE
false

FAIL

public static final String FAIL
creation failed

out

public static PrintStream out
output stream
Constructor Detail

PackageTest

public PackageTest()
Method Detail

main

public static final void main(String[] argument)
Runs the following test numbers (or all tests). The result ist printed to System.out.
Parameters:
argument - (optional) list of test numbers, a leading "-t " runs the exception test

test

public static final boolean test()
Run all normal tests in directory FILE_PATH. All files that start with TEST_FILE_PREFIX and end with INPUT_FILE_POSTFIX are put into testArgument(java.lang.String). Iff all these tests return true this method returns true.
Returns:
true iff all tests were ok

testException

public static final boolean testException()
Run all exception tests in directory FILE_PATH. All files that start with EXCEPTION_TEST_FILE_PREFIX and end with INPUT_FILE_POSTFIX are put into testArgument(java.lang.String). Iff all these tests return true this method returns true.
Returns:
true iff all tests were ok

testArgument

public static final boolean testArgument(String argument)
Test a single normal test file. The actual file name is build by connecting FILE_PATH TEST_FILE_PREFIX argument INPUT_FILE_POSTFIX. Start and result information is printed to System.out.
Parameters:
argument - part of the file name
Returns:
was test ok?

testExceptionArgument

public static final boolean testExceptionArgument(String argument)
Test a single exception test file. The actual file name is build by connecting FILE_PATH EXCEPTION_TEST_FILE_PREFIX argument INPUT_FILE_POSTFIX. Start and result information is printed to System.out.
Parameters:
argument - part of the file name
Returns:
was test ok?

testFile

public static final int testFile(String fileName)
Test this package with a file. Following tests are implemented:
Parameters:
fileName - name of file with test data
Returns:
number of errors that occured

testCreate

public static boolean testCreate(PackageTest.TestReader reader,
                                 int startLine)
                          throws IOException,
                                 IllegalArgumentException
Test creation of argument.
Parameters:
reader - source to read from
startLine - source line where test started
Returns:
result of test
Throws:
IOException - if any file error occured

testEquals

public static boolean testEquals(PackageTest.TestReader reader,
                                 int startLine)
                          throws IOException,
                                 IllegalArgumentException
Test equality of arguments.
Parameters:
reader - source to read from
startLine - source line where test started
Returns:
result of test
Throws:
IOException - if any file error occured
IllegalArgumentException - if an expected creation failed

testReplace1

public static boolean testReplace1(PackageTest.TestReader reader,
                                   int startLine)
                            throws IOException,
                                   IllegalArgumentException
Test simple replacement of arguments.
Parameters:
reader - source to read from
startLine - source line where test started
Returns:
result of test
Throws:
IOException - if any file error occured
IllegalArgumentException - if an expected creation failed

isNextSeparator

private static boolean isNextSeparator(String text)
Check if text is equal to NEXT.
Parameters:
text - compare text
Returns:
result of equal

isResultSeparator

private static boolean isResultSeparator(String text)
Check if text is equal to RESULT.
Parameters:
text - compare text
Returns:
result of equal

isEndSeparator

private static boolean isEndSeparator(String text)
Check if text is equal to END.
Parameters:
text - compare text
Returns:
result of equal

isSeparator

private static boolean isSeparator(String text)
Check if text is equal to any separator: NEXT, RESULT or END.
Parameters:
text - compare text
Returns:
is text equal to any separator

testArgument

public static void testArgument(Argument argument,
                                StringBuffer list)
                         throws IllegalArgumentException
Performes simple argument tests:
Parameters:
argument - argument to test
list - from this data the argument was created
Throws:
IllegalArgumentException - if test failed