Migrate tests in protocol/netconf-server/api from JUnit4 to JUnit5.
JIRA: NETCONF-1310
Change-Id: Ie99729cc76a6a88f29665e9f3b3790f51c055b5f
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
*/
package org.opendaylight.netconf.server.api.monitoring;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class SessionEventTest {
+@ExtendWith(MockitoExtension.class)
+class SessionEventTest {
@Mock
private NetconfManagementSession session;
@Test
- public void test() {
+ void test() {
assertEquals(SessionEvent.Type.IN_RPC_FAIL, SessionEvent.inRpcFail(session).getType());
assertEquals(SessionEvent.Type.IN_RPC_SUCCESS, SessionEvent.inRpcSuccess(session).getType());
assertEquals(SessionEvent.Type.NOTIFICATION, SessionEvent.notification(session).getType());
*/
package org.opendaylight.netconf.server.api.operations;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class AbstractLastNetconfOperationTest {
+class AbstractLastNetconfOperationTest {
private static final class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
boolean handleWithNoSubsequentOperationsRun;
LastNetconfOperationImplTest netconfOperation;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
netconfOperation = new LastNetconfOperationImplTest(new SessionIdType(Uint32.ONE));
}
@Test
- public void testNetconfOperation() throws Exception {
+ void testNetconfOperation() throws Exception {
netconfOperation.handleWithNoSubsequentOperations(null, null);
assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
}
- @Test(expected = DocumentedException.class)
- public void testHandle() throws Exception {
+ @Test
+ void testHandle() {
NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
doReturn("").when(operation).toString();
doReturn(false).when(operation).isExecutionTermination();
- netconfOperation.handle(null, null, operation);
+ assertThrows(DocumentedException.class, () -> netconfOperation.handle(null, null, operation));
}
}
*/
package org.opendaylight.netconf.server.api.operations;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-public class AbstractNetconfOperationTest {
+class AbstractNetconfOperationTest {
private static class NetconfOperationImpl extends AbstractNetconfOperation {
public boolean handleRun;
private final NetconfOperationImpl netconfOperation = new NetconfOperationImpl(new SessionIdType(Uint32.ONE));
private NetconfOperationChainedExecution operation;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
operation = mock(NetconfOperationChainedExecution.class);
}
@Test
- public void testAbstractNetconfOperation() throws Exception {
+ void testAbstractNetconfOperation() throws Exception {
Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/edit_config.xml");
assertEquals(new SessionIdType(Uint32.ONE), netconfOperation.sessionId());
assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.canHandle(helloMessage));
*/
package org.opendaylight.netconf.server.api.operations;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class AbstractSingletonNetconfOperationTest {
+class AbstractSingletonNetconfOperationTest {
private static final class SingletonNCOperationImpl extends AbstractSingletonNetconfOperation {
SingletonNCOperationImpl(final SessionIdType sessionId) {
super(sessionId);
}
@Test
- public void testAbstractSingletonNetconfOperation() throws Exception {
+ void testAbstractSingletonNetconfOperation() {
SingletonNCOperationImpl operation = new SingletonNCOperationImpl(new SessionIdType(Uint32.TEN));
assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY, operation.getHandlingPriority());
}
*/
package org.opendaylight.netconf.server.api.operations;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class HandlingPriorityTest {
+class HandlingPriorityTest {
@Test
- public void testHandlingPriority() {
+ void testHandlingPriority() {
assertEquals(0,
HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY));