lp.trans
Class DlpGrounderTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by lp.trans.DlpGrounderTest
All Implemented Interfaces:
Test

public class DlpGrounderTest
extends TestCase

Contains tests of the DlpGrounder class.

Version:
1.0.0
Author:
Martin Slota
See Also:
DlpGrounder

Field Summary
private  DlpGrounder grounder
          The tested DlpGrounder instance.
private  LpParser parser
          The parser used in the tests.
 
Constructor Summary
DlpGrounderTest(String testName)
          A default test case constructor.
 
Method Summary
private  void doTest(String[] inputDlp, String[] groundedDlp, GrounderMessage expError, List<GrounderMessage> expWarnings)
          Performs a single call of grounder.ground(inputProgram); and tests if expected output program, error and warnings are extracted from the lparse's output.
private  GrounderMessage makeGrounderMessage(String message, String sourceRule, boolean isWarning)
           
 void testAlreadyGroundedInput()
          Tests DlpGrounder on an already grounded input.
 void testConstraint()
          Tests DlpGrounder on input with constraints.
 void testErrorFreeInput()
          Tests DlpGrounder on an error free input.
 void testInputWithError()
          Tests DlpGrounder on input with an error.
 void testMultipleWarnings()
          Tests DlpGrounder on input that should issue multiple warnings.
 void testNoProgram()
          Tests DlpGrounder on input that only contains no program.
 void testOneEmptyProgram()
          Tests DlpGrounder on input that only contains one empty program.
 void testOneWarning()
          Tests DlpGrounder on input that should issue one warning.
 void testWeirdError()
          Tests DlpGrounder on input that should issue a weird error.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, 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

parser

private final LpParser parser
The parser used in the tests.


grounder

private final DlpGrounder grounder
The tested DlpGrounder instance.

Constructor Detail

DlpGrounderTest

public DlpGrounderTest(String testName)
A default test case constructor.

Parameters:
testName - the name of the test case
Method Detail

testAlreadyGroundedInput

public void testAlreadyGroundedInput()
Tests DlpGrounder on an already grounded input. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testErrorFreeInput

public void testErrorFreeInput()
Tests DlpGrounder on an error free input. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testInputWithError

public void testInputWithError()
Tests DlpGrounder on input with an error. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testOneWarning

public void testOneWarning()
Tests DlpGrounder on input that should issue one warning. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testMultipleWarnings

public void testMultipleWarnings()
Tests DlpGrounder on input that should issue multiple warnings. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testWeirdError

public void testWeirdError()
Tests DlpGrounder on input that should issue a weird error. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testOneEmptyProgram

public void testOneEmptyProgram()
Tests DlpGrounder on input that only contains one empty program. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testNoProgram

public void testNoProgram()
Tests DlpGrounder on input that only contains no program. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


testConstraint

public void testConstraint()
Tests DlpGrounder on input with constraints. This test can only pass if the lparse binary can be executed by issuing a simple "lparse" command.


makeGrounderMessage

private GrounderMessage makeGrounderMessage(String message,
                                            String sourceRule,
                                            boolean isWarning)

doTest

private void doTest(String[] inputDlp,
                    String[] groundedDlp,
                    GrounderMessage expError,
                    List<GrounderMessage> expWarnings)
Performs a single call of
grounder.ground(inputProgram);
and tests if expected output program, error and warnings are extracted from the lparse's output.

Parameters:
inputDlp - the input dynamic logic program to ground
groundedDlp - the expected grounded dynamic logic program
expError - the expected lparse error
expWarnings - the expected lparse warnings