KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > store > oc_rec2


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.harness.procedure
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derbyTesting.functionTests.tests.store;
23
24 import org.apache.derby.iapi.db.OnlineCompress;
25
26 import org.apache.derby.iapi.services.sanity.SanityManager;
27
28 import java.sql.CallableStatement JavaDoc;
29 import java.sql.Connection JavaDoc;
30 import java.sql.PreparedStatement JavaDoc;
31 import java.sql.ResultSet JavaDoc;
32 import java.sql.SQLException JavaDoc;
33 import java.sql.Statement JavaDoc;
34
35 import org.apache.derby.tools.ij;
36
37
38 public class oc_rec2 extends OnlineCompressTest
39 {
40
41     public oc_rec2()
42     {
43     }
44
45     /**
46      * setup for restart recovery test.
47      * <p>
48      * Do setup to test restart recovery of online compress. Real work
49      * is done in next test oc_rec2 which will run restart recovery on
50      * the work done in this test.
51      *
52      **/

53     private void test1(
54     Connection JavaDoc conn,
55     String JavaDoc test_name,
56     String JavaDoc table_name)
57         throws SQLException JavaDoc
58     {
59         beginTest(conn, test_name);
60         if (!checkConsistency(conn, "APP", table_name))
61         {
62             logError("conistency check failed.");
63         }
64         // make sure we can add data to the existing table after redo
65
// recovery.
66
createAndLoadTable(conn, false, table_name, 6000, 0);
67         if (!checkConsistency(conn, "APP", table_name))
68         {
69             logError("conistency check failed.");
70         }
71
72         // setup to test redo recovery on:
73
// create table, delete rows, compress, add rows, commit
74
String JavaDoc table_name_2 = table_name + "_2";
75         createAndLoadTable(conn, true, table_name_2, 2000, 0);
76         executeQuery(conn, "delete from " + table_name, true);
77         callCompress(conn, "APP", table_name, true, true, true, true);
78
79         endTest(conn, test_name);
80     }
81
82     public void testList(Connection JavaDoc conn)
83         throws SQLException JavaDoc
84     {
85         test1(conn, "test1", "TEST1");
86     }
87
88     public static void main(String JavaDoc[] argv)
89         throws Throwable JavaDoc
90     {
91         oc_rec2 test = new oc_rec2();
92
93         ij.getPropertyArg(argv);
94         Connection JavaDoc conn = ij.startJBMS();
95         conn.setAutoCommit(false);
96
97         try
98         {
99             test.testList(conn);
100         }
101         catch (SQLException JavaDoc sqle)
102         {
103             org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
104                 System.out, sqle);
105             sqle.printStackTrace(System.out);
106         }
107     }
108 }
109
Popular Tags