KickJava   Java API By Example, From Geeks To Geeks.

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


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  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
17  * @version $Revision$Date$
18  */

19 public class MapTest extends AbstractTest {
20
21
22     public MapTest() {
23         super("testContainsKey");
24     }
25
26     public MapTest(String JavaDoc name) {
27         super(name);
28     }
29
30     public void testContainsKey() throws Exception JavaDoc {
31         Class JavaDoc[] factories = {DxHashMap.class, DxTreeMap.class, DxMultiMap.class};
32
33         //
34
for (int i = 0; i < factories.length; i++) {
35             containsKey((DxMap) factories[i].newInstance(), CollectionTest.newDxStrings());
36         }
37         String JavaDoc mapDir = System.getProperty("java.io.tmpdir")+ "/test/page/";
38         DxDiskHashMap map = new DxDiskHashMap(mapDir, 30, 10, 8);
39         containsKey(map, CollectionTest.newIntegers());
40         map.printStatistics();
41     }
42     /**
43      */

44     public void containsKey(DxMap map, Object JavaDoc[] objs) throws Exception JavaDoc {
45         startTimer(map.getClass().getName(), "containsKey");
46         map.addAll(objs);
47         stopTimer();
48         //startTimer (map.getClass().getName(), "containsKey");
49

50         for (int i = 0; i < objs.length; i++) {
51             if (!map.containsKey(objs[i])) {
52                 error();
53             }
54             if (!map.containsKey(objs[i])) {
55                 error();
56             }
57         }
58         if (map.containsKey(new DxString("hallo"))) {
59             error();
60         }
61         stopTimer();
62     }
63
64 }
65
Popular Tags