Tap { public static void enableInitial() { if (initiallyEnabledPattern != null) { for (Dispatch dispatch : DISPATCHES.values()) { dispatch.setEnabled(initiallyEnabledPattern.matcher(dispatch.getName()).find()); } } } protected  Tap(String name); final String getName(); abstract long getDuration(); abstract void reset(); void disable(); boolean isSubsidiary(); InOutTap createSubsidiaryTap(String name, InOutTap outermostRecursiveTapWrapper); static PointTap createCount(String name); static InOutTap createTimer(String name); static InOutTap createRecursiveTimer(String name); static void defaultToOn(boolean defaultIsOn); static void setEnabled(String regExPattern, boolean enabled); static void enableInitial(); static void setInitiallyEnabled(String initiallyEnabledRegex); static void reset(String regExPattern); static TapReport[] getReport(String regExPattern); static String report(); synchronized static void registerBadNestingHandler(BadNestingHandler badNestingHandler);  }
@Test public void testEnableInitial() { Tap.setInitiallyEnabled("^c|d$"); InOutTap a = Tap.createTimer("a"); PointTap b = Tap.createCount("b"); InOutTap c = Tap.createTimer("c"); PointTap d = Tap.createCount("d"); Tap.setEnabled(".*", false); TapReport[] reports = Tap.getReport(".*"); assertEquals(0, reports.length); Tap.enableInitial(); reports = Tap.getReport(".*"); assertEquals(2, reports.length); int mask = 0; for (TapReport report : reports) { if (report.getName().equals("c")) { mask |= 0x1; } else if (report.getName().equals("d")) { mask |= 0x2; } else { fail(); } } assertEquals(0x3, mask); }