001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Library License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: Test.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009: package org.ozoneDB.DxLib.test;
010:
011: import java.lang.*;
012: import java.util.*;
013: import org.ozoneDB.DxLib.*;
014:
015: /**
016: */
017: class Test extends Object {
018:
019: final static int SIZE = 2000;
020:
021: /**
022: */
023: public static void main(String[] args) throws Exception {
024: // collTests();
025: // setTests();
026: mapTests();
027: }
028:
029: /**
030: */
031: public static void collTests() throws Exception {
032: Class[] factories = { DxListBag.class, DxArrayBag.class,
033: DxHashSet.class, DxTreeSet.class, DxHashMap.class,
034: DxTreeMap.class };
035:
036: CollectionTest collTest = new CollectionTest();
037: System.out.println("\n*** CollectionTest ***\n");
038:
039: // add_iterate
040: for (int i = 0; i < factories.length; i++) {
041: collTest.add_iterate((DxCollection) factories[i]
042: .newInstance(), CollectionTest.newDxStrings());
043: }
044: collTest.add_iterate(new DxTreeSet(new DxStringComparator()),
045: CollectionTest.newStrings());
046: collTest.add_iterate(new DxTreeMap(new DxStringComparator()),
047: CollectionTest.newStrings());
048:
049: // contains
050: for (int i = 0; i < factories.length; i++) {
051: collTest.contains(
052: (DxCollection) factories[i].newInstance(),
053: CollectionTest.newDxStrings());
054: }
055: collTest.contains(new DxTreeSet(new DxStringComparator()),
056: CollectionTest.newStrings());
057: collTest.contains(new DxTreeMap(new DxStringComparator()),
058: CollectionTest.newStrings());
059:
060: // containsAll
061: for (int i = 0; i < factories.length; i++) {
062: collTest.containsAll((DxCollection) factories[i]
063: .newInstance(), CollectionTest.newDxStrings());
064: }
065:
066: // remove_count_isEmpty
067: for (int i = 0; i < factories.length; i++) {
068: collTest.remove_count_isEmpty((DxCollection) factories[i]
069: .newInstance(), CollectionTest.newDxStrings());
070: }
071:
072: // removeAll
073: for (int i = 0; i < factories.length; i++) {
074: collTest.removeAll((DxCollection) factories[i]
075: .newInstance(), CollectionTest.newDxStrings());
076: }
077:
078: // equals
079: for (int i = 0; i < factories.length; i++) {
080: collTest.equals((DxCollection) factories[i].newInstance(),
081: (DxCollection) factories[i].newInstance(),
082: CollectionTest.newDxStrings());
083: }
084:
085: // toArray_clone_clear
086: for (int i = 0; i < factories.length; i++) {
087: collTest.toArray_clone_clear((DxCollection) factories[i]
088: .newInstance(), CollectionTest.newDxStrings());
089: }
090: }
091:
092: /**
093: */
094: public static void setTests() throws Exception {
095: Class[] setFactories = { DxHashSet.class, DxTreeSet.class };
096: SetTest setTest = new SetTest();
097: System.out.println("\n*** SetTest ***\n");
098:
099: // retainsAll
100: for (int i = 0; i < setFactories.length; i++) {
101: setTest.retainsAll((DxSet) setFactories[i].newInstance(),
102: CollectionTest.newDxStrings());
103: }
104: }
105:
106: /**
107: */
108: public static void mapTests() throws Exception {
109: Class[] factories = { DxHashMap.class, DxTreeMap.class,
110: DxMultiMap.class };
111:
112: MapTest test = new MapTest();
113: System.out.println("\n*** MapTest ***\n");
114:
115: //
116: for (int i = 0; i < factories.length; i++) {
117: test.containsKey((DxMap) factories[i].newInstance(),
118: CollectionTest.newDxStrings());
119: }
120: DxDiskHashMap map = new DxDiskHashMap("/tmp/test/page", 30, 10,
121: 8);
122: test.containsKey(map, CollectionTest.newIntegers());
123: map.printStatistics();
124: }
125:
126: }
|