public void TestReplace2() { ConcurrentHashMap <Object, Object> map = map5(); Assert.IsNotNull(map.Replace(one, "Z")); Assert.AreEqual("Z", map.Get(one)); }
public void TestPutIfAbsent() { ConcurrentHashMap <Object, Object> map = map5(); map.PutIfAbsent(six, "Z"); Assert.IsTrue(map.ContainsKey(six)); }
public void TestReplace() { ConcurrentHashMap <Object, Object> map = map5(); Assert.IsNull(map.Replace(six, "Z")); Assert.IsFalse(map.ContainsKey(six)); }
public void TestClear() { ConcurrentHashMap <Object, Object> map = map5(); map.Clear(); Assert.AreEqual(map.Size(), 0); }
public void TestContainsValue() { ConcurrentHashMap <Object, Object> map = map5(); Assert.IsTrue(map.ContainsValue("A")); Assert.IsFalse(map.ContainsValue("Z")); }
public void TestContainsKey() { ConcurrentHashMap <Object, Object> map = map5(); Assert.IsTrue(map.ContainsKey(one)); Assert.IsFalse(map.ContainsKey(zero)); }
public void TestRemove() { ConcurrentHashMap <Object, Object> map = map5(); map.Remove(five); Assert.AreEqual(4, map.Size()); Assert.IsFalse(map.ContainsKey(five)); }
public void TestReplaceValue2() { ConcurrentHashMap <Object, Object> map = map5(); Assert.AreEqual("A", map.Get(one)); Assert.IsTrue(map.Replace(one, "A", "Z")); Assert.AreEqual("Z", map.Get(one)); }
public void TestIsEmpty() { ConcurrentHashMap <Object, Object> empty = new ConcurrentHashMap <Object, Object>(); ConcurrentHashMap <Object, Object> map = map5(); Assert.IsTrue(empty.IsEmpty()); Assert.IsFalse(map.IsEmpty()); }
public HashIterator(ConcurrentHashMap <K, V> parent) { this.parent = parent; this.nextSegmentIndex = parent.segments.Length - 1; this.nextTableIndex = -1; Advance(); }
public void TestSize() { ConcurrentHashMap <Object, Object> map = map5(); ConcurrentHashMap <Object, Object> empty = new ConcurrentHashMap <Object, Object>(); Assert.AreEqual(0, empty.Size()); Assert.AreEqual(5, map.Size()); }
public void TestToString() { ConcurrentHashMap <Object, Object> map = map5(); String s = map.ToString(); for (int i = 1; i <= 5; ++i) { Assert.IsTrue(s.IndexOf(i.ToString()) >= 0); } }
public void TestGet() { ConcurrentHashMap <Object, Object> map = map5(); Assert.AreEqual("A", (String)map.Get(one)); ConcurrentHashMap <Object, Object> empty = new ConcurrentHashMap <Object, Object>(); Assert.IsNull(map.Get("anything")); Assert.IsNull(empty.Get("anything")); }
public void TestEquals() { ConcurrentHashMap <Object, Object> map1 = map5(); ConcurrentHashMap <Object, Object> map2 = map5(); Assert.AreEqual(map1, map2); Assert.AreEqual(map2, map1); map1.Clear(); Assert.IsFalse(map1.Equals(map2)); Assert.IsFalse(map2.Equals(map1)); }
public void TestKeySetToArray() { ConcurrentHashMap <Object, Object> map = map5(); Set <Object> s = map.KeySet(); Object[] ar = s.ToArray(); Assert.IsTrue(s.ContainsAll(Arrays.AsList(ar))); Assert.AreEqual(5, ar.Length); ar[0] = m10; Assert.IsFalse(s.ContainsAll(Arrays.AsList(ar))); }
public void TestGetNullReferenceException() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.Get(null); ShouldThrow(); } catch (NullReferenceException) { } }
public void TestPutIfAbsent2_NullReferenceException() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.PutIfAbsent("whatever", null); ShouldThrow(); } catch (NullReferenceException) { } }
public void TestValues() { ConcurrentHashMap <Object, Object> map = map5(); Collection <Object> s = map.Values(); Assert.AreEqual(5, s.Size()); Assert.IsTrue(s.Contains("A")); Assert.IsTrue(s.Contains("B")); Assert.IsTrue(s.Contains("C")); Assert.IsTrue(s.Contains("D")); Assert.IsTrue(s.Contains("E")); }
public void TestContainsValue_NullReferenceException() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.ContainsValue(null); ShouldThrow(); } catch (NullReferenceException) { } }
public void TestReplaceValue3_NullReferenceException() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.Replace("whatever", one, null); ShouldThrow(); } catch (NullReferenceException) { } }
public void TestKeySet() { ConcurrentHashMap <Object, Object> map = map5(); Set <Object> s = map.KeySet(); Assert.AreEqual(5, s.Size()); Assert.IsTrue(s.Contains(one)); Assert.IsTrue(s.Contains(two)); Assert.IsTrue(s.Contains(three)); Assert.IsTrue(s.Contains(four)); Assert.IsTrue(s.Contains(five)); }
public void TestPutAll() { ConcurrentHashMap <Object, Object> empty = new ConcurrentHashMap <Object, Object>(); ConcurrentHashMap <Object, Object> map = map5(); empty.PutAll(map); Assert.AreEqual(5, empty.Size()); Assert.IsTrue(empty.ContainsKey(one)); Assert.IsTrue(empty.ContainsKey(two)); Assert.IsTrue(empty.ContainsKey(three)); Assert.IsTrue(empty.ContainsKey(four)); Assert.IsTrue(empty.ContainsKey(five)); }
public void TestEntrySetToArray() { ConcurrentHashMap <Object, Object> map = map5(); Set <Entry <Object, Object> > s = map.EntrySet(); Object[] ar = s.ToArray(); Assert.AreEqual(5, ar.Length); for (int i = 0; i < 5; ++i) { Assert.IsTrue(map.ContainsKey(((Entry <Object, Object>)(ar[i])).Key)); Assert.IsTrue(map.ContainsValue(((Entry <Object, Object>)(ar[i])).Value)); } }
public void TestRemove3() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.Put("sadsdf", "asdads"); Assert.IsFalse(c.Remove("sadsdf", null)); } catch (NullReferenceException) { Assert.Fail(); } }
public void TestRemove2_NullReferenceException() { try { ConcurrentHashMap <Object, Object> c = new ConcurrentHashMap <Object, Object>(5); c.Put("sadsdf", "asdads"); c.Remove(null, "whatever"); ShouldThrow(); } catch (NullReferenceException) { } }
private static ConcurrentHashMap <Object, Object> map5() { ConcurrentHashMap <Object, Object> map = new ConcurrentHashMap <Object, Object>(5); Assert.IsTrue(map.IsEmpty()); map.Put(one, "A"); map.Put(two, "B"); map.Put(three, "C"); map.Put(four, "D"); map.Put(five, "E"); Assert.IsFalse(map.IsEmpty()); Assert.AreEqual(5, map.Size()); return(map); }
public void TestValuesToArray() { ConcurrentHashMap <Object, Object> map = map5(); Collection <Object> v = map.Values(); Object[] ar = v.ToArray(); ArrayList <Object> s = new ArrayList <Object>(Arrays.AsList(ar)); Assert.AreEqual(5, ar.Length); Assert.IsTrue(s.Contains("A")); Assert.IsTrue(s.Contains("B")); Assert.IsTrue(s.Contains("C")); Assert.IsTrue(s.Contains("D")); Assert.IsTrue(s.Contains("E")); }
public void TestEntrySet() { ConcurrentHashMap <Object, Object> map = map5(); Set <Entry <Object, Object> > s = map.EntrySet(); Assert.AreEqual(5, s.Size()); Iterator <Entry <Object, Object> > it = s.Iterator(); while (it.HasNext) { Entry <Object, Object> e = it.Next(); Assert.IsTrue( (e.Key.Equals(one) && e.Value.Equals("A")) || (e.Key.Equals(two) && e.Value.Equals("B")) || (e.Key.Equals(three) && e.Value.Equals("C")) || (e.Key.Equals(four) && e.Value.Equals("D")) || (e.Key.Equals(five) && e.Value.Equals("E"))); } }
public void TestSetValueWriteThrough() { ConcurrentHashMap <Object, Object> map = new ConcurrentHashMap <Object, Object>(2, 5.0f, 1); Assert.IsTrue(map.IsEmpty()); for (int i = 0; i < 20; i++) { map.Put(i, i); } Assert.IsFalse(map.IsEmpty()); Entry <Object, Object> entry1 = map.EntrySet().Iterator().Next(); // assert that entry1 is not 16 Assert.IsTrue(!entry1.Key.Equals(16), "entry is 16, test not valid"); // remove 16 (a different key) from map // which just happens to cause entry1 to be cloned in map map.Remove(16); entry1.Value = "XYZ"; Assert.IsTrue(map.ContainsValue("XYZ")); }
public EntrySetImpl(ConcurrentHashMap <K, V> parent) : base() { this.parent = parent; }