### Question:
DebugCounter implements IFloodlightModule, IDebugCounterService { @Override public IDebugCounter registerCounter(String moduleName, String counterHierarchy, String counterDescription, CounterType counterType, String... metaData) throws MaxCountersRegistered, MaxHierarchyRegistered, MissingHierarchicalLevel { if (!moduleCounters.containsKey(moduleName)) { moduleCounters.putIfAbsent(moduleName, new ConcurrentHashMap<String, CounterIndexStore>()); } RetCtrInfo rci = getCounterId(moduleName, counterHierarchy); if (rci.allLevelsFound) { log.info("Counter exists for {}/{} -- resetting counters", moduleName, counterHierarchy); resetCounterHierarchy(moduleName, counterHierarchy); return new CounterImpl(rci.ctrIds[rci.foundUptoLevel-1]); } if (rci.levels.length > MAX_HIERARCHY) { String err = "Registry of counterHierarchy " + counterHierarchy + " exceeds max hierachy " + MAX_HIERARCHY + ".. aborting"; throw new MaxHierarchyRegistered(err); } if (rci.foundUptoLevel < rci.levels.length-1) { String needToRegister = ""; for (int i=0; i<=rci.foundUptoLevel; i++) { needToRegister += rci.levels[i]; } String err = "Attempting to register hierarchical counterHierarchy " + counterHierarchy + " but parts of hierarchy missing. " + "Please register " + needToRegister + " first"; throw new MissingHierarchicalLevel(err); } int counterId = counterIdCounter.getAndIncrement(); if (counterId >= MAX_COUNTERS) { throw new MaxCountersRegistered("max counters reached"); } boolean enabled = (counterType == CounterType.ALWAYS_COUNT) ? true : false; CounterInfo ci = new CounterInfo(counterId, enabled, moduleName, counterHierarchy, counterDescription, counterType, metaData); allCounters[counterId] = new DebugCounterInfo(ci); addToModuleCounterHierarchy(moduleName, counterId, rci); if (enabled) { currentCounters.add(counterId); } return new CounterImpl(counterId); }  @Override IDebugCounter registerCounter(String moduleName, String counterHierarchy,
                           String counterDescription, CounterType counterType,
                           String... metaData); @Override void flushCounters(); @Override void resetCounterHierarchy(String moduleName, String counterHierarchy); @Override void resetAllCounters(); @Override void resetAllModuleCounters(String moduleName); @Override void enableCtrOnDemand(String moduleName, String counterHierarchy); @Override void disableCtrOnDemand(String moduleName, String counterHierarchy); @Override List<DebugCounterInfo> getCounterHierarchy(String moduleName,
                                                     String counterHierarchy); @Override List<DebugCounterInfo> getAllCounterValues(); @Override List<DebugCounterInfo> getModuleCounterValues(String moduleName); @Override boolean containsModuleCounterHierarchy(String moduleName,
                                                 String counterHierarchy); @Override boolean containsModuleName(String moduleName); @Override List<String> getModuleList(); @Override List<String> getModuleCounterList(String moduleName); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context);  }### Answer:
@Test public void testCounterReregistry() throws Exception { testCounterHierarchy(); checkCounters(1, 2, 3, 10, 20, 100, 105); S1 = dc.registerCounter("switch", "01", "switch01", CounterType.ALWAYS_COUNT); checkCounters(0, 2, 3, 0, 0, 0, 0); assertEquals(0, S1.getCounterValue()); }