private static final String CAT_COL_FLAGS = "Flags";
/** System catalog column name of the properties column */
private static final String CAT_COL_PROPS = "LvProp";
-
+
+ /** Error message prefix for unsupported file format. */
+ static final String MSG_PREFIX_CREATE_UNSUPPORTED_FILE_FORMAT = "Unsupported file format: ";
+ /** Error message prefix for unsupported file format. */
+ static final String MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT = "Unsupported Jet format: ";
+
public static enum FileFormat {
V1997(null, JetFormat.VERSION_3), // v97 is not supported, so no empty template is provided
boolean autoSync)
throws IOException
{
+ if (JetFormat.VERSION_3.equals(fileFormat.getJetFormat())) {
+ throw new IllegalArgumentException(MSG_PREFIX_CREATE_UNSUPPORTED_FILE_FORMAT + fileFormat);
+ }
+
FileChannel channel = openChannel(mdbFile, false);
channel.truncate(0);
channel.transferFrom(Channels.newChannel(
throws IOException
{
_format = JetFormat.getFormat(channel);
+ if (JetFormat.VERSION_3.equals(_format)) {
+ channel.close();
+ throw new IllegalArgumentException(MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT + _format);
+ }
_fileFormat = fileFormat;
_pageChannel = new PageChannel(channel, _format, autoSync);
// note, it's slighly sketchy to pass ourselves along partially
}
+ public void testUnsupportedCreate() throws Exception {
+ try {
+ create(JetFormatTest.UNSUPPORTED_TEST_V1997.getExpectedFileFormat());
+ fail("Create unsupported JetFormat should fail.");
+ } catch (IllegalArgumentException e) {
+ assertEquals(Database.MSG_PREFIX_CREATE_UNSUPPORTED_FILE_FORMAT + FileFormat.V1997, e.getMessage());
+ }
+ }
+
+ public void testUnsupportedOpen() throws Exception {
+ try {
+ open(JetFormatTest.UNSUPPORTED_TEST_V1997);
+ fail("Open unsupported JetFormat should fail.");
+ } catch (IllegalArgumentException e) {
+ assertEquals(
+ MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT + UNSUPPORTED_TEST_V1997.getExpectedFormat(),
+ e.getMessage());
+ }
+ }
+
+
public void testInvalidTableDefs() throws Exception {
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
String lval = createString(255); // "--255 chars long text--";
- if (FileFormat.V2007.equals(testDB.getExpectedFileFormat())) {
- // @todo Field order differs with V2007
- System.err.println("\n*** TODO: " + getName()
- + "(): Is OK that " + testDB.getExpectedFileFormat().name() + " field order differs? ***");
- }
-
for(int i = 0; i < 1000; ++i) {
if (FileFormat.V2007.equals(testDB.getExpectedFileFormat())) {
- // @todo Field order differs with V2007
+ // Field order differs with V2007
t.addRow(i, 13, 57, lval, lval, lval, lval, lval, lval, 47.0d);
} else {
t.addRow(i, 13, 57, 47.0d, lval, lval, lval, lval, lval, lval);
&& !FileFormat.V2007.equals(fileFormat)) {
assertNotNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects"));
} else {
- // @todo Does is matter that v2003, v2007 template files have no "MSysAccessObjects" table?
- System.err.println("\n*** TODO: " + getName()
- + "(): Is OK that " + fileFormat.name() + " template file has no \"MSysAccessObjects\" table? ***");
+ // v2003, v2007 template files have no "MSysAccessObjects" table
assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects"));
}
import java.io.File;
import java.io.IOException;
+import static com.healthmarketscience.jackcess.Database.MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT;
import static com.healthmarketscience.jackcess.JetFormatTest.*;
/**
try {
Database.open(UNSUPPORTED_TEST_V1997.getFile());
fail("mdb v97 usage map unsupported");
- } catch (IOException e) {
- assertEquals(UsageMap.MSG_PREFIX_UNRECOGNIZED_MAP + 2, e.getMessage());
+ } catch (IllegalArgumentException e) {
+ assertEquals(
+ MSG_PREFIX_OPEN_UNSUPPORTED_JET_FORMAT + UNSUPPORTED_TEST_V1997.getExpectedFormat(),
+ e.getMessage());
}
for (final TestDB testDB : SUPPORTED_DBS_TEST) {