X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Frepository%2FLockTest.java;h=5c1cc140ee0235d01ee0fd2fcebf86a32a7feb2c;hb=4db5e7d262aaa8ccf18feaa4bd93a6a925801333;hp=825010ab8c297b6eaec546e593b84e1c6cb7986e;hpb=14accd2e91460d1651fe2c228fe1ba964cbfb6a6;p=nonrtric.git diff --git a/policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java b/policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java index 825010ab..5c1cc140 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/repository/LockTest.java @@ -36,19 +36,21 @@ import reactor.test.StepVerifier; @ExtendWith(MockitoExtension.class) public class LockTest { + @SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests. private void sleep() { try { Thread.sleep(100); } catch (InterruptedException e) { + // Do nothing. } } private void asynchUnlock(Lock lock) { - Thread t = new Thread(() -> { + Thread thread = new Thread(() -> { sleep(); lock.unlockBlocking(); }); - t.start(); + thread.start(); } @Test @@ -71,10 +73,8 @@ public class LockTest { Lock lock = new Lock(); Mono seq = lock.lock(LockType.EXCLUSIVE) // - .doOnNext(l -> System.out.println("1 " + l)) // .flatMap(l -> lock.lock(LockType.EXCLUSIVE)) // - .flatMap(l -> lock.unlock()) // - .doOnNext(l -> System.out.println("2 " + l)); // + .flatMap(l -> lock.unlock()); asynchUnlock(lock); StepVerifier.create(seq) //