Skip to content

Commit 4aa8a32

Browse files
Do not use ExtendWith
* when the extension has a mandatory field to initialize, because ExtendWith only works with default constructor
1 parent bdf571b commit 4aa8a32

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

integration-test/src/test/java/org/cloudfoundry/AbstractIntegrationTest.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
import org.junit.jupiter.api.AfterEach;
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.TestInfo;
22-
import org.junit.jupiter.api.extension.ExtendWith;
22+
import org.junit.jupiter.api.extension.RegisterExtension;
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2727
import reactor.core.publisher.Mono;
2828
import reactor.util.function.Tuple2;
29-
29+
3030
import java.io.ByteArrayOutputStream;
3131
import java.io.File;
3232
import java.io.FileInputStream;
@@ -35,21 +35,24 @@
3535
import java.lang.reflect.Method;
3636
import java.util.Optional;
3737
import java.util.function.Consumer;
38-
38+
3939
import static org.assertj.core.api.Assertions.assertThat;
4040
import static org.cloudfoundry.util.tuple.TupleUtils.consumer;
41-
41+
4242
@SpringJUnitConfig(classes = IntegrationTestConfiguration.class)
43-
@ExtendWith(CloudFoundryVersionConditionalRule.class)
4443
public abstract class AbstractIntegrationTest {
45-
44+
4645
private final Logger logger = LoggerFactory.getLogger("cloudfoundry-client.test");
47-
46+
4847
public String testName;
49-
48+
5049
@Autowired
5150
protected NameFactory nameFactory;
52-
51+
52+
@Autowired
53+
@RegisterExtension
54+
public CloudFoundryVersionConditionalRule cloudFoundryVersionConditionalRule;
55+
5356
@BeforeEach
5457
public void testEntry(TestInfo testInfo) {
5558
Optional<Method> testMethod = testInfo.getTestMethod();
@@ -58,33 +61,33 @@ public void testEntry(TestInfo testInfo) {
5861
}
5962
this.logger.debug(">> {} <<", getTestName());
6063
}
61-
64+
6265
@AfterEach
6366
public final void testExit() {
6467
this.logger.debug("<< {} >>", getTestName());
6568
}
66-
69+
6770
protected static Mono<byte[]> getBytes(String path) {
6871
try (InputStream in = new FileInputStream(new File("src/test/resources", path)); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
6972
byte[] buffer = new byte[8192];
7073
int len;
71-
74+
7275
while ((len = in.read(buffer)) != -1) {
7376
out.write(buffer, 0, len);
7477
}
75-
78+
7679
return Mono.just(out.toByteArray());
7780
} catch (IOException e) {
7881
throw new RuntimeException(e);
7982
}
8083
}
81-
84+
8285
protected static <T> Consumer<Tuple2<T, T>> tupleEquality() {
8386
return consumer((expected, actual) -> assertThat(actual).isEqualTo(expected));
8487
}
85-
88+
8689
private String getTestName() {
8790
return String.format("%s.%s", this.getClass().getSimpleName(), this.testName);
8891
}
89-
92+
9093
}

integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersionConditionalRule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.cloudfoundry;
1818

1919
import com.github.zafarkhaja.semver.Version;
20-
import org.junit.jupiter.api.Assumptions;
2120
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
2221
import org.junit.jupiter.api.extension.ExecutionCondition;
2322
import org.junit.jupiter.api.extension.ExtensionContext;

0 commit comments

Comments
 (0)