RunListenerRegister extends RunListener { public RunListenerRegister() { listeners = new CopyOnWriteArrayList<>(); synchronized (RunListenerRegister.class) { if (listenerRegister == null) { listenerRegister = this; } else { throw new ExceptionInInitializerError("Attempting to instantiate second RunListenerRegister instance: " + this + ", existing: " + listenerRegister); } } } RunListenerRegister(); static boolean tryAddRunListener(final RunListener listener, final boolean first); static void addRunListener(final RunListener listener, final boolean first); static boolean removeRunListener(final RunListener listener); @Override void testIgnored(final Description description); @Override void testAssumptionFailure(final Failure failure); @Override void testFailure(final Failure failure); @Override void testFinished(final Description description); @Override void testStarted(final Description description); @Override void testRunFinished(final Result result); @Override void testRunStarted(final Description description); @Override String toString();  }
@Test @SuppressFBWarnings("SEC_SIDE_EFFECT_CONSTRUCTOR") public void testRunListenerRegister() { new RunListenerRegister(); RunListener runListener = new RunListener(); RunListenerRegister.addRunListener(runListener, true); Assert.assertTrue(RunListenerRegister.removeRunListener(runListener)); Assert.assertFalse(RunListenerRegister.removeRunListener(runListener)); try { new RunListenerRegister(); Assert.fail(); } catch (ExceptionInInitializerError ex) { } }