|
23 | 23 | import java.util.logging.Level; |
24 | 24 | import java.util.logging.Logger; |
25 | 25 | import net.sf.jsqlparser.JSQLParserException; |
| 26 | +import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
26 | 27 | import static net.sf.jsqlparser.test.TestUtils.*; |
27 | 28 | import org.apache.commons.io.FileUtils; |
28 | 29 | import org.junit.Test; |
29 | 30 |
|
30 | 31 | /** |
31 | | - * Tries to parse and deparse all statments in net.sf.jsqlparser.test.oracle-tests. |
| 32 | + * Tries to parse and deparse all statments in |
| 33 | + * net.sf.jsqlparser.test.oracle-tests. |
| 34 | + * |
32 | 35 | * @author toben |
33 | 36 | */ |
34 | 37 | public class SpecialOracleTests { |
35 | | - |
36 | | - private static final File SQLS_DIR = new File("target/test-classes/net/sf/jsqlparser/test/oracle-tests"); |
| 38 | + |
| 39 | + private static final File SQLS_DIR = new File("target/test-classes/net/sf/jsqlparser/test/oracle-tests"); |
37 | 40 | private static final Logger LOG = Logger.getLogger(SpecialOracleTests.class.getName()); |
38 | | - |
| 41 | + |
39 | 42 | @Test |
40 | | - public void testAllSqls() throws IOException { |
| 43 | + public void testAllSqlsParseDeparse() throws IOException { |
| 44 | + int count=0; |
| 45 | + int success=0; |
41 | 46 | File[] sqlTestFiles = SQLS_DIR.listFiles(); |
| 47 | + |
| 48 | + for (File file : sqlTestFiles) { |
| 49 | + if (file.isFile()) { |
| 50 | + count++; |
| 51 | + LOG.log(Level.INFO, "testing {0}", file.getName()); |
| 52 | + String sql = FileUtils.readFileToString(file); |
| 53 | + try { |
| 54 | + assertSqlCanBeParsedAndDeparsed(sql, true); |
| 55 | + success++; |
| 56 | + LOG.info(" -> SUCCESS"); |
| 57 | + } catch (JSQLParserException ex) { |
| 58 | + LOG.log(Level.SEVERE, null, ex); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
42 | 62 |
|
| 63 | + LOG.log(Level.INFO, "tested {0} files. got {1} correct parse results", new Object[]{count, success}); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void testAllSqlsOnlyParse() throws IOException { |
| 68 | + File[] sqlTestFiles = new File(SQLS_DIR, "only-parse-test").listFiles(); |
| 69 | + |
43 | 70 | for (File file : sqlTestFiles) { |
44 | 71 | LOG.log(Level.INFO, "testing {0}", file.getName()); |
45 | 72 | String sql = FileUtils.readFileToString(file); |
46 | 73 | try { |
47 | | - assertSqlCanBeParsedAndDeparsed(sql, true); |
48 | | - |
| 74 | + CCJSqlParserUtil.parse(sql); |
| 75 | + |
49 | 76 | LOG.info(" -> SUCCESS"); |
50 | 77 | } catch (JSQLParserException ex) { |
51 | 78 | LOG.log(Level.SEVERE, null, ex); |
|
0 commit comments