01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.db4ounit.common.regression;
22:
23: import java.io.IOException;
24:
25: import com.db4o.Db4o;
26: import com.db4o.db4ounit.util.IOServices;
27: import com.db4o.db4ounit.util.WorkspaceServices;
28: import com.db4o.ext.OldFormatException;
29: import com.db4o.foundation.io.File4;
30: import com.db4o.internal.Platform4;
31:
32: import db4ounit.Assert;
33: import db4ounit.CodeBlock;
34: import db4ounit.TestCase;
35: import db4ounit.extensions.fixtures.OptOutNoFileSystemData;
36:
37: /**
38: * @exclude
39: */
40: public class COR234TestCase implements TestCase, OptOutNoFileSystemData {
41:
42: public void test() {
43: if (WorkspaceServices.workspaceRoot() == null) {
44: System.err
45: .println("Build environment not available. Skipping test case...");
46: return;
47: }
48: if (!File4.exists(sourceFile())) {
49: System.err.println("Test source file " + sourceFile()
50: + " not available. Skipping test case...");
51: return;
52: }
53:
54: Db4o.configure().allowVersionUpdates(false);
55: Db4o.configure().reflectWith(
56: Platform4.reflectorForType(COR234TestCase.class));
57:
58: Assert.expect(OldFormatException.class, new CodeBlock() {
59: public void run() throws Throwable {
60: Db4o.openFile(oldDatabaseFilePath());
61: }
62: });
63: }
64:
65: protected String oldDatabaseFilePath() throws IOException {
66: final String oldFile = IOServices.buildTempPath("old_db.yap");
67: File4.copy(sourceFile(), oldFile);
68: return oldFile;
69: }
70:
71: private String sourceFile() {
72: return WorkspaceServices
73: .workspaceTestFilePath("db4oVersions/db4o_3.0.3");
74: }
75: }
|