R - the top-level result model classpublic abstract class AbstractTest<R extends IModel>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractTest.EqualitySetup<R extends IModel>
Setup data needed to compare test results for equality.
|
| Modifier and Type | Field and Description |
|---|---|
protected static ProgressObserver |
OBSERVER |
| Constructor and Description |
|---|
AbstractTest() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
assertNamingAndVersion(AbstractTest.EqualitySetup<R> data,
TranslationResult<R> result)
Asserts the naming and the version in
result. |
protected java.lang.String |
checkEqualsAndPrepareMessage(java.lang.String fileAsString,
java.io.Writer model)
Asserts the equality of two strings containing models and, if needed,
emits the location where the strings are not equal.
|
protected java.lang.String |
checkEqualsAndPrepareMessage(java.lang.String fileAsString,
java.io.Writer model,
boolean trimModel)
Asserts the equality of two strings containing models and, if needed,
emits the location where the strings are not equal.
|
protected boolean |
checkEqualsAndPrint(java.lang.String fileAsString,
java.lang.String modelAsString)
Asserts the equality of two strings containing models and, if needed,
prints the location where the strings are not equal.
|
protected boolean |
checkEqualsAndPrint(java.lang.String fileAsString,
java.lang.String modelAsString,
java.io.PrintWriter writer)
Asserts the equality of two strings containing models and, if needed,
prints the location where the strings are not equal.
|
protected java.lang.String |
checkErrorCodes(java.util.List<Message> messages,
java.util.List<Message> warnings,
int... expectedErrorCodes)
Asserts that the expected error codes match the errors stored in
result. |
protected java.lang.String |
checkErrorCodes(TranslationResult<R> result,
java.util.List<Message> warnings,
int... expectedErrorCodes)
Asserts that the expected error codes match the errors stored in
result. |
protected static java.lang.String |
checkWarnings(java.util.List<Message> warnings,
int... expectedWarnings)
Returns the message for missing expected warnings.
|
static java.io.File |
determineTestDataDir(java.lang.String property)
Determines the actual directory with the test IVML files depending on the
JVM system specified property which may contain a specific
directory (or be empty -> default directory
testdata). |
protected java.lang.String |
file2String(java.io.File file)
Turns a file into a string for comparison.
|
private boolean |
handleReplacementComment(StringWithPosition expected,
StringWithPosition actual)
Handles a replacement comment, i.e. //* occurred in
expected. |
private boolean |
handleWindowsLinuxLineEnd(StringWithPosition s1,
StringWithPosition s2)
Compare and handle possible line ends for equality over windows and linux conventions.
|
protected int |
isEqual(java.lang.String fileAsString,
java.lang.String modelAsString)
Compares two strings containing models and, if needed,
returns the location where the strings are not equal.
|
private static boolean |
isLineEnd(java.lang.Character ch)
Returns whether the given character is a line end.
|
private static boolean |
isWhitespaceButNotLineEnd(java.lang.Character ch)
Returns whether the given character is a whitespace but not a line end.
|
protected static void |
resourceInitialization()
Performs the resource initialization.
|
static java.lang.String |
toString(java.util.List<Message> messages)
Turns a list of messages into a readable string.
|
protected static final ProgressObserver OBSERVER
protected static void resourceInitialization()
public static java.io.File determineTestDataDir(java.lang.String property)
testdata).property - the JVM property to read outprotected java.lang.String checkErrorCodes(TranslationResult<R> result, java.util.List<Message> warnings, int... expectedErrorCodes)
result.result - the result from parsing and analyzing a projectwarnings - the warnings that occurred, to be modified as a side effect, may be nullexpectedErrorCodes - the allowed / expected error codesnull elseprotected java.lang.String checkErrorCodes(java.util.List<Message> messages, java.util.List<Message> warnings, int... expectedErrorCodes)
result.messages - the actual messages to be analyzedwarnings - the warnings that occurred, to be modified as a side effect, may be nullexpectedErrorCodes - the allowed / expected error codesnull elseprotected java.lang.String file2String(java.io.File file)
throws java.io.IOException
file is somewhat
temporary and you want to delete it, call System.gc(); after this
method. We do not call it by default as it affects the performance of the tests.file - the file to be turned into a stringjava.io.IOException - in case that file cannot be found/readprivate static final boolean isLineEnd(java.lang.Character ch)
ch - the character to testtrue if it is a line end, false elseprivate static final boolean isWhitespaceButNotLineEnd(java.lang.Character ch)
ch - the character to testtrue if it is a whitespace but not a line end,
false elseprotected int isEqual(java.lang.String fileAsString,
java.lang.String modelAsString)
fileAsString - the file as a stringmodelAsString - the model as a stringfileAsString where the inequality
occurs, a negative value if the model contains more data, no problem if return
value same/larger than length of fileAsStringprivate boolean handleWindowsLinuxLineEnd(StringWithPosition s1, StringWithPosition s2)
s1 and s2 are at line ends, advance the positions over line
endss1 - the first string to be compareds2 - the second string to be comparedtrue if s1 and s2 are at line ends and
both were advanced, false if nothing changedprivate boolean handleReplacementComment(StringWithPosition expected, StringWithPosition actual)
expected.
The current position in actual will be compared to expected and
if equal, the current and the next line in expected as well as the current line
in actual will be consumedexpected - the expected stringactual - the actual stringtrue if the comment is handled, false
if a comparison problem occurred and the lines are not considered to be equal.protected boolean checkEqualsAndPrint(java.lang.String fileAsString,
java.lang.String modelAsString)
fileAsString - the file as a stringmodelAsString - the model as a stringtrue if both are considered as equal, false elsecheckEqualsAndPrint(String, String, PrintWriter)protected boolean checkEqualsAndPrint(java.lang.String fileAsString,
java.lang.String modelAsString,
java.io.PrintWriter writer)
fileAsString - the file as a stringmodelAsString - the model as a stringwriter - A writer, which should be used for printing out a detailed error messagetrue if both are considered as equal, false elseprotected java.lang.String checkEqualsAndPrepareMessage(java.lang.String fileAsString,
java.io.Writer model)
throws java.io.IOException
fileAsString - the file as a stringmodel - the model as a string in the writerjava.io.IOException - in case of (internal) IO problemscheckEqualsAndPrint(String, String, PrintWriter)protected java.lang.String checkEqualsAndPrepareMessage(java.lang.String fileAsString,
java.io.Writer model,
boolean trimModel)
throws java.io.IOException
fileAsString - the file as a stringmodel - the model as a string in the writertrimModel - trim the model (string) on both sides before comparing it or only at the endjava.io.IOException - in case of (internal) IO problemscheckEqualsAndPrint(String, String, PrintWriter)protected static java.lang.String checkWarnings(java.util.List<Message> warnings, int... expectedWarnings)
warnings - the warnings to checkexpectedWarnings - the expected warningsprotected java.lang.String assertNamingAndVersion(AbstractTest.EqualitySetup<R> data, TranslationResult<R> result)
result.data - the data describing the setupresult - the data obtained from parsingpublic static java.lang.String toString(java.util.List<Message> messages)
messages - the messages to be turned into a stringCopyright © 2009 - 2018 SSE. All Rights Reserved.