diff --git a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java index 8bd50dc..a853d31 100644 --- a/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java +++ b/messaging/messaging-admin-runtime/src/main/java/dev/caskeleton/messaging/admin/runtime/DestructiveMessagingAdmin.java @@ -1,7 +1,7 @@ package dev.caskeleton.messaging.admin.runtime; -import dev.caskeleton.messaging.admin.VerifiedApproval; import dev.caskeleton.messaging.admin.DestructiveOperation; +import dev.caskeleton.messaging.admin.VerifiedApproval; import dev.caskeleton.messaging.api.destination.DestinationName; import java.time.Duration; import java.time.Instant; diff --git a/messaging/messaging-kafka-share-experimental/gradle.lockfile b/messaging/messaging-kafka-share-experimental/gradle.lockfile index cd62c0e..eaf97d5 100644 --- a/messaging/messaging-kafka-share-experimental/gradle.lockfile +++ b/messaging/messaging-kafka-share-experimental/gradle.lockfile @@ -31,7 +31,6 @@ com.puppycrawl.tools:checkstyle:13.5.0=checkstyle commons-beanutils:commons-beanutils:1.11.0=checkstyle commons-collections:commons-collections:3.2.2=checkstyle commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=runtimeClasspath,testRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor @@ -89,14 +88,6 @@ org.reflections:reflections:0.10.2=checkstyle org.slf4j:slf4j-api:2.0.18=runtimeClasspath,spotbugs,spotbugsSlf4j,testRuntimeClasspath org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework.kafka:spring-kafka:4.0.7=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-aop:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=runtimeClasspath,testRuntimeClasspath org.xerial.snappy:snappy-java:1.1.10.7=runtimeClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs empty= diff --git a/messaging/messaging-kafka/build.gradle b/messaging/messaging-kafka/build.gradle index dfd0533..789445b 100644 --- a/messaging/messaging-kafka/build.gradle +++ b/messaging/messaging-kafka/build.gradle @@ -12,7 +12,9 @@ auxiliarySourceSets { } dependencies { - implementation 'org.springframework.kafka:spring-kafka' + // No spring-kafka. It was declared here and imported by nothing: this adapter drives the plain + // `org.apache.kafka` producer API directly, and a declared library that no source names is a + // resolution, a lock entry and a transitive surface bought for nothing. api project(':messaging:messaging-core-api') api project(':messaging:messaging-schema-api') api project(':messaging:messaging-policy') diff --git a/messaging/messaging-kafka/gradle.lockfile b/messaging/messaging-kafka/gradle.lockfile index b38d867..b0dd01f 100644 --- a/messaging/messaging-kafka/gradle.lockfile +++ b/messaging/messaging-kafka/gradle.lockfile @@ -37,7 +37,6 @@ commons-codec:commons-codec:1.19.0=integrationTestCompileClasspath,integrationTe commons-collections:commons-collections:3.2.2=checkstyle commons-io:commons-io:2.20.0=integrationTestCompileClasspath,integrationTestRuntimeClasspath commons-io:commons-io:2.21.0=spotbugs -commons-logging:commons-logging:1.3.6=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath eu.rekawek.toxiproxy:toxiproxy-java:2.1.7=integrationTestCompileClasspath,integrationTestRuntimeClasspath info.picocli:picocli:4.7.7=checkstyle io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,integrationTestAnnotationProcessor,jmhAnnotationProcessor,testAnnotationProcessor,testFixturesAnnotationProcessor @@ -104,14 +103,6 @@ org.rnorth.duct-tape:duct-tape:1.0.8=integrationTestCompileClasspath,integration org.slf4j:slf4j-api:2.0.18=integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhRuntimeClasspath,runtimeClasspath,spotbugs,spotbugsSlf4j,testFixturesRuntimeClasspath,testRuntimeClasspath org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle -org.springframework.kafka:spring-kafka:4.0.7=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-aop:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-context:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-core:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-expression:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath -org.springframework:spring-tx:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,jmhCompileClasspath,jmhRuntimeClasspath,runtimeClasspath,testCompileClasspath,testFixturesRuntimeClasspath,testRuntimeClasspath org.testcontainers:testcontainers-junit-jupiter:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.testcontainers:testcontainers-kafka:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath org.testcontainers:testcontainers-toxiproxy:2.0.5=integrationTestCompileClasspath,integrationTestRuntimeClasspath diff --git a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java b/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java index 8270f05..941abf3 100644 --- a/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java +++ b/messaging/messaging-kafka/src/test/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrarTest.java @@ -524,7 +524,6 @@ class KafkaConsumerRegistrarTest { super.commitSync(offsets); } } - } /** Queues handler work so the in-flight ceiling is observable. */ diff --git a/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java index cb2d95d..992ad2f 100644 --- a/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java +++ b/messaging/messaging-outbox-jdbc-postgresql/src/integrationTest/java/dev/caskeleton/messaging/outbox/OutboxPostgresIT.java @@ -8,6 +8,7 @@ import dev.caskeleton.messaging.api.MessageType; import dev.caskeleton.messaging.api.SchemaVersion; import dev.caskeleton.messaging.api.destination.DestinationName; import dev.caskeleton.messaging.reliability.OutboxCanonicalMetadata; +import dev.caskeleton.messaging.reliability.OutboxLease; import dev.caskeleton.messaging.reliability.OutboxRecord; import dev.caskeleton.messaging.reliability.OutboxStatus; import dev.caskeleton.messaging.testkit.DockerAvailability; @@ -130,9 +131,14 @@ class OutboxPostgresIT { void anAmbiguousRowStaysClaimableUnderItsOriginalIdentity() { OutboxRecord record = record(); appendInTransaction(record); - repository.leaseBatch(10, Duration.ofSeconds(30), NOW); + // Claimed rather than leased: a terminal write is checked against the lease token, so + // `markAmbiguous` takes the lease that owns the row. The identity-keyed overload this test used + // to call is gone, and with it the possibility of one relay writing an outcome onto a row + // another relay currently owns. + OutboxLease lease = + repository.claimBatch("ambiguous-relay", 10, Duration.ofSeconds(30), NOW).getFirst(); - repository.markAmbiguous(record.messageId(), "CONFIRM_TIMEOUT", NOW); + repository.markAmbiguous(lease, "CONFIRM_TIMEOUT", NOW); assertThat(repository.find(record.messageId()).orElseThrow().status()) .isEqualTo(OutboxStatus.AMBIGUOUS); diff --git a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java index 678615c..040513e 100644 --- a/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java +++ b/messaging/messaging-rabbit/src/test/java/dev/caskeleton/messaging/rabbit/RabbitTopologyAndBatchTest.java @@ -131,9 +131,11 @@ class RabbitTopologyAndBatchTest { false, Duration.ofMillis(3)); - assertThat(result.failure()).hasValueSatisfying( - failure -> assertThat(failure.category()).isEqualTo( - dev.caskeleton.messaging.api.error.FailureCategory.AUTHENTICATION)); + assertThat(result.failure()) + .hasValueSatisfying( + failure -> + assertThat(failure.category()) + .isEqualTo(dev.caskeleton.messaging.api.error.FailureCategory.AUTHENTICATION)); } @Test @@ -142,17 +144,17 @@ class RabbitTopologyAndBatchTest { new com.rabbitmq.client.ShutdownSignalException( false, false, - new com.rabbitmq.client.impl.AMQImpl.Channel.Close( - 403, "ACCESS_REFUSED", 60, 40), + new com.rabbitmq.client.impl.AMQImpl.Channel.Close(403, "ACCESS_REFUSED", 60, 40), null); PublishResult result = - new RabbitPublishFailureClassifier() - .classify(accessRefused, false, Duration.ofMillis(3)); + new RabbitPublishFailureClassifier().classify(accessRefused, false, Duration.ofMillis(3)); - assertThat(result.failure()).hasValueSatisfying( - failure -> assertThat(failure.category()).isEqualTo( - dev.caskeleton.messaging.api.error.FailureCategory.AUTHORIZATION)); + assertThat(result.failure()) + .hasValueSatisfying( + failure -> + assertThat(failure.category()) + .isEqualTo(dev.caskeleton.messaging.api.error.FailureCategory.AUTHORIZATION)); } @Test diff --git a/messaging/messaging-runtime-core/src/test/java/dev/caskeleton/messaging/runtime/DefaultMessagePublisherTest.java b/messaging/messaging-runtime-core/src/test/java/dev/caskeleton/messaging/runtime/DefaultMessagePublisherTest.java index 5efc0c9..510c451 100644 --- a/messaging/messaging-runtime-core/src/test/java/dev/caskeleton/messaging/runtime/DefaultMessagePublisherTest.java +++ b/messaging/messaging-runtime-core/src/test/java/dev/caskeleton/messaging/runtime/DefaultMessagePublisherTest.java @@ -115,7 +115,8 @@ class DefaultMessagePublisherTest { assertThat(result.completion()).isEqualTo(PublishCompletion.CONFIRMED); assertThat(codecs.encodes()).isZero(); assertThat(transport.lastRequest().envelope().payload().bytes()).containsExactly(wireBytes); - assertThat(transport.lastRequest().envelope().payload().contentType()).isEqualTo(ContentType.JSON); + assertThat(transport.lastRequest().envelope().payload().contentType()) + .isEqualTo(ContentType.JSON); assertThat(admission.inFlight()).isZero(); } diff --git a/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile b/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile index 6e4716f..53df71c 100644 --- a/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile +++ b/messaging/messaging-spring-boot-starter-kafka/gradle.lockfile @@ -98,14 +98,12 @@ org.springframework.boot:spring-boot-actuator:4.0.8=runtimeClasspath,testRuntime org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor org.springframework.boot:spring-boot:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.kafka:spring-kafka:4.0.7=runtimeClasspath,testRuntimeClasspath org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-jdbc:7.0.9=runtimeClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=runtimeClasspath,testRuntimeClasspath org.springframework:spring-tx:7.0.9=runtimeClasspath,testRuntimeClasspath org.xerial.snappy:snappy-java:1.1.10.7=runtimeClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs diff --git a/messaging/messaging-spring-boot-starter/gradle.lockfile b/messaging/messaging-spring-boot-starter/gradle.lockfile index af7c26e..7f5981c 100644 --- a/messaging/messaging-spring-boot-starter/gradle.lockfile +++ b/messaging/messaging-spring-boot-starter/gradle.lockfile @@ -123,7 +123,6 @@ org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,integr org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor org.springframework.boot:spring-boot-test:4.0.8=integrationTestCompileClasspath,integrationTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework.boot:spring-boot:4.0.8=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework.kafka:spring-kafka:4.0.7=integrationTestRuntimeClasspath,testRuntimeClasspath org.springframework:spring-aop:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-beans:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-context:7.0.9=compileClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java index 789e1a5..227965c 100644 --- a/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java +++ b/messaging/messaging-spring-boot-starter/src/main/java/dev/caskeleton/messaging/autoconfigure/MessagingProviderSelection.java @@ -48,6 +48,12 @@ public class MessagingProviderSelection { "kafka", "dev.caskeleton.messaging.autoconfigure.KafkaMessagingAutoConfiguration", "rabbit", "dev.caskeleton.messaging.autoconfigure.RabbitMessagingAutoConfiguration"); + /** Broker id to the starter a deployment adds to its build to obtain that transport. */ + static final Map PROVIDER_STARTERS = + Map.of( + "kafka", "messaging-spring-boot-starter-kafka", + "rabbit", "messaging-spring-boot-starter-rabbit"); + /** * Broker ids that ship without a {@code MessagingTransport}, and why. * @@ -118,6 +124,23 @@ public class MessagingProviderSelection { + clientClass + " on the classpath; the deployment selected a transport it did not ship"); } + // The client library and the broker starter are two different build decisions, and only the + // second one carries the configuration that assembles the transport. A deployment can hold the + // Kafka client transitively and still not ship the Kafka starter — this core starter is + // broker-neutral on purpose — and until this check existed that combination reached Spring's + // import machinery, which reported a missing .class file rather than a missing capability. + String providerConfiguration = PROVIDER_CONFIGURATIONS.get(broker); + if (!ClassUtils.isPresent( + providerConfiguration, MessagingProviderSelection.class.getClassLoader())) { + throw new IllegalStateException( + MessagingSettings.PREFIX + + ".broker=" + + broker + + " needs the " + + PROVIDER_STARTERS.get(broker) + + " module on the classpath; this core starter is broker-neutral and the deployment" + + " did not compose the transport it selected"); + } String unfinished = BROKERS_WITHOUT_A_TRANSPORT.get(broker); if (unfinished != null) { throw new IllegalStateException( diff --git a/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformAutoConfigurationRegistrationTest.java b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformAutoConfigurationRegistrationTest.java new file mode 100644 index 0000000..a7227e6 --- /dev/null +++ b/messaging/messaging-spring-boot-starter/src/test/java/dev/caskeleton/messaging/autoconfigure/MessagingPlatformAutoConfigurationRegistrationTest.java @@ -0,0 +1,104 @@ +package dev.caskeleton.messaging.autoconfigure; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.core.annotation.AnnotatedElementUtils; + +/** + * This leaf's auto-configurations are registered, not merely annotated. + * + *

Spring Boot needs two independent things before an auto-configuration runs: the annotation on + * the class, and a line naming it in {@code META-INF/spring/...AutoConfiguration.imports}. Tests + * that build a context with {@code AutoConfigurations.of(...)} supply the second one themselves, so + * they stay green for a capability that is present in no running application — which is exactly how + * several capabilities in this repository came to be assembled by nothing. + * + *

So this reads the registration file the jar actually ships and asserts both directions: every + * class this leaf means to register is named in it, and every name in it resolves to a class that + * carries {@code @AutoConfiguration}. A rename, a move or a deleted line fails here rather than in + * a deployment that starts and quietly does less than it says. + */ +class MessagingPlatformAutoConfigurationRegistrationTest { + + private static final String IMPORTS_RESOURCE = + "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports"; + + /** The auto-configurations this leaf publishes. */ + private static final List PUBLISHED_ROOTS = + List.of("dev.caskeleton.messaging.autoconfigure.MessagingPlatformRootAutoConfiguration"); + + @Test + @DisplayName("the shipped registration file names every root this leaf publishes") + void theShippedRegistrationFileNamesEveryRoot() { + assertThat(registeredNames()) + .as("the registration lines this leaf's own jar ships") + .containsAll(PUBLISHED_ROOTS); + } + + @Test + @DisplayName("every registered name resolves to a real Boot auto-configuration") + void everyRegisteredNameResolvesToAnAutoConfiguration() { + for (String name : registeredNames()) { + Class registered; + try { + registered = + Class.forName( + name, + false, + MessagingPlatformAutoConfigurationRegistrationTest.class.getClassLoader()); + } catch (ClassNotFoundException missing) { + throw new AssertionError( + IMPORTS_RESOURCE + " registers " + name + ", which does not exist", missing); + } + assertThat(AnnotatedElementUtils.hasAnnotation(registered, AutoConfiguration.class)) + .as("%s is registered but is not annotated @AutoConfiguration", name) + .isTrue(); + } + } + + /** + * The registration lines this leaf's own resource declares. + * + *

Read from this leaf's source tree rather than from the classpath. {@code + * ClassLoader#getResources} returns every registration file on the test runtime classpath — + * Spring Boot's, springdoc's, and every dependency leaf's — so asserting over that set tests + * other people's modules and fails on their conditional classes. The file below is the one this + * leaf packages, which is the thing this contract is about. + */ + private static List registeredNames() { + Path resource = leafRoot().resolve("src/main/resources/" + IMPORTS_RESOURCE); + assertThat(Files.isRegularFile(resource)).as("%s", resource).isTrue(); + List names; + try { + names = + Files.readAllLines(resource, StandardCharsets.UTF_8).stream() + .map(String::strip) + .filter(line -> !line.isEmpty() && !line.startsWith("#")) + .toList(); + } catch (IOException failure) { + throw new UncheckedIOException("cannot read " + resource, failure); + } + assertThat(names).as("%s registers nothing", resource).isNotEmpty(); + return names; + } + + /** The nearest directory above the test's working directory that ships a registration file. */ + private static Path leafRoot() { + for (Path path = Path.of("").toAbsolutePath(); path != null; path = path.getParent()) { + if (Files.isRegularFile(path.resolve("src/main/resources/" + IMPORTS_RESOURCE))) { + return path; + } + } + throw new IllegalStateException( + "no leaf shipping " + IMPORTS_RESOURCE + " found above " + Path.of("").toAbsolutePath()); + } +}