InternalThreadLocal { public static int size() { InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.getIfSet(); if (threadLocalMap == null) { return 0; } else { return threadLocalMap.size(); } } InternalThreadLocal(); @SuppressWarnings("unchecked") static void removeAll(); static int size(); static void destroy(); @SuppressWarnings("unchecked") final V get(); final void set(V value); @SuppressWarnings("unchecked") final void remove(); @SuppressWarnings("unchecked") final void remove(InternalThreadLocalMap threadLocalMap);  }
@Test public void testSize() throws InterruptedException { final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>(); internalThreadLocal.set(1); Assert.assertTrue("size method is wrong!", InternalThreadLocal.size() == 1); final InternalThreadLocal<String> internalThreadLocalString = new InternalThreadLocal<String>(); internalThreadLocalString.set("value"); Assert.assertTrue("size method is wrong!", InternalThreadLocal.size() == 2); }
@Test public void testSize() throws InterruptedException { final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>(); internalThreadLocal.set(1); Assertions.assertEquals(1, InternalThreadLocal.size(), "size method is wrong!"); final InternalThreadLocal<String> internalThreadLocalString = new InternalThreadLocal<String>(); internalThreadLocalString.set("value"); Assertions.assertEquals(2, InternalThreadLocal.size(), "size method is wrong!"); }