use of java.util.Hashtable in project j2objc by google.
the class HashtableTest method test_toString.
/**
* java.util.Hashtable#toString()
*/
public void test_toString() {
// Test for method java.lang.String java.util.Hashtable.toString()
Hashtable h = new Hashtable();
assertEquals("Incorrect toString for Empty table", "{}", h.toString());
h.put("one", "1");
h.put("two", h);
h.put(h, "3");
h.put(h, h);
String result = h.toString();
assertTrue("should contain self ref", result.indexOf("(this") > -1);
}
use of java.util.Hashtable in project j2objc by google.
the class HashtableTest method test_HashTable_Constructor.
public void test_HashTable_Constructor() {
Hashtable hashTable = new Hashtable();
hashTable.put(hashTable, hashTable.keySet());
new Hashtable(hashTable);
}
use of java.util.Hashtable in project j2objc by google.
the class HashtableTest method test_size.
/**
* java.util.Hashtable#size()
*/
public void test_size() {
// Test for method int java.util.Hashtable.size()
assertTrue("Returned invalid size", ht10.size() == 10 && (ht100.size() == 0));
final Hashtable ht = new Hashtable();
ht.put("0", "");
Thread t1 = new Thread() {
public void run() {
while (ht.size() > 0) ;
ht.put("final", "");
}
};
t1.start();
for (int i = 1; i < 10000; i++) {
synchronized (ht) {
ht.remove(String.valueOf(i - 1));
ht.put(String.valueOf(i), "");
}
int size;
if ((size = ht.size()) != 1) {
String result = "Size is not 1: " + size + " " + ht;
// terminate the thread
ht.clear();
fail(result);
}
}
// terminate the thread
ht.clear();
}
use of java.util.Hashtable in project j2objc by google.
the class HashtableTest method test_putAllLjava_util_Map.
/**
* java.util.Hashtable#putAll(java.util.Map)
*/
public void test_putAllLjava_util_Map() {
// Test for method void java.util.Hashtable.putAll(java.util.Map)
Hashtable h = new Hashtable();
h.putAll(ht10);
Enumeration e = keyVector.elements();
while (e.hasMoreElements()) {
Object x = e.nextElement();
assertTrue("Failed to put all elements", h.get(x).equals(ht10.get(x)));
}
try {
h.putAll(null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
}
use of java.util.Hashtable in project j2objc by google.
the class HashtableTest method test_removeLjava_lang_Object.
/**
* java.util.Hashtable#remove(java.lang.Object)
*/
public void test_removeLjava_lang_Object() {
// Test for method java.lang.Object
// java.util.Hashtable.remove(java.lang.Object)
Hashtable h = hashtableClone(htfull);
Object k = h.remove("FKey 0");
assertTrue("Remove failed", !h.containsKey("FKey 0") || k == null);
assertNull(h.remove("FKey 0"));
try {
h.remove(null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}
Aggregations