### Question:
SpaceUtil { public static long nextLong (Space sp, Object key) { long l = 0L; synchronized (sp) { Object obj = sp.inp (key); wipe (sp, key); if (obj instanceof Long) l = (Long) obj; sp.out (key, ++l); } return l; }  static Object[] inpAll(Space sp, Object key); static void wipe(Space sp, Object key); static void wipeAndOut(Space sp, Object key, Object value); static void wipeAndOut(Space sp, Object key, Object value, long timeout); static long nextLong(Space sp, Object key); static boolean outIfEmpty(Space sp, Object key, Object value, long nrdTimeout, long outTimeout); static void outWhenEmpty(Space sp, Object key, Object value, long timeout); static void outWhenEmpty(Space sp, Object key, Object value);  }### Answer:
@Test public void testNextLong() throws Throwable { Space sp = new TSpace(); long result = SpaceUtil.nextLong(sp, ""); assertEquals(1, ((TSpace) sp).entries.size(), "(TSpace) sp.entries.size()"); assertEquals(1L, result, "result"); }
@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("key=null, value=1", ex.getMessage(), "ex.getMessage()"); assertTrue(((TSpace) sp).isEmpty(), "(TSpace) sp.isEmpty()"); } }
@Test public void testNextLongThrowsNullPointerException1() throws Throwable { try { SpaceUtil.nextLong(null, ""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot enter synchronized block because \"sp\" is null", ex.getMessage(), "ex.getMessage()"); } } }