Primary Features and Benefits

The xweld-test module provides a simple framework based on TestNG. The test framework is used to quickly build unit tests that require a self contain context to be set up that runs SetupTool on a H2 database, and optionally allows a configured user to login in and out during the unit test execution.

Key Concepts

Many applications require a database to run. Typically, the database stores static or domain data, configuration information as well security definitions for users and roles. Unit tests need the ability to set up and initialize in a runtime contexts that lives for the life of the test. The test module provides a set of base classes that can be extended when building unit tests for other modules and tools.

Packages and Classes

xweld-test includes the following packages:

  • com.xweld.test –the main package of the test framework

Test Base Classes

The RuntimeSetupTest is a base class that will run the setup tool and potentially log in a user or log them out. The RuntimeParamaters class holds the values for the various onfigurable settings for your test. The getRuntimeParameters method can be overridden to return a custom value in an derived test case. Any class derived from RuntimeSetupTest will automatically have a database initialized by SetupTool.

Example -- Building A Custom Test Case

Let's say we want to build a test that runs our custom setup tool, after running the default ones, like the security setup tool. We'll add a that we can log into a user to the system.

public class TestAuthorization extends RuntimeSetupTest
  public RuntimeParameters getRuntimeParameters()
    RuntimeParameters p = new RuntimeParameters();
    // override any values from the default settings here.

    p.setSetupTypes(p.getSetupTypes() + "," + "com.xweld.test.Setup");
    return p;

   public void testLogin() throws LoginException
    final IAuthenticationProvider m = new JAASAuthenticationProvider();

    UserDAO dao = new UserDAO(null);

    User user = dao.newInstance(new Object [] {"jdoe"} );;

    IUser u = null;
    for (int i = 0; i < 4; i++)
      Serializable s = performLogin("jdoe");
      u = m.getUser(s);

    Assert.assertTrue(m.isUserAuthenticated(user) == false);

Contact Us

For more information, please contact us at .


Copyright © 1999-2014 Free North Alliance Inc. All Rights Reserved.

The contents of this web site, including all images, text, graphics and software, are the sole property of Free North Alliance Inc. and its agents. Unauthorized use or transmission is strictly forbidden by international copyright law.

com.xweld.test.JPG View (38 KB) John Free, 05 March 2014 05:49 PM