Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using micronaut-platform and plugins for jackson test #356

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[versions]
micronaut-docs = "2.0.0"
micronaut = "4.1.11"
micronaut-platform = "4.1.6"
micronaut-gradle-plugin = "4.1.2"
groovy = "4.0.15"
spock = "2.3-groovy-4.0"
Expand All @@ -24,7 +23,6 @@ micronaut-logging = "1.1.2"
[libraries]
# Core
micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' }
micronaut-platform = { module = 'io.micronaut.platform:micronaut-platform', version.ref = 'micronaut-platform' }
micronaut-reactor = { module = "io.micronaut.reactor:micronaut-reactor-bom", version.ref = "micronaut-reactor" }
micronaut-serde = { module = "io.micronaut.serde:micronaut-serde-bom", version.ref = "micronaut-serde" }
micronaut-validation = { module = "io.micronaut.validation:micronaut-validation-bom", version.ref = "micronaut-validation" }
Expand Down
30 changes: 17 additions & 13 deletions test-suite-jackson/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
plugins {
id("io.micronaut.library")
id("io.micronaut.test-resources")
id 'java-library'
id 'groovy'
id("io.micronaut.build.internal.mqtt-tests")
}

version = "0.1"
group = "example.micronaut"

repositories {
mavenCentral()
}

dependencies {
annotationProcessor(mn.micronaut.inject.java)

implementation(projects.micronautMqttv5)
implementation(mn.micronaut.inject)
implementation(mn.micronaut.jackson.databind)
runtimeOnly(mn.snakeyaml)

runtimeOnly(mnLogging.logback.classic)

testAnnotationProcessor(mn.micronaut.inject.java)

testImplementation(projects.testSuiteUtils)

testImplementation(libs.awaitility)
testImplementation(libs.junit.jupiter.api)
testImplementation(mnTest.micronaut.test.junit5)

testRuntimeOnly(libs.junit.jupiter.engine)
}

micronaut {
version.set(libs.versions.micronaut.platform)
testRuntime("junit5")
processing {
incremental(true)
annotations("example.micronaut.*")
}
tasks.named('test') {
useJUnitPlatform()
}
18 changes: 0 additions & 18 deletions test-suite-jackson/src/main/resources/application.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package example.micronaut;

import io.micronaut.context.ApplicationContext;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.utility.DockerImageName;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public abstract class AbstractMQTTTest {

protected static GenericContainer mqttContainer = new GenericContainer(DockerImageName.parse("eclipse-mosquitto:1.6.12"))
.withExposedPorts(1883)
.waitingFor(new LogMessageWaitStrategy().withRegEx("(?s).*mosquitto version 1.6.12 running.*"))
.withClasspathResourceMapping("mosquitto.conf",
"/mosquitto/config/mosquitto.conf",
BindMode.READ_ONLY);

static {
mqttContainer.start();
}

protected ApplicationContext startContext() {
return ApplicationContext.run(getConfiguration(), "test");
}

protected Map<String, Object> getConfiguration() {
Map<String, Object> config = new HashMap<>();
config.put("mqtt.client.server-uri", "tcp://localhost:" + mqttContainer.getMappedPort(1883));
config.put("mqtt.client.client-id", UUID.randomUUID().toString());
config.put("spec.name", this.getClass().getSimpleName());
return config;
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
package example.micronaut;

import io.micronaut.context.ApplicationContext;
import io.micronaut.mqtt.annotation.Topic;
import io.micronaut.mqtt.annotation.v5.MqttPublisher;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import java.util.concurrent.TimeUnit;

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;

@MicronautTest
class SubscriptionTest {

@Inject
SmellClient client;

@Inject
SmellListener listener;
class SubscriptionTest extends AbstractMQTTTest {

@Test
void checkSubscriptionsAreReceived() {
client.publishLivingroomSmell(new Odour("cheesy"));
try(ApplicationContext applicationContext = startContext()) {
SmellClient client = applicationContext.getBean(SmellClient.class);
SmellListener listener = applicationContext.getBean(SmellListener.class);

client.publishLivingroomSmell(new Odour("cheesy"));

await()
.atMost(5, TimeUnit.SECONDS)
.untilAsserted(() -> assertEquals("cheesy", listener.getSmell()));
await()
.atMost(5, TimeUnit.SECONDS)
.untilAsserted(() -> assertEquals("cheesy", listener.getSmell()));
}
}

@MqttPublisher
Expand Down
Loading