aislib testkit

Testkit is a library of abstract JUnit test cases which helps in testing applications using aislib framework.

So far AbstractAppConfigTest is provided in this library, we are working on more classes.

AbstractAppConfigTest

AbstractAppConfigTest tests:

  • messages.xml
    • if there're no duplicates in message codes;
  • forms.xml
    • if classes defined as validators exists and are instantiable subclasses of BaseValidator (this will change to checking agains instance of Validator in version 1.1);
    • if defined properties are applicable to validators;
    • if messages defined as validation errors exists;
    • if messages defined as rule errors exists;
  • workflow.xml
    • if classes defined as pages exists and are instantiable subclasses of BasePage;
    • if page-ref points to exists pages;
    • if messages defined as includes exists;

AbstractAppConfigTest is an abstract class, subclasses must provide their implementation of getWorlkflowURL, getFormsURL and getMessagesURL. In typical Maven project this may be done in following way: In project.xml section:

<unitTest>
 <includes>
  <include>**/*Test.java</include>
 </includes>
 <resources>
  <resource>
   <directory>${basedir}/src/webapp</directory>
   <includes>
    <include>**/*</include>
   </includes>
  </resource>
 </resources>
</unitTest>
and subclass of AbstractAppConfigTest provides URLs to config files:
public class AdminConfigTest extends AbstractAppConfigTest {

  public URL getFormsURL() {
    URL result = getClass().getClassLoader().getResource("WEB-INF/fm/forms.xml");
    assertNotNull("Forms URL", result);
    return result;
  }

  public URL getFormsURL() {
    URL result = getClass().getClassLoader().getResource("WEB-INF/fm/forms.xml");
    assertNotNull("Forms URL", result);
    return result;
  }

  public URL getWorkflowURL() {
    URL result = getClass().getClassLoader().getResource("WEB-INF/fm/workflow.xml");
    assertNotNull("Workflow URL", result);
    return result;
  }
Asserts for URLs are needed because AbstractAppConfigTest do not perform tests for non-existing URLs (which in turn means, that those methods may returns null if given files do not exists in project - for example project may have workflow.xml and messages.xml but do not have forms.xml so getFormsURL method should simple returns null and validation tests won't be executed).