From 937fc205aafd66ff69758968af2a0fffef0b2e91 Mon Sep 17 00:00:00 2001 From: tvallin Date: Wed, 28 Feb 2024 16:43:58 +0100 Subject: [PATCH] review changes Signed-off-by: tvallin --- .../inject/processor/ActiveProcessorUtils.java | 2 +- .../io/helidon/inject/tools/CommonUtils.java | 3 ++- .../OciAuthenticationDetailsProvider.java | 3 ++- .../microprofile/telemetry/WithSpanTest.java | 3 --- .../telemetry/WithSpanWithExplicitAppTest.java | 3 --- .../telemetry/InMemorySpanExporter.java | 4 ++-- .../telemetry/RestSpanHierarchyTest.java | 9 --------- .../telemetry/TestFullUrlName.java | 18 +++++++++--------- .../messaging/connectors/jms/AckMpTest.java | 4 ---- .../connectors/kafka/KafkaSeTest.java | 3 --- .../integration/oidc/CommonLoginBase.java | 2 +- .../integration/oidc/CookieBasedLoginIT.java | 5 ----- .../tests/integration/oidc/IdTokenIT.java | 5 ----- .../integration/oidc/QueryBasedLoginIT.java | 5 ----- .../tests/integration/oidc/RefreshTokenIT.java | 5 ----- .../oidc/TenantIdentificationIT.java | 3 --- .../FileSystemContentHandler.java | 3 ++- .../staticcontent/CachedHandlerTest.java | 3 --- 18 files changed, 19 insertions(+), 64 deletions(-) diff --git a/inject/processor/src/main/java/io/helidon/inject/processor/ActiveProcessorUtils.java b/inject/processor/src/main/java/io/helidon/inject/processor/ActiveProcessorUtils.java index 126ea37e1f1..8260cc75b52 100644 --- a/inject/processor/src/main/java/io/helidon/inject/processor/ActiveProcessorUtils.java +++ b/inject/processor/src/main/java/io/helidon/inject/processor/ActiveProcessorUtils.java @@ -260,7 +260,7 @@ private static String normalizePath(String value) { if (value == null) { return null; } - return value.replace("\\", "/"); + return value.replace(File.separator, "/"); } } diff --git a/inject/tools/src/main/java/io/helidon/inject/tools/CommonUtils.java b/inject/tools/src/main/java/io/helidon/inject/tools/CommonUtils.java index b3078cff070..b45003333a8 100644 --- a/inject/tools/src/main/java/io/helidon/inject/tools/CommonUtils.java +++ b/inject/tools/src/main/java/io/helidon/inject/tools/CommonUtils.java @@ -17,6 +17,7 @@ package io.helidon.inject.tools; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; @@ -222,7 +223,7 @@ static String normalizePath(String value) { if (value == null) { return null; } - return value.replace("\\", "/"); + return value.replace(File.separator, "/"); } } diff --git a/integrations/oci/sdk/runtime/src/main/java/io/helidon/integrations/oci/sdk/runtime/OciAuthenticationDetailsProvider.java b/integrations/oci/sdk/runtime/src/main/java/io/helidon/integrations/oci/sdk/runtime/OciAuthenticationDetailsProvider.java index 7c37587ea2d..f1c19eea468 100644 --- a/integrations/oci/sdk/runtime/src/main/java/io/helidon/integrations/oci/sdk/runtime/OciAuthenticationDetailsProvider.java +++ b/integrations/oci/sdk/runtime/src/main/java/io/helidon/integrations/oci/sdk/runtime/OciAuthenticationDetailsProvider.java @@ -16,6 +16,7 @@ package io.helidon.integrations.oci.sdk.runtime; +import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Path; @@ -169,7 +170,7 @@ private static String normalizePath(String value) { if (value == null) { return null; } - return value.replace("\\", "/"); + return value.replace(File.separator, "/"); } diff --git a/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanTest.java b/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanTest.java index 42221952425..07d4aa2f9ed 100644 --- a/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanTest.java +++ b/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanTest.java @@ -22,15 +22,12 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.sdk.trace.data.SpanData; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -@DisabledOnOs(OS.WINDOWS) class WithSpanTest extends WithSpanTestBase { @Test diff --git a/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanWithExplicitAppTest.java b/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanWithExplicitAppTest.java index c5196a1089e..1c978a0115c 100644 --- a/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanWithExplicitAppTest.java +++ b/microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/WithSpanWithExplicitAppTest.java @@ -19,14 +19,11 @@ import io.helidon.microprofile.testing.junit5.AddBean; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @AddBean(App.class) @AddBean(AppTracedResource.class) -@DisabledOnOs(OS.WINDOWS) class WithSpanWithExplicitAppTest extends WithSpanTestBase { @ParameterizedTest() diff --git a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/InMemorySpanExporter.java b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/InMemorySpanExporter.java index ef6c3ae3d1d..045134ebee0 100644 --- a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/InMemorySpanExporter.java +++ b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/InMemorySpanExporter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class InMemorySpanExporter implements SpanExporter { */ public List getFinishedSpanItems(int spanCount) { assertSpanCount(spanCount); - return finishedSpanItems.stream().sorted(comparingLong(SpanData::getStartEpochNanos).reversed()) + return finishedSpanItems.stream().sorted(comparingLong(SpanData::getEndEpochNanos)) .collect(Collectors.toList()); } diff --git a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/RestSpanHierarchyTest.java b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/RestSpanHierarchyTest.java index e4e23775cd2..9a78268d24d 100644 --- a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/RestSpanHierarchyTest.java +++ b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/RestSpanHierarchyTest.java @@ -19,11 +19,8 @@ import java.util.List; -import io.helidon.http.Status; -import io.helidon.microprofile.telemetry.InMemorySpanExporterProvider; import io.helidon.microprofile.testing.junit5.AddBean; import io.helidon.microprofile.testing.junit5.AddConfig; -import io.helidon.microprofile.testing.junit5.AddExtension; import io.helidon.microprofile.testing.junit5.HelidonTest; import io.opentelemetry.api.common.AttributeKey; @@ -31,17 +28,12 @@ import io.opentelemetry.sdk.trace.data.SpanData; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.Response; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.opentelemetry.api.trace.SpanKind.INTERNAL; import static io.opentelemetry.api.trace.SpanKind.SERVER; @@ -73,7 +65,6 @@ void setup() { } @Test - @DisabledOnOs(OS.WINDOWS) void spanHierarchy() { assertThat(webTarget.path("mixed").request().get().getStatus(), is(Response.Status.OK.getStatusCode())); diff --git a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/TestFullUrlName.java b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/TestFullUrlName.java index cbecd852b37..339c80499bf 100644 --- a/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/TestFullUrlName.java +++ b/microprofile/tests/telemetry/src/test/java/io/helidon/microprofile/telemetry/TestFullUrlName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,8 @@ package io.helidon.microprofile.telemetry; import java.util.List; +import java.util.stream.Collectors; -import io.helidon.http.Status; -import io.helidon.microprofile.telemetry.InMemorySpanExporter; -import io.helidon.microprofile.telemetry.InMemorySpanExporterProvider; import io.helidon.microprofile.testing.junit5.AddBean; import io.helidon.microprofile.testing.junit5.AddConfig; import io.helidon.microprofile.testing.junit5.AddExtension; @@ -29,16 +27,15 @@ import io.opentelemetry.sdk.trace.data.SpanData; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; /** @@ -76,9 +73,12 @@ void spanNaming() { assertThat(webTarget.path("named").request().get().getStatus(), is(Response.Status.OK.getStatusCode())); - List spanItems = spanExporter.getFinishedSpanItems(2); - assertThat(spanItems.size(), is(2)); - assertThat(spanItems.get(0).getName(), is("http://localhost:" + webTarget.getUri().getPort() + "/named")); + List names = spanExporter.getFinishedSpanItems(2).stream() + .map(SpanData::getName) + .collect(Collectors.toList()); + assertThat(names.size(), is(2)); + assertThat(names, hasItem("http://localhost:" + webTarget.getUri().getPort() + "/named")); + assertThat(names, hasItem("HTTP GET")); } diff --git a/tests/integration/jms/src/test/java/io/helidon/messaging/connectors/jms/AckMpTest.java b/tests/integration/jms/src/test/java/io/helidon/messaging/connectors/jms/AckMpTest.java index 6ea3b16e3c7..2d4e7c3250a 100644 --- a/tests/integration/jms/src/test/java/io/helidon/messaging/connectors/jms/AckMpTest.java +++ b/tests/integration/jms/src/test/java/io/helidon/messaging/connectors/jms/AckMpTest.java @@ -43,8 +43,6 @@ import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static java.lang.System.Logger.Level.DEBUG; @@ -108,14 +106,12 @@ void resendAckTestPart1(SeContainer cdi) { @Test @Order(2) - @DisabledOnOs(OS.WINDOWS) void resendAckTestPart2(SeContainer cdi) { MockConnector mockConnector = cdi.select(MockConnector.class, TEST_CONNECTOR_ANNOTATION).get(); //Check if not acked messages are redelivered mockConnector.outgoing("mock-conn-channel", String.class) .requestMax() - .awaitCount(Duration.ofSeconds(5), 1) .awaitPayloads(Duration.ofSeconds(5), "NO_ACK-1", "NO_ACK-2", "NO_ACK-3"); } diff --git a/tests/integration/kafka/src/test/java/io/helidon/messaging/connectors/kafka/KafkaSeTest.java b/tests/integration/kafka/src/test/java/io/helidon/messaging/connectors/kafka/KafkaSeTest.java index fd2a2a37c22..e0287fd04de 100644 --- a/tests/integration/kafka/src/test/java/io/helidon/messaging/connectors/kafka/KafkaSeTest.java +++ b/tests/integration/kafka/src/test/java/io/helidon/messaging/connectors/kafka/KafkaSeTest.java @@ -60,8 +60,6 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -72,7 +70,6 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; -@DisabledOnOs(OS.WINDOWS) public class KafkaSeTest extends AbstractKafkaTest { private static final Logger LOGGER = Logger.getLogger(KafkaSeTest.class.getName()); diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CommonLoginBase.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CommonLoginBase.java index 66c62d30ae4..2a360049c3a 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CommonLoginBase.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CommonLoginBase.java @@ -54,7 +54,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; -@Testcontainers +@Testcontainers(disabledWithoutDocker = true) @HelidonTest(resetPerTest = true) @AddBean(TestResource.class) class CommonLoginBase { diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CookieBasedLoginIT.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CookieBasedLoginIT.java index 4184117caca..e41aad99134 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CookieBasedLoginIT.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CookieBasedLoginIT.java @@ -20,11 +20,7 @@ import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Form; import jakarta.ws.rs.core.Response; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_POST_LOGOUT_TEST_MESSAGE; import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE; @@ -32,7 +28,6 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; -@DisabledOnOs(OS.WINDOWS) class CookieBasedLoginIT extends CommonLoginBase { @Test diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/IdTokenIT.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/IdTokenIT.java index 05296e5a11b..e06fd86fa5f 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/IdTokenIT.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/IdTokenIT.java @@ -38,13 +38,9 @@ import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.helidon.security.providers.oidc.common.OidcConfig.DEFAULT_ID_COOKIE_NAME; import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE; @@ -56,7 +52,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; -@DisabledOnOs(OS.WINDOWS) class IdTokenIT extends CommonLoginBase { private static final ClientConfig CONFIG_CLIENT_2 = new ClientConfig() diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/QueryBasedLoginIT.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/QueryBasedLoginIT.java index 1720e3552f8..cd85db67d78 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/QueryBasedLoginIT.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/QueryBasedLoginIT.java @@ -24,11 +24,7 @@ import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientProperties; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE; import static org.hamcrest.CoreMatchers.is; @@ -38,7 +34,6 @@ @AddConfig(key = "security.providers.1.oidc.cookie-use", value = "false") @AddConfig(key = "security.providers.1.oidc.query-param-use", value = "true") @AddConfig(key = "server.protocols.http_1_1.max-prologue-length", value = "4096") -@DisabledOnOs(OS.WINDOWS) class QueryBasedLoginIT extends CommonLoginBase { @Test diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/RefreshTokenIT.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/RefreshTokenIT.java index e2792c81b8b..4bc66076001 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/RefreshTokenIT.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/RefreshTokenIT.java @@ -33,11 +33,7 @@ import jakarta.ws.rs.core.Form; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE; import static org.hamcrest.CoreMatchers.hasItem; @@ -49,7 +45,6 @@ import static org.hamcrest.Matchers.empty; @AddConfig(key = "security.providers.1.oidc.token-signature-validation", value = "false") -@DisabledOnOs(OS.WINDOWS) class RefreshTokenIT extends CommonLoginBase { @Test diff --git a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/TenantIdentificationIT.java b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/TenantIdentificationIT.java index 78b85c8bd8d..46c0f56fd51 100644 --- a/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/TenantIdentificationIT.java +++ b/tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/TenantIdentificationIT.java @@ -34,8 +34,6 @@ import jakarta.ws.rs.core.Response; import org.glassfish.jersey.client.ClientProperties; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; @@ -46,7 +44,6 @@ @HelidonTest(resetPerTest = true) @AddBean(TestResource.class) @AddConfig(key = "security.providers.1.oidc.oidc-metadata-well-known", value = "false") -@DisabledOnOs(OS.WINDOWS) class TenantIdentificationIT { @Test diff --git a/webserver/static-content/src/main/java/io/helidon/webserver/staticcontent/FileSystemContentHandler.java b/webserver/static-content/src/main/java/io/helidon/webserver/staticcontent/FileSystemContentHandler.java index d0ab9570794..ed0c8224301 100644 --- a/webserver/static-content/src/main/java/io/helidon/webserver/staticcontent/FileSystemContentHandler.java +++ b/webserver/static-content/src/main/java/io/helidon/webserver/staticcontent/FileSystemContentHandler.java @@ -16,6 +16,7 @@ package io.helidon.webserver.staticcontent; +import java.io.File; import java.io.IOException; import java.lang.System.Logger.Level; import java.nio.file.Files; @@ -79,7 +80,7 @@ boolean doHandle(Method method, String requestedPath, ServerRequest req, ServerR String rawPath = req.prologue().uriPath().rawPath(); - String relativePath = root.relativize(path).toString().replace("\\", "/"); + String relativePath = root.relativize(path).toString().replace(File.separator, "/"); String requestedResource; if (mapped) { requestedResource = relativePath; diff --git a/webserver/static-content/src/test/java/io/helidon/webserver/staticcontent/CachedHandlerTest.java b/webserver/static-content/src/test/java/io/helidon/webserver/staticcontent/CachedHandlerTest.java index e440a4589d0..60d1d8277e1 100644 --- a/webserver/static-content/src/test/java/io/helidon/webserver/staticcontent/CachedHandlerTest.java +++ b/webserver/static-content/src/test/java/io/helidon/webserver/staticcontent/CachedHandlerTest.java @@ -38,8 +38,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import static io.helidon.common.testing.http.junit5.HttpHeaderMatcher.hasHeader; import static io.helidon.common.testing.junit5.OptionalMatcher.optionalPresent; @@ -183,7 +181,6 @@ void testFsInMemoryCache() { } @Test - @DisabledOnOs(OS.WINDOWS) void testFsFromInMemory() throws IOException { ServerResponseHeaders responseHeaders = ServerResponseHeaders.create();