package org.apache.hadoop.hive.ql.parse; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import java.io.*; import java.util.*; import org.apache.hadoop.hive.ql.QTestUtil; import org.apache.hadoop.hive.ql.exec.Task; public class $className extends TestCase { private QTestUtil qt; public $className(String name) { super(name); qt = null; } @Override protected void setUp() { try { qt = new QTestUtil("$resultsDir.getCanonicalPath()", "$logDir.getCanonicalPath()"); #foreach ($qf in $qfiles) qt.addFile("$qf.getCanonicalPath()"); #end } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); System.out.flush(); fail("Unexpected exception in setup"); } } public static Test suite() { TestSuite suite = new TestSuite(); #foreach ($qf in $qfiles) #set ($fname = $qf.getName()) #set ($eidx = $fname.length() - 2) #set ($tname = $fname.substring(0, $eidx)) suite.addTest(new $className("testParse_$tname")); #end return suite; } #foreach ($qf in $qfiles) #set ($fname = $qf.getName()) #set ($eidx = $fname.length() - 2) #set ($tname = $fname.substring(0, $eidx)) public void testParse_$tname() throws Exception { try { System.out.println("Begin query: " + "$fname"); qt.init("$fname"); ASTNode tree = qt.parseQuery("$fname"); int ecode = qt.checkParseResults("$fname", tree); if (ecode != 0) { fail("Parse has unexpected out with error code = " + ecode); } List> tasks = qt.analyzeAST(tree); ecode = qt.checkPlan("$fname", tasks); if (ecode != 0) { fail("Semantic Analysis has unexpected output with error code = " + ecode); } System.out.println("Done query: " + "$fname"); } catch (Throwable e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); System.out.flush(); fail("Unexpected exception"); } assertTrue("Test passed", true); } #end }