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.jre12.defragment;
22:
23: import java.io.*;
24:
25: import com.db4o.db4ounit.common.defragment.*;
26: import com.db4o.defragment.*;
27: import com.db4o.foundation.*;
28: import com.db4o.test.util.*;
29:
30: import db4ounit.*;
31:
32: /**
33: * This one tests common, non-jdk1.2 specific functionality, but requires an
34: * ExcludingClassLoader which doesn't work on JDK < 1.2.
35: */
36: public class DefragmentSkipClassTestCase implements TestLifeCycle {
37:
38: public void testSkipsClass() throws Exception {
39: DefragmentConfig defragConfig = SlotDefragmentFixture
40: .defragConfig(true);
41: Defragment.defrag(defragConfig);
42: SlotDefragmentFixture.assertDataClassKnown(true);
43:
44: defragConfig = SlotDefragmentFixture.defragConfig(true);
45: defragConfig.storedClassFilter(new AvailableClassFilter(
46: SlotDefragmentFixture.Data.class.getClassLoader()));
47: Defragment.defrag(defragConfig);
48: SlotDefragmentFixture.assertDataClassKnown(true);
49:
50: defragConfig = SlotDefragmentFixture.defragConfig(true);
51: Collection4 excluded = new Collection4();
52: excluded.add(SlotDefragmentFixture.Data.class.getName());
53: ExcludingClassLoader loader = new ExcludingClassLoader(
54: SlotDefragmentFixture.Data.class.getClassLoader(),
55: excluded);
56: defragConfig
57: .storedClassFilter(new AvailableClassFilter(loader));
58: Defragment.defrag(defragConfig);
59: SlotDefragmentFixture.assertDataClassKnown(false);
60: }
61:
62: public void setUp() throws Exception {
63: new File(SlotDefragmentTestConstants.FILENAME).delete();
64: new File(SlotDefragmentTestConstants.BACKUPFILENAME).delete();
65: SlotDefragmentFixture
66: .createFile(SlotDefragmentTestConstants.FILENAME);
67: }
68:
69: public void tearDown() throws Exception {
70: }
71: }
|