Search in sources :

Example 16 with Hashtable

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);
}
Also used : Hashtable(java.util.Hashtable)

Example 17 with Hashtable

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);
}
Also used : Hashtable(java.util.Hashtable)

Example 18 with 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();
}
Also used : Hashtable(java.util.Hashtable)

Example 19 with Hashtable

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
    }
}
Also used : Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable)

Example 20 with Hashtable

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
    }
}
Also used : Hashtable(java.util.Hashtable)

Aggregations

Hashtable (java.util.Hashtable)1752 Test (org.junit.Test)374 ArrayList (java.util.ArrayList)355 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)219 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)142 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)137 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)136 HashMap (java.util.HashMap)104 IOException (java.io.IOException)91 Dictionary (java.util.Dictionary)91 Vector (java.util.Vector)88 File (java.io.File)86 Map (java.util.Map)84 Bundle (org.osgi.framework.Bundle)84 BundleContext (org.osgi.framework.BundleContext)78 Configuration (org.osgi.service.cm.Configuration)75 Enumeration (java.util.Enumeration)70 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)70 State (org.eclipse.osgi.service.resolver.State)70 ServiceRegistration (org.osgi.framework.ServiceRegistration)65