### Question:
LogPipelineCheck extends AbstractMasterCheck { @Override public void run() throws Exception { List<URL> urls = ClassLoaders.getClassLoaderURLs(getClass().getClassLoader(), new ArrayList<URL>()); for (File libJar : LoggingUtil.getExtensionJars(cConf)) { urls.add(libJar.toURI().toURL()); } StringWriter writer = new StringWriter(); this.cConf.writeXml(writer); ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), null); Class<?> cConfClass = classLoader.loadClass(CConfiguration.class.getName()); Object cConf = cConfClass.getMethod("create").invoke(null); cConfClass.getMethod("clear").invoke(cConf); InputStream input = new ByteArrayInputStream(writer.toString().getBytes(StandardCharsets.UTF_8)); cConfClass.getMethod("addResource", InputStream.class).invoke(cConf, input); Class<?> loaderClass = classLoader.loadClass(LogPipelineLoader.class.getName()); Object loader = loaderClass.getConstructor(cConfClass).newInstance(cConf); try { loaderClass.getMethod("validate").invoke(loader); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (InvalidPipelineException.class.getName().equals(cause.getClass().getName())) { InvalidPipelineException ex = new InvalidPipelineException(cause.getMessage(), cause.getCause()); ex.setStackTrace(cause.getStackTrace()); throw ex; } Throwables.propagateIfPossible(cause, Exception.class); throw new RuntimeException(cause); } LOG.info("Log pipeline configurations verified."); } @Inject  LogPipelineCheck(CConfiguration cConf); @Override void run();  }### Answer:
@Test public void testValid() throws Exception { File libDir = TEMP_FOLDER.newFolder(); String appenderClassName = NoopAppender.class.getSimpleName() + "2"; try (JarOutputStream jarOutput = new JarOutputStream(new FileOutputStream(new File(libDir, "lib.jar")))) { jarOutput.putNextEntry(new JarEntry(appenderClassName + ".class")); jarOutput.write(renameClass(NoopAppender.class, appenderClassName)); } File configDir = TEMP_FOLDER.newFolder(); generateLogConfig("ALL", Collections.<String, String>emptyMap(), appenderClassName, new File(configDir, "test.xml")); CConfiguration cConf = CConfiguration.create(); cConf.set(Constants.Logging.PIPELINE_LIBRARY_DIR, libDir.getAbsolutePath()); cConf.set(Constants.Logging.PIPELINE_CONFIG_DIR, configDir.getAbsolutePath()); new LogPipelineCheck(cConf).run(); }
@Test (expected = InvalidPipelineException.class) public void testInvalid() throws Exception { CConfiguration cConf = CConfiguration.create(); cConf.set("log.pipeline.cdap.file.sync.interval.bytes", "-1"); new LogPipelineCheck(cConf).run(); }