KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > lang > VTITest


1 /*
2     Derby - Class org.apache.derbyTesting.functionTests.tests.lang.VTITest
3
4     Licensed to the Apache Software Foundation (ASF) under one or more
5     contributor license agreements. See the NOTICE file distributed with
6     this work for additional information regarding copyright ownership.
7     The ASF licenses this file to You under the Apache License, Version 2.0
8     (the "License"); you may not use this file except in compliance with
9     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  
23 import java.sql.SQLException JavaDoc;
24 import java.sql.Statement JavaDoc;
25 import java.sql.ResultSet JavaDoc;
26
27 import junit.framework.Test;
28 import junit.framework.TestSuite;
29 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
30 import org.apache.derbyTesting.junit.JDBC;
31
32 /**
33  * Add tests that use VTI
34  */

35  public class VTITest extends BaseJDBCTestCase {
36      
37
38      public static Test suite()
39      {
40          TestSuite suite = new TestSuite();
41          // requires DriverManager support
42
if (JDBC.vmSupportsJDBC2())
43             suite.addTest(new VTITest("bulkInsertVtiTest"));
44          
45          return suite;
46      }
47      
48
49      public VTITest(String JavaDoc name) {
50          super(name);
51      }
52      
53
54      /**
55       * Setup: create a table for this test
56       */

57      protected void setUp() throws SQLException JavaDoc {
58          Statement JavaDoc stmt = createStatement();
59          stmt.execute("CREATE TABLE warehouse (id int)");
60          stmt.close();
61      }
62      
63      /**
64       * Drop the table created during setup.
65       * @throws Exception
66       */

67      protected void tearDown()
68          throws Exception JavaDoc {
69          Statement JavaDoc stmt = createStatement();
70          stmt.execute("DROP TABLE warehouse");
71          stmt.close();
72          super.tearDown();
73      }
74  
75   
76      /**
77       * Execute SYSCS_BULK_INSERT procedure to insert rows.
78       * @throws SQLException
79       */

80      public void bulkInsertVtiTest()
81      throws SQLException JavaDoc
82      {
83         int expectedRows = 10;
84         Statement JavaDoc stmt = createStatement();
85         stmt.execute("call SYSCS_UTIL.SYSCS_BULK_INSERT('APP','WAREHOUSE'," +
86                 "'org.apache.derbyTesting.functionTests.tests.lang.WarehouseVTI',"
87                 +"\'"+expectedRows+"')");
88         stmt.close();
89         stmt = createStatement();
90         ResultSet JavaDoc rs = stmt.executeQuery("SELECT COUNT(*) from warehouse");
91         rs.next();
92         assertEquals(expectedRows,rs.getInt(1));
93         rs.close();
94         stmt.close();
95      }
96  }
Popular Tags