### Question:
JNDIUtil { public static Hashtable<String, String> arrayToHashtable(String[] entries, ConnectorMessages messages) { Hashtable<String, String> result = new Hashtable<String, String>(); if (entries != null) { for (String entry : entries) { if (StringUtil.isNotBlank(entry)) { int firstEq = entry.indexOf('='); if (firstEq == -1) { throwFormatException(messages, entry, "Invalid value in JNDI entry"); } if (firstEq == 0) { throwFormatException(messages, entry, "First character cannot be ="); } final String key = entry.substring(0, firstEq); final String value = firstEq == entry.length() - 1 ? null : entry.substring(firstEq + 1); result.put(key, value); } } } return result; } private  JNDIUtil(); static Hashtable<String, String> arrayToHashtable(String[] entries,
            ConnectorMessages messages); static final String INVALID_JNDI_ENTRY; }### Answer:
@Test public void testArrayToHashtableSuc() { String[] entries1 = { "a=A", "b=B" }; Map<String, String> res1 = new HashMap<String, String>(); res1.put("a", "A"); res1.put("b", "B"); AssertJUnit.assertEquals(res1, JNDIUtil.arrayToHashtable(entries1, null)); }
@Test public void testArrayToHashtableFail() { try { String[] entries2 = { "a=A", "b=" }; JNDIUtil.arrayToHashtable(entries2, null); Assert.fail(); } catch (RuntimeException e) { } try { String[] entries2 = { "a=A", "=" }; JNDIUtil.arrayToHashtable(entries2, null); Assert.fail(); } catch (RuntimeException e) { } try { String[] entries2 = { "a=A", "=B" }; JNDIUtil.arrayToHashtable(entries2, null); Assert.fail(); } catch (RuntimeException e) { } }
@Test public void testArrayToHashtableNull() { JNDIUtil.arrayToHashtable(null, null); String[] entries2 = {}; JNDIUtil.arrayToHashtable(entries2, null); String[] entries3 = { null, null }; JNDIUtil.arrayToHashtable(entries3, null); String[] entries4 = { "", " " }; JNDIUtil.arrayToHashtable(entries4, null); }