@Test @SuppressWarnings("unchecked") public void can_add_shutdownhook() { try { Class clazz = Class.forName("java.lang.ApplicationShutdownHooks"); Field field = clazz.getDeclaredField("hooks"); field.setAccessible(true); IdentityHashMap<Thread, Thread> hooks = (IdentityHashMap<Thread, Thread>)field.get(null); int initialHooksNumber = hooks.size(); HosebirdReader tr = new ConcreteHosebirdReader(); tr.runtimeAddShutdownHook(new Thread()); IdentityHashMap<Thread, Thread> hooks2 = (IdentityHashMap<Thread, Thread>)field.get(null); assertEquals(initialHooksNumber + 1, hooks2.size()); } catch (Exception e) { assertNull(e); } }
@VisibleForTesting @SuppressWarnings("checkstyle:designforextension") protected void runtimeAddShutdownHook(final Thread thread) { Runtime.getRuntime().addShutdownHook(thread); }
HosebirdReader { @VisibleForTesting @SuppressWarnings("checkstyle:designforextension") protected void runtimeAddShutdownHook(final Thread thread) { Runtime.getRuntime().addShutdownHook(thread); } }
HosebirdReader { @VisibleForTesting @SuppressWarnings("checkstyle:designforextension") protected void runtimeAddShutdownHook(final Thread thread) { Runtime.getRuntime().addShutdownHook(thread); } HosebirdReader(); }
HosebirdReader { @VisibleForTesting @SuppressWarnings("checkstyle:designforextension") protected void runtimeAddShutdownHook(final Thread thread) { Runtime.getRuntime().addShutdownHook(thread); } HosebirdReader(); final void run(final String[] args); }
HosebirdReader { @VisibleForTesting @SuppressWarnings("checkstyle:designforextension") protected void runtimeAddShutdownHook(final Thread thread) { Runtime.getRuntime().addShutdownHook(thread); } HosebirdReader(); final void run(final String[] args);  }