aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/java/com/healthmarketscience/jackcess
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-07-20 03:47:49 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-07-20 03:47:49 +0000
commit7afa998954f52053f68d7bee96b674e43153e6af (patch)
tree31fc6f5cbefa5fec659d02d9d72f0a8970fc1c24 /test/src/java/com/healthmarketscience/jackcess
parent16d611821a3b6cba866ab596cd5a53b3533e68f8 (diff)
downloadjackcess-7afa998954f52053f68d7bee96b674e43153e6af.tar.gz
jackcess-7afa998954f52053f68d7bee96b674e43153e6af.zip
Share out-of-line long value pages in order to generate more compact database files
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@362 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test/src/java/com/healthmarketscience/jackcess')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java70
1 files changed, 59 insertions, 11 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 6102c6c..19078ee 100644
--- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -46,6 +46,7 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -121,6 +122,16 @@ public class DatabaseTest extends TestCase {
// success
}
+ try {
+ new TableBuilder("test")
+ .addColumn(new ColumnBuilder("A_" + createString(70), DataType.TEXT)
+ .toColumn())
+ .toTable(db);
+ fail("created table with too long column name?");
+ } catch(IllegalArgumentException e) {
+ // success
+ }
+
new TableBuilder("test")
.addColumn(new ColumnBuilder("A", DataType.TEXT).toColumn())
.toTable(db);
@@ -352,12 +363,7 @@ public class DatabaseTest extends TestCase {
.toTable(db);
String testStr = "This is a test";
- StringBuilder strBuf = new StringBuilder();
- for(int i = 0; i < 2030; ++i) {
- char c = (char)('a' + (i % 26));
- strBuf.append(c);
- }
- String longMemo = strBuf.toString();
+ String longMemo = createString(2030);
byte[] oleValue = toByteArray(new File("test/data/test2BinData.dat"));
@@ -383,7 +389,7 @@ public class DatabaseTest extends TestCase {
public void testManyMemos() throws Exception {
final int numColumns = 126;
Database db = create();
- TableBuilder bigTableBuilder = new TableBuilder("myBigTable");
+ TableBuilder bigTableBuilder = new TableBuilder("test");
for (int i = 0; i < numColumns; i++)
{
@@ -394,15 +400,58 @@ public class DatabaseTest extends TestCase {
Table bigTable = bigTableBuilder.toTable(db);
- for (int j = 999; j < 1010; j++)
+ List<Object[]> expectedRows = new ArrayList<Object[]>();
+
+ for (int j = 0; j < 3; j++)
+ {
+ Object[] rowData = new String[numColumns];
+ for (int i = 0; i < numColumns; i++)
+ {
+ rowData[i] = "v_" + i + ";" + (j + 999);
+ }
+ expectedRows.add(rowData);
+ bigTable.addRow(rowData);
+ }
+
+ String extra1 = createString(100);
+ String extra2 = createString(2050);
+
+ for (int j = 0; j < 1; j++)
{
Object[] rowData = new String[numColumns];
for (int i = 0; i < numColumns; i++)
{
- rowData[i] = "v_" + i + ";" + j;
+ rowData[i] = "v_" + i + ";" + (j + 999) + extra2;
}
+ expectedRows.add(rowData);
bigTable.addRow(rowData);
}
+
+ for (int j = 0; j < 2; j++)
+ {
+ Object[] rowData = new String[numColumns];
+ for (int i = 0; i < numColumns; i++)
+ {
+ String tmp = "v_" + i + ";" + (j + 999);
+ if((i % 3) == 0) {
+ tmp += extra1;
+ } else if((i % 7) == 0) {
+ tmp += extra2;
+ }
+ rowData[i] = tmp;
+ }
+ expectedRows.add(rowData);
+ bigTable.addRow(rowData);
+ }
+
+ bigTable.reset();
+ Iterator<Object[]> expIter = expectedRows.iterator();
+ for(Map<?,?> row : bigTable) {
+ Object[] expectedRow = expIter.next();
+ assertEquals(Arrays.asList(expectedRow),
+ new ArrayList<Object>(row.values()));
+ }
+
db.close();
}
@@ -876,8 +925,7 @@ public class DatabaseTest extends TestCase {
for(int i = 0; i < len; ++i) {
builder.append((char)('a' + (i % 26)));
}
- String str = builder.toString();
- return str;
+ return builder.toString();
}
static void assertRowCount(int expectedRowCount, Table table)