KickJava   Java API By Example, From Geeks To Geeks.

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


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