/**
 * Copyright (c) 2016-2018 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 *
 * @author Chris Jackson
 *
 */
public class TestUtilities {

    static public void setField(Class clazz, Object object, String fieldName, Object newValue) throws Exception {
        Field field = clazz.getDeclaredField(fieldName);
        field.setAccessible(true);
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
        field.set(object, newValue);
    }

}

@@ -407,524 +407,2254 @@
 ect.
-Modifier;%0A%0A/**%0A *%0A * @author Chris Jackson%0A *%0A */%0Apublic class TestUtilities %7B%0A%0A    static public void setField(Class clazz, Object object, String fieldName, Object newValue) throws Exception %7B%0A        Field field = clazz.getDeclaredField(fieldName);%0A        field.setAccessible(true);%0A        Field modifiersField = Field.class.getDeclaredField(%22modifiers%22);%0A        modifiersField.setAccessible(true);%0A        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);%0A        field.set(object, newValue
+InvocationTargetException;%0Aimport java.lang.reflect.Method;%0Aimport java.lang.reflect.Modifier;%0A%0A/**%0A * A class of helper methods for running tests.%0A * %0A * @author Chris Jackson%0A *%0A */%0Apublic class TestUtilities %7B%0A%0A    /**%0A     * Set the value of a private field in a class%0A     * %0A     * @param clazz the class where the field resides%0A     * @param object the object where the field resides%0A     * @param fieldName the field name%0A     * @param newValue the Object to be set%0A     * @throws Exception%0A     */%0A    static public void setField(Class clazz, Object object, String fieldName, Object newValue) throws Exception %7B%0A        Field field = clazz.getDeclaredField(fieldName);%0A        field.setAccessible(true);%0A        Field modifiersField = Field.class.getDeclaredField(%22modifiers%22);%0A        modifiersField.setAccessible(true);%0A        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);%0A        field.set(object, newValue);%0A    %7D%0A%0A    /**%0A     * Invokes a private method%0A     *%0A     * @param clazz the class where the method resides%0A     * @param object the object where the method resides%0A     * @param methodName the method name%0A     * @param params an array of parameters - each parameter is the parameter class, followed by the parameter%0A     * @return the return object from the method%0A     * @throws NoSuchMethodException%0A     * @throws SecurityException%0A     * @throws IllegalAccessException%0A     * @throws IllegalArgumentException%0A     * @throws InvocationTargetException%0A     */%0A    static public Object invokeMethod(Class clazz, Object object, String methodName, Object... params)%0A            throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,%0A            InvocationTargetException %7B%0A        int paramCount = params.length;%0A        Method method;%0A        Class%3C?%3E%5B%5D classArray = new Class%3C?%3E%5BparamCount / 2%5D;%0A        Object%5B%5D paramArray = new Object%5BparamCount / 2%5D;%0A        for (int i = 0; i %3C paramCount; i += 2) %7B%0A            classArray%5Bi%5D = (Class) params%5Bi%5D;%0A            paramArray%5Bi%5D = params%5Bi + 1%5D;%0A        %7D%0A        method = clazz.getDeclaredMethod(methodName, classArray);%0A        method.setAccessible(true);%0A        return method.invoke(object, paramArray
 );%0A 

Add test utility to invoke a private method in a class (#491)