private void gc (int generation) { Set<K> exps; synchronized (this) { exps = expirables[generation]; expirables[generation] = new HashSet<K>(); } for (K k : exps) { if (rdp(k) != null) { synchronized (this) { expirables[generation].add(k); } } Thread.yield (); } if (sl != null) { synchronized (this) { if (sl != null && sl.isEmpty()) sl = null; } } }
@Test public void testIsEmpty() throws Throwable { TSpace tSpace = new TSpace(); boolean result = tSpace.isEmpty(); assertTrue("result", result); assertEquals("tSpace.entries.size()", 0, tSpace.entries.size()); }
@Test public void testGetSpace2() throws Throwable { TSpace result = (TSpace) SpaceFactory.getSpace("testString"); assertTrue("result.isEmpty()", result.isEmpty()); }
@Test public void testNextLongThrowsNullPointerException() throws Throwable { Space sp = new TSpace(); try { SpaceUtil.nextLong(sp, null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("ex.getMessage()", "key=null, value=1", ex.getMessage()); assertTrue("(TSpace) sp.isEmpty()", ((TSpace) sp).isEmpty()); } }
@Test public void testConstructor() throws Throwable { LocalSpace ssp = new TSpace(); Object key = new Object(); SpaceTap spaceTap = new SpaceTap(ssp, ssp, key, "", 100L); assertFalse("(TSpace) ssp.sl.isEmpty()", ((TSpace) ssp).sl.isEmpty()); assertSame("spaceTap.dsp", ssp, spaceTap.dsp); assertSame("spaceTap.key", key, spaceTap.key); assertEquals("spaceTap.tapKey", "", spaceTap.tapKey); assertEquals("spaceTap.tapTimeout", 100L, spaceTap.tapTimeout); assertSame("spaceTap.ssp", ssp, spaceTap.ssp); }