* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
+ * Modifications Copyright (C) 2022-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.pap.main.comm;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
/**
* Configures the topic and attaches a listener.
- *
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
final PapParameterGroup parameterGroup = new CommonTestData().getPapParameterGroup(6969);
TopicEndpointManager.getManager().shutdown();
TopicEndpointManager.getManager().start();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
TopicEndpointManager.getManager().shutdown();
}
*
* @throws Exception if an error occurs
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
*
* @throws Exception if an error occurs
*/
- @After
+ @AfterEach
public void tearDown() throws Exception {
TopicEndpointManager.getManager().getNoopTopicSink(PDP_PAP_TOPIC).unregister(listener);
}
@Test
- public void testPublisher_testStop() throws Exception {
+ void testPublisher_testStop() throws Exception {
startThread(pub);
pub.stop();
}
@Test
- public void testPublisher_Ex() {
+ void testPublisher_Ex() {
assertThatThrownBy(() -> new Publisher<>("unknwon-topic")).isInstanceOf(PolicyPapException.class);
}
@Test
- public void testEnqueue() throws Exception {
+ void testEnqueue() throws Exception {
// enqueue before running
pub.enqueue(new QueueToken<>(MSG1));
}
@Test
- public void testRun_StopBeforeProcess() throws Exception {
+ void testRun_StopBeforeProcess() throws Exception {
// enqueue before running
QueueToken<PdpMessage> token = new QueueToken<>(MSG1);
pub.enqueue(token);
}
@Test
- public void testRun() throws Exception {
+ void testRun() throws Exception {
startThread(pub);
// should skip token with null message
}
@Test
- public void testGetNext() throws Exception {
+ void testGetNext() throws Exception {
startThread(pub);
// wait for a message to be processed
/**
* Waits for a message to be published to the topic.
*
- * @param waitMs time to wait, in milli-seconds
- * @return the next message in the queue, or {@code null} if there are no messages
- * or if the timeout was reached
+ * @param waitMs time to wait, in milliseconds
+ * @return the next message in the queue, or {@code null} if there are no messages/timeout was reached
* @throws InterruptedException if this thread was interrupted while waiting
*/
public String await(long waitMs) throws InterruptedException {