package test.utils.collection;

import java.util.UUID;

import org.junit.Assert;
import org.junit.Test;

import com.firefly.utils.collection.ConcurrentAutomaticClearMap;
import com.firefly.utils.collection.WeakReferenceConcurrentHashMap;

public class TestWeakReferenceConcurrentHashMap {

	@Test
	public void test() {
		ConcurrentAutomaticClearMap<String, String> map = new WeakReferenceConcurrentHashMap<>();

		long i = 0;
		while (true) {
			i = i + 1;
			map.put("key" + i, UUID.randomUUID().toString());
//			System.out.println(map.get("key1") + "|" + map.size());
			if (map.get("key1") == null)
				break;
		}
		System.out.println(i);
		System.out.println(map.size());
//		System.out.println(map.entrySet());
//		System.out.println(map.size());
		Assert.assertTrue(i >= map.size());
	}

}

@@ -29,81 +29,8 @@
 n;%0A%0A
-import java.util.UUID;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A
 impo
@@ -157,16 +157,88 @@
 HashMap;
+%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.util.UUID;
 %0A%0Apublic
@@ -286,16 +286,22 @@
  %7B%0A%0A
-%09
+    
 @Test%0A
-%09
+    
 publ
@@ -317,18 +317,24 @@
 est() %7B%0A
-%09%09
+        
 Concurre
@@ -416,18 +416,24 @@
 p%3C%3E();%0A%0A
-%09%09
+        
 long i =
@@ -436,18 +436,24 @@
  i = 0;%0A
-%09%09
+        
 while (t
@@ -463,25 +463,43 @@
 ) %7B%0A
-%09%09%09i = i + 1;%0A%09%09%09
+            i = i + 1;%0A            
 map.
@@ -548,118 +548,171 @@
 ));%0A
-//%09%09%09System.out.println(map.get(%22key1%22) + %22%7C%22 + map.size());%0A%09%09%09if (map.get(%22key1%22) == null)%0A%09%09%09%09break;%0A%09%09%7D%0A%09%09
+            if (map.get(%22key1%22) == null) %7B%0A                break;%0A            %7D%0A%0A            if (i %3E 100) %7B%0A                break;%0A            %7D%0A        %7D%0A        
 Syst
@@ -730,18 +730,24 @@
 tln(i);%0A
-%09%09
+        
 System.o
@@ -846,18 +846,24 @@
 ize());%0A
-%09%09
+        
 Assert.a
@@ -890,14 +890,17 @@
 ize());%0A
-%09
+    
 %7D%0A%0A%7D%0A

modify exit condition for WeakReferenceConcurrentHashMap test case