Skip to content

Commit

Permalink
Update Hexagon
Browse files Browse the repository at this point in the history
  • Loading branch information
jaguililla committed Apr 2, 2024
1 parent c3e0ea9 commit 57ce7cd
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: temurin
cache: gradle
- name: Build Project
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ hs_err_pid*
# Other Tools
kotlin-js-store/
node_modules/
package-lock.json
.env
.sdkmanrc

# System Files
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The slides are on the `slides` folder (surprisingly). They are written in Markdo
presented by [reveal.js] and served by a Kotlin script (though you can use any other means).

For the sake of the demo, all code was contained on a single file, you can check a better structure
example in the [hexagonal_starter](https://github.com/hexagonkt/hexagonal_starter) template project.
example in the [hexagonal_starter](https://github.com/hexagontk/hexagonal_starter) template project.

Below you can find the information regarding the building and running of the presented demo
application.
Expand Down
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import org.graalvm.buildtools.gradle.dsl.GraalVMExtension
import java.lang.System.getProperty

plugins {
kotlin("jvm") version("1.8.10")
id("org.graalvm.buildtools.native") version("0.9.20")
kotlin("jvm") version("1.9.23")
id("org.graalvm.buildtools.native") version("0.10.1")
}

val options = "-Xmx48m"
val hexagonVersion = "2.6.6"
val gradleScripts = "https://raw.githubusercontent.com/hexagonkt/hexagon/$hexagonVersion/gradle"
val hexagonVersion = "3.5.3"
val gradleScripts = "https://raw.githubusercontent.com/hexagontk/hexagon/$hexagonVersion/gradle"

apply(from = "$gradleScripts/kotlin.gradle")
apply(from = "$gradleScripts/application.gradle")
Expand All @@ -31,7 +31,7 @@ extensions.configure<JavaApplication> {
dependencies {
"implementation"("com.hexagonkt:http_server_jetty:$hexagonVersion")
"implementation"("com.hexagonkt:serialization_jackson_json:$hexagonVersion")
"implementation"("org.slf4j:slf4j-nop:2.0.6")
"implementation"("org.slf4j:slf4j-nop:2.0.7")

"testImplementation"("com.hexagonkt:http_client_jetty:$hexagonVersion")
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
2 changes: 1 addition & 1 deletion slides/slides.main.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env kotlin

@file:DependsOn("com.hexagonkt:http_server_netty:2.6.6")
@file:DependsOn("com.hexagonkt:http_server_netty:3.5.3")

import com.hexagonkt.core.logging.info
import com.hexagonkt.core.logging.logger
Expand Down
8 changes: 4 additions & 4 deletions slides/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
---

## Hello World
* Check the <a href="https://hexagonkt.com/quick_start" target="_blank">
* Check the <a href="https://hexagontk.com/quick_start" target="_blank">
Quick start</a> page
* Clone a 'starter' repository
* These slides are served used Hexagon
Expand All @@ -63,7 +63,7 @@
* Application logic: use cases, services or domain
<!-- .element: class="fragment" data-fragment-index="5" -->

![Img](https://hexagonkt.com/img/architecture.svg)
![Img](https://hexagontk.com/img/architecture.svg)
<!-- .element: class="r-stretch" -->

---
Expand All @@ -76,7 +76,7 @@
* Uses the Ports/Adapters scheme, the domain is the client application
<!-- .element: class="fragment" data-fragment-index="3" -->

![Img](https://hexagonkt.com/img/architecture.svg)
![Img](https://hexagontk.com/img/architecture.svg)
<!-- .element: class="r-stretch" -->

---
Expand Down Expand Up @@ -140,5 +140,5 @@ graph TD
* Follow the [@hexagon_kt] Twitter account to be notified on Hexagon and related tools
* If you like the project, please share... And give it a ⭐

[codecv]: https://github.com/hexagonkt/codecv
[codecv]: https://github.com/hexagontk/codecv
[@hexagon_kt]: https://twitter.com/hexagon_kt
6 changes: 3 additions & 3 deletions src/main/kotlin/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.hexagonkt.http.server.*
import com.hexagonkt.http.server.jetty.JettyServletAdapter
import com.hexagonkt.core.require
import com.hexagonkt.http.model.ContentType
import com.hexagonkt.http.server.handlers.HttpHandler
import com.hexagonkt.http.server.handlers.path
import com.hexagonkt.http.handlers.HttpHandler
import com.hexagonkt.http.handlers.path
import com.hexagonkt.serialization.jackson.json.Json
import com.hexagonkt.serialization.parseMap
import com.hexagonkt.serialization.serialize
Expand Down Expand Up @@ -117,7 +117,7 @@ class RestApi(
) {
val appointmentsHandler: HttpHandler = path("/appointments") {
post {
val data = request.bodyString().parseMap(Json).mapKeys { it.key.toString() }
val data = request.bodyString().parseMap(Json).mapKeys { it.key }
val user = AppointmentMessage(data)
appointmentsService.create(user.appointment())
ok(user)
Expand Down
12 changes: 8 additions & 4 deletions src/test/kotlin/ApplicationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package org.example

import com.hexagonkt.core.logging.info
import com.hexagonkt.core.media.APPLICATION_JSON
import com.hexagonkt.core.urlOf
import com.hexagonkt.http.client.HttpClient
import com.hexagonkt.http.client.HttpClientSettings
import com.hexagonkt.http.client.jetty.JettyClientAdapter
import com.hexagonkt.http.model.HttpMethod.POST
import com.hexagonkt.http.model.NOT_FOUND_404
import com.hexagonkt.http.model.OK_200
import com.hexagonkt.http.server.model.HttpServerRequest
import com.hexagonkt.http.model.HttpRequest
import com.hexagonkt.serialization.jackson.json.Json
import com.hexagonkt.serialization.parseMap
import com.hexagonkt.serialization.serialize
Expand All @@ -16,15 +18,17 @@ 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 java.time.LocalDateTime
import kotlin.test.assertEquals

@TestInstance(PER_CLASS)
internal class ApplicationTest {

private val client by lazy {
HttpClient(JettyClientAdapter(), URL("http://localhost:${restApi.server.runtimePort}"))
HttpClient(
JettyClientAdapter(),
HttpClientSettings(urlOf("http://localhost:${restApi.server.runtimePort}"))
)
}

@BeforeAll fun beforeAll() {
Expand All @@ -44,7 +48,7 @@ internal class ApplicationTest {
val body = appointmentMessage.data.serialize(Json)
val handler = restApi.applicationHandler

handler.process(HttpServerRequest(POST, path="/api/appointments", body = body)).apply {
handler.process(HttpRequest(POST, path="/api/appointments", body = body)).apply {
assertEquals(OK_200, status)
assertEquals(APPLICATION_JSON, response.contentType?.mediaType)
}
Expand Down

0 comments on commit 57ce7cd

Please sign in to comment.