提交 c26f2c09 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting / tests

上级 5a546e5c
...@@ -1809,7 +1809,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1809,7 +1809,7 @@ public class JdbcConnection extends TraceObject implements Connection {
/** /**
* Check that the given type map is either null or empty. * Check that the given type map is either null or empty.
* *
* @param map the type map * @param map the type map
* @throws DbException if the map is not empty * @throws DbException if the map is not empty
*/ */
......
...@@ -39,6 +39,7 @@ public class TestIndex extends TestBase { ...@@ -39,6 +39,7 @@ public class TestIndex extends TestBase {
@Override @Override
public void test() throws SQLException { public void test() throws SQLException {
deleteDb("index"); deleteDb("index");
testIndexTypes();
testHashIndexOnMemoryTable(); testHashIndexOnMemoryTable();
testErrorMessage(); testErrorMessage();
testDuplicateKeyException(); testDuplicateKeyException();
...@@ -93,6 +94,29 @@ public class TestIndex extends TestBase { ...@@ -93,6 +94,29 @@ public class TestIndex extends TestBase {
deleteDb("index"); deleteDb("index");
} }
private void testIndexTypes() throws SQLException {
Connection conn = getConnection("index;MV_STORE=false");
stat = conn.createStatement();
for (String type : new String[] { "unique", "hash", "unique hash" }) {
stat.execute("create table test(id int)");
stat.execute("create " + type + " index idx_name on test(id)");
stat.execute("insert into test select x from system_range(1, 1000)");
ResultSet rs = stat.executeQuery("select * from test where id=100");
assertTrue(rs.next());
assertFalse(rs.next());
stat.execute("delete from test where id=100");
rs = stat.executeQuery("select * from test where id=100");
assertFalse(rs.next());
rs = stat.executeQuery("select min(id), max(id) from test");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertEquals(1000, rs.getInt(2));
stat.execute("drop table test");
}
conn.close();
deleteDb("index");
}
private void testErrorMessage() throws SQLException { private void testErrorMessage() throws SQLException {
reconnect(); reconnect();
stat.execute("create table test(id int primary key, name varchar)"); stat.execute("create table test(id int primary key, name varchar)");
......
...@@ -1034,31 +1034,31 @@ public class TestPreparedStatement extends TestBase { ...@@ -1034,31 +1034,31 @@ public class TestPreparedStatement extends TestBase {
rs.next(); rs.next();
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)",
Statement.RETURN_GENERATED_KEYS); Statement.RETURN_GENERATED_KEYS);
prep.execute(); prep.execute();
rs = prep.getGeneratedKeys(); rs = prep.getGeneratedKeys();
rs.next(); rs.next();
assertEquals(2, rs.getInt(1)); assertEquals(2, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)",
new int[] { 1 }); new int[] { 1 });
prep.execute(); prep.execute();
rs = prep.getGeneratedKeys(); rs = prep.getGeneratedKeys();
rs.next(); rs.next();
assertEquals(3, rs.getInt(1)); assertEquals(3, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)",
new String[] { "ID" }); new String[] { "ID" });
prep.execute(); prep.execute();
rs = prep.getGeneratedKeys(); rs = prep.getGeneratedKeys();
rs.next(); rs.next();
assertEquals(4, rs.getInt(1)); assertEquals(4, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)", prep = conn.prepareStatement("INSERT INTO TEST VALUES(NEXT VALUE FOR SEQ)",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_READ_ONLY,
...@@ -1068,7 +1068,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -1068,7 +1068,7 @@ public class TestPreparedStatement extends TestBase {
rs.next(); rs.next();
assertEquals(5, rs.getInt(1)); assertEquals(5, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
......
...@@ -57,13 +57,13 @@ public class TestStatement extends TestBase { ...@@ -57,13 +57,13 @@ public class TestStatement extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, stat).isWrapperFor(Object.class); assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, stat).isWrapperFor(Object.class);
assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, stat).unwrap(Object.class); assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, stat).unwrap(Object.class);
conn.setTypeMap(null); conn.setTypeMap(null);
HashMap<String, Class<?>> map = New.hashMap(); HashMap<String, Class<?>> map = New.hashMap();
conn.setTypeMap(map); conn.setTypeMap(map);
map.put("x", Object.class); map.put("x", Object.class);
assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, conn).setTypeMap(map); assertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1, conn).setTypeMap(map);
assertThrows(SQLClientInfoException.class, conn).setClientInfo("X", "Y"); assertThrows(SQLClientInfoException.class, conn).setClientInfo("X", "Y");
assertThrows(SQLClientInfoException.class, conn).setClientInfo(new Properties()); assertThrows(SQLClientInfoException.class, conn).setClientInfo(new Properties());
} }
......
...@@ -50,7 +50,7 @@ public class TestBnf extends TestBase { ...@@ -50,7 +50,7 @@ public class TestBnf extends TestBase {
conn.close(); conn.close();
} }
} }
private void testModes(Connection conn) throws Exception { private void testModes(Connection conn) throws Exception {
DbContents dbContents; DbContents dbContents;
dbContents = new DbContents(); dbContents = new DbContents();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论