diff --git a/messaging/messaging-kafka/build.gradle b/messaging/messaging-kafka/build.gradle index 8f28164..00c9892 100644 --- a/messaging/messaging-kafka/build.gradle +++ b/messaging/messaging-kafka/build.gradle @@ -1,6 +1,5 @@ plugins { id 'java-test-fixtures' - id 'ca.auxiliary-source-set' id 'ca.platform-module' id 'me.champeau.jmh' } @@ -10,11 +9,20 @@ jmh { includeTests = true } -auxiliarySourceSets { - sourceSet('integrationTest') { - compilesAgainst 'main', 'testFixtures' +testing { + suites { + integrationTest(JvmTestSuite) { + dependencies { + implementation project() + implementation testFixtures(project()) + } + } } } +configurations { + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly +} dependencies { // No spring-kafka. It was declared here and imported by nothing: this adapter drives the plain diff --git a/messaging/messaging-reliability-jdbc-postgresql/build.gradle b/messaging/messaging-reliability-jdbc-postgresql/build.gradle index cfa5217..f549b2d 100644 --- a/messaging/messaging-reliability-jdbc-postgresql/build.gradle +++ b/messaging/messaging-reliability-jdbc-postgresql/build.gradle @@ -1,13 +1,20 @@ plugins { - id 'ca.auxiliary-source-set' id 'ca.platform-module' } -auxiliarySourceSets { - sourceSet('integrationTest') { - compilesAgainst 'main' +testing { + suites { + integrationTest(JvmTestSuite) { + dependencies { + implementation project() + } + } } } +configurations { + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly +} // The relational implementations of the reliability ports: the outbox repository, the inbox // repository and the destructive-operation journal. Spring JDBC for the transaction join, and SQL diff --git a/messaging/messaging-reliability-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java b/messaging/messaging-reliability-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java index f3f1d2a..16becff 100644 --- a/messaging/messaging-reliability-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java +++ b/messaging/messaging-reliability-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java @@ -290,14 +290,31 @@ class OutboxPostgresIT { if (directory == null) { throw new IOException("the messaging migrations are missing from the classpath"); } - java.io.File[] files = - new java.io.File(java.net.URI.create(directory.toString())) - .listFiles((dir, name) -> name.endsWith(".sql")); - if (files == null || files.length == 0) { + // The migrations may sit in a directory or, when the suite runs against the main jar, inside + // it; a jar URL is not a file URI, so list through a filesystem that understands either. + java.net.URI uri; + try { + uri = directory.toURI(); + } catch (java.net.URISyntaxException malformed) { + throw new IOException(malformed); + } + java.util.List names; + if ("jar".equals(uri.getScheme())) { + try (java.nio.file.FileSystem jar = + java.nio.file.FileSystems.newFileSystem(uri, java.util.Map.of()); + java.util.stream.Stream listed = + java.nio.file.Files.list(jar.getPath("db/migration/messaging"))) { + names = sqlNames(listed); + } + } else { + try (java.util.stream.Stream listed = + java.nio.file.Files.list(java.nio.file.Path.of(uri))) { + names = sqlNames(listed); + } + } + if (names.isEmpty()) { throw new IOException("no migration applied; the schema under test would be empty"); } - java.util.List names = - java.util.Arrays.stream(files).map(java.io.File::getName).sorted().toList(); java.util.List statements = new java.util.ArrayList<>(); for (String name : names) { statements.add(migration(name)); @@ -305,6 +322,15 @@ class OutboxPostgresIT { return statements; } + private static java.util.List sqlNames( + java.util.stream.Stream listed) { + return listed + .map(path -> path.getFileName().toString()) + .filter(name -> name.endsWith(".sql")) + .sorted() + .toList(); + } + private int countWhere(String predicate) { try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); diff --git a/messaging/messaging-spring-boot-starter/build.gradle b/messaging/messaging-spring-boot-starter/build.gradle index 7f3f781..efed4b9 100644 --- a/messaging/messaging-spring-boot-starter/build.gradle +++ b/messaging/messaging-spring-boot-starter/build.gradle @@ -1,5 +1,4 @@ plugins { - id 'ca.auxiliary-source-set' id 'ca.platform-module' id 'ca.spring-config' } @@ -9,11 +8,19 @@ plugins { // `api` is the types that genuinely appear in this module's public signatures; everything else is // `implementation`. Broker transports live in capability starters (messaging-spring-boot-starter-kafka), // so this starter's compile classpath carries no broker SDK. -auxiliarySourceSets { - sourceSet('integrationTest') { - compilesAgainst 'main' +testing { + suites { + integrationTest(JvmTestSuite) { + dependencies { + implementation project() + } + } } } +configurations { + integrationTestImplementation.extendsFrom testImplementation + integrationTestRuntimeOnly.extendsFrom testRuntimeOnly +} dependencies { // Types an adopter writes against: envelopes, destinations, publish results, profiles, ports.