### Question:
ModulePluginUtils { public static void cacheModulePluginConfig(String realConfigDirectory) { if (realConfigDirectory == null || "".equals(realConfigDirectory)) { throw new ModulePluginConfigException("模块插件配置信息缓存文件夹路径不能为空或null！"); } File directory = new File(realConfigDirectory); if (!directory.exists()) { directory.mkdirs(); } else if (directory.isFile()) { throw new ModulePluginConfigException(realConfigDirectory + "不是文件夹路径！"); } try { File file = new File(realConfigDirectory, CONFIG_FILE_NAME); if (file.exists()) { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file)); Object obj = ois.readObject(); ois.close(); Map<String, Long> cacheMap = new HashMap<String, Long>(8); if (obj instanceof List) { List<?> list = (List<?>) obj; for (Object object : list) { if (object instanceof SerializableDriverInfo) { SerializableDriverInfo sdi = (SerializableDriverInfo) object; if (sdi.inJar) { cacheMap.put(sdi.driverClass, sdi.lastModifyTime); } } } } Enumeration<ModulePluginDriverInfo> driverInfos = getDriverInfos(); while (driverInfos.hasMoreElements()) { ModulePluginDriverInfo driverInfo = driverInfos.nextElement(); String key = driverInfo.driverClass.getName(); if (cacheMap.containsKey(key) && cacheMap.get(key) != driverInfo.lastModifyTime) { needUpdateDriverInfos.add(driverInfo); } } if (needUpdateDriverInfos.size() > 0) { SystemLogUtils.rootPrintln("更新模块插件驱动详细信息缓存文件Begin！"); for (ModulePluginDriverInfo mpdi : needUpdateDriverInfos) { SystemLogUtils.secondPrintln("更新" + mpdi.getDriver() + "缓存文件！"); } serializeDriverInfos(file, false); SystemLogUtils.rootPrintln("更新模块插件驱动详细信息缓存文件End！"); } } else { SystemLogUtils.rootPrintln("创建模块插件驱动详细信息缓存文件Begin！"); serializeDriverInfos(file, true); SystemLogUtils.rootPrintln("创建模块插件驱动详细信息缓存文件End！"); } } catch (Exception e) { e.printStackTrace(); throw new ModulePluginConfigException(realConfigDirectory + "模块插件配置信息缓存文件写入信息失败！"); } }  static void cacheModulePluginConfig(String realConfigDirectory); static Enumeration<ModulePluginDriverInfo> getDriverInfos(); static Enumeration<ModulePluginDriverInfo> getDriverInfos(Class<? extends ModulePluginDriver> clazz); static ModulePluginDriverInfo getDriverInfo(String driverClassName); @SuppressWarnings("unchecked") static Enumeration<X> getDrivers(Class<X> clazz); static final String DELIMITERS; }### Answer:
@Test public void testCacheModulePluginConfig() { try { ModulePluginUtils.cacheModulePluginConfig(null); } catch (ModulePluginConfigException e) { log.error(e.getMessage()); } try { String realPath = new ClassPathResource("/LICENSE.txt", getClass()).getFile().getAbsolutePath(); ModulePluginUtils.cacheModulePluginConfig(realPath); } catch (ModulePluginConfigException e) { log.info(e.getMessage()); } catch (IOException e) { log.info(e.getMessage()); } String realPath = getClass().getResource("/").getPath(); ModulePluginUtils.cacheModulePluginConfig(realPath); ModulePluginUtils.cacheModulePluginConfig(realPath); }