KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ozoneDB > DxLib > Test


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id$
8

9 package test.ozoneDB.DxLib;
10
11 import org.ozoneDB.DxLib.*;
12
13
14 /**
15  */

16 class Test extends Object JavaDoc {
17
18     /**
19      */

20     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
21         // collTests();
22
// setTests();
23
mapTests();
24     }
25
26
27     /**
28      */

29     public static void collTests() throws Exception JavaDoc {
30         Class JavaDoc[] factories =
31                 {DxListBag.class, DxArrayBag.class, DxHashSet.class, DxTreeSet.class, DxHashMap.class, DxTreeMap.class};
32
33         CollectionTest collTest = new CollectionTest();
34         System.out.println("\n*** CollectionTest ***\n");
35
36         // add_iterate
37
for (int i = 0; i < factories.length; i++) {
38             collTest.add_iterate((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
39         }
40         collTest.add_iterate(new DxTreeSet(new DxStringComparator()), CollectionTest.newStrings());
41         collTest.add_iterate(new DxTreeMap(new DxStringComparator()), CollectionTest.newStrings());
42
43         // contains
44
for (int i = 0; i < factories.length; i++) {
45             collTest.contains((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
46         }
47         collTest.contains(new DxTreeSet(new DxStringComparator()), CollectionTest.newStrings());
48         collTest.contains(new DxTreeMap(new DxStringComparator()), CollectionTest.newStrings());
49
50         // containsAll
51
for (int i = 0; i < factories.length; i++) {
52             collTest.containsAll((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
53         }
54
55         // remove_count_isEmpty
56
for (int i = 0; i < factories.length; i++) {
57             collTest.remove_count_isEmpty((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
58         }
59
60         // removeAll
61
for (int i = 0; i < factories.length; i++) {
62             collTest.removeAll((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
63         }
64
65         // equals
66
for (int i = 0; i < factories.length; i++) {
67             collTest.equals((DxCollection) factories[i].newInstance(), (DxCollection) factories[i].newInstance(),
68                     CollectionTest.newDxStrings());
69         }
70
71         // toArray_clone_clear
72
for (int i = 0; i < factories.length; i++) {
73             collTest.toArray_clone_clear((DxCollection) factories[i].newInstance(), CollectionTest.newDxStrings());
74         }
75     }
76
77
78     /**
79      */

80     public static void setTests() throws Exception JavaDoc {
81         Class JavaDoc[] setFactories = {DxHashSet.class, DxTreeSet.class};
82         SetTest setTest = new SetTest();
83         System.out.println("\n*** SetTest ***\n");
84
85         // retainsAll
86
for (int i = 0; i < setFactories.length; i++) {
87             setTest.retainsAll((DxSet) setFactories[i].newInstance(), CollectionTest.newDxStrings());
88         }
89     }
90
91
92     /**
93      */

94     public static void mapTests() throws Exception JavaDoc {
95         Class JavaDoc[] factories = {DxHashMap.class, DxTreeMap.class, DxMultiMap.class};
96
97         MapTest test = new MapTest();
98         System.out.println("\n*** MapTest ***\n");
99
100         //
101
for (int i = 0; i < factories.length; i++) {
102             test.containsKey((DxMap) factories[i].newInstance(), CollectionTest.newDxStrings());
103         }
104         DxDiskHashMap map = new DxDiskHashMap("/tmp/test/page", 30, 10, 8);
105         test.containsKey(map, CollectionTest.newIntegers());
106         map.printStatistics();
107     }
108
109 }
110
Popular Tags