|
4 | 4 |
|
5 | 5 | import java.util.HashMap;
|
6 | 6 | import java.util.Map;
|
7 |
| -import java.util.concurrent.locks.ReentrantReadWriteLock; |
| 7 | + |
| 8 | +import org.junit.jupiter.api.BeforeEach; |
| 9 | +import org.junit.jupiter.api.Order; |
| 10 | +import org.junit.jupiter.api.parallel.Isolated; |
8 | 11 |
|
9 | 12 | import dev.openfeature.sdk.Client;
|
10 | 13 | import dev.openfeature.sdk.EvaluationContext;
|
| 14 | +import dev.openfeature.sdk.FeatureProvider; |
11 | 15 | import dev.openfeature.sdk.FlagEvaluationDetails;
|
12 | 16 | import dev.openfeature.sdk.ImmutableContext;
|
13 | 17 | import dev.openfeature.sdk.ImmutableStructure;
|
| 18 | +import dev.openfeature.sdk.OpenFeatureAPI; |
14 | 19 | import dev.openfeature.sdk.Reason;
|
15 | 20 | import dev.openfeature.sdk.Structure;
|
16 | 21 | import dev.openfeature.sdk.Value;
|
17 |
| -import io.cucumber.java.BeforeAll; |
| 22 | +import io.cucumber.java.AfterAll; |
18 | 23 | import io.cucumber.java.en.And;
|
19 | 24 | import io.cucumber.java.en.Given;
|
20 | 25 | import io.cucumber.java.en.Then;
|
|
23 | 28 | /**
|
24 | 29 | * Common test suite used by both RPC and in-process flagd providers.
|
25 | 30 | */
|
| 31 | +@Isolated() |
| 32 | +@Order(value = Integer.MAX_VALUE) |
26 | 33 | public class StepDefinitions {
|
27 | 34 |
|
28 |
| - private static final ReentrantReadWriteLock sync = new ReentrantReadWriteLock(); |
29 | 35 | private static Client client;
|
| 36 | + private static FeatureProvider provider; |
30 | 37 |
|
31 | 38 | private String booleanFlagKey;
|
32 | 39 | private String stringFlagKey;
|
@@ -63,15 +70,25 @@ public class StepDefinitions {
|
63 | 70 | *
|
64 | 71 | * @param client client to inject into test.
|
65 | 72 | */
|
66 |
| - public static void setClient(Client client) { |
67 |
| - StepDefinitions.client = client; |
| 73 | + public static void setProvider(FeatureProvider provider) { |
| 74 | + StepDefinitions.provider = provider; |
68 | 75 | }
|
69 | 76 |
|
70 |
| - @BeforeAll() |
| 77 | + @BeforeEach() |
71 | 78 | @Given("a provider is registered")
|
72 | 79 | @Given("a flagd provider is set")
|
73 | 80 | public static void setup() {
|
74 |
| - // this is handled by the "Setup" files |
| 81 | + if (StepDefinitions.client == null) { |
| 82 | + OpenFeatureAPI.getInstance().setProviderAndWait("e2e", provider); |
| 83 | + StepDefinitions.client = OpenFeatureAPI.getInstance().getClient("e2e"); |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + @AfterAll() |
| 88 | + public static void cleanUp() throws InterruptedException { |
| 89 | + StepDefinitions.provider.shutdown(); |
| 90 | + StepDefinitions.provider = null; |
| 91 | + StepDefinitions.client = null; |
75 | 92 | }
|
76 | 93 |
|
77 | 94 | /*
|
|
0 commit comments