01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (license2)
04: * Initial Developer: H2 Group
05: */
06: package org.h2.test.db;
07:
08: import java.sql.Connection;
09: import java.sql.ResultSet;
10: import java.sql.Statement;
11:
12: import org.h2.test.TestBase;
13:
14: /**
15: * Test for views.
16: */
17: public class TestView extends TestBase {
18:
19: public void test() throws Exception {
20: deleteDb("view");
21: Connection conn = getConnection("view");
22: Statement s = conn.createStatement();
23: s.execute("create table t0(id int primary key)");
24: s.execute("insert into t0 values(1), (2), (3)");
25: for (int i = 0; i < 30; i++) {
26: s.execute("create view t" + (i + 1) + " as select * from t"
27: + i);
28: s.execute("select * from t" + (i + 1));
29: ResultSet rs = s.executeQuery("select count(*) from t"
30: + (i + 1) + " where id=2");
31: check(rs.next());
32: check(rs.getInt(1), 1);
33: }
34: conn.close();
35: conn = getConnection("view");
36: conn.close();
37: deleteDb("view");
38: }
39: }
|