@Test
public void testGenerateSparkCmd() {

    KylinConfig kylinConfig = getTestConfig();
    final String kylinHome = System.getProperty("KYLIN_HOME");
    try {
        System.setProperty("KYLIN_HOME", "/kylin");
        NSparkExecutable sparkExecutable = new NSparkExecutable();
        sparkExecutable.setProject("default");
        String hadoopConf = System.getProperty("KYLIN_HOME") + "/hadoop";
        String kylinJobJar = System.getProperty("KYLIN_HOME") + "/lib/job.jar";
        String appArgs = "/tmp/output";
        String cmd = sparkExecutable.generateSparkCmd(kylinConfig, hadoopConf, kylinJobJar, kylinJobJar, appArgs);
        Assert.assertNotNull(cmd);
        Assert.assertTrue(cmd.contains("export HADOOP_CONF_DIR"));
        Assert.assertTrue(cmd.contains("spark-submit"));
        Assert.assertTrue(cmd.contains("spark.executor.extraClassPath=job.jar"));
        Assert.assertTrue(cmd.contains("spark.driver.log4j.appender.hdfs.File="));
    } finally {
        if (StringUtils.isEmpty(kylinHome)) {
            System.clearProperty("KYLIN_HOME");
        } else {
            System.setProperty("KYLIN_HOME", kylinHome);
        }
    }
}