summaryrefslogtreecommitdiffstats
path: root/pki/base/common/test/com/netscape/cmscore/request/ExtDataHashtableTest.java
blob: 177ccbbc3806f1b8d629378d0d29478b9efa3766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.netscape.cmscore.request;

import com.netscape.cmscore.test.CMSBaseTestCase;
import com.netscape.cmscore.dbs.RequestRecordDefaultStub;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.request.IRequestRecord;
import com.netscape.certsrv.request.RequestId;
import junit.framework.Test;
import junit.framework.TestSuite;

import java.util.*;

import netscape.ldap.LDAPAttributeSet;
import netscape.ldap.LDAPAttribute;

public class ExtDataHashtableTest extends CMSBaseTestCase {

    ExtDataHashtable hash;

    public ExtDataHashtableTest(String name) {
        super(name);
    }

    public void cmsTestSetUp() {
        hash = new ExtDataHashtable();
    }

    public void cmsTestTearDown() {
    }

    public static Test suite() {
        return new TestSuite(ExtDataHashtableTest.class);
    }

    public void testContainsKey() {
        hash.put("FOO", "bar");
        assertTrue(hash.containsKey("foo"));
        assertTrue(hash.containsKey("Foo"));
    }

    public void testGet() {
        hash.put("FOO", "bar");
        assertEquals("bar", hash.get("foo"));
        assertEquals("bar", hash.get("fOO"));
    }

    public void testPut() {
        hash.put("FOO", "bar");
        hash.put("foo", "bar2");
        assertEquals(1, hash.keySet().size());
        assertEquals("bar2", hash.get("foo"));
    }

    public void testPutAll() {
        Hashtable hash2 = new Hashtable();
        hash2.put("KEY1", "VAL1");
        hash2.put("KEY2", "val2");

        hash.putAll(hash2);

        assertTrue(hash.containsKey("key1"));
        assertEquals("VAL1", hash.get("key1"));
        assertEquals("val2", hash.get("Key2"));
    }

    public void testRemove() {
        hash.put("foo", "bar");
        hash.put("one", "two");

        hash.remove("FOO");
        assertFalse(hash.containsKey("foo"));
        assertTrue(hash.containsKey("one"));
    }

    public void testMapConstructor() {
        Hashtable hash2 = new Hashtable();
        hash2.put("KEY1", "VAL1");
        hash2.put("KEY2", "val2");

        hash = new ExtDataHashtable(hash2);

        assertTrue(hash.containsKey("key1"));
        assertEquals("VAL1", hash.get("key1"));
        assertEquals("val2", hash.get("Key2"));
    }

}