X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fpolicyagent%2FMockPolicyAgent.java;h=2b66a353c94006666d564dd8d137080e7df106cc;hb=ee5dde3cccb64e50c02f22a5731ba0134e0d761c;hp=4f4a9be2375bb3112b999bfbfb3683c55dd6b67d;hpb=336d24471b994ebe62828d5327e116f766bbfc85;p=nonrtric.git diff --git a/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java b/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java index 4f4a9be2..2b66a353 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/MockPolicyAgent.java @@ -22,10 +22,12 @@ package org.oransc.policyagent; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.Files; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.oransc.policyagent.configuration.ApplicationConfig; @@ -35,6 +37,8 @@ import org.oransc.policyagent.repository.PolicyType; import org.oransc.policyagent.repository.PolicyTypes; import org.oransc.policyagent.repository.Rics; import org.oransc.policyagent.utils.MockA1ClientFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -46,6 +50,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) public class MockPolicyAgent { + private static final Logger logger = LoggerFactory.getLogger(MockPolicyAgent.class); @Autowired Rics rics; @@ -115,7 +120,7 @@ public class MockPolicyAgent { PolicyType type = ImmutablePolicyType.builder().name(typeName).schema(schema).build(); policyTypes.put(type); } catch (Exception e) { - System.out.println("Could not load json schema " + e); + logger.error("Could not load json schema ", e); } } } @@ -124,14 +129,10 @@ public class MockPolicyAgent { @LocalServerPort private int port; - private void keepServerAlive() { - System.out.println("Keeping server alive!"); - try { - synchronized (this) { - this.wait(); - } - } catch (Exception ex) { - System.out.println("Unexpected: " + ex.toString()); + private void keepServerAlive() throws InterruptedException { + logger.info("Keeping server alive!"); + synchronized (this) { + this.wait(); } } @@ -142,6 +143,9 @@ public class MockPolicyAgent { } @Test + @SuppressWarnings("squid:S2699") // Tests should include assertions. This test is only for keeping the server + // alive, + // so it will only be confusing to add an assertion. public void runMock() throws Exception { keepServerAlive(); }