Skip to content

Commit 84fb8f6

Browse files
committed
migrate to 4.0.0-M2 and testResources
1 parent babd802 commit 84fb8f6

File tree

61 files changed

+859
-946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+859
-946
lines changed

buildSrc/build.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
plugins {
22
id 'groovy-gradle-plugin'
33
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
implementation libs.gradle.micronaut
12+
implementation libs.gradle.kotlin
13+
implementation libs.gradle.kotlin.allopen
14+
implementation libs.gradle.kotlin.noarg
15+
}

buildSrc/settings.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rootProject.name = 'nats-parent'
2+
dependencyResolutionManagement {
3+
dependencyResolutionManagement {
4+
versionCatalogs {
5+
libs {
6+
from(files("../gradle/libs.versions.toml"))
7+
}
8+
}
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
plugins {
2+
id 'java'
3+
}
4+
15
repositories {
26
mavenCentral()
3-
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
4-
}
7+
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }}
58

6-
configurations.all {
7-
resolutionStrategy.dependencySubstitution {
8-
substitute(module("org.codehaus.groovy:groovy"))
9-
.using(module("org.apache.groovy:groovy:${libs.versions.groovy.get()}"))
10-
}
9+
dependencies {
10+
testRuntimeOnly mn.logback.classic
1111
}
1212

13-
tasks.withType(GroovyCompile).configureEach {
14-
options.forkOptions.jvmArgs << '-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true'
13+
test {
14+
useJUnitPlatform()
15+
16+
jvmArgs '-Duser.country=US'
17+
jvmArgs '-Duser.language=en'
18+
failFast = true
1519
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
plugins {
2+
id "io.micronaut.build.internal.nats-base"
3+
id "io.micronaut.application"
4+
id "io.micronaut.test-resources"
5+
}
6+
7+
dependencies {
8+
testImplementation projects.micronautNats
9+
10+
runtimeOnly mn.snakeyaml
11+
testRuntimeOnly mn.snakeyaml
12+
testImplementation mn.reactor
13+
testImplementation libs.awaitility
14+
testImplementation 'io.micronaut.testresources:micronaut-test-resources-client'
15+
}
16+
17+
18+
configurations.all {
19+
resolutionStrategy.dependencySubstitution {
20+
substitute module('io.micronaut.nats:micronaut-nats') using project(':micronaut-nats')
21+
}
22+
}
23+
24+
micronaut {
25+
version libs.versions.micronaut.platform.get()
26+
testRuntime "junit5"
27+
testResources {
28+
clientTimeout = 300
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id 'io.micronaut.build.internal.nats-examples'
3+
id 'org.graalvm.buildtools.native'
4+
}
5+
6+
tasks.named("check") { task ->
7+
def graal = ["jvmci.Compiler", "java.vendor.version", "java.vendor"].any {
8+
System.getProperty(it)?.toLowerCase(Locale.ENGLISH)?.contains("graal")
9+
}
10+
if (graal) {
11+
task.dependsOn("nativeTest")
12+
}
13+
}

buildSrc/src/main/groovy/io.micronaut.build.internal.nats-tests.gradle

-3
This file was deleted.
+2-34
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,13 @@
11
plugins {
2-
id "groovy"
3-
id 'io.micronaut.build.internal.nats-tests'
4-
}
5-
6-
repositories {
7-
mavenCentral()
2+
id 'io.micronaut.build.internal.nats-examples'
3+
id 'groovy'
84
}
95

106
dependencies {
11-
testImplementation projects.micronautNats
12-
137
testCompileOnly mn.micronaut.inject.groovy
14-
testImplementation libs.testcontainers.spock
15-
testImplementation mn.micronaut.inject
16-
testImplementation mn.reactor
178
testImplementation mnTest.micronaut.test.spock
18-
testRuntimeOnly libs.junit.jupiter.engine
19-
testRuntimeOnly mn.snakeyaml
20-
}
21-
22-
test {
23-
useJUnitPlatform()
24-
25-
jvmArgs '-Duser.country=US'
26-
jvmArgs '-Duser.language=en'
27-
failFast = true
289
}
2910

3011
tasks.withType(GroovyCompile) {
3112
groovyOptions.forkOptions.jvmArgs.add('-Dgroovy.parameters=true')
3213
}
33-
34-
java {
35-
sourceCompatibility = JavaVersion.toVersion("17")
36-
targetCompatibility = JavaVersion.toVersion("17")
37-
}
38-
39-
test {
40-
useJUnitPlatform()
41-
testLogging {
42-
showStandardStreams = true
43-
exceptionFormat = 'full'
44-
}
45-
}

docs-examples/example-groovy/src/test/groovy/io/micronaut/nats/AbstractNatsTest.groovy

-46
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
package io.micronaut.nats.docs.consumer.connection
2-
3-
import io.micronaut.nats.AbstractNatsTest
4-
5-
class ConnectionSpec extends AbstractNatsTest {
6-
7-
void "test product client and listener"() {
8-
startContext()
9-
10-
when:
11-
// tag::producer[]
12-
def productClient = applicationContext.getBean(ProductClient)
13-
productClient.send("connection-test".bytes)
14-
// end::producer[]
15-
16-
ProductListener productListener = applicationContext.getBean(ProductListener)
17-
18-
then:
19-
waitFor {
20-
productListener.messageLengths.size() == 1
21-
productListener.messageLengths[0] == "connection-test"
22-
}
23-
24-
cleanup:
25-
// Finding that the context is closing the channel before ack is sent
26-
sleep 200
27-
}
28-
29-
protected Map<String, Object> getConfiguration() {
30-
super.configuration + ["nats.product-cluster.addresses": super.configuration.remove("nats.default.addresses")]
31-
}
32-
}
1+
package io.micronaut.nats.docs.consumer.connection
2+
3+
import io.micronaut.context.annotation.Property
4+
import io.micronaut.test.extensions.spock.annotation.MicronautTest
5+
6+
@MicronautTest
7+
@Property(name = "spec.name", value = "ConnectionSpec")
8+
class ConnectionSpec {
9+
10+
void "test product client and listener"() {
11+
startContext()
12+
13+
when:
14+
// tag::producer[]
15+
def productClient = applicationContext.getBean(ProductClient)
16+
productClient.send("connection-test".bytes)
17+
// end::producer[]
18+
19+
ProductListener productListener = applicationContext.getBean(ProductListener)
20+
21+
then:
22+
waitFor {
23+
productListener.messageLengths.size() == 1
24+
productListener.messageLengths[0] == "connection-test"
25+
}
26+
27+
cleanup:
28+
// Finding that the context is closing the channel before ack is sent
29+
sleep 200
30+
}
31+
32+
protected Map<String, Object> getConfiguration() {
33+
super.configuration + ["nats.product-cluster.addresses": super.configuration.remove("nats.default.addresses")]
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
package io.micronaut.nats.docs.consumer.custom.annotation
2-
3-
import io.micronaut.nats.AbstractNatsTest
4-
5-
class SIDSpec extends AbstractNatsTest {
6-
7-
void "test using a custom annotation binder"() {
8-
startContext()
9-
10-
when:
11-
// tag::producer[]
12-
def productClient = applicationContext.getBean(ProductClient)
13-
productClient.send("body".getBytes())
14-
productClient.send("body2".getBytes())
15-
productClient.send("body3".getBytes())
16-
// end::producer[]
17-
18-
ProductListener productListener = applicationContext.getBean(ProductListener)
19-
20-
then:
21-
waitFor {
22-
productListener.messages.size() == 3
23-
}
24-
25-
cleanup:
26-
sleep 200
27-
}
28-
}
1+
package io.micronaut.nats.docs.consumer.custom.annotation
2+
3+
import io.micronaut.context.annotation.Property
4+
import io.micronaut.test.extensions.spock.annotation.MicronautTest
5+
import jakarta.inject.Inject
6+
import spock.lang.Specification
7+
8+
import static java.util.concurrent.TimeUnit.SECONDS
9+
import static org.awaitility.Awaitility.await
10+
11+
@MicronautTest
12+
@Property(name = "spec.name", value = "SIDSpec")
13+
class SIDSpec extends Specification {
14+
@Inject ProductClient productClient
15+
@Inject ProductListener productListener
16+
17+
18+
void "test using a custom annotation binder"() {
19+
when:
20+
// tag::producer[]
21+
productClient.send("body".getBytes())
22+
productClient.send("body2".getBytes())
23+
productClient.send("body3".getBytes())
24+
// end::producer[]
25+
26+
then:
27+
await().atMost(10, SECONDS).until {
28+
productListener.messages.size() == 3
29+
}
30+
31+
cleanup:
32+
sleep 200
33+
}
34+
}

0 commit comments

Comments
 (0)