blob: aad1ddf668c9cef42fda1e668de78d0b7e5fe345 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package com.healthmarketscience.jackcess.impl;
import java.io.File;
import java.io.IOException;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import static com.healthmarketscience.jackcess.impl.JetFormatTest.*;
import junit.framework.TestCase;
/**
* @author Dan Rollo
* Date: Mar 5, 2010
* Time: 2:21:22 PM
*/
public final class UsageMapTest extends TestCase {
public void testRead() throws Exception {
for (final TestDB testDB : SUPPORTED_DBS_TEST) {
final int expectedFirstPage;
final int expectedLastPage;
final Database.FileFormat expectedFileFormat = testDB.getExpectedFileFormat();
if (Database.FileFormat.V2000.equals(expectedFileFormat)) {
expectedFirstPage = 743;
expectedLastPage = 767;
} else if (Database.FileFormat.V2003.equals(expectedFileFormat)) {
expectedFirstPage = 16;
expectedLastPage = 799;
} else if (Database.FileFormat.V2007.equals(expectedFileFormat)) {
expectedFirstPage = 94;
expectedLastPage = 511;
} else if (Database.FileFormat.V2010.equals(expectedFileFormat)) {
expectedFirstPage = 109;
expectedLastPage = 511;
} else {
throw new IllegalAccessException("Unknown file format: " + expectedFileFormat);
}
checkUsageMapRead(testDB.getFile(), expectedFirstPage, expectedLastPage);
}
}
private static void checkUsageMapRead(final File dbFile,
final int expectedFirstPage, final int expectedLastPage)
throws IOException {
final Database db = DatabaseBuilder.open(dbFile);
final UsageMap usageMap = UsageMap.read((DatabaseImpl)db,
PageChannel.PAGE_GLOBAL_USAGE_MAP,
PageChannel.ROW_GLOBAL_USAGE_MAP,
true);
assertEquals("Unexpected FirstPageNumber.", expectedFirstPage, usageMap.getFirstPageNumber());
assertEquals("Unexpected LastPageNumber.", expectedLastPage, usageMap.getLastPageNumber());
}
}
|