generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(deps): update mikepenz/action-junit-report action to v3.6.1 (#217) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency gradle to v7.6 (#216) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update peter-evans/create-pull-request action to v4.2.3 (#214) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency org.testcontainers:spock to v1.17.6 (#213) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * ci: Gradle 7.6 and java distro temurin, cla provenance (#202) * chore(deps): update kotlin monorepo to v1.7.21 (#211) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> # Conflicts: # gradle/libs.versions.toml * build: groovy to 3.0.12 * build: Micronaut Test 3.7.1 * build: spock 2.2-groovy-3.0 * ci: projectVersion=2.4.0-SNAPSHOT [ci skip] [ * ci: githubcoreBranch 3.8.x [ci skip] * build: Micronaut Test 3.8.0 * build: Micronaut Framework 3.7.4 (#218) * build: Micronaut Framework 3.7.4 * Kotest 4 eventually doesn't work with Kotlin 1.7.21 Co-authored-by: Tim Yates <tim.yates@gmail.com> * doc: configuration asciidoc macro and build plugin 5.4.5 (#230) * Add GraalVM native tests (#232) * Add native test for mqttv3 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: micronaut-build <65172877+micronaut-build@users.noreply.github.com> Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com> Co-authored-by: Dean Wette <wetted@objectcomputing.com>
- Loading branch information
1 parent
da1f9cf
commit 122f0fb
Showing
21 changed files
with
425 additions
and
6 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugins { | ||
id("groovy-gradle-plugin") | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.21") | ||
implementation("io.micronaut.gradle:micronaut-gradle-plugin:4.0.0-M1") | ||
implementation("io.micronaut.gradle:micronaut-test-resources-plugin:4.0.0-M1") | ||
} |
53 changes: 53 additions & 0 deletions
53
buildSrc/src/main/groovy/io.micronaut.build.internal.graal-test.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
plugins { | ||
id("org.graalvm.buildtools.native") | ||
id("io.micronaut.library") | ||
id("io.micronaut.test-resources") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
configurations.all { | ||
resolutionStrategy { | ||
force 'io.micronaut.platform:micronaut-platform:4.0.0-M1' | ||
} | ||
} | ||
|
||
dependencies { | ||
testAnnotationProcessor(mn.micronaut.inject.java) | ||
testImplementation(mn.micronaut.http) | ||
testImplementation(mn.micronaut.json.core) | ||
testImplementation(mn.micronaut.http.client) | ||
testImplementation(mn.micronaut.http.server.netty) | ||
testImplementation(mnTest.micronaut.test.junit5) | ||
testImplementation(libs.awaitility) | ||
testImplementation(mnSerde.micronaut.serde.jackson) | ||
testRuntimeOnly(mn.logback.classic) | ||
} | ||
|
||
micronaut { | ||
version = libs.versions.micronaut.asProvider().get() | ||
testResources { | ||
enabled = true | ||
additionalModules.add("hivemq") | ||
} | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
def isGraalVMJdk = ["jvmci.Compiler", "java.vendor.version", "java.vendor"].any { | ||
System.getProperty(it)?.toLowerCase(Locale.ENGLISH)?.contains("graal") | ||
} | ||
|
||
tasks.named("check") { | ||
if (isGraalVMJdk) { | ||
it.dependsOn("nativeTest") | ||
} | ||
} | ||
|
||
graalvmNative { | ||
toolchainDetection.set(false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id("io.micronaut.build.internal.graal-test") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation(projects.micronautMqttv3) | ||
} |
12 changes: 12 additions & 0 deletions
12
...suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MessageConverterMqttClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import io.micronaut.mqtt.annotation.Topic; | ||
import io.micronaut.mqtt.v3.annotation.MqttPublisher; | ||
|
||
@MqttPublisher | ||
public interface MessageConverterMqttClient { | ||
|
||
@Topic("message") | ||
void sendMessage(MessageRequest messageRequest); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
test-suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import io.micronaut.mqtt.annotation.MqttSubscriber; | ||
import io.micronaut.mqtt.annotation.Topic; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@MqttSubscriber | ||
public class MessageListener { | ||
|
||
private final List<MessageResponse> messages = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
@Topic("message") | ||
public void receiveMessage(MessageRequest message) { | ||
messages.add(new MessageResponse(message.getText())); | ||
} | ||
|
||
public List<MessageResponse> getMessages() { | ||
return messages; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test-suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MessageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public class MessageRequest { | ||
|
||
private final String text; | ||
|
||
public MessageRequest(String text) { | ||
this.text = text; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test-suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MessageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Serdeable | ||
public class MessageResponse { | ||
|
||
private final String text; | ||
|
||
private final LocalDateTime date; | ||
|
||
public MessageResponse(String text) { | ||
this.text = text.toUpperCase(); | ||
this.date = LocalDateTime.now(); | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
public LocalDateTime getDate() { | ||
return date; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
test-suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MqttController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
|
||
import java.util.List; | ||
|
||
@Controller("/mqtt") | ||
public class MqttController { | ||
|
||
private final MessageConverterMqttClient messageConverterMqttClient; | ||
private final MessageListener messageListener; | ||
|
||
public MqttController(MessageConverterMqttClient messageConverterMqttClient, | ||
MessageListener messageListener) { | ||
this.messageConverterMqttClient = messageConverterMqttClient; | ||
this.messageListener = messageListener; | ||
} | ||
|
||
@Get("/send/{text}") | ||
public void send(String text) { | ||
messageConverterMqttClient.sendMessage(new MessageRequest(text)); | ||
} | ||
|
||
@Get("/messages") | ||
public List<MessageResponse> messages() { | ||
return messageListener.getMessages(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
test-suite-mqttv3-graal/src/test/java/io/micronaut/mqtt3/graal/MqttTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.micronaut.mqtt3.graal; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.core.type.Argument; | ||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.client.HttpClient; | ||
import io.micronaut.http.client.annotation.Client; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@MicronautTest | ||
@Property(name = "mqtt.client.client-id", value = "micronaut") | ||
class MqttTest { | ||
|
||
@Inject | ||
@Client("/") | ||
HttpClient httpClient; | ||
|
||
@Test | ||
void helloWorld() { | ||
HttpResponse<Object> exchange = httpClient.toBlocking().exchange("/mqtt/send/Micronaut"); | ||
assertEquals(200, exchange.getStatus().getCode()); | ||
await().atMost(5, TimeUnit.SECONDS).until(() -> { | ||
List<MessageResponse> exchange1 = httpClient.toBlocking().exchange(HttpRequest.GET("/mqtt/messages"), Argument.listOf(MessageResponse.class)).body(); | ||
return exchange1 != null && exchange1.size() == 1 && exchange1.get(0).getText().equals("MICRONAUT"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<withJansi>true</withJansi> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
|
||
<logger name="io.micronaut.mqtt" level="TRACE" /> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id("io.micronaut.build.internal.graal-test") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation(projects.micronautMqttv5) | ||
} |
12 changes: 12 additions & 0 deletions
12
...suite-mqttv5-graal/src/test/java/io/micronaut/mqtt5/graal/MessageConverterMqttClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.micronaut.mqtt5.graal; | ||
|
||
import io.micronaut.mqtt.annotation.Topic; | ||
import io.micronaut.mqtt.v5.annotation.MqttPublisher; | ||
|
||
@MqttPublisher | ||
public interface MessageConverterMqttClient { | ||
|
||
@Topic("message") | ||
void sendMessage(MessageRequest messageRequest); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
test-suite-mqttv5-graal/src/test/java/io/micronaut/mqtt5/graal/MessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.micronaut.mqtt5.graal; | ||
|
||
import io.micronaut.mqtt.annotation.MqttSubscriber; | ||
import io.micronaut.mqtt.annotation.Topic; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@MqttSubscriber | ||
public class MessageListener { | ||
|
||
private final List<MessageResponse> messages = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
@Topic("message") | ||
public void receiveMessage(MessageRequest message) { | ||
messages.add(new MessageResponse(message.getText())); | ||
} | ||
|
||
public List<MessageResponse> getMessages() { | ||
return messages; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test-suite-mqttv5-graal/src/test/java/io/micronaut/mqtt5/graal/MessageRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.micronaut.mqtt5.graal; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public class MessageRequest { | ||
|
||
private final String text; | ||
|
||
public MessageRequest(String text) { | ||
this.text = text; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test-suite-mqttv5-graal/src/test/java/io/micronaut/mqtt5/graal/MessageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.micronaut.mqtt5.graal; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Serdeable | ||
public class MessageResponse { | ||
|
||
private final String text; | ||
|
||
private final LocalDateTime date; | ||
|
||
public MessageResponse(String text) { | ||
this.text = text.toUpperCase(); | ||
this.date = LocalDateTime.now(); | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
public LocalDateTime getDate() { | ||
return date; | ||
} | ||
} |
Oops, something went wrong.