01: /*
02: Derby - Class org.apache.derbyTesting.functionTests.tests.lang.VTITest
03:
04: Licensed to the Apache Software Foundation (ASF) under one or more
05: contributor license agreements. See the NOTICE file distributed with
06: this work for additional information regarding copyright ownership.
07: The ASF licenses this file to You under the Apache License, Version 2.0
08: (the "License"); you may not use this file except in compliance with
09: the License. You may obtain a copy of the License at
10:
11: http://www.apache.org/licenses/LICENSE-2.0
12:
13: Unless required by applicable law or agreed to in writing, software
14: distributed under the License is distributed on an "AS IS" BASIS,
15: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: See the License for the specific language governing permissions and
17: limitations under the License.
18:
19: */
20: package org.apache.derbyTesting.functionTests.tests.lang;
21:
22: import java.sql.SQLException;
23: import java.sql.Statement;
24: import java.sql.ResultSet;
25:
26: import junit.framework.Test;
27: import junit.framework.TestSuite;
28: import org.apache.derbyTesting.junit.BaseJDBCTestCase;
29: import org.apache.derbyTesting.junit.JDBC;
30:
31: /**
32: * Add tests that use VTI
33: */
34: public class VTITest extends BaseJDBCTestCase {
35:
36: public static Test suite() {
37: TestSuite suite = new TestSuite();
38: // requires DriverManager support
39: if (JDBC.vmSupportsJDBC2())
40: suite.addTest(new VTITest("bulkInsertVtiTest"));
41:
42: return suite;
43: }
44:
45: public VTITest(String name) {
46: super (name);
47: }
48:
49: /**
50: * Setup: create a table for this test
51: */
52: protected void setUp() throws SQLException {
53: Statement stmt = createStatement();
54: stmt.execute("CREATE TABLE warehouse (id int)");
55: stmt.close();
56: }
57:
58: /**
59: * Drop the table created during setup.
60: * @throws Exception
61: */
62: protected void tearDown() throws Exception {
63: Statement stmt = createStatement();
64: stmt.execute("DROP TABLE warehouse");
65: stmt.close();
66: super .tearDown();
67: }
68:
69: /**
70: * Execute SYSCS_BULK_INSERT procedure to insert rows.
71: * @throws SQLException
72: */
73: public void bulkInsertVtiTest() throws SQLException {
74: int expectedRows = 10;
75: Statement stmt = createStatement();
76: stmt
77: .execute("call SYSCS_UTIL.SYSCS_BULK_INSERT('APP','WAREHOUSE',"
78: + "'org.apache.derbyTesting.functionTests.tests.lang.WarehouseVTI',"
79: + "\'" + expectedRows + "')");
80: stmt.close();
81: stmt = createStatement();
82: ResultSet rs = stmt
83: .executeQuery("SELECT COUNT(*) from warehouse");
84: rs.next();
85: assertEquals(expectedRows, rs.getInt(1));
86: rs.close();
87: stmt.close();
88: }
89: }
|