• 物联网项目


    1.JUnit测试,私有类的测试

    package com.message.service;

    import static org.junit.Assert.*;
    import static org.junit.Assert.assertEquals;

    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;

    import org.junit.Test;

    public class BaseTestCase {
    protected Object invokeUnPublicMethod(Object pInstance, String pMethodName, Class[] paramTypes, Object[] parmValues) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
    Object result = null;
    //MessageHandler h = new MessageHandler();
    Method m = pInstance.getClass().getDeclaredMethod(pMethodName, paramTypes);
    m.setAccessible(true);

    result = m.invoke(pInstance,parmValues);
    m.setAccessible(false);
    System.out.println(result);
    return result;
    }
    }
  • 相关阅读:
    第七天冲刺
    MySQL管理
    LNMP环境搭建
    docker使用笔记
    Laravel5.2使用笔记
    Linux使用笔记
    Redis3.2.11在centos9安装与卸载
    Ubuntu系统
    Linux下安装与卸载PHP
    安装Linux
  • 原文地址:https://www.cnblogs.com/xiashiwendao/p/3395530.html
Copyright © 2020-2023  润新知