All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.kroxylicious.testing.kafka.junit5ext.ConstraintsMethodSource Maven / Gradle / Ivy

Go to download

Provides a JUnit5 extension for providing KafkaCluster implementations to tests and running tests over multiple cluster configurations.

There is a newer version: 0.9.1
Show newest version
/*
 * Copyright Kroxylicious Authors.
 *
 * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package io.kroxylicious.testing.kafka.junit5ext;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Reference to a method providing a Stream, Collection or array of constraint annotations tuples
 * for a {@code TestTemplate}.
 * The method will be invoked by the {@link KafkaClusterExtension}
 * to provide a list of constraint lists over which the test will parameterized.
 * The annotation should be used on a {@code KafkaCluster}-typed parameter of a
 * {@code TestTemplate}-annotated method.
 * The referenced method must be {@code static} and package- or {@code public}ly-accessible.
 *
 * 

For example

*
{@code
 * static Stream> clusters() {
 *     return Stream.of(
 *         List.of(ConstraintUtils.brokerCluster(1), ConstraintUtils.kraftCluster(1)),
 *         List.of(ConstraintUtils.brokerCluster(3), ConstraintUtils.kraftCluster(1)),
 *         List.of(ConstraintUtils.brokerCluster(3), ConstraintUtils.zooKeeperCluster()));
 * }
 *
 * @TestTemplate
 * void matrixTest(@ConstraintMethodSource("clusters") KafkaCluster cluster) {
 *     // ....
 * }
 * }*
* *

If you want to execute a tests for each of the Cartesian product * of a number of dimensions you might find {@link DimensionMethodSource @DimensionMethodSource} * more convenient.

*/ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.PARAMETER, ElementType.FIELD }) public @interface ConstraintsMethodSource { /** * Value of contraints method source. * * @return the value */ String value(); /** * The class where defining the static method, or Void.class (default), if the method * is defined with the class defining the annotation test. * @return the class */ Class clazz() default Void.class; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy