### Question:
CentralCollector implements Collector { @VisibleForTesting static String escapeHostName(String hostName) { hostName = hostName.replace("\\", "\\\\"); if (hostName.startsWith(":")) { hostName = "\\" + hostName; } while (hostName.contains("::")) { hostName = hostName.replace("::", ":\\:"); } return hostName; } CentralCollector(Map<String, String> properties, String collectorAddress,
            @Nullable String collectorAuthority, File confDir, @Nullable File sharedConfDir,
            LiveJvmServiceImpl liveJvmService, LiveWeavingServiceImpl liveWeavingService,
            LiveTraceRepositoryImpl liveTraceRepository, AgentConfigUpdater agentConfigUpdater,
            ConfigService configService); @Override void init(File confDir, @Nullable File sharedConfDir, final Environment environment,
            AgentConfig agentConfig, final AgentConfigUpdater agentConfigUpdater); @Override void collectAggregates(AggregateReader aggregateReader); @Override void collectGaugeValues(List<GaugeValue> gaugeValues); @Override void collectTrace(TraceReader traceReader); @Override void log(LogEvent logEvent); @OnlyUsedByTests void close(); @OnlyUsedByTests void awaitClose();  }### Answer:
@Test public void shouldEscape() { assertThat(CentralCollector.escapeHostName("")).isEqualTo(""); assertThat(CentralCollector.escapeHostName("abc")).isEqualTo("abc"); assertThat(CentralCollector.escapeHostName("a:b:c")).isEqualTo("a:b:c"); assertThat(CentralCollector.escapeHostName(":a:b:c:")).isEqualTo("\\:a:b:c:"); assertThat(CentralCollector.escapeHostName("::a::b::c::")) .isEqualTo("\\:\\:a:\\:b:\\:c:\\:"); assertThat(CentralCollector.escapeHostName(":::a:::b:::c:::")) .isEqualTo("\\:\\:\\:a:\\:\\:b:\\:\\:c:\\:\\:"); assertThat(CentralCollector.escapeHostName("::::")).isEqualTo("\\:\\:\\:\\:"); assertThat(CentralCollector.escapeHostName("a\\b\\c")).isEqualTo("a\\\\b\\\\c"); }