11package dev .openfeature .sdk ;
22
33import com .vmlens .api .AllInterleavings ;
4+ import com .vmlens .api .Runner ;
45import dev .openfeature .sdk .providers .memory .Flag ;
56import dev .openfeature .sdk .providers .memory .InMemoryProvider ;
67import java .util .HashMap ;
1011 * Javadoc.
1112 */
1213public class VmLensTest {
13- int jaVar = 0 ;
14-
15-
1614 public static void main (String [] args ) throws InterruptedException {
1715 new VmLensTest ().asomeMethod ();
1816 }
1917
20- private void asomeMethod () throws InterruptedException {
18+ public void asomeMethod () throws InterruptedException {
2119 var c = new AtomicInteger ();
2220 final OpenFeatureAPI api = new OpenFeatureAPI ();
2321
@@ -27,36 +25,20 @@ private void asomeMethod() throws InterruptedException {
2725 flags .put ("c" , Flag .builder ().variant ("a" , "dfs" ).defaultVariant ("a" ).build ());
2826 flags .put ("d" , Flag .builder ().variant ("a" , "asddd" ).defaultVariant ("a" ).build ());
2927 api .setProviderAndWait (new InMemoryProvider (flags ));
28+ var client = api .getClient ();
3029 try (AllInterleavings allInterleavings = new AllInterleavings ("Concurrent evaluations and hook additions" )) {
3130 while (allInterleavings .hasNext ()) {
3231 c .incrementAndGet ();
33- var client = api .getClient ();
34- var firstReady = new Awaitable ();
35- Thread first = new Thread ("test thread" ) {
36- @ Override
37- public void run () {
38- firstReady .wakeup ();
39- client .getStringValue ("a" , "a" );
40- //client.getStringValue("a", "a");
41- }
42- };
43-
44- first .start ();
45- firstReady .await ();
4632
47- client . addHooks ( new Hook () {});
48- // client.addHooks(new Hook() {});
49-
50- first . join ( );
33+ Runner . runParallel (
34+ () -> client .getStringValue ( "a" , "a" ),
35+ () -> client . addHooks ( new Hook () {})
36+ );
5137 }
5238 }
5339
5440 api .shutdown ();
5541
5642 System .out .println ("c = " + c );
57- System .out .println ("jaVar = " + jaVar );
58-
59- //Thread.sleep(5000);
60- //System.exit(0);
6143 }
6244}
0 commit comments