KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > test > db > TestSpaceReuse


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.test.db;
6
7 import java.io.*;
8 import java.sql.*;
9
10 import org.h2.test.TestBase;
11
12 public class TestSpaceReuse extends TestBase {
13
14     public void test() throws Exception JavaDoc {
15         if(config.memory) {
16             return;
17         }
18         deleteDb("spaceReuse");
19         long first = 0, now = 0;
20         for (int i = 0; i < 10; i++) {
21             Connection conn = getConnection("spaceReuse");
22             Statement stat = conn.createStatement();
23             stat.execute("create table if not exists t(i int)");
24             stat.execute("insert into t select x from system_range(1, 500)");
25             conn.close();
26             conn = getConnection("spaceReuse");
27             conn.createStatement().execute("delete from t");
28             conn.close();
29             now = new File(BASE_DIR + "/spaceReuse.data.db").length();
30             if(first == 0) {
31                 first = now;
32             }
33         }
34         if(now > first) {
35             this.error("first: " + first + " now: " + now);
36         }
37     }
38
39 }
40
Popular Tags