Fork me on GitHub

Library Lutece Unit testing

Introduction

This library provides classes to facilitate the implementation of unit tests.

LuteceTestCase

A class LuteceTestCase to create test classes with all services Lutece initialized (AppPropertiesService, AppPathService, database access ...).


public MyTestCase extends LuteceTestCase
{
...
}
                        

Mock Objects

Mock objects from spring-test can be used. Some utilities are provided.

In the example below, a false application containing false identified user was created to test an AdminFeature subjected to authentication.


MockHttpServletRequest request = new MockHttpServletRequest( );
Utils.registerAdminUserWithRigth( request, new AdminUser( ), RIGHT_MY_FEATURE);
request.addParameter( PARAM_NANE, param_value );

MyPluginJspBean instance = new MyPluginJspBean( );

instance.init( request, RIGHT_MY_FEATURE );
instance.getMyFeature( request );