01: /*
02: * HA-JDBC: High-Availability JDBC
03: * Copyright (c) 2004-2007 Paul Ferraro
04: *
05: * This library is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as published by the
07: * Free Software Foundation; either version 2.1 of the License, or (at your
08: * option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13: * for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public License
16: * along with this library; if not, write to the Free Software Foundation,
17: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * Contact: ferraro@users.sourceforge.net
20: */
21: package net.sf.hajdbc.dialect;
22:
23: import java.sql.SQLException;
24:
25: import net.sf.hajdbc.Dialect;
26:
27: import org.testng.annotations.DataProvider;
28: import org.testng.annotations.Test;
29:
30: /**
31: * @author Paul Ferraro
32: */
33: @SuppressWarnings("nls")
34: public class TestMckoiDialect extends TestStandardDialect {
35: @Override
36: protected Dialect createDialect() {
37: return new MckoiDialect();
38: }
39:
40: @Override
41: @Test(dataProvider="insert-table-sql")
42: public String parseInsertTable(String sql) throws SQLException {
43: this .replay();
44:
45: String table = this .dialect.parseInsertTable(sql);
46:
47: this .verify();
48:
49: assert table == null : table;
50:
51: return table;
52: }
53:
54: @Override
55: @DataProvider(name="sequence-sql")
56: Object[][] sequenceSQLProvider() {
57: return new Object[][] {
58: new Object[] { "SELECT NEXTVAL('success')" },
59: new Object[] { "SELECT NEXTVAL ( 'success' )" },
60: new Object[] { "SELECT CURRVAL('success')" },
61: new Object[] { "SELECT CURRVAL ( 'success' )" },
62: new Object[] { "SELECT NEXTVAL('success'), * FROM table" },
63: new Object[] { "SELECT NEXTVAL ( 'success' ) , * FROM table" },
64: new Object[] { "SELECT CURRVAL('success'), * FROM table" },
65: new Object[] { "SELECT CURRVAL ( 'success' ) , * FROM table" },
66: new Object[] { "INSERT INTO table VALUES (NEXTVAL('success'), 0)" },
67: new Object[] { "INSERT INTO table VALUES (NEXTVAL ( 'success' ) , 0)" },
68: new Object[] { "INSERT INTO table VALUES (CURRVAL('success'), 0)" },
69: new Object[] { "INSERT INTO table VALUES (CURRVAL ( 'success' ) , 0)" },
70: new Object[] { "UPDATE table SET id = NEXTVAL('success')" },
71: new Object[] { "UPDATE table SET id = NEXTVAL ( 'success' )" },
72: new Object[] { "UPDATE table SET id = CURRVAL('success')" },
73: new Object[] { "UPDATE table SET id = CURRVAL ( 'success' )" },
74: new Object[] { "SELECT * FROM table" }, };
75: }
76: }
|