From 7d758b18e16beb2d4337cce33f4719c3b22f52b6 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 10 Jul 2023 13:20:50 +0200 Subject: [PATCH 01/18] Set new release version --- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 6 +++--- .github/workflows/release_branch.yml | 4 ++-- gradle.properties | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2bb85f4d43..558e33a80e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -89,7 +89,7 @@ jobs: distribution: graalvm-community cache: gradle - name: Build Project - run: ./gradlew --info --stacktrace nativeTest + run: ./gradlew --stacktrace nativeTest build_site: name: Build Site diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd3ddff225..845e92ff44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,8 +40,8 @@ jobs: export REMOTE="https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" git remote set-url origin "$REMOTE" git clone "$REMOTE" --branch gh-pages build/gh-pages - ./gradlew --info build - ./gradlew --info -x build buildSite + ./gradlew build + ./gradlew -x build buildSite ls -AlF site/build/site - name: Publish Packages @@ -50,7 +50,7 @@ jobs: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - run: ./gradlew --info --no-daemon -x test release + run: ./gradlew --no-daemon -x test release - name: Publish Site run: | diff --git a/.github/workflows/release_branch.yml b/.github/workflows/release_branch.yml index 30996b429d..9da961162b 100644 --- a/.github/workflows/release_branch.yml +++ b/.github/workflows/release_branch.yml @@ -31,5 +31,5 @@ jobs: SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} run: | - ./gradlew --info build - ./gradlew --info --no-daemon -x test release + ./gradlew build + ./gradlew --no-daemon -x test release diff --git a/gradle.properties b/gradle.properties index 13361e033b..368253f772 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.warning.mode=all org.gradle.console=plain # Gradle -version=3.0.0-B8 +version=3.0.0-B9 group=com.hexagonkt description=The atoms of your platform From fc04fadaef46fd10a32798e9fe7fd24e56673464 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 10 Jul 2023 16:32:00 +0200 Subject: [PATCH 02/18] Update Gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4f77340f99..42082d7240 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-8.2-all.zip +distributionUrl=https://services.gradle.org/distributions/gradle-8.2.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 9393973a304d5a33c5c180ef2c4558bdafddc8b5 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 15 Jul 2023 12:54:59 +0200 Subject: [PATCH 03/18] Refactor --- http/http_server/api/http_server.api | 2 +- .../main/kotlin/com/hexagonkt/http/server/HttpServer.kt | 2 +- .../com/hexagonkt/http/server/HttpServerSettings.kt | 8 +++++--- .../com/hexagonkt/http/server/HttpServerSettingsTest.kt | 4 ++-- http/web/src/main/kotlin/com/hexagonkt/web/Web.kt | 5 ++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/http/http_server/api/http_server.api b/http/http_server/api/http_server.api index 91607b2a37..1c28b8ff96 100644 --- a/http/http_server/api/http_server.api +++ b/http/http_server/api/http_server.api @@ -59,9 +59,9 @@ public final class com/hexagonkt/http/server/HttpServerSettings { public static synthetic fun copy$default (Lcom/hexagonkt/http/server/HttpServerSettings;Ljava/net/InetAddress;ILjava/lang/String;Lcom/hexagonkt/http/model/HttpProtocol;Lcom/hexagonkt/http/SslSettings;Ljava/lang/String;ZILjava/lang/Object;)Lcom/hexagonkt/http/server/HttpServerSettings; public fun equals (Ljava/lang/Object;)Z public final fun getBanner ()Ljava/lang/String; - public final fun getBase ()Ljava/lang/String; public final fun getBindAddress ()Ljava/net/InetAddress; public final fun getBindPort ()I + public final fun getBindUrl ()Ljava/net/URL; public final fun getContextPath ()Ljava/lang/String; public final fun getProtocol ()Lcom/hexagonkt/http/model/HttpProtocol; public final fun getSslSettings ()Lcom/hexagonkt/http/SslSettings; diff --git a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServer.kt b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServer.kt index cb4b48fe92..f78e872177 100644 --- a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServer.kt +++ b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServer.kt @@ -142,7 +142,7 @@ data class HttpServer( val startUpTime = "%,.0f".format(startUpTimestamp / 1e6) val protocol = settings.protocol - val binding = "${settings.base}:$runtimePort" + val binding = "${settings.bindUrl}:$runtimePort" val banner = settings.banner ?: return " at $binding ($startUpTime ms)" val jvmMemoryValue = "$BLUE${totalMemory()} KB$RESET" diff --git a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServerSettings.kt b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServerSettings.kt index 593d3c37da..fa16fd4505 100644 --- a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServerSettings.kt +++ b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/HttpServerSettings.kt @@ -1,10 +1,12 @@ package com.hexagonkt.http.server import com.hexagonkt.core.Jvm +import com.hexagonkt.core.urlOf import com.hexagonkt.http.SslSettings import com.hexagonkt.http.model.HttpProtocol import com.hexagonkt.http.model.HttpProtocol.HTTP import java.net.InetAddress +import java.net.URL /** * Holds server settings info. @@ -16,7 +18,7 @@ import java.net.InetAddress * @property sslSettings SSL settings info for configuring the server. * @property banner Server banner message. * @property zip Option to compress server responses. - * @property base Base URL to connect to the server. It lacks the port (as it can be dynamic). + * @property bindUrl Base URL to connect to the server. It lacks the port (as it can be dynamic). */ data class HttpServerSettings( val bindAddress: InetAddress = InetAddress.getLoopbackAddress(), @@ -27,9 +29,9 @@ data class HttpServerSettings( val banner: String? = HttpServer.banner, val zip: Boolean = false, ) { - val base by lazy { + val bindUrl: URL by lazy { val hostName = if (bindAddress.isAnyLocalAddress) Jvm.ip else bindAddress.canonicalHostName val scheme = if (protocol == HTTP) "http" else "https" - "$scheme://$hostName" + urlOf("$scheme://$hostName") } } diff --git a/http/http_server/src/test/kotlin/com/hexagonkt/http/server/HttpServerSettingsTest.kt b/http/http_server/src/test/kotlin/com/hexagonkt/http/server/HttpServerSettingsTest.kt index 4375fd2619..69cc68ab3f 100644 --- a/http/http_server/src/test/kotlin/com/hexagonkt/http/server/HttpServerSettingsTest.kt +++ b/http/http_server/src/test/kotlin/com/hexagonkt/http/server/HttpServerSettingsTest.kt @@ -17,7 +17,7 @@ internal class HttpServerSettingsTest { assertNull(it.sslSettings) assertEquals(HttpServer.banner, it.banner) assertEquals(false, it.zip) - assert(it.base.startsWith("http://")) + assert(it.bindUrl.toString().startsWith("http://")) } } @@ -30,7 +30,7 @@ internal class HttpServerSettingsTest { assertNull(it.sslSettings) assertEquals(HttpServer.banner, it.banner) assertEquals(true, it.zip) - assertEquals("https://192.168.0.1", it.base) + assertEquals("https://192.168.0.1", it.bindUrl.toString()) } } } diff --git a/http/web/src/main/kotlin/com/hexagonkt/web/Web.kt b/http/web/src/main/kotlin/com/hexagonkt/web/Web.kt index 087ac1ef5c..d4772f7727 100644 --- a/http/web/src/main/kotlin/com/hexagonkt/web/Web.kt +++ b/http/web/src/main/kotlin/com/hexagonkt/web/Web.kt @@ -26,10 +26,9 @@ fun HttpContext.callContext(): Map = * TODO Review order precedence and complete code (now only taking request attribute) * * 1. Request - * 2. Session + * 2. Accept-language * 3. Cookie - * 4. Accept-language - * 5. Server default locale + * 4. Server default locale */ fun HttpContext.obtainLocale(): Locale = when { attributes["lang"] as? String != null -> localeFor(attributes["lang"] as String) From eaf23f29352191c6c79aabf20d69881fcf233055 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 15 Jul 2023 13:05:55 +0200 Subject: [PATCH 04/18] Remove :warnings --- .../main/kotlin/com/hexagonkt/core/Network.kt | 2 +- .../http/client/jetty/JettyWsClientAdapter.kt | 4 +-- .../http/server/callbacks/UrlCallback.kt | 3 +- .../server/async/callbacks/UrlCallback.kt | 3 +- .../com/hexagonkt/http/test/BaseTest.kt | 4 +-- .../http/test/examples/ClientTest.kt | 14 +++++----- .../http/test/examples/FiltersTest.kt | 4 +-- .../hexagonkt/http/test/examples/HttpsTest.kt | 24 ++++++++-------- .../http/test/examples/SamplesTest.kt | 28 +++++++++---------- .../http/test/examples/WebSocketsTest.kt | 10 +++---- .../hexagonkt/http/test/examples/ZipTest.kt | 6 ++-- .../http/test/async/examples/ClientTest.kt | 14 +++++----- .../http/test/async/examples/FilesTest.kt | 10 +++---- .../http/test/async/examples/FiltersTest.kt | 4 +-- .../http/test/async/examples/HttpsTest.kt | 24 ++++++++-------- .../http/test/async/examples/SamplesTest.kt | 28 +++++++++---------- .../templates/test/TemplateAdapterTest.kt | 3 +- 17 files changed, 94 insertions(+), 91 deletions(-) diff --git a/core/src/main/kotlin/com/hexagonkt/core/Network.kt b/core/src/main/kotlin/com/hexagonkt/core/Network.kt index 7be35328f1..28fff58fed 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Network.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Network.kt @@ -73,7 +73,7 @@ fun URL.firstVariant(vararg suffixes: String): URL { val fileName = file.removeSuffix(".$extension") suffixes.forEach { - val u = URL("$protocol:$fileName$it.$extension") + val u = urlOf("$protocol:$fileName$it.$extension") if (u.exists()) return u } diff --git a/http/http_client_jetty_ws/src/main/kotlin/com/hexagonkt/http/client/jetty/JettyWsClientAdapter.kt b/http/http_client_jetty_ws/src/main/kotlin/com/hexagonkt/http/client/jetty/JettyWsClientAdapter.kt index 8ec6cd26a4..aeb753e8fe 100644 --- a/http/http_client_jetty_ws/src/main/kotlin/com/hexagonkt/http/client/jetty/JettyWsClientAdapter.kt +++ b/http/http_client_jetty_ws/src/main/kotlin/com/hexagonkt/http/client/jetty/JettyWsClientAdapter.kt @@ -1,10 +1,10 @@ package com.hexagonkt.http.client.jetty +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.model.ws.WsSession import org.eclipse.jetty.websocket.client.WebSocketClient import java.net.URI -import java.net.URL /** * Client to use other REST services. @@ -34,7 +34,7 @@ class JettyWsClientAdapter : JettyClientAdapter() { onClose: WsSession.(status: Int, reason: String) -> Unit, ): WsSession { - val baseUrl = httpClient.settings.baseUrl ?: URL(path) + val baseUrl = httpClient.settings.baseUrl ?: urlOf(path) val scheme = if (baseUrl.protocol.lowercase() == "https") "wss" else "ws" val uri = URI("$scheme://${baseUrl.host}:${baseUrl.port}${baseUrl.path}$path") val adapter = diff --git a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt index f2a3336c80..36ff221aaa 100644 --- a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt +++ b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt @@ -4,6 +4,7 @@ import com.hexagonkt.core.ResourceNotFoundException import com.hexagonkt.core.logging.Logger import com.hexagonkt.core.media.mediaTypeOfOrNull import com.hexagonkt.core.require +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.handlers.HttpContext import java.net.URL @@ -31,7 +32,7 @@ class UrlCallback(private val url: URL) : (HttpContext) -> HttpContext { else -> "$url/$requestPath" } - val resource = URL(url) + val resource = urlOf(url) val bytes = resource.readBytes() val mediaType = mediaTypeOfOrNull(resource) context.ok(bytes, contentType = mediaType?.let { ContentType(it) }) diff --git a/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt b/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt index d8db05589a..0a725ba73b 100644 --- a/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt +++ b/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt @@ -4,6 +4,7 @@ import com.hexagonkt.core.ResourceNotFoundException import com.hexagonkt.core.logging.Logger import com.hexagonkt.core.media.mediaTypeOfOrNull import com.hexagonkt.core.require +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.handlers.async.HttpContext @@ -33,7 +34,7 @@ class UrlCallback(private val url: URL) : (HttpContext) -> CompletableFuture "$url/$requestPath" } - val resource = URL(url) + val resource = urlOf(url) val bytes = resource.readBytes() val mediaType = mediaTypeOfOrNull(resource) context.ok(bytes, contentType = mediaType?.let { ContentType(it) }).done() diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/BaseTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/BaseTest.kt index e9b19778b7..327ad73679 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/BaseTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/BaseTest.kt @@ -4,6 +4,7 @@ import com.hexagonkt.core.encodeToBase64 import com.hexagonkt.core.logging.LoggingLevel.DEBUG import com.hexagonkt.core.logging.LoggingLevel.OFF import com.hexagonkt.core.logging.LoggingManager +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.client.HttpClientSettings @@ -19,7 +20,6 @@ import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import kotlin.test.assertEquals @TestInstance(PER_CLASS) @@ -35,7 +35,7 @@ abstract class BaseTest { } protected val client: HttpClient by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(clientAdapter(), settings) } diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt index eb9d83d0b1..94af5c841a 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.http.test.examples import com.hexagonkt.core.require import com.hexagonkt.core.media.APPLICATION_JSON import com.hexagonkt.core.media.APPLICATION_YAML +import com.hexagonkt.core.urlOf import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -26,7 +27,6 @@ import com.hexagonkt.serialization.serialize import org.junit.jupiter.api.* import java.math.BigInteger -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNull @@ -147,13 +147,13 @@ abstract class ClientTest( // clientCreation HttpClient(adapter) - HttpClient(adapter, HttpClientSettings(URL("http://host:1234/base"))) + HttpClient(adapter, HttpClientSettings(urlOf("http://host:1234/base"))) // clientCreation // clientSettingsCreation // All client settings parameters are optionals and provide default values HttpClient(adapter, HttpClientSettings( - baseUrl = URL("http://host:1234/base"), + baseUrl = urlOf("http://host:1234/base"), contentType = ContentType(APPLICATION_JSON), useCookies = true, headers = Headers(Header("x-api-Key", "cafebabe")), // Headers used in all requests @@ -278,7 +278,7 @@ abstract class ClientTest( @Test fun `Parameters are set properly` () { val clientHeaders = Headers(Header("header1", "val1", "val2")) val settings = HttpClientSettings( - baseUrl = URL("http://localhost:${server.runtimePort}"), + baseUrl = urlOf("http://localhost:${server.runtimePort}"), contentType = ContentType(APPLICATION_JSON), useCookies = false, headers = clientHeaders, @@ -376,8 +376,8 @@ abstract class ClientTest( val trustStorePassword = trust.reversed() // Key stores can be set as URIs to classpath resources (the triple slash is needed) - val keyStore = URL("classpath:ssl/$identity") - val trustStore = URL("classpath:ssl/$trust") + val keyStore = urlOf("classpath:ssl/$identity") + val trustStore = urlOf("classpath:ssl/$trust") val sslSettings = SslSettings( keyStore = keyStore, @@ -403,7 +403,7 @@ abstract class ClientTest( // We'll use the same certificate for the client (in a real scenario it would be different) val clientSettings = HttpClientSettings( - baseUrl = URL("https://localhost:${server.runtimePort}"), + baseUrl = urlOf("https://localhost:${server.runtimePort}"), sslSettings = sslSettings ) diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/FiltersTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/FiltersTest.kt index 29d36955aa..8b51223f36 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/FiltersTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/FiltersTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.http.test.examples import com.hexagonkt.core.decodeBase64 +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.client.HttpClientSettings @@ -17,7 +18,6 @@ import com.hexagonkt.http.handlers.HttpHandler import com.hexagonkt.http.handlers.path import com.hexagonkt.http.test.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals @Suppress("FunctionName") // This class's functions are intended to be used only in tests @@ -132,7 +132,7 @@ abstract class FiltersTest( private fun authorizedClient(user: String, password: String): HttpClient { val settings = HttpClientSettings( - baseUrl = URL("http://localhost:${server.runtimePort}"), + baseUrl = urlOf("http://localhost:${server.runtimePort}"), headers = Headers(Header("authorization", basicAuth(user, password))) ) return HttpClient(clientAdapter(), settings).apply { start() } diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/HttpsTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/HttpsTest.kt index 460b3d3cfe..b35f953a9c 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/HttpsTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/HttpsTest.kt @@ -5,6 +5,7 @@ import com.hexagonkt.core.require import com.hexagonkt.core.security.getPrivateKey import com.hexagonkt.core.security.getPublicKey import com.hexagonkt.core.security.loadKeyStore +import com.hexagonkt.core.urlOf import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -17,7 +18,6 @@ import com.hexagonkt.http.handlers.HttpHandler import com.hexagonkt.http.handlers.path import com.hexagonkt.http.test.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFails import kotlin.test.assertNotNull @@ -31,8 +31,8 @@ abstract class HttpsTest( private val identity = "hexagonkt.p12" private val trust = "trust.p12" - private val keyStore = URL("classpath:ssl/$identity") - private val trustStore = URL("classpath:ssl/$trust") + private val keyStore = urlOf("classpath:ssl/$identity") + private val trustStore = urlOf("classpath:ssl/$trust") private val keyStorePassword = identity.reversed() private val trustStorePassword = trust.reversed() @@ -74,8 +74,8 @@ abstract class HttpsTest( val trustStorePassword = trust.reversed() // Key stores can be set as URIs to classpath resources (the triple slash is needed) - val keyStore = URL("classpath:ssl/$identity") - val trustStore = URL("classpath:ssl/$trust") + val keyStore = urlOf("classpath:ssl/$identity") + val trustStore = urlOf("classpath:ssl/$trust") val sslSettings = SslSettings( keyStore = keyStore, @@ -105,7 +105,7 @@ abstract class HttpsTest( val clientSettings = HttpClientSettings(sslSettings = sslSettings) // Create an HTTP client and make an HTTPS request - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -123,7 +123,7 @@ abstract class HttpsTest( val server = serve(serverAdapter(), handler, http2ServerSettings.copy(protocol = HTTPS)) - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -139,7 +139,7 @@ abstract class HttpsTest( val server = serve(serverAdapter(), handler, http2ServerSettings) - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -158,7 +158,7 @@ abstract class HttpsTest( // keyStoreSettings val keyStoreSettings = SslSettings( - keyStore = URL("classpath:ssl/$identity"), + keyStore = urlOf("classpath:ssl/$identity"), keyStorePassword = identity.reversed() ) // keyStoreSettings @@ -178,7 +178,7 @@ abstract class HttpsTest( // trustStoreSettings val trustStoreSettings = SslSettings( - trustStore = URL("classpath:ssl/$trust"), + trustStore = urlOf("classpath:ssl/$trust"), trustStorePassword = trust.reversed() ) // trustStoreSettings @@ -188,7 +188,7 @@ abstract class HttpsTest( ) // Create an HTTP client and make an HTTPS request - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -206,7 +206,7 @@ abstract class HttpsTest( assertFails { val adapter = clientAdapter() - val contextPath1 = URL("https://127.0.0.1:${server.runtimePort}") + val contextPath1 = urlOf("https://127.0.0.1:${server.runtimePort}") HttpClient(adapter, clientSettings.copy(baseUrl = contextPath1)).use { it.start() it.get("/hello") diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt index 6601b2b924..c213443a3a 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt @@ -7,6 +7,7 @@ import com.hexagonkt.core.media.APPLICATION_JSON import com.hexagonkt.core.media.APPLICATION_XML import com.hexagonkt.core.media.TEXT_CSS import com.hexagonkt.core.media.TEXT_HTML +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.client.HttpClientSettings @@ -32,7 +33,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import java.net.InetAddress -import java.net.URL import kotlin.test.assertEquals @TestInstance(PER_CLASS) @@ -72,7 +72,7 @@ abstract class SamplesTest( // Servers implement closeable, you can use them inside a block assuring they will be closed runningServer.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(s.started()) assertEquals("Hello World!", it.get("/context/hello").body) @@ -86,7 +86,7 @@ abstract class SamplesTest( // serverCreation defaultSettingsServer.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(s.started()) assertEquals("Hello World!", it.get("/hello").body) @@ -108,7 +108,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Get greeting", it.get("/hello").body) assertEquals("Put greeting", it.put("/hello").body) @@ -135,7 +135,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Greeting", it.get("/nested/hello").body) assertEquals("Second level greeting", it.get("/nested/secondLevel/hello").body) @@ -160,7 +160,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${server.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${server.runtimePort}"))).use { it.start() assertEquals("Get client", it.get("/clients").body) @@ -328,7 +328,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.cookies += Cookie("foo", "bar") it.start() @@ -346,7 +346,7 @@ abstract class SamplesTest( assertEquals(OK_200, it.get("/cookie").status) assertEquals(INTERNAL_SERVER_ERROR_500, it.get("/halt").status) - val stream = URL("classpath:assets/index.html").readBytes() + val stream = urlOf("classpath:assets/index.html").readBytes() val parts = listOf(HttpPart("file", stream, "index.html")) val response = it.send(HttpRequest(POST, path = "/file", parts = parts)) assert(response.bodyString().contains("Hexagon")) @@ -401,7 +401,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${server.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${server.runtimePort}"))).use { it.start() assertResponse(it.get("/filters/route"), "filters route", "b-filters", "a-filters") assertResponse(it.get("/filters"), "filters") @@ -454,7 +454,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() val errors = it.get("/errors") @@ -486,17 +486,17 @@ abstract class SamplesTest( on( status = NOT_FOUND_404, pattern = "/web/*", - callback = UrlCallback(URL("classpath:public")) + callback = UrlCallback(urlOf("classpath:public")) ) // Maps resources on 'assets' on the server root (assets/f.css -> /f.css) // '/public/css/style.css' resource would be: 'http://{host}:{port}/css/style.css' - on(status = NOT_FOUND_404, pattern = "/*", callback = UrlCallback(URL("classpath:assets"))) + on(status = NOT_FOUND_404, pattern = "/*", callback = UrlCallback(urlOf("classpath:assets"))) // files } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(it.get("/web/file.txt").bodyString().startsWith("It matches this route")) @@ -525,7 +525,7 @@ abstract class SamplesTest( val server = serve(serverAdapter(), router, serverSettings) server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Hi!", it.get("/hello").body) } diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/WebSocketsTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/WebSocketsTest.kt index 36cbd3ab79..5b7ba7c9c0 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/WebSocketsTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/WebSocketsTest.kt @@ -2,6 +2,7 @@ package com.hexagonkt.http.test.examples import com.hexagonkt.core.logging.logger import com.hexagonkt.core.require +import com.hexagonkt.core.urlOf import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -15,7 +16,6 @@ import com.hexagonkt.http.handlers.path import com.hexagonkt.http.test.BaseTest import org.junit.jupiter.api.Test import kotlin.IllegalStateException -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFails import kotlin.test.assertFailsWith @@ -30,8 +30,8 @@ abstract class WebSocketsTest( private val identity = "hexagonkt.p12" private val trust = "trust.p12" - private val keyStore = URL("classpath:ssl/$identity") - private val trustStore = URL("classpath:ssl/$trust") + private val keyStore = urlOf("classpath:ssl/$identity") + private val trustStore = urlOf("classpath:ssl/$trust") private val keyStorePassword = identity.reversed() private val trustStorePassword = trust.reversed() @@ -105,7 +105,7 @@ abstract class WebSocketsTest( // ws_server @Test fun `WebSockets client check start and stop states`() { - val settings = clientSettings.copy(baseUrl = URL("https://localhost:9999")) + val settings = clientSettings.copy(baseUrl = urlOf("https://localhost:9999")) val client = HttpClient(clientAdapter(), settings) assertEquals( @@ -149,7 +149,7 @@ abstract class WebSocketsTest( ) { val server = serve(serverAdapter(), handler, serverSettings) - val contextPath = URL("$protocol://localhost:${server.runtimePort}") + val contextPath = urlOf("$protocol://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ZipTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ZipTest.kt index 3c109609d6..48cc414a98 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ZipTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ZipTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.http.test.examples +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.client.HttpClientSettings @@ -10,7 +11,6 @@ import com.hexagonkt.http.handlers.HttpHandler import com.hexagonkt.http.handlers.path import com.hexagonkt.http.test.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertNull @@ -38,7 +38,7 @@ abstract class ZipTest( } server.start() - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) val client = HttpClient(clientAdapter(), settings) client.start() @@ -67,7 +67,7 @@ abstract class ZipTest( } server.start() - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) val client = HttpClient(clientAdapter(), settings) client.start() diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ClientTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ClientTest.kt index a730830418..a22d095ce7 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ClientTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ClientTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.http.test.async.examples import com.hexagonkt.core.require import com.hexagonkt.core.media.APPLICATION_JSON import com.hexagonkt.core.media.APPLICATION_YAML +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient @@ -30,7 +31,6 @@ import com.hexagonkt.serialization.serialize import org.junit.jupiter.api.* import java.math.BigInteger -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNull @@ -151,13 +151,13 @@ abstract class ClientTest( // clientCreation HttpClient(adapter) - HttpClient(adapter, HttpClientSettings(URL("http://host:1234/base"))) + HttpClient(adapter, HttpClientSettings(urlOf("http://host:1234/base"))) // clientCreation // clientSettingsCreation // All client settings parameters are optionals and provide default values HttpClient(adapter, HttpClientSettings( - baseUrl = URL("http://host:1234/base"), + baseUrl = urlOf("http://host:1234/base"), contentType = ContentType(APPLICATION_JSON), useCookies = true, headers = Headers(Header("x-api-Key", "cafebabe")), // Headers used in all requests @@ -276,7 +276,7 @@ abstract class ClientTest( @Test fun `Parameters are set properly` () { val clientHeaders = Headers(Header("header1", "val1", "val2")) val settings = HttpClientSettings( - baseUrl = URL("http://localhost:${server.runtimePort}"), + baseUrl = urlOf("http://localhost:${server.runtimePort}"), contentType = ContentType(APPLICATION_JSON), useCookies = false, headers = clientHeaders, @@ -374,8 +374,8 @@ abstract class ClientTest( val trustStorePassword = trust.reversed() // Key stores can be set as URIs to classpath resources (the triple slash is needed) - val keyStore = URL("classpath:ssl/$identity") - val trustStore = URL("classpath:ssl/$trust") + val keyStore = urlOf("classpath:ssl/$identity") + val trustStore = urlOf("classpath:ssl/$trust") val sslSettings = SslSettings( keyStore = keyStore, @@ -401,7 +401,7 @@ abstract class ClientTest( // We'll use the same certificate for the client (in a real scenario it would be different) val clientSettings = HttpClientSettings( - baseUrl = URL("https://localhost:${server.runtimePort}"), + baseUrl = urlOf("https://localhost:${server.runtimePort}"), sslSettings = sslSettings ) diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FilesTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FilesTest.kt index 94e21ce754..798aa163a5 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FilesTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FilesTest.kt @@ -2,6 +2,7 @@ package com.hexagonkt.http.test.async.examples import com.hexagonkt.core.media.TEXT_CSS import com.hexagonkt.core.media.TEXT_HTML +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.model.HttpRequest @@ -22,7 +23,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import java.io.File -import java.net.URL import kotlin.test.assertEquals @TestInstance(PER_CLASS) @@ -46,15 +46,15 @@ abstract class FilesTest( methods = setOf(GET), pattern = "/*", status = NOT_FOUND_404, - callback = UrlCallback(URL("classpath:public")) + callback = UrlCallback(urlOf("classpath:public")) ) path("/static") { - get("/files/*", UrlCallback(URL("classpath:assets"))) + get("/files/*", UrlCallback(urlOf("classpath:assets"))) get("/resources/*", FileCallback(File(directory))) } - get("/html/*", UrlCallback(URL("classpath:assets"))) // Serve `assets` files on `/html/*` + get("/html/*", UrlCallback(urlOf("classpath:assets"))) // Serve `assets` files on `/html/*` get("/pub/*", FileCallback(File(directory))) // Serve `test` folder on `/pub/*` post("/multipart") { @@ -154,7 +154,7 @@ abstract class FilesTest( @Test fun `Sending files works properly`() { // clientFile - val stream = URL("classpath:assets/index.html").readBytes() + val stream = urlOf("classpath:assets/index.html").readBytes() val parts = listOf(HttpPart("file", stream, "index.html")) val response = client.send(HttpRequest(POST, path = "/file", parts = parts)) // clientFile diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FiltersTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FiltersTest.kt index fdf84c2012..e3cb2e63fa 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FiltersTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/FiltersTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.http.test.async.examples import com.hexagonkt.core.decodeBase64 +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -18,7 +19,6 @@ import com.hexagonkt.http.handlers.async.HttpHandler import com.hexagonkt.http.handlers.async.path import com.hexagonkt.http.test.async.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals @Suppress("FunctionName") // This class's functions are intended to be used only in tests @@ -133,7 +133,7 @@ abstract class FiltersTest( private fun authorizedClient(user: String, password: String): HttpClient { val settings = HttpClientSettings( - baseUrl = URL("http://localhost:${server.runtimePort}"), + baseUrl = urlOf("http://localhost:${server.runtimePort}"), headers = Headers(Header("authorization", basicAuth(user, password))) ) return HttpClient(clientAdapter(), settings).apply { start() } diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/HttpsTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/HttpsTest.kt index e2e430fa9a..18a1fbf5c2 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/HttpsTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/HttpsTest.kt @@ -5,6 +5,7 @@ import com.hexagonkt.core.require import com.hexagonkt.core.security.getPrivateKey import com.hexagonkt.core.security.getPublicKey import com.hexagonkt.core.security.loadKeyStore +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient @@ -20,7 +21,6 @@ import com.hexagonkt.http.handlers.async.path import com.hexagonkt.http.server.async.HttpServerSettings import com.hexagonkt.http.test.async.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFails import kotlin.test.assertNotNull @@ -34,8 +34,8 @@ abstract class HttpsTest( private val identity = "hexagonkt.p12" private val trust = "trust.p12" - private val keyStore = URL("classpath:ssl/$identity") - private val trustStore = URL("classpath:ssl/$trust") + private val keyStore = urlOf("classpath:ssl/$identity") + private val trustStore = urlOf("classpath:ssl/$trust") private val keyStorePassword = identity.reversed() private val trustStorePassword = trust.reversed() @@ -77,8 +77,8 @@ abstract class HttpsTest( val trustStorePassword = trust.reversed() // Key stores can be set as URIs to classpath resources (the triple slash is needed) - val keyStore = URL("classpath:ssl/$identity") - val trustStore = URL("classpath:ssl/$trust") + val keyStore = urlOf("classpath:ssl/$identity") + val trustStore = urlOf("classpath:ssl/$trust") val sslSettings = SslSettings( keyStore = keyStore, @@ -108,7 +108,7 @@ abstract class HttpsTest( val clientSettings = HttpClientSettings(sslSettings = sslSettings) // Create an HTTP client and make an HTTPS request - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -126,7 +126,7 @@ abstract class HttpsTest( val server = serve(serverAdapter(), handler, http2ServerSettings.copy(protocol = HTTPS)) - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -142,7 +142,7 @@ abstract class HttpsTest( val server = serve(serverAdapter(), handler, http2ServerSettings) - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -161,7 +161,7 @@ abstract class HttpsTest( // keyStoreSettings val keyStoreSettings = SslSettings( - keyStore = URL("classpath:ssl/$identity"), + keyStore = urlOf("classpath:ssl/$identity"), keyStorePassword = identity.reversed() ) // keyStoreSettings @@ -181,7 +181,7 @@ abstract class HttpsTest( // trustStoreSettings val trustStoreSettings = SslSettings( - trustStore = URL("classpath:ssl/$trust"), + trustStore = urlOf("classpath:ssl/$trust"), trustStorePassword = trust.reversed() ) // trustStoreSettings @@ -191,7 +191,7 @@ abstract class HttpsTest( ) // Create an HTTP client and make an HTTPS request - val contextPath = URL("https://localhost:${server.runtimePort}") + val contextPath = urlOf("https://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() client.get("/hello").apply { @@ -209,7 +209,7 @@ abstract class HttpsTest( assertFails { val adapter = clientAdapter() - val contextPath1 = URL("https://127.0.0.1:${server.runtimePort}") + val contextPath1 = urlOf("https://127.0.0.1:${server.runtimePort}") HttpClient(adapter, clientSettings.copy(baseUrl = contextPath1)).use { it.start() it.get("/hello") diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/SamplesTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/SamplesTest.kt index b290cc848e..872548701b 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/SamplesTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/SamplesTest.kt @@ -7,6 +7,7 @@ import com.hexagonkt.core.media.APPLICATION_JSON import com.hexagonkt.core.media.APPLICATION_XML import com.hexagonkt.core.media.TEXT_CSS import com.hexagonkt.core.media.TEXT_HTML +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -33,7 +34,6 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import java.net.InetAddress -import java.net.URL import kotlin.test.assertEquals @TestInstance(PER_CLASS) @@ -73,7 +73,7 @@ abstract class SamplesTest( // Servers implement closeable, you can use them inside a block assuring they will be closed runningServer.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(s.started()) assertEquals("Hello World!", it.get("/context/hello").body) @@ -87,7 +87,7 @@ abstract class SamplesTest( // serverCreation defaultSettingsServer.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(s.started()) assertEquals("Hello World!", it.get("/hello").body) @@ -109,7 +109,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Get greeting", it.get("/hello").body) assertEquals("Put greeting", it.put("/hello").body) @@ -136,7 +136,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Greeting", it.get("/nested/hello").body) assertEquals("Second level greeting", it.get("/nested/secondLevel/hello").body) @@ -161,7 +161,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${server.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${server.runtimePort}"))).use { it.start() assertEquals("Get client", it.get("/clients").body) @@ -329,7 +329,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.cookies += Cookie("foo", "bar") it.start() @@ -347,7 +347,7 @@ abstract class SamplesTest( assertEquals(OK_200, it.get("/cookie").status) assertEquals(INTERNAL_SERVER_ERROR_500, it.get("/halt").status) - val stream = URL("classpath:assets/index.html").readBytes() + val stream = urlOf("classpath:assets/index.html").readBytes() val parts = listOf(HttpPart("file", stream, "index.html")) val response = it.send(HttpRequest(POST, path = "/file", parts = parts)) assert(response.bodyString().contains("Hexagon")) @@ -402,7 +402,7 @@ abstract class SamplesTest( server.use { s -> s.start() - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${server.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${server.runtimePort}"))).use { it.start() assertResponse(it.get("/filters/route"), "filters route", "b-filters", "a-filters") assertResponse(it.get("/filters"), "filters") @@ -455,7 +455,7 @@ abstract class SamplesTest( } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() val errors = it.get("/errors") @@ -487,17 +487,17 @@ abstract class SamplesTest( on( status = NOT_FOUND_404, pattern = "/web/*", - callback = UrlCallback(URL("classpath:public")) + callback = UrlCallback(urlOf("classpath:public")) ) // Maps resources on 'assets' on the server root (assets/f.css -> /f.css) // '/public/css/style.css' resource would be: 'http://{host}:{port}/css/style.css' - on(status = NOT_FOUND_404, pattern = "/*", callback = UrlCallback(URL("classpath:assets"))) + on(status = NOT_FOUND_404, pattern = "/*", callback = UrlCallback(urlOf("classpath:assets"))) // files } server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assert(it.get("/web/file.txt").bodyString().startsWith("It matches this route")) @@ -526,7 +526,7 @@ abstract class SamplesTest( val server = serve(serverAdapter(), router, serverSettings) server.use { s -> - HttpClient(clientAdapter(), HttpClientSettings(URL("http://localhost:${s.runtimePort}"))).use { + HttpClient(clientAdapter(), HttpClientSettings(urlOf("http://localhost:${s.runtimePort}"))).use { it.start() assertEquals("Hi!", it.get("/hello").body) } diff --git a/templates/templates_test/src/main/kotlin/com/hexagonkt/templates/test/TemplateAdapterTest.kt b/templates/templates_test/src/main/kotlin/com/hexagonkt/templates/test/TemplateAdapterTest.kt index 5307dd41b9..58320f4351 100644 --- a/templates/templates_test/src/main/kotlin/com/hexagonkt/templates/test/TemplateAdapterTest.kt +++ b/templates/templates_test/src/main/kotlin/com/hexagonkt/templates/test/TemplateAdapterTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.templates.test +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.TemplateManager import com.hexagonkt.templates.TemplatePort import org.junit.jupiter.api.BeforeAll @@ -64,7 +65,7 @@ abstract class TemplateAdapterTest(private val url: URL, private val adapter: Te // TODO Decide if return a Toolkit exception, or leave the template engine handle it assertFails { - TemplateManager.render(URL("classpath:invalid.html"), context) + TemplateManager.render(urlOf("classpath:invalid.html"), context) } } } From 54118e522f3de0b6f4dcd5408dc1c3ef5f58a03b Mon Sep 17 00:00:00 2001 From: Arlak Date: Fri, 21 Jul 2023 20:23:05 +0530 Subject: [PATCH 05/18] Update HelloWorldTest.kt hello world docs to include missing imports --- .../test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt index 2a85126e90..89642fbc7a 100644 --- a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt +++ b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt @@ -1,12 +1,9 @@ package com.hexagonkt.http.test -import com.hexagonkt.core.media.TEXT_PLAIN import com.hexagonkt.http.client.jetty.JettyClientAdapter import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings -import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.model.OK_200 -import com.hexagonkt.http.server.HttpServer import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test @@ -16,6 +13,9 @@ import java.net.URL import kotlin.test.assertEquals // hello_world +import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.http.model.ContentType +import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.jetty.serve lateinit var server: HttpServer From 9efb91539d1da6a5304e6836d29168505725a5f5 Mon Sep 17 00:00:00 2001 From: Arlak Date: Fri, 21 Jul 2023 20:26:03 +0530 Subject: [PATCH 06/18] Update quick_start.md to include a name in the endpoint, so there's no 404 --- site/pages/quick_start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/pages/quick_start.md b/site/pages/quick_start.md index 912d1b1d27..5c9a8dac2f 100644 --- a/site/pages/quick_start.md +++ b/site/pages/quick_start.md @@ -33,7 +33,7 @@ a project from scratch following these steps: @code http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt?hello_world -5. Run the service and view the results at: [http://localhost:2010/hello][Endpoint] +5. Run the service and view the results at: [http://localhost:2010/hello/hex][Endpoint] # Dependencies Verification Hexagon's dependencies are signed, you can get the public key at the From 82df2f574dab153b75d6fbda8d4a4945bbd5034b Mon Sep 17 00:00:00 2001 From: Abhishek Kalra Date: Wed, 26 Jul 2023 03:06:25 +0530 Subject: [PATCH 07/18] imports added to ReadMe --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cdf1c9ad78..ee5563f713 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,9 @@ from scratch following these steps: ```kotlin // hello_world +import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.http.model.ContentType +import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.jetty.serve lateinit var server: HttpServer From 5a8dc85477268cff3276e409488cc115cfca8368 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 29 Jul 2023 18:06:41 +0200 Subject: [PATCH 08/18] Update dependencies --- gradle.properties | 6 +++--- gradle/kotlin.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 368253f772..cca26e2e54 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,15 +34,15 @@ iconsDirectory=content kotlinVersion=1.9.0 dokkaVersion=1.8.20 mockkVersion=1.13.5 -junitVersion=5.9.3 +junitVersion=5.10.0 gatlingVersion=3.9.5 jmhVersion=1.36 -mkdocsMaterialVersion=9.1.18 +mkdocsMaterialVersion=9.1.21 mermaidDokkaVersion=0.4.4 nativeToolsVersion=0.9.23 # http_server_netty -nettyVersion=4.1.94.Final +nettyVersion=4.1.96.Final nettyTcNativeVersion=2.0.61.Final # http_server_nima diff --git a/gradle/kotlin.gradle b/gradle/kotlin.gradle index 8c29b78138..9094227b9d 100644 --- a/gradle/kotlin.gradle +++ b/gradle/kotlin.gradle @@ -35,7 +35,7 @@ repositories { } dependencies { - final String scriptJunitVersion = findProperty("junitVersion") ?: "5.9.3" + final String scriptJunitVersion = findProperty("junitVersion") ?: "5.10.0" implementation("org.jetbrains.kotlin:kotlin-stdlib") From 8361c66e485061a405164f72eb85dd999e8fc78c Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 29 Jul 2023 18:22:43 +0200 Subject: [PATCH 09/18] Run Detekt explicitly --- gradle/detekt.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gradle/detekt.gradle b/gradle/detekt.gradle index 08465eb725..4c509092f0 100644 --- a/gradle/detekt.gradle +++ b/gradle/detekt.gradle @@ -4,6 +4,10 @@ apply(plugin: "io.gitlab.arturbosch.detekt") +check { + dependsOn(dependsOn.findAll { it != "detekt" }) +} + detekt { final String detektConfigPath = findProperty("detektConfigPath") From 86d80688529f9179b897102370c7a0be23fec143 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 29 Jul 2023 19:37:06 +0200 Subject: [PATCH 10/18] Update Nima --- gradle.properties | 2 +- .../http/server/nima/NimaServerAdapter.kt | 32 +++++++------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index cca26e2e54..34c2fb6d1d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ nettyVersion=4.1.96.Final nettyTcNativeVersion=2.0.61.Final # http_server_nima -nimaVersion=4.0.0-ALPHA6 +nimaVersion=4.0.0-M1 # http_server_servlet servletVersion=5.0.0 diff --git a/http/http_server_nima/src/main/kotlin/com/hexagonkt/http/server/nima/NimaServerAdapter.kt b/http/http_server_nima/src/main/kotlin/com/hexagonkt/http/server/nima/NimaServerAdapter.kt index 5a91205d52..7f0b61d1d0 100644 --- a/http/http_server_nima/src/main/kotlin/com/hexagonkt/http/server/nima/NimaServerAdapter.kt +++ b/http/http_server_nima/src/main/kotlin/com/hexagonkt/http/server/nima/NimaServerAdapter.kt @@ -17,7 +17,6 @@ import com.hexagonkt.http.server.HttpServerPort import io.helidon.common.http.Http.* import io.helidon.common.http.HttpMediaType import io.helidon.common.http.SetCookie -import io.helidon.nima.common.tls.Tls import io.helidon.nima.webserver.WebServer import io.helidon.nima.webserver.http.ServerResponse import java.security.SecureRandom @@ -54,28 +53,10 @@ class NimaServerAdapter : HttpServerPort { .byMethod() .mapKeys { Method.create(it.key.toString()) } - nimaServer = WebServer + val serverBuilder = WebServer .builder() .host(settings.bindAddress.hostName) .port(settings.bindPort) - .defaultSocket { - val b = it - .port(settings.bindPort) - .host(settings.bindAddress.hostName) - .backlog(8192) - - if (sslSettings == null) - b - else - b.tls( - Tls.builder() - .sslParameters( - SSLParameters().apply { needClientAuth = sslSettings.clientAuth } - ) - .sslContext(sslContext(sslSettings)) - .build() - ) - } .routing { it.any({ nimaRequest, nimaResponse -> val method = nimaRequest.prologue().method() @@ -84,7 +65,16 @@ class NimaServerAdapter : HttpServerPort { setResponse(response, nimaResponse) }) } - .build() + + if (sslSettings != null) + serverBuilder.tls { + val sslClientAuth = sslSettings.clientAuth + it + .sslParameters(SSLParameters().apply { needClientAuth = sslClientAuth }) + .sslContext(sslContext(sslSettings)) + } + + nimaServer = serverBuilder.build() nimaServer?.start() ?: error(startErrorMessage) } From 51a894e769a19ae866cc09cfef161cd8bfc27653 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 30 Jul 2023 13:33:34 +0200 Subject: [PATCH 11/18] Fix native tests --- .../native-image/com.hexagonkt/core/native-image.properties | 2 ++ .../native-image/com.hexagonkt/handlers/native-image.properties | 2 ++ .../com.hexagonkt/handlers_async/native-image.properties | 2 ++ .../native-image/com.hexagonkt/http/native-image.properties | 2 ++ .../com.hexagonkt/http_client/native-image.properties | 2 ++ .../com.hexagonkt/http_client_jetty/native-image.properties | 2 ++ .../com.hexagonkt/http_client_jetty_ws/native-image.properties | 2 ++ .../com.hexagonkt/http_handlers/native-image.properties | 2 ++ .../com.hexagonkt/http_handlers_async/native-image.properties | 2 ++ .../com.hexagonkt/http_server/native-image.properties | 2 ++ .../com.hexagonkt/http_server_async/native-image.properties | 2 ++ .../com.hexagonkt/http_server_jetty/native-image.properties | 2 ++ .../com.hexagonkt/http_server_netty/native-image.properties | 2 ++ .../http_server_netty_async/native-image.properties | 2 ++ .../http_server_netty_epoll/native-image.properties | 2 ++ .../http_server_netty_epoll_async/native-image.properties | 2 ++ .../com.hexagonkt/http_server_nima/native-image.properties | 2 ++ .../com.hexagonkt/http_server_servlet/native-image.properties | 2 ++ .../com.hexagonkt/http_test/native-image.properties | 2 ++ .../native-image/com.hexagonkt/rest/native-image.properties | 2 ++ .../com.hexagonkt/rest_tools/native-image.properties | 2 ++ .../store_mongodb_json/native-image.properties | 2 ++ .../com.hexagonkt/logging_jul/native-image.properties | 2 ++ .../com.hexagonkt/logging_logback/native-image.properties | 2 ++ .../com.hexagonkt/logging_slf4j_jul/native-image.properties | 2 ++ .../com.hexagonkt/serialization/native-image.properties | 2 ++ .../serialization_dsl_json/native-image.properties | 2 ++ .../com.hexagonkt/serialization_jackson/native-image.properties | 2 ++ .../serialization_jackson_csv/native-image.properties | 2 ++ .../serialization_jackson_json/native-image.properties | 2 ++ .../serialization_jackson_toml/native-image.properties | 2 ++ .../serialization_jackson_xml/native-image.properties | 2 ++ .../serialization_jackson_yaml/native-image.properties | 2 ++ .../com.hexagonkt/serialization_test/native-image.properties | 2 ++ .../com.hexagonkt/templates/native-image.properties | 2 ++ .../com.hexagonkt/templates_freemarker/native-image.properties | 2 ++ .../com.hexagonkt/templates_pebble/native-image.properties | 2 ++ .../com.hexagonkt/templates_rocker/native-image.properties | 2 ++ 38 files changed, 76 insertions(+) diff --git a/core/src/test/resources/META-INF/native-image/com.hexagonkt/core/native-image.properties b/core/src/test/resources/META-INF/native-image/com.hexagonkt/core/native-image.properties index 6487e38f2d..732c4a853b 100644 --- a/core/src/test/resources/META-INF/native-image/com.hexagonkt/core/native-image.properties +++ b/core/src/test/resources/META-INF/native-image/com.hexagonkt/core/native-image.properties @@ -2,6 +2,8 @@ Args= \ -ea \ -H:IncludeResources=.* \ --enable-url-protocols=ftp \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=org.junit.jupiter.api.condition.OS \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/handlers/src/test/resources/META-INF/native-image/com.hexagonkt/handlers/native-image.properties b/handlers/src/test/resources/META-INF/native-image/com.hexagonkt/handlers/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/handlers/src/test/resources/META-INF/native-image/com.hexagonkt/handlers/native-image.properties +++ b/handlers/src/test/resources/META-INF/native-image/com.hexagonkt/handlers/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/handlers_async/native-image.properties b/handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/handlers_async/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/handlers_async/native-image.properties +++ b/handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/handlers_async/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http/src/test/resources/META-INF/native-image/com.hexagonkt/http/native-image.properties b/http/http/src/test/resources/META-INF/native-image/com.hexagonkt/http/native-image.properties index 0d93e41bec..ab5856836f 100644 --- a/http/http/src/test/resources/META-INF/native-image/com.hexagonkt/http/native-image.properties +++ b/http/http/src/test/resources/META-INF/native-image/com.hexagonkt/http/native-image.properties @@ -1,5 +1,7 @@ Args= \ -ea \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_client/src/test/resources/META-INF/native-image/com.hexagonkt/http_client/native-image.properties b/http/http_client/src/test/resources/META-INF/native-image/com.hexagonkt/http_client/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_client/src/test/resources/META-INF/native-image/com.hexagonkt/http_client/native-image.properties +++ b/http/http_client/src/test/resources/META-INF/native-image/com.hexagonkt/http_client/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_client_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty/native-image.properties b/http/http_client_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_client_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty/native-image.properties +++ b/http/http_client_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_client_jetty_ws/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty_ws/native-image.properties b/http/http_client_jetty_ws/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty_ws/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_client_jetty_ws/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty_ws/native-image.properties +++ b/http/http_client_jetty_ws/src/test/resources/META-INF/native-image/com.hexagonkt/http_client_jetty_ws/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_handlers/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers/native-image.properties b/http/http_handlers/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_handlers/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers/native-image.properties +++ b/http/http_handlers/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers_async/native-image.properties b/http/http_handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers_async/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers_async/native-image.properties +++ b/http/http_handlers_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_handlers_async/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server/src/test/resources/META-INF/native-image/com.hexagonkt/http_server/native-image.properties b/http/http_server/src/test/resources/META-INF/native-image/com.hexagonkt/http_server/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/http/http_server/src/test/resources/META-INF/native-image/com.hexagonkt/http_server/native-image.properties +++ b/http/http_server/src/test/resources/META-INF/native-image/com.hexagonkt/http_server/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_async/native-image.properties b/http/http_server_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_async/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/http/http_server_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_async/native-image.properties +++ b/http/http_server_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_async/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_jetty/native-image.properties b/http/http_server_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_jetty/native-image.properties index 9493100333..7a9b5c163c 100644 --- a/http/http_server_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_jetty/native-image.properties +++ b/http/http_server_jetty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_jetty/native-image.properties @@ -1,4 +1,6 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=org.junit.jupiter.api.condition.OS \ --initialize-at-build-time=org.junit.jupiter.api.condition.JRE \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ diff --git a/http/http_server_netty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty/native-image.properties b/http/http_server_netty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/http/http_server_netty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty/native-image.properties +++ b/http/http_server_netty/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_netty_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_async/native-image.properties b/http/http_server_netty_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_async/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_server_netty_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_async/native-image.properties +++ b/http/http_server_netty_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_async/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_netty_epoll/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll/native-image.properties b/http/http_server_netty_epoll/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll/native-image.properties index be3417e4bb..99f66b76d2 100644 --- a/http/http_server_netty_epoll/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll/native-image.properties +++ b/http/http_server_netty_epoll/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll/native-image.properties @@ -1,5 +1,7 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=org.junit.jupiter.api.condition.OS \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_netty_epoll_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll_async/native-image.properties b/http/http_server_netty_epoll_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll_async/native-image.properties index be3417e4bb..99f66b76d2 100644 --- a/http/http_server_netty_epoll_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll_async/native-image.properties +++ b/http/http_server_netty_epoll_async/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_netty_epoll_async/native-image.properties @@ -1,5 +1,7 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=org.junit.jupiter.api.condition.OS \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_nima/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_nima/native-image.properties b/http/http_server_nima/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_nima/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_server_nima/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_nima/native-image.properties +++ b/http/http_server_nima/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_nima/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_server_servlet/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_servlet/native-image.properties b/http/http_server_servlet/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_servlet/native-image.properties index ce0280453d..561aa3628a 100644 --- a/http/http_server_servlet/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_servlet/native-image.properties +++ b/http/http_server_servlet/src/test/resources/META-INF/native-image/com.hexagonkt/http_server_servlet/native-image.properties @@ -1,4 +1,6 @@ Args= \ --enable-preview \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/http_test/src/test/resources/META-INF/native-image/com.hexagonkt/http_test/native-image.properties b/http/http_test/src/test/resources/META-INF/native-image/com.hexagonkt/http_test/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/http_test/src/test/resources/META-INF/native-image/com.hexagonkt/http_test/native-image.properties +++ b/http/http_test/src/test/resources/META-INF/native-image/com.hexagonkt/http_test/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/rest/src/test/resources/META-INF/native-image/com.hexagonkt/rest/native-image.properties b/http/rest/src/test/resources/META-INF/native-image/com.hexagonkt/rest/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/rest/src/test/resources/META-INF/native-image/com.hexagonkt/rest/native-image.properties +++ b/http/rest/src/test/resources/META-INF/native-image/com.hexagonkt/rest/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/rest_tools/src/test/resources/META-INF/native-image/com.hexagonkt/rest_tools/native-image.properties b/http/rest_tools/src/test/resources/META-INF/native-image/com.hexagonkt/rest_tools/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/http/rest_tools/src/test/resources/META-INF/native-image/com.hexagonkt/rest_tools/native-image.properties +++ b/http/rest_tools/src/test/resources/META-INF/native-image/com.hexagonkt/rest_tools/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/http/web/src/test/resources/META-INF/native-image/com.hexagonkt.extra/store_mongodb_json/native-image.properties b/http/web/src/test/resources/META-INF/native-image/com.hexagonkt.extra/store_mongodb_json/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/http/web/src/test/resources/META-INF/native-image/com.hexagonkt.extra/store_mongodb_json/native-image.properties +++ b/http/web/src/test/resources/META-INF/native-image/com.hexagonkt.extra/store_mongodb_json/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/logging/logging_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_jul/native-image.properties b/logging/logging_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_jul/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/logging/logging_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_jul/native-image.properties +++ b/logging/logging_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_jul/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/logging/logging_logback/src/test/resources/META-INF/native-image/com.hexagonkt/logging_logback/native-image.properties b/logging/logging_logback/src/test/resources/META-INF/native-image/com.hexagonkt/logging_logback/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/logging/logging_logback/src/test/resources/META-INF/native-image/com.hexagonkt/logging_logback/native-image.properties +++ b/logging/logging_logback/src/test/resources/META-INF/native-image/com.hexagonkt/logging_logback/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/logging/logging_slf4j_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_slf4j_jul/native-image.properties b/logging/logging_slf4j_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_slf4j_jul/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/logging/logging_slf4j_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_slf4j_jul/native-image.properties +++ b/logging/logging_slf4j_jul/src/test/resources/META-INF/native-image/com.hexagonkt/logging_slf4j_jul/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization/src/test/resources/META-INF/native-image/com.hexagonkt/serialization/native-image.properties b/serialization/serialization/src/test/resources/META-INF/native-image/com.hexagonkt/serialization/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization/src/test/resources/META-INF/native-image/com.hexagonkt/serialization/native-image.properties +++ b/serialization/serialization/src/test/resources/META-INF/native-image/com.hexagonkt/serialization/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_dsl_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_dsl_json/native-image.properties b/serialization/serialization_dsl_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_dsl_json/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization_dsl_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_dsl_json/native-image.properties +++ b/serialization/serialization_dsl_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_dsl_json/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson/native-image.properties b/serialization/serialization_jackson/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/serialization/serialization_jackson/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson/native-image.properties +++ b/serialization/serialization_jackson/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson_csv/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_csv/native-image.properties b/serialization/serialization_jackson_csv/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_csv/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/serialization/serialization_jackson_csv/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_csv/native-image.properties +++ b/serialization/serialization_jackson_csv/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_csv/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_json/native-image.properties b/serialization/serialization_jackson_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_json/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization_jackson_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_json/native-image.properties +++ b/serialization/serialization_jackson_json/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_json/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson_toml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_toml/native-image.properties b/serialization/serialization_jackson_toml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_toml/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization_jackson_toml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_toml/native-image.properties +++ b/serialization/serialization_jackson_toml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_toml/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson_xml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_xml/native-image.properties b/serialization/serialization_jackson_xml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_xml/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/serialization/serialization_jackson_xml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_xml/native-image.properties +++ b/serialization/serialization_jackson_xml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_xml/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_jackson_yaml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_yaml/native-image.properties b/serialization/serialization_jackson_yaml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_yaml/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization_jackson_yaml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_yaml/native-image.properties +++ b/serialization/serialization_jackson_yaml/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_jackson_yaml/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/serialization/serialization_test/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_test/native-image.properties b/serialization/serialization_test/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_test/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/serialization/serialization_test/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_test/native-image.properties +++ b/serialization/serialization_test/src/test/resources/META-INF/native-image/com.hexagonkt/serialization_test/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/templates/templates/src/test/resources/META-INF/native-image/com.hexagonkt/templates/native-image.properties b/templates/templates/src/test/resources/META-INF/native-image/com.hexagonkt/templates/native-image.properties index f68b9ce179..42b6a04b08 100644 --- a/templates/templates/src/test/resources/META-INF/native-image/com.hexagonkt/templates/native-image.properties +++ b/templates/templates/src/test/resources/META-INF/native-image/com.hexagonkt/templates/native-image.properties @@ -1,3 +1,5 @@ Args= \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/templates/templates_freemarker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_freemarker/native-image.properties b/templates/templates_freemarker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_freemarker/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/templates/templates_freemarker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_freemarker/native-image.properties +++ b/templates/templates_freemarker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_freemarker/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/templates/templates_pebble/src/test/resources/META-INF/native-image/com.hexagonkt/templates_pebble/native-image.properties b/templates/templates_pebble/src/test/resources/META-INF/native-image/com.hexagonkt/templates_pebble/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/templates/templates_pebble/src/test/resources/META-INF/native-image/com.hexagonkt/templates_pebble/native-image.properties +++ b/templates/templates_pebble/src/test/resources/META-INF/native-image/com.hexagonkt/templates_pebble/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget diff --git a/templates/templates_rocker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_rocker/native-image.properties b/templates/templates_rocker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_rocker/native-image.properties index 63f352c059..bfd028b3be 100644 --- a/templates/templates_rocker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_rocker/native-image.properties +++ b/templates/templates_rocker/src/test/resources/META-INF/native-image/com.hexagonkt/templates_rocker/native-image.properties @@ -1,4 +1,6 @@ Args= \ -H:IncludeResources=.* \ + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig \ + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter \ --initialize-at-build-time=kotlin.annotation.AnnotationRetention \ --initialize-at-build-time=kotlin.annotation.AnnotationTarget From fe5f671b91d3a585400c59cd798bdd805f0d3044 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 30 Jul 2023 14:21:56 +0200 Subject: [PATCH 12/18] Update dependencies --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 60a4a1271d..a33bf9b5bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ plugins { id("com.github.jk1.dependency-license-report") version("2.5") id("org.jetbrains.kotlinx.binary-compatibility-validator") version("0.13.2") id("org.graalvm.buildtools.native") version("0.9.23") apply(false) - id("io.gitlab.arturbosch.detekt") version("1.23.0") apply(false) + id("io.gitlab.arturbosch.detekt") version("1.23.1") apply(false) id("me.champeau.jmh") version("0.7.1") apply(false) } From c646e1881936b2e36bc37bddbce4171d68e509b7 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 31 Jul 2023 12:18:07 +0200 Subject: [PATCH 13/18] Fix warnings --- .../hexagonkt/http/server/callbacks/UrlCallback.kt | 2 +- .../http/server/callbacks/UrlCallbackTest.kt | 12 ++++++------ .../http/server/async/callbacks/UrlCallback.kt | 2 +- .../http/server/async/callbacks/UrlCallbackTest.kt | 12 ++++++------ .../kotlin/com/hexagonkt/http/test/ws/WebSocket.kt | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt index 36ff221aaa..4024688a64 100644 --- a/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt +++ b/http/http_server/src/main/kotlin/com/hexagonkt/http/server/callbacks/UrlCallback.kt @@ -28,7 +28,7 @@ class UrlCallback(private val url: URL) : (HttpContext) -> HttpContext { val url = when { requestPath.isEmpty() -> url.toString() - url.toString() == "classpath:" -> "$url$requestPath" + url.toString() == "classpath:/" -> "classpath:$requestPath" else -> "$url/$requestPath" } diff --git a/http/http_server/src/test/kotlin/com/hexagonkt/http/server/callbacks/UrlCallbackTest.kt b/http/http_server/src/test/kotlin/com/hexagonkt/http/server/callbacks/UrlCallbackTest.kt index 1a95b83f12..abf0b9dd12 100644 --- a/http/http_server/src/test/kotlin/com/hexagonkt/http/server/callbacks/UrlCallbackTest.kt +++ b/http/http_server/src/test/kotlin/com/hexagonkt/http/server/callbacks/UrlCallbackTest.kt @@ -1,13 +1,13 @@ package com.hexagonkt.http.server.callbacks import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.* import com.hexagonkt.http.patterns.TemplatePathPattern import com.hexagonkt.http.handlers.HttpContext import com.hexagonkt.http.handlers.HttpPredicate import kotlin.test.Test import kotlin.IllegalStateException -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNull @@ -16,7 +16,7 @@ internal class UrlCallbackTest { @Test fun `Request referencing parent directories raises an error`() { val e = assertFailsWith { - processUrlCallback("classpath:", "/params/../1", "/params/*") + processUrlCallback("classpath:/", "/params/../1", "/params/*") } assertEquals("Requested path cannot contain '..': ../1", e.message) @@ -31,7 +31,7 @@ internal class UrlCallbackTest { } @Test fun `Filter with one parameter resolves to content`() { - val result = processUrlCallback("classpath:", "/params/hexagonkt.p12", "/params/*") + val result = processUrlCallback("classpath:/", "/params/hexagonkt.p12", "/params/*") assertEquals(OK_200, result.status) assertNull(result.contentType) @@ -45,14 +45,14 @@ internal class UrlCallbackTest { } @Test fun `Filter with one parameter resolves to missing content`() { - val result = processUrlCallback("classpath:", "/params/foo.bar", "/params/*") + val result = processUrlCallback("classpath:/", "/params/foo.bar", "/params/*") assertEquals(NOT_FOUND_404, result.status) assertEquals("classpath:foo.bar cannot be open", result.bodyString()) } @Test fun `Filter with a directory resolves to missing content`() { - val result = processUrlCallback("classpath:", "/params/foo/", "/params/*") + val result = processUrlCallback("classpath:/", "/params/foo/", "/params/*") assertEquals(NOT_FOUND_404, result.status) assertEquals("foo/ not found (folder)", result.bodyString()) @@ -70,7 +70,7 @@ internal class UrlCallbackTest { requestPath: String, pathPattern: String ): HttpResponsePort = - UrlCallback(URL(url))( + UrlCallback(urlOf(url))( HttpContext( HttpCall(HttpRequest(path = requestPath)), HttpPredicate(pathPattern = TemplatePathPattern(pathPattern)) diff --git a/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt b/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt index 0a725ba73b..4a57cf940d 100644 --- a/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt +++ b/http/http_server_async/src/main/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallback.kt @@ -30,7 +30,7 @@ class UrlCallback(private val url: URL) : (HttpContext) -> CompletableFuture url.toString() - url.toString() == "classpath:" -> "$url$requestPath" + url.toString() == "classpath:/" -> "classpath:$requestPath" else -> "$url/$requestPath" } diff --git a/http/http_server_async/src/test/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallbackTest.kt b/http/http_server_async/src/test/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallbackTest.kt index eef451619a..643d82eec7 100644 --- a/http/http_server_async/src/test/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallbackTest.kt +++ b/http/http_server_async/src/test/kotlin/com/hexagonkt/http/server/async/callbacks/UrlCallbackTest.kt @@ -1,13 +1,13 @@ package com.hexagonkt.http.server.async.callbacks import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.* import com.hexagonkt.http.patterns.TemplatePathPattern import com.hexagonkt.http.handlers.async.HttpContext import com.hexagonkt.http.handlers.async.HttpPredicate import kotlin.test.Test import kotlin.IllegalStateException -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNull @@ -16,7 +16,7 @@ internal class UrlCallbackTest { @Test fun `Request referencing parent directories raises an error`() { val e = assertFailsWith { - processUrlCallback("classpath:", "/params/../1", "/params/*") + processUrlCallback("classpath:/", "/params/../1", "/params/*") } assertEquals("Requested path cannot contain '..': ../1", e.message) @@ -31,7 +31,7 @@ internal class UrlCallbackTest { } @Test fun `Filter with one parameter resolves to content`() { - val result = processUrlCallback("classpath:", "/params/hexagonkt.p12", "/params/*") + val result = processUrlCallback("classpath:/", "/params/hexagonkt.p12", "/params/*") assertEquals(OK_200, result.status) assertNull(result.contentType) @@ -45,14 +45,14 @@ internal class UrlCallbackTest { } @Test fun `Filter with one parameter resolves to missing content`() { - val result = processUrlCallback("classpath:", "/params/foo.bar", "/params/*") + val result = processUrlCallback("classpath:/", "/params/foo.bar", "/params/*") assertEquals(NOT_FOUND_404, result.status) assertEquals("classpath:foo.bar cannot be open", result.bodyString()) } @Test fun `Filter with a directory resolves to missing content`() { - val result = processUrlCallback("classpath:", "/params/foo/", "/params/*") + val result = processUrlCallback("classpath:/", "/params/foo/", "/params/*") assertEquals(NOT_FOUND_404, result.status) assertEquals("foo/ not found (folder)", result.bodyString()) @@ -70,7 +70,7 @@ internal class UrlCallbackTest { requestPath: String, pathPattern: String ): HttpResponsePort = - UrlCallback(URL(url))( + UrlCallback(urlOf(url))( HttpContext( HttpCall(HttpRequest(path = requestPath)), HttpPredicate(pathPattern = TemplatePathPattern(pathPattern)) diff --git a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/ws/WebSocket.kt b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/ws/WebSocket.kt index 50fbe4e842..7ed65c7d7e 100644 --- a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/ws/WebSocket.kt +++ b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/ws/WebSocket.kt @@ -1,12 +1,12 @@ package com.hexagonkt.http.test.ws import com.hexagonkt.core.logging.logger +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.ServerEvent import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.callbacks.UrlCallback import com.hexagonkt.http.model.ws.WsSession import com.hexagonkt.http.server.netty.serve -import java.net.URL import java.util.concurrent.* import java.util.concurrent.TimeUnit.MILLISECONDS import java.util.function.Supplier @@ -56,7 +56,7 @@ fun main () { var sessions = emptyList() server = serve { - get(callback = UrlCallback(URL("classpath:ws.html"))) + get(callback = UrlCallback(urlOf("classpath:ws.html"))) get("/sse") { val body = event(executor, 2_000) { ServerEvent(data = System.currentTimeMillis().toString()) From 64d2d4887f535ab1547b1f24cb46965004e930f0 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 31 Jul 2023 21:28:21 +0200 Subject: [PATCH 14/18] Fix module definition --- http/http_client_jetty_ws/src/main/kotlin/module-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/http/http_client_jetty_ws/src/main/kotlin/module-info.java b/http/http_client_jetty_ws/src/main/kotlin/module-info.java index 594c94961f..465a725068 100644 --- a/http/http_client_jetty_ws/src/main/kotlin/module-info.java +++ b/http/http_client_jetty_ws/src/main/kotlin/module-info.java @@ -2,6 +2,7 @@ module com.hexagonkt.http_client_jetty_ws { requires transitive kotlin.stdlib; + requires transitive com.hexagonkt.core; requires transitive com.hexagonkt.http_client_jetty; requires transitive org.eclipse.jetty.io; requires transitive org.eclipse.jetty.util; From 262a352a4012b39a3fa8d891bb6fb834ba43302d Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 31 Jul 2023 21:42:26 +0200 Subject: [PATCH 15/18] :Fix warnings --- .../core/ClasspathHandlerProviderTest.kt | 15 +++++++------- .../hexagonkt/core/HexagonCoreSamplesTest.kt | 3 +-- .../test/kotlin/com/hexagonkt/core/JvmTest.kt | 5 ++--- .../hexagonkt/core/media/MediaTypesTest.kt | 20 +++++++++---------- .../hexagonkt/core/security/KeyStoresTest.kt | 4 ++-- site/build.gradle.kts | 2 +- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/core/src/test/kotlin/com/hexagonkt/core/ClasspathHandlerProviderTest.kt b/core/src/test/kotlin/com/hexagonkt/core/ClasspathHandlerProviderTest.kt index 3cf229cf06..f34e53b1b9 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/ClasspathHandlerProviderTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/ClasspathHandlerProviderTest.kt @@ -7,7 +7,6 @@ import kotlin.test.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import java.net.MalformedURLException -import java.net.URL import kotlin.test.assertFailsWith @TestInstance(PER_CLASS) @@ -23,26 +22,26 @@ internal class ClasspathHandlerProviderTest { } @Test fun `Require classpath resource`() { - val resource = URL("classpath:application_test.yml") + val resource = urlOf("classpath:application_test.yml") assert(resource.file == resource.file) val e = assertFailsWith { - URL("classpath:foo.txt").openConnection() + urlOf("classpath:foo.txt").openConnection() } assert(e.message == "classpath:foo.txt cannot be open") } @Test fun `Classpath resource folder`() { - assert(URL("classpath:data").readText().lines().isNotEmpty()) + assert(urlOf("classpath:data").readText().lines().isNotEmpty()) } @Test fun `Read classpath resource returns resource's text` () { - val resourceText = URL("classpath:sample.properties").readText() + val resourceText = urlOf("classpath:sample.properties").readText() assert(resourceText.contains("handlers=com.hexagonkt.core.logging.jul.SystemStreamHandler")) } @Test fun `Unknown protocol throws exception`() { val e = assertFailsWith { - assert(URL("unknown:data").readText().lines().isNotEmpty()) + assert(urlOf("unknown:data").readText().lines().isNotEmpty()) } val errorJvm = "unknown protocol: unknown" @@ -52,7 +51,7 @@ internal class ClasspathHandlerProviderTest { } @Test fun `Resource loading using URL returns data`() { - assert(URL("classpath:data/companies.json").readText().isNotBlank()) - assert(URL("file:README.md").readText().isNotBlank()) + assert(urlOf("classpath:data/companies.json").readText().isNotBlank()) + assert(urlOf("file:README.md").readText().isNotBlank()) } } diff --git a/core/src/test/kotlin/com/hexagonkt/core/HexagonCoreSamplesTest.kt b/core/src/test/kotlin/com/hexagonkt/core/HexagonCoreSamplesTest.kt index be3fb2137f..19c4d14910 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/HexagonCoreSamplesTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/HexagonCoreSamplesTest.kt @@ -4,14 +4,13 @@ import com.hexagonkt.core.logging.logger import com.hexagonkt.core.logging.Logger import com.hexagonkt.core.logging.LoggingLevel.* import com.hexagonkt.core.logging.LoggingManager -import java.net.URL import kotlin.test.Test import kotlin.test.assertContains internal class HexagonCoreSamplesTest { @Test fun buildPropertiesBundled() { - val hexagonProperties = URL("classpath:hexagon.properties").readText() + val hexagonProperties = urlOf("classpath:hexagon.properties").readText() assertContains(hexagonProperties, "project=") assertContains(hexagonProperties, "module=") diff --git a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt index 538f143dc9..982a455a54 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt @@ -4,7 +4,6 @@ import kotlin.test.Test import kotlin.IllegalArgumentException import java.net.Inet4Address import java.net.URI -import java.net.URL import kotlin.test.* internal class JvmTest { @@ -58,7 +57,7 @@ internal class JvmTest { System.setProperty("validFloat", 0.5F.toString()) System.setProperty("validDouble", 1.5.toString()) System.setProperty("validInetAddress", LOOPBACK_INTERFACE.hostName) - System.setProperty("validURL", URL("http://localhost:1234/path").toString()) + System.setProperty("validURL", urlOf("http://localhost:1234/path").toString()) System.setProperty("validURI", URI("ws://localhost:1234/path").toString()) System.setProperty("invalidBoolean", "_") System.setProperty("invalidInt", "_") @@ -77,7 +76,7 @@ internal class JvmTest { assertEquals(0.5F, Jvm.systemSetting("validFloat")) assertEquals(1.5, Jvm.systemSetting("validDouble")) assertEquals(LOOPBACK_INTERFACE, Jvm.systemSetting("validInetAddress")) - assertEquals(URL("http://localhost:1234/path"), Jvm.systemSetting("validURL")) + assertEquals(urlOf("http://localhost:1234/path"), Jvm.systemSetting("validURL")) assertEquals(URI("ws://localhost:1234/path"), Jvm.systemSetting("validURI")) assertNull(Jvm.systemSettingOrNull("invalidInt")) diff --git a/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypesTest.kt b/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypesTest.kt index 2067940d18..4297ff70e4 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypesTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypesTest.kt @@ -1,12 +1,12 @@ package com.hexagonkt.core.media import com.hexagonkt.core.media.MediaTypeGroup.* +import com.hexagonkt.core.urlOf import kotlin.test.Test import java.io.File import java.net.URI import kotlin.IllegalArgumentException import kotlin.IllegalStateException -import java.net.URL import java.nio.file.Path import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -44,14 +44,14 @@ internal class MediaTypesTest { @Test fun `Media types of files and URLs can be retrieved`() { assertEquals(APPLICATION_TOML, mediaTypeOfOrNull(URI("http://localhost/file.toml"))) - assertEquals(TEXT_PLAIN, mediaTypeOfOrNull(URL("http://localhost/file.txt"))) - assertEquals(APPLICATION_JSON, mediaTypeOfOrNull(URL("http://localhost/file.json"))) + assertEquals(TEXT_PLAIN, mediaTypeOfOrNull(urlOf("http://localhost/file.txt"))) + assertEquals(APPLICATION_JSON, mediaTypeOfOrNull(urlOf("http://localhost/file.json"))) assertEquals(APPLICATION_TOML, mediaTypeOf(URI("http://localhost/file.toml"))) - assertEquals(TEXT_PLAIN, mediaTypeOf(URL("http://localhost/file.txt"))) - assertEquals(APPLICATION_JSON, mediaTypeOf(URL("http://localhost/file.json"))) + assertEquals(TEXT_PLAIN, mediaTypeOf(urlOf("http://localhost/file.txt"))) + assertEquals(APPLICATION_JSON, mediaTypeOf(urlOf("http://localhost/file.json"))) assertEquals(APPLICATION_AVRO, mediaTypeOf("avro")) - assertNull(mediaTypeOfOrNull(URL("http://localhost/file"))) - assertNull(mediaTypeOfOrNull(URL("http://localhost/file.foo"))) + assertNull(mediaTypeOfOrNull(urlOf("http://localhost/file"))) + assertNull(mediaTypeOfOrNull(urlOf("http://localhost/file.foo"))) assertEquals(TEXT_HTML, mediaTypeOfOrNull(File("file.html"))) assertEquals(TEXT_HTML, mediaTypeOfOrNull(File("file.htm"))) @@ -64,7 +64,7 @@ internal class MediaTypesTest { assertNull(mediaTypeOfOrNull(File("file"))) assertNull(mediaTypeOfOrNull(File("file.baz"))) assertNull(mediaTypeOfOrNull(URI("http://localhost/file.baz"))) - assertNull(mediaTypeOfOrNull(URL("http://localhost/file.baz"))) + assertNull(mediaTypeOfOrNull(urlOf("http://localhost/file.baz"))) assertEquals(TEXT_HTML, mediaTypeOfOrNull(Path.of("file.html"))) assertEquals(TEXT_HTML, mediaTypeOfOrNull(Path.of("file.htm"))) assertEquals(APPLICATION_YAML, mediaTypeOfOrNull(Path.of("file.yaml"))) @@ -80,12 +80,12 @@ internal class MediaTypesTest { @Test fun `Exception is thrown if the media type is not found`() { assertEquals( "Media type not found for: 'http://host/f' URL", - assertFailsWith { mediaTypeOf(URL("http://host/f")) }.message + assertFailsWith { mediaTypeOf(urlOf("http://host/f")) }.message ) assertEquals( "Media type not found for: 'http://host/f.foo' URL", - assertFailsWith { mediaTypeOf(URL("http://host/f.foo")) }.message + assertFailsWith { mediaTypeOf(urlOf("http://host/f.foo")) }.message ) assertEquals( diff --git a/core/src/test/kotlin/com/hexagonkt/core/security/KeyStoresTest.kt b/core/src/test/kotlin/com/hexagonkt/core/security/KeyStoresTest.kt index b311b1dd34..5f4ee536a3 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/security/KeyStoresTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/security/KeyStoresTest.kt @@ -1,10 +1,10 @@ package com.hexagonkt.core.security +import com.hexagonkt.core.urlOf import kotlin.test.Test import org.junit.jupiter.api.condition.DisabledOnOs import org.junit.jupiter.api.condition.OS.WINDOWS import java.io.File -import java.net.URL import java.security.cert.X509Certificate import kotlin.test.assertEquals @@ -18,7 +18,7 @@ internal class KeyStoresTest { val pwd = f.reversed() val p = if (File("http_test").exists()) "http/http_test" else "../http/http_test" - val ks = loadKeyStore(URL("file:$p/src/main/resources/ssl/$f"), pwd) + val ks = loadKeyStore(urlOf("file:$p/src/main/resources/ssl/$f"), pwd) val public = ks.getPublicKey(n) val private = ks.getPrivateKey(n, pwd) val cert = ks.getCertificate(n) as X509Certificate diff --git a/site/build.gradle.kts b/site/build.gradle.kts index 66a53f421f..4685fc27e7 100644 --- a/site/build.gradle.kts +++ b/site/build.gradle.kts @@ -210,7 +210,7 @@ fun insertSamplesCode(parent: File, content: String): String = content.replace("@code (.*)".toRegex()) { try { val sampleLocation = it.groups[1]?.value?.trim() ?: error("Location expected") - val url = java.net.URL("file:${parent.absolutePath}/$sampleLocation") + val url = java.net.URI("file:${parent.absolutePath}/$sampleLocation").toURL() val tag = "// ${url.query}" val lines = url.readText().lines() val text = lines.slice(lines.rangeOf(tag)).joinToString("\n").trimIndent() From 9b2e42969eb69d08b96fe0f4d6dae3e2aa066705 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 31 Jul 2023 22:19:45 +0200 Subject: [PATCH 16/18] :Fix warnings --- .../hexagonkt/http/model/HttpRequestTest.kt | 10 ++++---- .../hexagonkt/http/client/HttpClientTest.kt | 6 ++--- .../server/jetty/JettyServletAdapterTest.kt | 4 ++-- .../server/jetty/poc/JettyWsServerTest.kt | 4 ++-- .../http/server/servlet/ServletServerTest.kt | 4 ++-- .../com/hexagonkt/http/test/HelloWorldTest.kt | 4 ++-- .../com/hexagonkt/http/test/async/BaseTest.kt | 4 ++-- .../test/async/examples/WebSocketsTest.kt | 10 ++++---- .../http/test/async/examples/ZipTest.kt | 6 ++--- .../com/hexagonkt/http/test/HelloWorldTest.kt | 4 ++-- .../http/test/openapi/OpenApiHandlerTest.kt | 4 ++-- .../test/kotlin/com/hexagonkt/web/WebTest.kt | 8 +++---- .../com/hexagonkt/web/examples/TodoTest.kt | 4 ++-- .../serialization/SerializationManagerTest.kt | 4 ++-- .../serialization/SerializationTest.kt | 16 ++++++------- .../hexagonkt/serialization/TestUtilities.kt | 6 ++--- .../serialization/dsl/json/JsonTest.kt | 9 +++---- .../serialization/jackson/json/JsonTest.kt | 9 +++---- .../serialization/jackson/toml/TomlTest.kt | 5 ++-- .../serialization/jackson/yaml/YamlTest.kt | 5 ++-- .../serialization/SerializationHelpersTest.kt | 10 ++++---- .../templates/TemplateManagerTest.kt | 24 +++++++++---------- .../templates/examples/TemplatesTest.kt | 9 +++---- .../templates/freemarker/FreeMarkerAdapter.kt | 5 ++-- .../freemarker/FreeMarkerAdapterTest.kt | 8 +++---- .../FreeMarkerTemplateAdapterTest.kt | 4 ++-- .../templates/pebble/PebbleAdapterTest.kt | 12 +++++----- .../pebble/PebbleTemplateAdapterTest.kt | 4 ++-- .../templates/rocker/RockerAdapterTest.kt | 4 ++-- .../rocker/RockerTemplateAdapterTest.kt | 4 ++-- 30 files changed, 108 insertions(+), 102 deletions(-) diff --git a/http/http/src/test/kotlin/com/hexagonkt/http/model/HttpRequestTest.kt b/http/http/src/test/kotlin/com/hexagonkt/http/model/HttpRequestTest.kt index 890c8ce93d..c4d5d11ad0 100644 --- a/http/http/src/test/kotlin/com/hexagonkt/http/model/HttpRequestTest.kt +++ b/http/http/src/test/kotlin/com/hexagonkt/http/model/HttpRequestTest.kt @@ -6,10 +6,10 @@ import com.hexagonkt.core.media.TEXT_HTML import com.hexagonkt.core.media.TEXT_PLAIN import com.hexagonkt.core.media.TEXT_RICHTEXT import com.hexagonkt.core.security.loadKeyStore +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.HttpMethod.POST import com.hexagonkt.http.model.HttpMethod.PUT import com.hexagonkt.http.model.HttpProtocol.* -import java.net.URL import java.security.cert.X509Certificate import kotlin.test.* @@ -116,7 +116,7 @@ internal class HttpRequestTest { } private val keyStoreResource = "hexagonkt.p12" - private val keyStoreUrl = URL("classpath:$keyStoreResource") + private val keyStoreUrl = urlOf("classpath:$keyStoreResource") private val keyStore = loadKeyStore(keyStoreUrl, keyStoreResource.reversed()) private val certificate = keyStore.getCertificate("hexagonkt") private val certificates = listOf(certificate as X509Certificate) @@ -239,11 +239,11 @@ internal class HttpRequestTest { } @Test fun `URL is generated correctly`() { - assertEquals(URL("http://localhost/path?qp1=value1&qp1=value2"), TestRequest.url()) + assertEquals(urlOf("http://localhost/path?qp1=value1&qp1=value2"), TestRequest.url()) testPort = 9999 - assertEquals(URL("http://localhost:9999/path?qp1=value1&qp1=value2"), TestRequest.url()) + assertEquals(urlOf("http://localhost:9999/path?qp1=value1&qp1=value2"), TestRequest.url()) testQueryParameters = QueryParameters() - assertEquals(URL("http://localhost:9999/path"), TestRequest.url()) + assertEquals(urlOf("http://localhost:9999/path"), TestRequest.url()) } @Test fun `HTTP Request operators work ok`() { diff --git a/http/http_client/src/test/kotlin/com/hexagonkt/http/client/HttpClientTest.kt b/http/http_client/src/test/kotlin/com/hexagonkt/http/client/HttpClientTest.kt index a455566de1..6a417cb396 100644 --- a/http/http_client/src/test/kotlin/com/hexagonkt/http/client/HttpClientTest.kt +++ b/http/http_client/src/test/kotlin/com/hexagonkt/http/client/HttpClientTest.kt @@ -1,11 +1,11 @@ package com.hexagonkt.http.client import com.hexagonkt.core.media.TEXT_CSV +import com.hexagonkt.core.urlOf import com.hexagonkt.http.handlers.FilterHandler import com.hexagonkt.http.model.HttpResponsePort import com.hexagonkt.http.model.* import java.lang.StringBuilder -import java.net.URL import java.util.concurrent.Flow import java.util.concurrent.Flow.Subscription import kotlin.test.* @@ -19,7 +19,7 @@ internal class HttpClientTest { assertFalse(HttpClient(VoidAdapter, noCookiesSettings).settings.useCookies) val base = "http://example.org" - val baseUrl = URL(base) + val baseUrl = urlOf(base) assertEquals( baseUrl, HttpClient(VoidAdapter, HttpClientSettings(baseUrl)).settings.baseUrl @@ -32,7 +32,7 @@ internal class HttpClientTest { HttpClient(VoidAdapter, noCookiesSettings.copy(baseUrl = baseUrl)).settings.useCookies ) - val settingsBaseUrl = URL("http://server.com") + val settingsBaseUrl = urlOf("http://server.com") val baseUrlSettings = HttpClientSettings(baseUrl = settingsBaseUrl) assertEquals( baseUrl, diff --git a/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/JettyServletAdapterTest.kt b/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/JettyServletAdapterTest.kt index abe82cc74e..c433345bc3 100644 --- a/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/JettyServletAdapterTest.kt +++ b/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/JettyServletAdapterTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.http.server.jetty import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings import com.hexagonkt.http.client.jetty.JettyWsClientAdapter @@ -11,7 +12,6 @@ import kotlin.test.Test import org.junit.jupiter.api.condition.EnabledForJreRange import org.junit.jupiter.api.condition.JRE.JAVA_17 import org.junit.jupiter.api.condition.JRE.JAVA_19 -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -53,7 +53,7 @@ internal class JettyServletAdapterTest { val server = serve(handlers = path) server.use { s -> - val settings = HttpClientSettings(URL("http://localhost:${s.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${s.runtimePort}")) HttpClient(JettyWsClientAdapter(), settings).use { it.start() val result = it.get("/hello/Ada") diff --git a/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/poc/JettyWsServerTest.kt b/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/poc/JettyWsServerTest.kt index dfd660309d..ef552a2bf6 100644 --- a/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/poc/JettyWsServerTest.kt +++ b/http/http_server_jetty/src/test/kotlin/com/hexagonkt/http/server/jetty/poc/JettyWsServerTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.http.server.jetty.poc +import com.hexagonkt.core.urlOf import jakarta.servlet.* import org.eclipse.jetty.server.Server import org.eclipse.jetty.server.ServerConnector @@ -22,7 +23,6 @@ import org.junit.jupiter.api.condition.DisabledInNativeImage import kotlin.test.Test import org.junit.jupiter.api.condition.DisabledOnOs import org.junit.jupiter.api.condition.OS.WINDOWS -import java.net.URL import kotlin.test.assertEquals @DisabledOnOs(WINDOWS) // TODO Investigate what makes this test fail on Windows @@ -85,7 +85,7 @@ internal class JettyWsServerTest { var result = "" - val settings = HttpClientSettings(URL("http://localhost:8080")) + val settings = HttpClientSettings(urlOf("http://localhost:8080")) val httpClient = HttpClient(JettyWsClientAdapter(), settings) httpClient.start() val ws = httpClient.ws( diff --git a/http/http_server_servlet/src/test/kotlin/com/hexagonkt/http/server/servlet/ServletServerTest.kt b/http/http_server_servlet/src/test/kotlin/com/hexagonkt/http/server/servlet/ServletServerTest.kt index d4ea96645c..c0f4e8fd25 100644 --- a/http/http_server_servlet/src/test/kotlin/com/hexagonkt/http/server/servlet/ServletServerTest.kt +++ b/http/http_server_servlet/src/test/kotlin/com/hexagonkt/http/server/servlet/ServletServerTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.http.server.servlet import com.hexagonkt.core.logging.LoggingLevel.DEBUG import com.hexagonkt.core.logging.LoggingLevel.OFF import com.hexagonkt.core.logging.LoggingManager +import com.hexagonkt.core.urlOf import com.hexagonkt.logging.jul.JulLoggingAdapter import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings @@ -17,7 +18,6 @@ import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import java.net.InetSocketAddress import jakarta.servlet.annotation.WebListener -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertNull import org.eclipse.jetty.server.Server as JettyServer @@ -57,7 +57,7 @@ internal class ServletServerTest { } @Test fun `Servlet server starts`() { - val settings = HttpClientSettings(URL("http://127.0.0.1:9897")) + val settings = HttpClientSettings(urlOf("http://127.0.0.1:9897")) HttpClient(JettyClientAdapter(), settings).use { it.start() assertEquals("Hello Servlet!", it.get("/").body) diff --git a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt index 89642fbc7a..5877384ff7 100644 --- a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt +++ b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt @@ -9,11 +9,11 @@ import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import kotlin.test.assertEquals // hello_world import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.jetty.serve @@ -37,7 +37,7 @@ fun main() { internal class HelloWorldTest { private val client: HttpClient by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(JettyClientAdapter(), settings) } diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/BaseTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/BaseTest.kt index d7b0e7eec3..71950010c5 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/BaseTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/BaseTest.kt @@ -4,6 +4,7 @@ import com.hexagonkt.core.encodeToBase64 import com.hexagonkt.core.logging.LoggingLevel.DEBUG import com.hexagonkt.core.logging.LoggingLevel.OFF import com.hexagonkt.core.logging.LoggingManager +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort import com.hexagonkt.http.client.HttpClientSettings @@ -19,7 +20,6 @@ import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import kotlin.test.assertEquals @TestInstance(PER_CLASS) @@ -35,7 +35,7 @@ abstract class BaseTest { } protected val client: HttpClient by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(clientAdapter(), settings) } diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/WebSocketsTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/WebSocketsTest.kt index d53e7c51e4..e2687245ec 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/WebSocketsTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/WebSocketsTest.kt @@ -2,6 +2,7 @@ package com.hexagonkt.http.test.async.examples import com.hexagonkt.core.logging.logger import com.hexagonkt.core.require +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient @@ -18,7 +19,6 @@ import com.hexagonkt.http.server.async.HttpServerSettings import com.hexagonkt.http.test.async.BaseTest import org.junit.jupiter.api.Test import kotlin.IllegalStateException -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFails import kotlin.test.assertFailsWith @@ -33,8 +33,8 @@ abstract class WebSocketsTest( private val identity = "hexagonkt.p12" private val trust = "trust.p12" - private val keyStore = URL("classpath:ssl/$identity") - private val trustStore = URL("classpath:ssl/$trust") + private val keyStore = urlOf("classpath:ssl/$identity") + private val trustStore = urlOf("classpath:ssl/$trust") private val keyStorePassword = identity.reversed() private val trustStorePassword = trust.reversed() @@ -108,7 +108,7 @@ abstract class WebSocketsTest( // ws_server @Test fun `WebSockets client check start and stop states`() { - val settings = clientSettings.copy(baseUrl = URL("https://localhost:9999")) + val settings = clientSettings.copy(baseUrl = urlOf("https://localhost:9999")) val client = HttpClient(clientAdapter(), settings) assertEquals( @@ -152,7 +152,7 @@ abstract class WebSocketsTest( ) { val server = serve(serverAdapter(), handler, serverSettings) - val contextPath = URL("$protocol://localhost:${server.runtimePort}") + val contextPath = urlOf("$protocol://localhost:${server.runtimePort}") val client = HttpClient(clientAdapter(), clientSettings.copy(baseUrl = contextPath)) client.start() diff --git a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ZipTest.kt b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ZipTest.kt index 88b464b2be..76770cd2ad 100644 --- a/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ZipTest.kt +++ b/http/http_test_async/src/main/kotlin/com/hexagonkt/http/test/async/examples/ZipTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.http.test.async.examples +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -12,7 +13,6 @@ import com.hexagonkt.http.handlers.async.path import com.hexagonkt.http.server.async.HttpServerSettings import com.hexagonkt.http.test.async.BaseTest import org.junit.jupiter.api.Test -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertNull @@ -40,7 +40,7 @@ abstract class ZipTest( } server.start() - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) val client = HttpClient(clientAdapter(), settings) client.start() @@ -69,7 +69,7 @@ abstract class ZipTest( } server.start() - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) val client = HttpClient(clientAdapter(), settings) client.start() diff --git a/http/http_test_async/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt b/http/http_test_async/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt index b16917bf5f..fa8847b610 100644 --- a/http/http_test_async/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt +++ b/http/http_test_async/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.http.test import com.hexagonkt.core.media.TEXT_PLAIN +import com.hexagonkt.core.urlOf import com.hexagonkt.handlers.async.done import com.hexagonkt.http.client.jetty.JettyClientAdapter import com.hexagonkt.http.client.HttpClient @@ -13,7 +14,6 @@ import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import kotlin.test.assertEquals // hello_world @@ -38,7 +38,7 @@ fun main() { internal class HelloWorldTest { private val client: HttpClient by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(JettyClientAdapter(), settings) } diff --git a/http/rest_tools/src/test/kotlin/com/hexagonkt/http/test/openapi/OpenApiHandlerTest.kt b/http/rest_tools/src/test/kotlin/com/hexagonkt/http/test/openapi/OpenApiHandlerTest.kt index 373c9b6e9d..49b00cb6e8 100644 --- a/http/rest_tools/src/test/kotlin/com/hexagonkt/http/test/openapi/OpenApiHandlerTest.kt +++ b/http/rest_tools/src/test/kotlin/com/hexagonkt/http/test/openapi/OpenApiHandlerTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.http.test.openapi +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings import com.hexagonkt.http.client.jetty.JettyClientAdapter @@ -7,7 +8,6 @@ import com.hexagonkt.http.model.* import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.jetty.JettyServletAdapter import org.junit.jupiter.api.* -import java.net.URL import kotlin.test.assertEquals @Disabled // TODO Fix this functionality @@ -19,7 +19,7 @@ internal class OpenApiHandlerTest { } private val client by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(JettyClientAdapter(), settings) } diff --git a/http/web/src/test/kotlin/com/hexagonkt/web/WebTest.kt b/http/web/src/test/kotlin/com/hexagonkt/web/WebTest.kt index 98aca91b6b..2b7dc12592 100644 --- a/http/web/src/test/kotlin/com/hexagonkt/web/WebTest.kt +++ b/http/web/src/test/kotlin/com/hexagonkt/web/WebTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.web +import com.hexagonkt.core.urlOf import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings import com.hexagonkt.http.client.jetty.JettyClientAdapter @@ -16,7 +17,6 @@ import org.junit.jupiter.api.BeforeAll import kotlin.test.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import java.time.LocalDateTime import kotlin.test.assertContains import kotlin.test.assertEquals @@ -29,7 +29,7 @@ internal class WebTest { private val router: PathHandler = path { get("/template") { template( - url = URL("classpath:templates/pebble_template.html"), + url = urlOf("classpath:templates/pebble_template.html"), context = callContext() + ("date" to LocalDateTime.now()) ) } @@ -37,7 +37,7 @@ internal class WebTest { get("/template/adapter") { template( templateEngine = templateEngine, - url = URL("classpath:templates/pebble_template.html"), + url = urlOf("classpath:templates/pebble_template.html"), context = callContext() + ("date" to LocalDateTime.now()) ) } @@ -48,7 +48,7 @@ internal class WebTest { } private val client by lazy { - val settings = HttpClientSettings(URL("http://localhost:${server.runtimePort}")) + val settings = HttpClientSettings(urlOf("http://localhost:${server.runtimePort}")) HttpClient(JettyClientAdapter(), settings) } diff --git a/http/web/src/test/kotlin/com/hexagonkt/web/examples/TodoTest.kt b/http/web/src/test/kotlin/com/hexagonkt/web/examples/TodoTest.kt index 42ca7095df..38b10b7458 100644 --- a/http/web/src/test/kotlin/com/hexagonkt/web/examples/TodoTest.kt +++ b/http/web/src/test/kotlin/com/hexagonkt/web/examples/TodoTest.kt @@ -7,6 +7,7 @@ import com.hexagonkt.core.logging.Logger import com.hexagonkt.core.logging.LoggingLevel.DEBUG import com.hexagonkt.core.logging.LoggingManager import com.hexagonkt.core.media.APPLICATION_JSON +import com.hexagonkt.core.urlOf import com.hexagonkt.logging.jul.JulLoggingAdapter import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientSettings @@ -22,7 +23,6 @@ import org.junit.jupiter.api.BeforeAll import kotlin.test.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS -import java.net.URL import kotlin.test.assertEquals /** @@ -145,7 +145,7 @@ abstract class TodoTest(adapter: HttpServerPort) { HttpClient( JettyClientAdapter(), HttpClientSettings( - baseUrl = URL("http://localhost:${server.runtimePort}"), + baseUrl = urlOf("http://localhost:${server.runtimePort}"), contentType = ContentType(APPLICATION_JSON) ) ) diff --git a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationManagerTest.kt b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationManagerTest.kt index c50dc1b646..edcd594ee2 100644 --- a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationManagerTest.kt +++ b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationManagerTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.serialization import com.hexagonkt.core.media.* +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.SerializationManager.defaultFormat import com.hexagonkt.serialization.SerializationManager.formatOf import com.hexagonkt.serialization.SerializationManager.formatOfOrNull @@ -9,7 +10,6 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import kotlin.test.Test import java.io.File -import java.net.URL import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNull @@ -88,7 +88,7 @@ internal class SerializationManagerTest { @Test fun `Searching serialization format for content types, URLs, files and resources works`() { assertEquals(TextTestFormat, formatOf(APPLICATION_PHP)) assertEquals(TextTestFormat, formatOf(mediaTypeOf("php"))) - assertEquals(TextTestFormat, formatOf(mediaTypeOf(URL("http://l/a.php")))) + assertEquals(TextTestFormat, formatOf(mediaTypeOf(urlOf("http://l/a.php")))) assertEquals(TextTestFormat, formatOf(mediaTypeOf(File("f.php")))) } } diff --git a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationTest.kt b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationTest.kt index 070d7d6d79..f7b01cae61 100644 --- a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationTest.kt +++ b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/SerializationTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.serialization import com.hexagonkt.core.decodeBase64 import com.hexagonkt.core.media.APPLICATION_PHP import com.hexagonkt.core.media.APPLICATION_AVRO +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.Department.DESIGN import com.hexagonkt.serialization.Department.DEVELOPMENT import com.hexagonkt.serialization.jackson.json.Json @@ -10,7 +11,6 @@ import kotlin.test.Test import java.io.File import java.net.InetAddress import kotlin.IllegalStateException -import java.net.URL import java.nio.ByteBuffer import java.time.LocalDate import java.time.LocalDateTime @@ -78,8 +78,8 @@ internal class SerializationTest { assertEquals("string".parse(TextTestFormat), "string".parse(APPLICATION_PHP)) assertEquals("string".parse(BinaryTestFormat), "string".parse(APPLICATION_AVRO)) - assertEquals(listOf("text"), URL("classpath:data/company.php").parse()) - assertEquals(listOf("bytes"), URL("classpath:data/company.avro").parse()) + assertEquals(listOf("text"), urlOf("classpath:data/company.php").parse()) + assertEquals(listOf("bytes"), urlOf("classpath:data/company.avro").parse()) val resources = "src/test/resources" val phpFile = File("$resources/data/company.php").let { @@ -99,25 +99,25 @@ internal class SerializationTest { @Test fun `Data serialization helpers convert data properly`() { SerializationManager.formats = setOf(Json) - URL("classpath:data/company.json").parse().toData(::Company).first().apply { + urlOf("classpath:data/company.json").parse().toData(::Company).first().apply { assertEquals("id1", id) assertEquals(LocalDate.of(2014, 1, 25), foundation) assertEquals(LocalTime.of(11, 42), closeTime) assertEquals(LocalTime.of(8, 30)..LocalTime.of(14, 51), openTime) - assertEquals(URL("http://example.org"), web) + assertEquals(urlOf("http://example.org"), web) assertEquals(setOf(Person("John"), Person("Mike")), people) assertEquals(LocalDateTime.of(2016, 1, 1, 0, 0), creationDate) assertEquals(InetAddress.getByName("127.0.0.1"), host) } - URL("classpath:data/companies.json").parse().toData(::Company).first().apply { - val clientList = listOf(URL("http://c1.example.org"), URL("http://c2.example.org")) + urlOf("classpath:data/companies.json").parse().toData(::Company).first().apply { + val clientList = listOf(urlOf("http://c1.example.org"), urlOf("http://c2.example.org")) assertEquals("id", id) assertEquals(LocalDate.of(2014, 1, 25), foundation) assertEquals(LocalTime.of(11, 42), closeTime) assertEquals(LocalTime.of(8, 30)..LocalTime.of(14, 51), openTime) - assertEquals(URL("http://example.org"), web) + assertEquals(urlOf("http://example.org"), web) assertEquals(clientList, clients) assertEquals(ByteBuffer.wrap("AAEC".decodeBase64()), logo) assertEquals("notes", notes) diff --git a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/TestUtilities.kt b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/TestUtilities.kt index 8121f6c7f3..b34f343407 100644 --- a/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/TestUtilities.kt +++ b/serialization/serialization/src/test/kotlin/com/hexagonkt/serialization/TestUtilities.kt @@ -45,7 +45,7 @@ internal data class Company( foundation = LocalDate.now(), closeTime = LocalTime.now(), openTime = LocalTime.now()..LocalTime.now(), - web = URL("http://example.com"), + web = urlOf("http://example.com"), people = emptySet(), host = InetAddress.getLocalHost(), averageMargin = 0.0F, @@ -81,8 +81,8 @@ internal data class Company( start..end } ?: openTime, - web = data.getString(Company::web)?.let(::URL) ?: web, - clients = data.getStrings(Company::clients)?.map(::URL) ?: clients, + web = data.getString(Company::web)?.let(::urlOf) ?: web, + clients = data.getStrings(Company::clients)?.map(::urlOf) ?: clients, logo = data.getString(Company::logo)?.let { ByteBuffer.wrap(it.decodeBase64()) } ?: logo, notes = data[Company::notes], diff --git a/serialization/serialization_dsl_json/src/test/kotlin/com/hexagonkt/serialization/dsl/json/JsonTest.kt b/serialization/serialization_dsl_json/src/test/kotlin/com/hexagonkt/serialization/dsl/json/JsonTest.kt index 180d46bc85..2acae15ce1 100644 --- a/serialization/serialization_dsl_json/src/test/kotlin/com/hexagonkt/serialization/dsl/json/JsonTest.kt +++ b/serialization/serialization_dsl_json/src/test/kotlin/com/hexagonkt/serialization/dsl/json/JsonTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.serialization.dsl.json +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.SerializationFormat import com.hexagonkt.serialization.parse import com.hexagonkt.serialization.test.SerializationTest @@ -14,13 +15,13 @@ internal class JsonTest : SerializationTest() { override val format: SerializationFormat = Json override val urls: List = listOf( - URL("classpath:data/companies.json"), - URL("classpath:data/company.json"), + urlOf("classpath:data/companies.json"), + urlOf("classpath:data/company.json"), ) @Test fun `Parse URL generates the correct collection`() { - assert(URL("classpath:data/companies.json").parse() is List<*>) - assert(URL("classpath:data/company.json").parse() is Map<*, *>) + assert(urlOf("classpath:data/companies.json").parse() is List<*>) + assert(urlOf("classpath:data/company.json").parse() is Map<*, *>) } @Test fun `Test Jackson text format`() { diff --git a/serialization/serialization_jackson_json/src/test/kotlin/com/hexagonkt/serialization/jackson/json/JsonTest.kt b/serialization/serialization_jackson_json/src/test/kotlin/com/hexagonkt/serialization/jackson/json/JsonTest.kt index 7c70cc9da9..cfeb9e39d8 100644 --- a/serialization/serialization_jackson_json/src/test/kotlin/com/hexagonkt/serialization/jackson/json/JsonTest.kt +++ b/serialization/serialization_jackson_json/src/test/kotlin/com/hexagonkt/serialization/jackson/json/JsonTest.kt @@ -1,5 +1,6 @@ package com.hexagonkt.serialization.jackson.json +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.SerializationFormat import com.hexagonkt.serialization.parse import com.hexagonkt.serialization.test.SerializationTest @@ -12,13 +13,13 @@ internal class JsonTest : SerializationTest() { override val format: SerializationFormat = Json override val urls: List = listOf( - URL("classpath:data/companies.json"), - URL("classpath:data/company.json"), + urlOf("classpath:data/companies.json"), + urlOf("classpath:data/company.json"), ) @Test fun `Parse URL generates the correct collection`() { - assert(URL("classpath:data/companies.json").parse() is List<*>) - assert(URL("classpath:data/company.json").parse() is Map<*, *>) + assert(urlOf("classpath:data/companies.json").parse() is List<*>) + assert(urlOf("classpath:data/company.json").parse() is Map<*, *>) } @Test fun `Test Jackson text format`() { diff --git a/serialization/serialization_jackson_toml/src/test/kotlin/com/hexagonkt/serialization/jackson/toml/TomlTest.kt b/serialization/serialization_jackson_toml/src/test/kotlin/com/hexagonkt/serialization/jackson/toml/TomlTest.kt index e9d4890953..6449012a8e 100644 --- a/serialization/serialization_jackson_toml/src/test/kotlin/com/hexagonkt/serialization/jackson/toml/TomlTest.kt +++ b/serialization/serialization_jackson_toml/src/test/kotlin/com/hexagonkt/serialization/jackson/toml/TomlTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.serialization.jackson.toml import com.hexagonkt.core.fieldsMapOfNotNull import com.hexagonkt.core.require import com.hexagonkt.core.requirePath +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.* import com.hexagonkt.serialization.test.SerializationTest import org.junit.jupiter.api.BeforeAll @@ -16,8 +17,8 @@ internal class TomlTest : SerializationTest() { override val format: SerializationFormat = Toml override val urls: List = listOf( - URL("classpath:data/companies.toml"), - URL("classpath:data/company.toml"), + urlOf("classpath:data/companies.toml"), + urlOf("classpath:data/company.toml"), ) data class Player(val name: String, val number: Int, val category: ClosedRange) diff --git a/serialization/serialization_jackson_yaml/src/test/kotlin/com/hexagonkt/serialization/jackson/yaml/YamlTest.kt b/serialization/serialization_jackson_yaml/src/test/kotlin/com/hexagonkt/serialization/jackson/yaml/YamlTest.kt index 9ad416e85a..fc471eb145 100644 --- a/serialization/serialization_jackson_yaml/src/test/kotlin/com/hexagonkt/serialization/jackson/yaml/YamlTest.kt +++ b/serialization/serialization_jackson_yaml/src/test/kotlin/com/hexagonkt/serialization/jackson/yaml/YamlTest.kt @@ -3,6 +3,7 @@ package com.hexagonkt.serialization.jackson.yaml import com.hexagonkt.core.fieldsMapOfNotNull import com.hexagonkt.core.require import com.hexagonkt.core.requirePath +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.* import com.hexagonkt.serialization.test.SerializationTest import org.junit.jupiter.api.BeforeAll @@ -16,8 +17,8 @@ internal class YamlTest : SerializationTest() { override val format: SerializationFormat = Yaml override val urls: List = listOf( - URL("classpath:data/companies.yml"), - URL("classpath:data/company.yml"), + urlOf("classpath:data/companies.yml"), + urlOf("classpath:data/company.yml"), ) data class Player(val name: String, val number: Int, val category: ClosedRange) diff --git a/serialization/serialization_test/src/test/kotlin/com/hexagonkt/serialization/SerializationHelpersTest.kt b/serialization/serialization_test/src/test/kotlin/com/hexagonkt/serialization/SerializationHelpersTest.kt index aacbd74de1..8ec4c75045 100644 --- a/serialization/serialization_test/src/test/kotlin/com/hexagonkt/serialization/SerializationHelpersTest.kt +++ b/serialization/serialization_test/src/test/kotlin/com/hexagonkt/serialization/SerializationHelpersTest.kt @@ -2,10 +2,10 @@ package com.hexagonkt.serialization import com.hexagonkt.core.media.APPLICATION_JSON import com.hexagonkt.core.toStream +import com.hexagonkt.core.urlOf import com.hexagonkt.serialization.jackson.json.Json import org.junit.jupiter.api.Test import java.io.File -import java.net.URL import java.nio.file.Path import kotlin.test.assertFailsWith @@ -16,16 +16,16 @@ internal class SerializationHelpersTest { } @Test fun `Parse URL helpers fails if parsed type does not match`() { - assertFailsWith { URL("classpath:companies.json").parseMap() } + assertFailsWith { urlOf("classpath:companies.json").parseMap() } .apply { assert(message?.endsWith("cannot be cast to Map") ?: false) } - assertFailsWith { URL("classpath:company.json").parseList() } + assertFailsWith { urlOf("classpath:company.json").parseList() } .apply { assert(message?.endsWith("cannot be cast to List") ?: false) } } @Test fun `Parse URL helpers generates the correct collection`() { - assert(URL("classpath:companies.json").parseList().isNotEmpty()) - assert(URL("classpath:company.json").parseMap().isNotEmpty()) + assert(urlOf("classpath:companies.json").parseList().isNotEmpty()) + assert(urlOf("classpath:company.json").parseMap().isNotEmpty()) } @Test fun `Parse file helpers generates the correct collection`() { diff --git a/templates/templates/src/test/kotlin/com/hexagonkt/templates/TemplateManagerTest.kt b/templates/templates/src/test/kotlin/com/hexagonkt/templates/TemplateManagerTest.kt index 5d3d0f51c6..f783f0e6bd 100644 --- a/templates/templates/src/test/kotlin/com/hexagonkt/templates/TemplateManagerTest.kt +++ b/templates/templates/src/test/kotlin/com/hexagonkt/templates/TemplateManagerTest.kt @@ -1,10 +1,10 @@ package com.hexagonkt.templates import com.hexagonkt.core.Glob +import com.hexagonkt.core.urlOf import org.junit.jupiter.api.Assertions.assertEquals import kotlin.test.Test import org.junit.jupiter.api.assertThrows -import java.net.URL import kotlin.test.assertFailsWith internal class TemplateManagerTest { @@ -15,8 +15,8 @@ internal class TemplateManagerTest { TemplateManager.adapters = mapOf(Regex(".*") to SampleTemplateAdapter("default")) - val html = TemplateManager.render(URL("classpath:template.html"), context) - val plain = TemplateManager.render(URL("classpath:template.txt"), context) + val html = TemplateManager.render(urlOf("classpath:template.html"), context) + val plain = TemplateManager.render(urlOf("classpath:template.txt"), context) assertEquals("default:classpath:template.html", html) assertEquals("default:classpath:template.txt", plain) @@ -28,11 +28,11 @@ internal class TemplateManagerTest { TemplateManager.adapters = mapOf(Regex(".*\\.html") to SampleTemplateAdapter("html")) - val html = TemplateManager.render(URL("classpath:template.html"), context) + val html = TemplateManager.render(urlOf("classpath:template.html"), context) assertEquals("html:classpath:template.html", html) assertFailsWith { - TemplateManager.render(URL("classpath:template.txt"), context) + TemplateManager.render(urlOf("classpath:template.txt"), context) } } @@ -45,14 +45,14 @@ internal class TemplateManagerTest { Regex(".*\\.txt") to SampleTemplateAdapter("text") ) - val html = TemplateManager.render(URL("classpath:template.html"), context) - val plain = TemplateManager.render(URL("classpath:template.txt"), context) + val html = TemplateManager.render(urlOf("classpath:template.html"), context) + val plain = TemplateManager.render(urlOf("classpath:template.txt"), context) assertEquals("html:classpath:template.html", html) assertEquals("text:classpath:template.txt", plain) assertFailsWith { - TemplateManager.render(URL("classpath:template.svg"), context) + TemplateManager.render(urlOf("classpath:template.svg"), context) } } @@ -65,8 +65,8 @@ internal class TemplateManagerTest { Regex(".*") to SampleTemplateAdapter("*"), ) - val html = TemplateManager.render(URL("classpath:template.txt"), context) - val plain = TemplateManager.render(URL("classpath:template.txz"), context) + val html = TemplateManager.render(urlOf("classpath:template.txt"), context) + val plain = TemplateManager.render(urlOf("classpath:template.txz"), context) assertEquals("txt:classpath:template.txt", html) assertEquals("*:classpath:template.txz", plain) @@ -76,7 +76,7 @@ internal class TemplateManagerTest { Glob("*.txt").regex to SampleTemplateAdapter("txt"), ) - val render = TemplateManager.render(URL("classpath:template.txt"), context) + val render = TemplateManager.render(urlOf("classpath:template.txt"), context) assertEquals("*:classpath:template.txt", render) } @@ -85,7 +85,7 @@ internal class TemplateManagerTest { val resource = "classpath:test.pebble.html" assertThrows { - TemplateManager.render(URL(resource), mapOf()) + TemplateManager.render(urlOf(resource), mapOf()) } } } diff --git a/templates/templates/src/test/kotlin/com/hexagonkt/templates/examples/TemplatesTest.kt b/templates/templates/src/test/kotlin/com/hexagonkt/templates/examples/TemplatesTest.kt index ac728ead0d..fb3eb460b0 100644 --- a/templates/templates/src/test/kotlin/com/hexagonkt/templates/examples/TemplatesTest.kt +++ b/templates/templates/src/test/kotlin/com/hexagonkt/templates/examples/TemplatesTest.kt @@ -1,6 +1,7 @@ package com.hexagonkt.templates.examples import com.hexagonkt.core.Glob +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.SampleTemplateAdapter import com.hexagonkt.templates.TemplateManager import com.hexagonkt.templates.TemplatePort @@ -39,7 +40,7 @@ class TemplatesTest { // templateUsage val context = mapOf("key1" to "value1", "key2" to "value2") - val rendered = TemplateManager.render(URL("classpath:template.txt"), context) + val rendered = TemplateManager.render(urlOf("classpath:template.txt"), context) // templateUsage assert(rendered.startsWith("classpath:template.txt {key1=value1, key2=value2")) @@ -49,9 +50,9 @@ class TemplatesTest { private fun checkRegisteredAdapters() { val context = mapOf() - val html = TemplateManager.render(URL("classpath:template.html"), context) - val plain = TemplateManager.render(URL("classpath:template.txt"), context) - val others = TemplateManager.render(URL("classpath:template.other"), context) + val html = TemplateManager.render(urlOf("classpath:template.html"), context) + val plain = TemplateManager.render(urlOf("classpath:template.txt"), context) + val others = TemplateManager.render(urlOf("classpath:template.other"), context) assertEquals("html:classpath:template.html", html) assertEquals("text:classpath:template.txt", plain) diff --git a/templates/templates_freemarker/src/main/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapter.kt b/templates/templates_freemarker/src/main/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapter.kt index de7b7f8c30..898d5eb0fa 100644 --- a/templates/templates_freemarker/src/main/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapter.kt +++ b/templates/templates_freemarker/src/main/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapter.kt @@ -1,6 +1,7 @@ package com.hexagonkt.templates.freemarker import com.hexagonkt.core.ResourceNotFoundException +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.TemplatePort import freemarker.cache.StringTemplateLoader import freemarker.cache.TemplateLookupContext @@ -22,7 +23,7 @@ class FreeMarkerAdapter : TemplatePort { override fun lookup(ctx: TemplateLookupContext): TemplateLookupResult = try { val templateName = ctx.templateName - URL(templateName) + urlOf(templateName) ctx.lookupWithAcquisitionStrategy(templateName) } catch (e: ResourceNotFoundException) { @@ -32,7 +33,7 @@ class FreeMarkerAdapter : TemplatePort { object AdapterTemplateLoader : URLTemplateLoader() { override fun getURL(name: String): URL = - URL(name) + urlOf(name) } override fun render(url: URL, context: Map, locale: Locale): String { diff --git a/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapterTest.kt b/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapterTest.kt index d624108745..43293c745b 100644 --- a/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapterTest.kt +++ b/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.freemarker +import com.hexagonkt.core.urlOf import kotlin.test.Test -import java.net.URL import java.time.LocalDateTime import java.util.Locale @@ -11,7 +11,7 @@ internal class FreeMarkerAdapterTest { @Test fun `Templates are rendered properly`() { val context = mapOf("_now_" to LocalDateTime.now()) - val url = URL("classpath:templates/test.freemarker.html") + val url = urlOf("classpath:templates/test.freemarker.html") val html = FreeMarkerAdapter().render(url, context, locale) assert(html.contains("This is a test template")) } @@ -22,14 +22,14 @@ internal class FreeMarkerAdapterTest { "testTitle" to "This is a test title", "testBody" to "This is a test body" ) - val html = FreeMarkerAdapter().render(URL(resource), context, locale) + val html = FreeMarkerAdapter().render(urlOf(resource), context, locale) assert(html.contains("This is a test title")) assert(html.contains("This is a test body")) } @Test fun `Dates are converted properly`() { val context = mapOf("localDate" to LocalDateTime.of(2000, 12, 31, 23, 45)) - val url = URL("classpath:templates/test_dates.freemarker.html") + val url = urlOf("classpath:templates/test_dates.freemarker.html") val html = FreeMarkerAdapter().render(url, context, locale) assert(html.contains("23:45")) assert(html.contains("2000")) diff --git a/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerTemplateAdapterTest.kt b/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerTemplateAdapterTest.kt index 6a096e36ec..51736e1921 100644 --- a/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerTemplateAdapterTest.kt +++ b/templates/templates_freemarker/src/test/kotlin/com/hexagonkt/templates/freemarker/FreeMarkerTemplateAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.freemarker +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.test.TemplateAdapterTest -import java.net.URL internal class FreeMarkerTemplateAdapterTest : - TemplateAdapterTest(URL("classpath:templates/test.freemarker.html"), FreeMarkerAdapter()) + TemplateAdapterTest(urlOf("classpath:templates/test.freemarker.html"), FreeMarkerAdapter()) diff --git a/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleAdapterTest.kt b/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleAdapterTest.kt index 46d2614da0..7ebcc09dcc 100644 --- a/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleAdapterTest.kt +++ b/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.pebble +import com.hexagonkt.core.urlOf import kotlin.test.Test -import java.net.URL import java.time.LocalDateTime import java.util.Locale @@ -12,7 +12,7 @@ internal class PebbleAdapterTest { @Test fun `Dates are converted properly`() { val context = mapOf("localDate" to LocalDateTime.of(2000, 12, 31, 23, 45)) val resource = "classpath:templates/test.pebble.html" - val html = PebbleAdapter().render(URL(resource), context, locale) + val html = PebbleAdapter().render(urlOf(resource), context, locale) assert(html.contains("23:45")) assert(html.contains("2000")) assert(html.contains("31")) @@ -21,7 +21,7 @@ internal class PebbleAdapterTest { @Test fun `Templates can be extended`() { val context = mapOf("localDate" to LocalDateTime.of(2000, 12, 31, 23, 45)) val resource = "classpath:templates/index.pebble.html" - val html = PebbleAdapter().render(URL(resource), context, locale) + val html = PebbleAdapter().render(urlOf(resource), context, locale) assert(html.contains("23:45")) assert(html.contains("2000")) assert(html.contains("31")) @@ -31,9 +31,9 @@ internal class PebbleAdapterTest { @Test fun `Templates can be loaded from custom sources`() { val context = mapOf("localDate" to LocalDateTime.of(2000, 12, 31, 23, 45)) val resources = listOf( - URL("classpath:templates/index.pebble.html"), - URL("classpath:templates/main.pebble.html"), - URL("classpath:templates/test.pebble.html"), + urlOf("classpath:templates/index.pebble.html"), + urlOf("classpath:templates/main.pebble.html"), + urlOf("classpath:templates/test.pebble.html"), ) val name = resources.first().path val templates = resources.map { it.path to it.readText() } diff --git a/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleTemplateAdapterTest.kt b/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleTemplateAdapterTest.kt index e9fddcbd5b..ea6760edd6 100644 --- a/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleTemplateAdapterTest.kt +++ b/templates/templates_pebble/src/test/kotlin/com/hexagonkt/templates/pebble/PebbleTemplateAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.pebble +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.test.TemplateAdapterTest -import java.net.URL internal class PebbleTemplateAdapterTest : - TemplateAdapterTest(URL("classpath:templates/test.pebble.html"), PebbleAdapter()) + TemplateAdapterTest(urlOf("classpath:templates/test.pebble.html"), PebbleAdapter()) diff --git a/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerAdapterTest.kt b/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerAdapterTest.kt index 32f338b853..7b6570c6c1 100644 --- a/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerAdapterTest.kt +++ b/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.rocker +import com.hexagonkt.core.urlOf import kotlin.test.Test -import java.net.URL import java.time.LocalDateTime import java.util.Locale import kotlin.test.assertEquals @@ -14,7 +14,7 @@ internal class RockerAdapterTest { @Test fun `Dates are converted properly`() { val context = mapOf("localDate" to LocalDateTime.of(2000, 12, 31, 23, 45)) val resource = "classpath:templates/test.rocker.html" - val html = RockerAdapter().render(URL(resource), context, locale) + val html = RockerAdapter().render(urlOf(resource), context, locale) assert(html.contains("23:45")) assert(html.contains("2000")) assert(html.contains("31")) diff --git a/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerTemplateAdapterTest.kt b/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerTemplateAdapterTest.kt index ab22894459..986a455602 100644 --- a/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerTemplateAdapterTest.kt +++ b/templates/templates_rocker/src/test/kotlin/com/hexagonkt/templates/rocker/RockerTemplateAdapterTest.kt @@ -1,7 +1,7 @@ package com.hexagonkt.templates.rocker +import com.hexagonkt.core.urlOf import com.hexagonkt.templates.test.TemplateAdapterTest -import java.net.URL internal class RockerTemplateAdapterTest : - TemplateAdapterTest(URL("classpath:templates/test.rocker.html"), RockerAdapter()) + TemplateAdapterTest(urlOf("classpath:templates/test.rocker.html"), RockerAdapter()) From c7fb11c6207c8be56ca83908eb851c481b3593f6 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Tue, 1 Aug 2023 00:11:24 +0200 Subject: [PATCH 17/18] :Fix warnings --- core/src/main/kotlin/com/hexagonkt/core/Strings.kt | 2 +- detekt.yml | 6 ++++-- .../main/kotlin/com/hexagonkt/http/model/HttpRequestPort.kt | 3 ++- .../src/main/kotlin/com/hexagonkt/http/test/Http.kt | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/com/hexagonkt/core/Strings.kt b/core/src/main/kotlin/com/hexagonkt/core/Strings.kt index 3b87c42623..640e244226 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Strings.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Strings.kt @@ -123,7 +123,7 @@ fun String.parse(type: KClass): T = Double::class -> this.toDoubleOrNull() String::class -> this InetAddress::class -> this.let(InetAddress::getByName) - URL::class -> this.let(::URL) + URL::class -> this.let(::urlOf) URI::class -> this.let(::URI) File::class -> this.let(::File) LocalDate::class -> LocalDate.parse(this) diff --git a/detekt.yml b/detekt.yml index b1f08aea5d..195555926c 100644 --- a/detekt.yml +++ b/detekt.yml @@ -164,7 +164,7 @@ style: active: true ForbiddenComment: active: true - values: [ TODO, FIXME ] + comments: [ TODO, FIXME ] ForbiddenVoid: active: true ignoreOverridden: false @@ -197,8 +197,10 @@ style: active: true OptionalUnit: active: true - OptionalWhenBraces: + BracesOnWhenStatements: active: true + singleLine: necessary + multiLine: necessary PreferToOverPairSyntax: active: true RedundantExplicitType: diff --git a/http/http/src/main/kotlin/com/hexagonkt/http/model/HttpRequestPort.kt b/http/http/src/main/kotlin/com/hexagonkt/http/model/HttpRequestPort.kt index 36134d7f3a..622fc0355c 100644 --- a/http/http/src/main/kotlin/com/hexagonkt/http/model/HttpRequestPort.kt +++ b/http/http/src/main/kotlin/com/hexagonkt/http/model/HttpRequestPort.kt @@ -1,5 +1,6 @@ package com.hexagonkt.http.model +import com.hexagonkt.core.urlOf import com.hexagonkt.http.formatQueryString import java.net.URL import java.security.cert.X509Certificate @@ -78,7 +79,7 @@ interface HttpRequestPort : HttpMessage { queryParameters.isEmpty() -> "${protocol.schema}://$host:$port/$path" else -> "${protocol.schema}://$host:$port/$path?${formatQueryString(queryParameters)}" } - .let(::URL) + .let(::urlOf) fun userAgent(): String? = headers["user-agent"]?.value as? String diff --git a/http/rest_tools/src/main/kotlin/com/hexagonkt/http/test/Http.kt b/http/rest_tools/src/main/kotlin/com/hexagonkt/http/test/Http.kt index 4f9403f0e4..c8389ae748 100644 --- a/http/rest_tools/src/main/kotlin/com/hexagonkt/http/test/Http.kt +++ b/http/rest_tools/src/main/kotlin/com/hexagonkt/http/test/Http.kt @@ -1,6 +1,7 @@ package com.hexagonkt.http.test import com.hexagonkt.core.media.MediaType +import com.hexagonkt.core.urlOf import com.hexagonkt.http.SslSettings import com.hexagonkt.http.client.HttpClient import com.hexagonkt.http.client.HttpClientPort @@ -53,7 +54,7 @@ data class Http( private val settings = HttpClientSettings( - baseUrl = url?.let(::URL), + baseUrl = url?.let(::urlOf), contentType = contentType, useCookies = true, headers = toHeaders(headers), From a84a54896cca39918a2322fc4cd3a79c86d0144d Mon Sep 17 00:00:00 2001 From: jaguililla Date: Tue, 1 Aug 2023 09:35:34 +0200 Subject: [PATCH 18/18] :Fix documentation --- .../src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt index 5877384ff7..e7330b642d 100644 --- a/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt +++ b/http/http_test/src/test/kotlin/com/hexagonkt/http/test/HelloWorldTest.kt @@ -10,10 +10,10 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS import kotlin.test.assertEquals +import com.hexagonkt.core.urlOf // hello_world import com.hexagonkt.core.media.TEXT_PLAIN -import com.hexagonkt.core.urlOf import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.server.HttpServer import com.hexagonkt.http.server.jetty.serve