diff --git a/kroxylicious-annotations/pom.xml b/kroxylicious-annotations/pom.xml new file mode 100644 index 0000000000..94b8128e0d --- /dev/null +++ b/kroxylicious-annotations/pom.xml @@ -0,0 +1,22 @@ + + + + 4.0.0 + + io.kroxylicious + kroxylicious-parent + 0.5.0-SNAPSHOT + + + kroxylicious-annotations + + + \ No newline at end of file diff --git a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/tag/VisibleForTesting.java b/kroxylicious-annotations/src/main/java/io/kroxylicious/proxy/tag/VisibleForTesting.java similarity index 100% rename from kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/tag/VisibleForTesting.java rename to kroxylicious-annotations/src/main/java/io/kroxylicious/proxy/tag/VisibleForTesting.java diff --git a/kroxylicious-app/pom.xml b/kroxylicious-app/pom.xml index 0e48d198a4..12cf1f0a0c 100644 --- a/kroxylicious-app/pom.xml +++ b/kroxylicious-app/pom.xml @@ -35,6 +35,10 @@ kroxylicious-api runtime + + io.kroxylicious + kroxylicious-annotations + diff --git a/kroxylicious-app/src/main/java/io/kroxylicious/app/BannerLogger.java b/kroxylicious-app/src/main/java/io/kroxylicious/app/BannerLogger.java index 8ed65ee38f..d05af486a1 100644 --- a/kroxylicious-app/src/main/java/io/kroxylicious/app/BannerLogger.java +++ b/kroxylicious-app/src/main/java/io/kroxylicious/app/BannerLogger.java @@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory; import org.slf4j.event.Level; +import io.kroxylicious.proxy.tag.VisibleForTesting; + public class BannerLogger { public static final String DEFAULT_BANNER_LOCATION = "banner.txt"; @@ -44,7 +46,8 @@ public void log() { bannerReader.get().forEach(line -> targetLogger.atLevel(targetLevel).log(line)); } - /* test */ static class BannerSupplier implements Supplier> { + @VisibleForTesting + static class BannerSupplier implements Supplier> { private final Supplier> linesSupplier; private final Set licenseLines; @@ -64,7 +67,8 @@ public Stream get() { } } - /* test */ static class FileLinesSupplier implements Supplier> { + @VisibleForTesting + static class FileLinesSupplier implements Supplier> { private final String resourceName; diff --git a/kroxylicious-bom/pom.xml b/kroxylicious-bom/pom.xml index ef11af8a8b..5cbb70caf3 100644 --- a/kroxylicious-bom/pom.xml +++ b/kroxylicious-bom/pom.xml @@ -92,6 +92,12 @@ + + io.kroxylicious + kroxylicious-annotations + ${project.version} + + io.kroxylicious kroxylicious-api diff --git a/kroxylicious-filters/kroxylicious-encryption/pom.xml b/kroxylicious-filters/kroxylicious-encryption/pom.xml index 060849e5a5..cf44157901 100644 --- a/kroxylicious-filters/kroxylicious-encryption/pom.xml +++ b/kroxylicious-filters/kroxylicious-encryption/pom.xml @@ -31,6 +31,10 @@ io.kroxylicious kroxylicious-api + + io.kroxylicious + kroxylicious-annotations + io.kroxylicious diff --git a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Dek.java b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Dek.java index cbca062656..8d314c9753 100644 --- a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Dek.java +++ b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Dek.java @@ -95,7 +95,7 @@ public final class Dek { * «{@link #END}» // key gets destroyed * */ - final AtomicLong outstandingCryptors; + private final AtomicLong outstandingCryptors; private static final long START = combine(1, 1); private static final long END = combine(-1, -1); diff --git a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Wrapping96BitCounter.java b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Wrapping96BitCounter.java index 9333b8eb63..9d9c21a468 100644 --- a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Wrapping96BitCounter.java +++ b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/dek/Wrapping96BitCounter.java @@ -11,6 +11,8 @@ import javax.annotation.concurrent.NotThreadSafe; import javax.security.auth.Destroyable; +import io.kroxylicious.proxy.tag.VisibleForTesting; + import edu.umd.cs.findbugs.annotations.NonNull; /** @@ -40,6 +42,7 @@ class Wrapping96BitCounter implements Destroyable { hi = rng.nextInt(); } + @VisibleForTesting int sizeBytes() { return 12; } diff --git a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/InBandEncryptionManager.java b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/InBandEncryptionManager.java index eae77639d6..83e969ebc0 100644 --- a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/InBandEncryptionManager.java +++ b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/InBandEncryptionManager.java @@ -31,6 +31,7 @@ import io.kroxylicious.filter.encryption.dek.ExhaustedDekException; import io.kroxylicious.filter.encryption.records.RecordStream; import io.kroxylicious.kms.service.Serde; +import io.kroxylicious.proxy.tag.VisibleForTesting; import edu.umd.cs.findbugs.annotations.NonNull; @@ -95,7 +96,7 @@ public InBandEncryptionManager(@NonNull Serde edekSerde, } - // @VisibleForTesting + @VisibleForTesting CompletionStage> currentDek(@NonNull EncryptionScheme encryptionScheme) { // todo should we add some scheduled timeout as well? or should we rely on the KMS to timeout appropriately. return dekCache.get(encryptionScheme, filterThreadExecutor); diff --git a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/Parcel.java b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/Parcel.java index 9e1b99f825..b72606cb82 100644 --- a/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/Parcel.java +++ b/kroxylicious-filters/kroxylicious-encryption/src/main/java/io/kroxylicious/filter/encryption/inband/Parcel.java @@ -20,6 +20,7 @@ import io.kroxylicious.filter.encryption.EncryptionException; import io.kroxylicious.filter.encryption.ParcelVersion; import io.kroxylicious.filter.encryption.RecordField; +import io.kroxylicious.proxy.tag.VisibleForTesting; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; @@ -32,6 +33,7 @@ public class Parcel { private static final Header[] ABSENT_HEADERS = new Header[0]; private static final ByteBuffer ABSENT_VALUE = ByteBuffer.allocate(0); + @VisibleForTesting static int sizeOfParcel(ParcelVersion parcelVersion, Set recordFields, Record kafkaRecord) { switch (parcelVersion) { case V1: diff --git a/kroxylicious-filters/pom.xml b/kroxylicious-filters/pom.xml index ac4d8e775d..84fb90322b 100644 --- a/kroxylicious-filters/pom.xml +++ b/kroxylicious-filters/pom.xml @@ -47,6 +47,7 @@ io.kroxylicious + io.kroxylicious:kroxylicious-annotations io.kroxylicious:kroxylicious-api io.kroxylicious:kroxylicious-filter-test-support io.kroxylicious:kroxylicious-kms diff --git a/kroxylicious-kms-provider-hashicorp-vault/pom.xml b/kroxylicious-kms-provider-hashicorp-vault/pom.xml index cf58a4d37c..3641d15a85 100644 --- a/kroxylicious-kms-provider-hashicorp-vault/pom.xml +++ b/kroxylicious-kms-provider-hashicorp-vault/pom.xml @@ -27,6 +27,10 @@ io.kroxylicious kroxylicious-kms + + io.kroxylicious + kroxylicious-annotations + io.kroxylicious kroxylicious-api diff --git a/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/VaultKms.java b/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/VaultKms.java index ba8f7c4e09..7850b864a5 100644 --- a/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/VaultKms.java +++ b/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/VaultKms.java @@ -36,6 +36,7 @@ import io.kroxylicious.kms.service.Serde; import io.kroxylicious.kms.service.UnknownAliasException; import io.kroxylicious.kms.service.UnknownKeyException; +import io.kroxylicious.proxy.tag.VisibleForTesting; import edu.umd.cs.findbugs.annotations.NonNull; @@ -80,7 +81,8 @@ private URI ensureEndsInSlash(URI uri) { return uri.resolve(uri.getPath() + "/").normalize(); } - /* exposed for testing */ HttpClient createClient(SSLContext sslContext) { + @VisibleForTesting + HttpClient createClient(SSLContext sslContext) { HttpClient.Builder builder = HttpClient.newBuilder(); if (sslContext != null) { builder.sslContext(sslContext); @@ -179,7 +181,8 @@ public Serde edekSerde() { return new VaultEdekSerde(); } - /* exposed for testing */ HttpRequest.Builder createVaultRequest() { + @VisibleForTesting + HttpRequest.Builder createVaultRequest() { return HttpRequest.newBuilder() .timeout(timeout) .header("X-Vault-Token", vaultToken) @@ -198,7 +201,8 @@ else if (r.statusCode() != 200) { }; } - /* testing */ URI getVaultTransitEngineUri() { + @VisibleForTesting + URI getVaultTransitEngineUri() { return vaultTransitEngineUrl; } } diff --git a/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/config/JdkTls.java b/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/config/JdkTls.java index d7b2be54b3..89bbb1cb6b 100644 --- a/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/config/JdkTls.java +++ b/kroxylicious-kms-provider-hashicorp-vault/src/main/java/io/kroxylicious/kms/provider/hashicorp/vault/config/JdkTls.java @@ -31,6 +31,7 @@ import io.kroxylicious.proxy.config.tls.TrustProvider; import io.kroxylicious.proxy.config.tls.TrustProviderVisitor; import io.kroxylicious.proxy.config.tls.TrustStore; +import io.kroxylicious.proxy.tag.VisibleForTesting; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; @@ -97,7 +98,7 @@ public SSLContext sslContext() { } } - /* exposed for testing */ + @VisibleForTesting static KeyManager[] getKeyManagers(KeyProvider key) { return key.accept(new KeyProviderVisitor<>() { @Override @@ -149,7 +150,7 @@ private static SSLContext getSslContext(TrustManager[] trustManagers, KeyManager } } - /* exposed for testing */ + @VisibleForTesting static TrustManager[] getTrustManagers(TrustProvider trust) { return trust.accept(new TrustProviderVisitor<>() { diff --git a/kroxylicious-runtime/pom.xml b/kroxylicious-runtime/pom.xml index 0e0e3021ff..47ef0b58f8 100644 --- a/kroxylicious-runtime/pom.xml +++ b/kroxylicious-runtime/pom.xml @@ -30,6 +30,10 @@ + + io.kroxylicious + kroxylicious-annotations + io.kroxylicious kroxylicious-api diff --git a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/internal/MeterRegistries.java b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/internal/MeterRegistries.java index 929141fd80..fc216e84eb 100644 --- a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/internal/MeterRegistries.java +++ b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/internal/MeterRegistries.java @@ -25,6 +25,7 @@ import io.kroxylicious.proxy.micrometer.MicrometerConfigurationHook; import io.kroxylicious.proxy.micrometer.MicrometerConfigurationHookContributor; import io.kroxylicious.proxy.service.ContributionManager; +import io.kroxylicious.proxy.tag.VisibleForTesting; import static io.kroxylicious.proxy.service.Context.wrap; @@ -59,7 +60,7 @@ private List registerHooks(List constructPossibleBindingsToCreate(Virtu return creations; } - /* test */ boolean isRegistered(VirtualCluster virtualCluster) { + @VisibleForTesting + boolean isRegistered(VirtualCluster virtualCluster) { return registeredVirtualClusters.containsKey(virtualCluster); } - /* test */ int listeningChannelCount() { + @VisibleForTesting + int listeningChannelCount() { return listeningChannels.size(); } diff --git a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/micrometer/StandardBindersHook.java b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/micrometer/StandardBindersHook.java index 0cfa7986be..7023672d05 100644 --- a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/micrometer/StandardBindersHook.java +++ b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/micrometer/StandardBindersHook.java @@ -26,6 +26,8 @@ import io.micrometer.core.instrument.binder.system.ProcessorMetrics; import io.micrometer.core.instrument.binder.system.UptimeMetrics; +import io.kroxylicious.proxy.tag.VisibleForTesting; + public class StandardBindersHook implements MicrometerConfigurationHook { private static final Logger log = LoggerFactory.getLogger(StandardBindersHook.class); private final StandardBindersHookConfig config; @@ -72,7 +74,8 @@ public void close() { }); } - /* testing */ protected MeterBinder getBinder(String binderName) { + @VisibleForTesting + protected MeterBinder getBinder(String binderName) { return switch (binderName) { case "UptimeMetrics" -> new UptimeMetrics(); case "ProcessorMetrics" -> new ProcessorMetrics(); diff --git a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/service/ContributionManager.java b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/service/ContributionManager.java index 6ed3e7761b..c6049b5dc8 100644 --- a/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/service/ContributionManager.java +++ b/kroxylicious-runtime/src/main/java/io/kroxylicious/proxy/service/ContributionManager.java @@ -11,6 +11,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; +import io.kroxylicious.proxy.tag.VisibleForTesting; + /** * @deprecated We want to remove the generic Contributor type so this has to be rethought/reimplemented. */ @@ -26,7 +28,8 @@ private ContributionManager() { this(ServiceLoader::load); } - /* test */ ContributionManager(Function loaderFunction) { + @VisibleForTesting + ContributionManager(Function loaderFunction) { this.contributors = new ConcurrentHashMap<>(); this.loaderFunction = loaderFunction; } diff --git a/pom.xml b/pom.xml index 3c5ad373fd..e6cfba761f 100644 --- a/pom.xml +++ b/pom.xml @@ -381,6 +381,7 @@ + kroxylicious-annotations kroxylicious-kms kroxylicious-kms-test-support kroxylicious-kms-provider-kroxylicious-inmemory @@ -765,6 +766,9 @@ org.apache.logging.log4j:log4j-slf4j2-impl io.netty:netty-transport-native-unix-common + + io.kroxylicious:kroxylicious-annotations