private void routeBasedRequestNameIncludesPathPrefix(String prefix) throws Exception { Response request1 = get(prefix + "/1?foo"); Response request2 = get(prefix + "/2?bar"); // get() doesn't check the response, check to make sure the server didn't 500 assertThat(request1.isSuccessful()).isTrue(); assertThat(request2.isSuccessful()).isTrue(); // Reading the route parameter from the response ensures the test endpoint is correct assertThat(request1.body().string()) .isEqualTo("1"); assertThat(request2.body().string()) .isEqualTo("2"); Span span1 = takeSpan(), span2 = takeSpan(); // verify that the path and url reflect the initial request (not a route expression) assertThat(span1.tags()) .containsEntry("http.method", "GET") .containsEntry("http.path", prefix + "/1") .containsEntry("http.url", url(prefix + "/1?foo")); assertThat(span2.tags()) .containsEntry("http.method", "GET") .containsEntry("http.path", prefix + "/2") .containsEntry("http.url", url(prefix + "/2?bar")); // We don't know the exact format of the http route as it is framework specific // However, we know that it should match both requests and include the common part of the path Set<String> routeBasedNames = new LinkedHashSet<>(Arrays.asList(span1.name(), span2.name())); assertThat(routeBasedNames).hasSize(1); assertThat(routeBasedNames.iterator().next()) .startsWith("get " + prefix) .doesNotEndWith("/") // no trailing slashes .doesNotContain("//"); // no duplicate slashes }
@Test public void consoleModeShouldRedirectOnlyJDKLoggers() { gfsh = new Gfsh(true, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); // when initialized in console mode, all log messages will show up in console // initially. so that we see messages when "start locator", "start server" command // are executed. Only after connection, JDK's logging is turned off while (loggerNames.hasMoreElements()) { String loggerName = loggerNames.nextElement(); Logger logger = logManager.getLogger(loggerName); // make sure jdk's logging goes to the gfsh log file if (loggerName.startsWith("java")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure Gfsh's logging goes to the gfsh log file else if (loggerName.endsWith(".Gfsh")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } // make sure SimpleParser's logging will still show up in the console else if (loggerName.endsWith(".SimpleParser")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } } } }
@Test public void headlessModeShouldRedirectBothJDKAndGFSHLoggers() { gfsh = new Gfsh(false, null, new GfshConfig()); LogManager logManager = LogManager.getLogManager(); Enumeration<String> loggerNames = logManager.getLoggerNames(); while (loggerNames.hasMoreElements()) { String loggerName = loggerNames.nextElement(); Logger logger = logManager.getLogger(loggerName); // make sure jdk's logging goes to the gfsh log file if (loggerName.startsWith("java")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure Gfsh's logging goes to the gfsh log file else if (loggerName.endsWith(".Gfsh")) { assertThat(logger.getParent().getName()).endsWith("LogWrapper"); } // make sure SimpleParser's logging will still show up in the console else if (loggerName.endsWith(".SimpleParser")) { assertThat(logger.getParent().getName()).doesNotEndWith("LogWrapper"); } } } }
private void routeBasedRequestNameIncludesPathPrefix(String prefix) throws Exception { Response request1 = get(prefix + "/1?foo"); Response request2 = get(prefix + "/2?bar"); // get() doesn't check the response, check to make sure the server didn't 500 assertThat(request1.isSuccessful()).isTrue(); assertThat(request2.isSuccessful()).isTrue(); // Reading the route parameter from the response ensures the test endpoint is correct assertThat(request1.body().string()) .isEqualTo("1"); assertThat(request2.body().string()) .isEqualTo("2"); Span span1 = takeSpan(), span2 = takeSpan(); // verify that the path and url reflect the initial request (not a route expression) assertThat(span1.tags()) .containsEntry("http.method", "GET") .containsEntry("http.path", prefix + "/1") .containsEntry("http.url", url(prefix + "/1?foo")); assertThat(span2.tags()) .containsEntry("http.method", "GET") .containsEntry("http.path", prefix + "/2") .containsEntry("http.url", url(prefix + "/2?bar")); // We don't know the exact format of the http route as it is framework specific // However, we know that it should match both requests and include the common part of the path Set<String> routeBasedNames = new LinkedHashSet<>(Arrays.asList(span1.name(), span2.name())); assertThat(routeBasedNames).hasSize(1); assertThat(routeBasedNames.iterator().next()) .startsWith("get " + prefix) .doesNotEndWith("/") // no trailing slashes .doesNotContain("//"); // no duplicate slashes }