Search in sources :

Example 1 with ConstantsNotLoadedException

use of org.mifos.framework.exceptions.ConstantsNotLoadedException in project head by mifos.

the class ConstPlugin method buildClasses.

List<Class> buildClasses(List<String> constantFileNameList) throws ConstantsNotLoadedException {
    List<Class> constantClassNameList = new ArrayList<Class>();
    String constantFileName = null;
    try {
        for (String fileName : constantFileNameList) {
            constantFileName = fileName.trim();
            constantClassNameList.add(Class.forName(constantFileName));
        }
    } catch (ClassNotFoundException cnfe) {
        Object[] values = new Object[] { constantFileName };
        throw new ConstantsNotLoadedException(ExceptionConstants.CONSTANTSNOTLOADEDEXCEPTION, cnfe, values);
    }
    return constantClassNameList;
}
Also used : ArrayList(java.util.ArrayList) ConstantsNotLoadedException(org.mifos.framework.exceptions.ConstantsNotLoadedException)

Example 2 with ConstantsNotLoadedException

use of org.mifos.framework.exceptions.ConstantsNotLoadedException in project head by mifos.

the class ConstPluginStrutsTest method testConstantsPluginException.

@Test
public void testConstantsPluginException() throws Exception {
    ConstPlugin constPlugin = new ConstPlugin();
    ArrayList<String> constPluginClasses = new ArrayList<String>();
    constPluginClasses.add("org.mifos.doesNotExist");
    try {
        Class doesNotExistClass = ConstPlugin.class;
        Field[] fields = doesNotExistClass.getDeclaredFields();
        Field field = fields[0];
        ConstPlugin.checkModifiers(field);
    } catch (ConstantsNotLoadedException expected) {
    }
    try {
        constPlugin.buildClasses(constPluginClasses);
        Assert.fail();
    } catch (ConstantsNotLoadedException expected) {
    }
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) ConstantsNotLoadedException(org.mifos.framework.exceptions.ConstantsNotLoadedException) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 ConstantsNotLoadedException (org.mifos.framework.exceptions.ConstantsNotLoadedException)2 Field (java.lang.reflect.Field)1 Test (org.junit.Test)1