initMocks has been deprecated. Use MockitoJUnitRunner instead.
Also, remove unnecessary stubbings and fix some typos in
openflow-protocol-impl.
JIRA: OPNFLWPLUG-1122
Change-Id: I9f30868c84b67a69b262044c047b43df1510ff93
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
import io.netty.channel.ChannelHandlerContext;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
import org.opendaylight.yangtools.yang.binding.DataObject;
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class DelegatingInboundHandlerTest {
@Mock ChannelHandlerContext mockChHndlrCtx;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
dih = new DelegatingInboundHandler(mockMsgConsumer) ;
}
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent;
/**
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class IdleHandlerTest {
@Mock ChannelHandlerContext mockChHndlrCtx ;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
idleHandler = new IdleHandler(60L, TimeUnit.MINUTES);
}
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import java.net.InetSocketAddress;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFDatagramPacketDecoderTest {
@Mock DeserializationFactory deserializationFactory;
@Mock ChannelHandlerContext ctx;
private VersionMessageUdpWrapper msgWrapper;
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
@Test
public void test() {
OFDatagramPacketDecoder decoder = new OFDatagramPacketDecoder();
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
*
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFDatagramPacketEncoderTest {
@Mock ChannelHandlerContext ctx;
* @param version openflow protocol wire version
*/
public void startUp(Uint8 version) {
- MockitoAnnotations.initMocks(this);
out = new ArrayList<>();
HelloInputBuilder builder = new HelloInputBuilder();
builder.setVersion(version);
*/
package org.opendaylight.openflowjava.protocol.impl.core;
-import static org.mockito.Mockito.when;
-
import io.netty.buffer.ByteBuf;
-import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFDatagramPacketHandlerTest {
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
@Mock ChannelHandlerContext ctxMock;
@Mock SwitchConnectionHandler switchConnHandler;
@Mock MessageConsumer consumerMock;
- @Mock Channel channelMock;
-
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- when(ctxMock.channel()).thenReturn(channelMock);
- }
/**
* Test {@link OFDatagramPacketHandler}.
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.opendaylight.openflowjava.statistics.CounterEventTypes;
import org.opendaylight.openflowjava.statistics.StatisticsCounters;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFDecoderStatisticsTest {
@Mock ChannelHandlerContext mockChHndlrCtx;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
ofDecoder = new OFDecoder();
ofDecoder.setDeserializationFactory(mockDeserializationFactory);
outList = new ArrayList<>();
* Stop counting after each test.
*/
@After
- public void tierDown() {
+ public void tearDown() {
statCounters.stopCounting();
}
* Test decode success counter.
*/
@Test
- public void testDecodeSuccesfullCounter() {
+ public void testDecodeSuccessfulCounter() {
if (!statCounters.isCounterEnabled(CounterEventTypes.US_DECODE_SUCCESS)) {
Assert.fail("Counter " + CounterEventTypes.US_DECODE_SUCCESS + " is not enable");
}
import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.yangtools.yang.binding.DataObject;
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFDecoderTest {
@Mock ChannelHandlerContext mockChHndlrCtx ;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
ofDecoder = new OFDecoder();
ofDecoder.setDeserializationFactory(mockDeserializationFactory);
writeObj = ByteBufUtils.hexStringToByteBuf("16 03 01 00");
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFEncoderStatisticsTest {
@Mock ChannelHandlerContext mockChHndlrCtx ;
@Mock MessageListenerWrapper wrapper;
@Mock OfHeader mockMsg ;
@Mock ByteBuf mockOut ;
- @Mock Future<Void> future;
@Mock GenericFutureListener<Future<Void>> listener;
@Mock FlowModInput mockFlowModInput;
* Initialize tests, start and reset counters before each test.
*/
@Before
- public void initTlest() {
- MockitoAnnotations.initMocks(this);
+ public void initTest() {
ofEncoder = new OFEncoder() ;
ofEncoder.setSerializationFactory(mockSerializationFactory) ;
statCounters = StatisticsCounters.getInstance();
* Stop counting after each test.
*/
@After
- public void tierDown() {
+ public void tearDown() {
statCounters.stopCounting();
}
Assert.fail("Counter " + cet + " is not enabled.");
}
- when(mockOut.readableBytes()).thenReturn(1);
when(wrapper.getMsg()).thenReturn(mockMsg);
when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID));
if (!statCounters.isCounterEnabled(cet)) {
Assert.fail("Counter " + cet + " is not enabled.");
}
- when(mockOut.readableBytes()).thenReturn(1);
when(wrapper.getMsg()).thenReturn(mockFlowModInput);
when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID));
import io.netty.util.concurrent.GenericFutureListener;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class OFEncoderTest {
@Mock ChannelHandlerContext mockChHndlrCtx ;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
ofEncoder = new OFEncoder() ;
ofEncoder.setSerializationFactory(mockSerializationFactory);
}
*/
@Test
public void testEncodeSuccess() throws Exception {
- when(mockOut.readableBytes()).thenReturn(1);
when(wrapper.getMsg()).thenReturn(mockMsg);
when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID));
*/
@Test
public void testEncodeSerializesNoBytes() throws Exception {
- when(mockOut.readableBytes()).thenReturn(0);
when(wrapper.getMsg()).thenReturn(mockMsg);
when(wrapper.getMsg().getVersion()).thenReturn(Uint8.valueOf(EncodeConstants.OF13_VERSION_ID));
import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class PublishingChannelInitializerFactoryTest {
TlsConfiguration tlsConfiguration ;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
factory = new ChannelInitializerFactory();
tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore",
PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH,
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
-import javax.net.ssl.SSLEngine;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
*
* @author james.hall
*/
+@RunWith(MockitoJUnitRunner.class)
public class PublishingChannelInitializerTest {
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
@Mock ConnectionAdapterFactory mockConnAdaptorFactory;
@Mock DefaultChannelGroup mockChGrp ;
@Mock ConnectionFacade mockConnFacade ;
- @Mock
- SSLEngine sslEngine ;
@Mock SerializationFactory mockSerializationFactory ;
@Mock DeserializationFactory mockDeserializationFactory ;
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
pubChInitializer = new TcpChannelInitializer(mockChGrp, mockConnAdaptorFactory) ;
pubChInitializer.setSerializationFactory(mockSerializationFactory);
pubChInitializer.setDeserializationFactory(mockDeserializationFactory);
* Test channel initialization with null encryption config.
*/
@Test
- public void testinitChannelEncryptionSetNullTls() {
+ public void testInitChannelEncryptionSetNullTls() {
pubChInitializer.setTlsConfiguration(null);
pubChInitializer.initChannel(mockSocketCh) ;
* Test channel initialization without setting the encryption.
*/
@Test
- public void testinitChannelEncryptionNotSet() {
+ public void testInitChannelEncryptionNotSet() {
// Without encryption, only the common
pubChInitializer.initChannel(mockSocketCh) ;
* Test disconnect on new connection rejected.
*/
@Test
- public void testinitChannelNoEncryptionAcceptFails() throws UnknownHostException {
+ public void testInitChannelNoEncryptionAcceptFails() throws UnknownHostException {
when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(false) ;
pubChInitializer.initChannel(mockSocketCh) ;
import java.net.Socket;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
*
* @author jameshall
*/
+@RunWith(MockitoJUnitRunner.class)
public class TcpHandlerTest {
private final InetAddress serverAddress = InetAddress.getLoopbackAddress() ;
TcpHandler tcpHandler ;
- /**
- * Initialize mocks.
- */
- public TcpHandlerTest() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Test run with null address set.
*/
import io.netty.channel.socket.DatagramPacket;
import java.net.InetSocketAddress;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
/**
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class UdpConnectionMapTest {
@Mock MessageConsumer consumerMock;
@Mock ByteBuf messageBuffer;
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Test {@link UdpConnectionMap} - sender address is not null.
*/
import io.netty.buffer.ByteBuf;
import java.net.InetSocketAddress;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yangtools.yang.common.Uint8;
/**
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class VersionMessageUdpWrapperTest {
@Mock ByteBuf byteBuff;
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
@Test
public void test() {
Uint8 version = Uint8.valueOf(35);
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class ChannelOutboundQueue02Test {
private static int counter;
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
mockXid(echoInput);
mockXid(barrierInput);
mockXid(echoReplyInput);
* Disconnect adapter after each test.
*/
@After
- public void tierDown() {
+ public void tearDown() {
if (adapter != null && adapter.isAlive()) {
adapter.disconnect();
}
import io.netty.channel.Channel;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* UNit tests for ChannelOutboundQueue.
*
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class ChannelOutboundQueueTest {
@Mock Channel channel;
- /**
- * Initialize mocks.
- */
- public ChannelOutboundQueueTest() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Test incorrect queue creation handling.
*/
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* Unit tests for ConnectionAdapterFactoryImpl.
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class ConnectionAdapterFactoryImplTest {
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
@Before
public void startUp() {
- MockitoAnnotations.initMocks(this);
when(channel.pipeline()).thenReturn(channnelPipe);
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
* @author madamjak
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class ConnectionAdapterImp02lTest {
private static final int RPC_RESPONSE_EXPIRATION = 1;
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
mockXid(barrierInput);
mockXid(echoInput);
mockXid(echoReplyInput);
* Disconnect adapter.
*/
@After
- public void tierDown() {
+ public void tearDown() {
if (adapter != null && adapter.isAlive()) {
adapter.disconnect();
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
* @author madamjak
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class ConnectionAdapterImpl02Test {
private static final int RPC_RESPONSE_EXPIRATION = 1;
private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
mockXid(barrierInput);
mockXid(echoInput);
mockXid(echoReplyInput);
* Disconnect adapter.
*/
@After
- public void tierDown() {
+ public void tearDown() {
if (adapter != null && adapter.isAlive()) {
adapter.disconnect();
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
import org.opendaylight.openflowjava.statistics.CounterEventTypes;
import org.opendaylight.openflowjava.statistics.StatisticsCounters;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class ConnectionAdapterImplStatisticsTest {
private static final int RPC_RESPONSE_EXPIRATION = 1;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
mockXid(barrierInput);
mockXid(echoInput);
mockXid(echoReplyInput);
* Stop counting after each test.
*/
@After
- public void tierDown() {
+ public void tearDown() {
if (adapter != null && adapter.isAlive()) {
adapter.disconnect();
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
* @author michal.polkorab
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class ConnectionAdapterImplTest {
private static final int RPC_RESPONSE_EXPIRATION = 1;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
when(channel.pipeline()).thenReturn(pipeline);
adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true,
CHANNEL_OUTBOUND_QUEUE_SIZE);
import io.netty.util.concurrent.Future;
import java.util.concurrent.ExecutionException;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
*
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class SimpleRpcListenerTest {
@Mock Future<Void> future;
- /**
- * Initializes mocks.
- */
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Test SimpleRpcListener creation.
*/
import java.net.UnknownHostException;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
* @author madamjak
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class SwitchConnectionProviderImpl02Test {
@Mock SwitchConnectionHandler handler;
@Mock OFGeneralSerializer serializer;
* @param protocol communication protocol
*/
public void startUp(final TransportProtocol protocol) throws UnknownHostException {
- MockitoAnnotations.initMocks(this);
config = null;
if (protocol != null) {
createConfig(protocol);
import java.util.concurrent.TimeoutException;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
*
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class SwitchConnectionProviderImplTest {
@Mock SwitchConnectionHandler handler;
*/
public void startUp(final TransportProtocol protocol) throws UnknownHostException {
- MockitoAnnotations.initMocks(this);
config = null;
if (protocol != null) {
createConfig(protocol);
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.impl.core.UdpChannelInitializer;
import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler;
import org.slf4j.Logger;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class UdpHandlerTest {
private static final Logger LOG = LoggerFactory.getLogger(UdpHandlerTest.class);
private UdpChannelInitializer udpChannelInitializerMock;
private UdpHandler udpHandler;
- /**
- * Mock init.
- */
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Test to create UdpHandler with empty address and zero port.
*/
import io.netty.util.concurrent.GenericFutureListener;
import java.net.InetSocketAddress;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
/**
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class UdpMessageListenerWrapperTest {
@Mock GenericFutureListener<Future<Void>> listener;
@Mock OfHeader msg;
- @Before
- public void startUp() {
- MockitoAnnotations.initMocks(this);
- }
-
/**
* Getters test.
*/
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.openflowjava.protocol.impl.serialization.action;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
*
* @author madamjak
*/
+@RunWith(MockitoJUnitRunner.class)
public class OF13SetFieldActionSerializerTest {
private SerializerRegistry registry;
*/
@Before
public void startUp() {
- MockitoAnnotations.initMocks(this);
registry = new SerializerRegistryImpl();
registry.init();
}
import io.netty.buffer.ByteBuf;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
*
* @author michal.polkorab
*/
+@RunWith(MockitoJUnitRunner.class)
public class ExperimenterInputMessageFactoryTest {
@Mock SerializerRegistry registry;
* @param real true if setup should use real registry, false when mock is desired
*/
public void startUp(boolean real) {
- MockitoAnnotations.initMocks(this);
expFactory = new ExperimenterInputMessageFactory();
if (real) {
SerializerRegistry realRegistry = new SerializerRegistryImpl();
* Stop counting after each test.
*/
@After
- public void tierDown() {
+ public void tearDown() {
statCounters.stopCounting();
}