Tests
Class FileInputReaderTest
java.lang.Object
Tests.FileInputReaderTest
public class FileInputReaderTest
- extends java.lang.Object
- Version:
- 1.00
The FileInputReaderTest class is designed to test the functionality of methods and output in the FileInputReader class.
Static Variables are defined to prevent any mutation to the variable.
- Author:
- Jonathan Field jof2@aber.ac.uk 073717922
Method Summary |
void |
setUp()
|
void |
testContext()
This test ensures that the contextual information is being stored correctly. |
void |
testInputIndex()
The purpose of this test is to ensure that index words are being succesfully read in from a textfile and store in the HashTable. |
void |
testInputTextConcordance()
This test ensures that the concordance is being generated correctly, The index file is first read in to the HashTable with default linenumbers. |
void |
testLineNumberDefaultSet()
This test ensures that the default line number is being set on Constructor call to ensure that the correct line numbers are produced for the Concordance. |
void |
testReturnedHashTableEqualsActual()
This method ensures that the correct HashTable is being returned to ensure that there are no errors when retrieving values from the HashTable. |
void |
testSortingCorrectly()
This method checks to ensure that the Index words are being sorted correctly in alphabetical order. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileInputReaderTest
public FileInputReaderTest()
setUp
public void setUp()
throws java.lang.Exception
- Throws:
java.lang.Exception
testLineNumberDefaultSet
public void testLineNumberDefaultSet()
- This test ensures that the default line number is being set on Constructor call to ensure that the correct line numbers are produced for the Concordance.
testInputIndex
public void testInputIndex()
throws java.io.FileNotFoundException
- The purpose of this test is to ensure that index words are being succesfully read in from a textfile and store in the HashTable.
The processInputIndex method is called to read in files via a FileInputStream and a BufferedReader.
The index words are then added to the HashTable with an empty line number.
The HashTable is then returned and the index words are checked against the HashTable to ensure they contain the key.
- Throws:
java.io.FileNotFoundException
testInputTextConcordance
public void testInputTextConcordance()
- This test ensures that the concordance is being generated correctly, The index file is first read in to the HashTable with default linenumbers.
The index words are then checked to see if they are in the reference text, if they are in the text they are added to the HashTable with a line number and context.
This test ensures that it is working correctly but checking that the index words are matched correctly the line number that they appear in the text.
testContext
public void testContext()
- This test ensures that the contextual information is being stored correctly.
The index and text files are processed and then the HashTable is returned, the index word is used to retrieve the LinkedList structure that stores both the line number and context,
The getter method is then called to retrieve the context, the retrieved context is then checked against a static variable containing the actual context to ensure that they match.
testReturnedHashTableEqualsActual
public void testReturnedHashTableEqualsActual()
- This method ensures that the correct HashTable is being returned to ensure that there are no errors when retrieving values from the HashTable.
Two separate FileInputReader objects are instantiated and then processed and returned.
The two HashTables are checked to ensure they both contain the same data.
testSortingCorrectly
public void testSortingCorrectly()
- This method checks to ensure that the Index words are being sorted correctly in alphabetical order.
An index file is read in and then hashed in the HashTable using MD5, the contents of that HashTable are then added to an ArrayList.
The contexts of the text file are "apple" , "banana", "orange" and "pineapple" in non alphabetical order.
The list is then sorted alphabetically and compared against an alphabetically sorted version of the List to ensure that they match,
thus ensuring that the sort is working correctly.