import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyExperimenter.
*
+ * @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
public class MultipartReplyExperimenterTest {
@Mock DeserializerRegistry registry;
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
@Mock
private OFDeserializer<ExperimenterDataOfChoice> vendorDeserializer;
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyExperimenter() {
Mockito.verify(vendorDeserializer).deserialize(bb);
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import java.math.BigInteger;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyFlow.
*
+ * @author michal.polkorab
*/
public class MultipartReplyFlowTest {
private OFDeserializer<MultipartReplyMessage> factory;
/**
- * Initializes deserializer registry and lookups correct deserializer
+ * Initializes deserializer registry and lookups correct deserializer.
*/
@Before
public void startUp() {
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
- public void testEmptyMultipartReplyFlowBody(){
+ public void testEmptyMultipartReplyFlowBody() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
- public void testMultipartReplyFlowBody(){
- ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+
+ public void testMultipartReplyFlowBody() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 " + //
// first flow stat
- "00 48 08 00 "+ // length, tableId, padding
- "00 00 00 09 "+//durationSec
- "00 00 00 07 "+//durationNsec
- "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags
- "00 00 00 00 "+//pad_02
- "FF 01 01 01 01 01 01 01 "+//cookie
- "EF 01 01 01 01 01 01 01 "+//packetCount
- "7F 01 01 01 01 01 01 01 "+//byteCount
- "00 01 00 04 00 00 00 00 "+//empty match
- "00 01 00 08 06 00 00 00 "+
- "00 01 00 08 06 00 00 00 "+
+ "00 48 08 00 " + // length, tableId, padding
+ "00 00 00 09 " + //durationSec
+ "00 00 00 07 " + //durationNsec
+ "00 0C 00 0E 00 0F 00 1F " + //priority, idleTimeout, hardTimeout, flags
+ "00 00 00 00 " + //pad_02
+ "FF 01 01 01 01 01 01 01 " + //cookie
+ "EF 01 01 01 01 01 01 01 " + //packetCount
+ "7F 01 01 01 01 01 01 01 " + //byteCount
+ "00 01 00 04 00 00 00 00 " + //empty match
+ "00 01 00 08 06 00 00 00 " + //
+ "00 01 00 08 06 00 00 00 " + //
// second flow stat
- "00 48 08 00 "+ // length, tableId, padding
- "00 00 00 09 "+//durationSec
- "00 00 00 07 "+//durationNsec
- "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags
- "00 00 00 00 "+//pad_02
- "FF 01 01 01 01 01 01 01 "+//cookie
- "EF 01 01 01 01 01 01 01 "+//packetCount
- "7F 01 01 01 01 01 01 01 "+//byteCount
- "00 01 00 04 00 00 00 00 "+//empty match
- "00 01 00 08 06 00 00 00 "+
+ "00 48 08 00 " + // length, tableId, padding
+ "00 00 00 09 " + //durationSec
+ "00 00 00 07 " + //durationNsec
+ "00 0C 00 0E 00 0F 00 00 " + // priority, idleTimeout, hardTimeout, flags
+ "00 00 00 00 " + //pad_02
+ "FF 01 01 01 01 01 01 01 " + //cookie
+ "EF 01 01 01 01 01 01 01 " + //packetCount
+ "7F 01 01 01 01 01 01 01 " + //byteCount
+ "00 01 00 04 00 00 00 00 " + //empty match
+ "00 01 00 08 06 00 00 00 " + //
"00 01 00 08 06 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());
Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01}), flowStats1.getCookie());
+ 0x01, 0x01, 0x01}), flowStats1.getCookie());
Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
flowStats1 = message.getFlowStats().get(1);
Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());
Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01}), flowStats1.getCookie());
+ 0x01, 0x01, 0x01}), flowStats1.getCookie());
Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyGroupFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartReplyGroupFeaturesTest {
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyGroupFeatures() {
- ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
- "00 00 00 0F "+// types
- "00 00 00 0F "+// capabilities
- "00 00 00 01 "+// max groups
- "00 00 00 02 "+// max groups
- "00 00 00 03 "+// max groups
- "00 00 00 04 "+// max groups
- "0F FF 98 01 "+// actions bitmap (all actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 " + //
+ "00 00 00 0F " + // types
+ "00 00 00 0F " + // capabilities
+ "00 00 00 01 " + // max groups
+ "00 00 00 02 " + // max groups
+ "00 00 00 03 " + // max groups
+ "00 00 00 04 " + // max groups
+ "0F FF 98 01 " + // actions bitmap (all actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00"// actions bitmap (no actions included)
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue());
Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue());
Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue());
- Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true,
- true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true,
+ true, true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(1));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(2));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(3));
}
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
- * (with different group types and capabilities)
+ * (with different group types and capabilities).
*/
@Test
public void testMultipartReplyGroupFeatures2() {
- ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
- "00 00 00 00 "+// types
- "00 00 00 00 "+// capabilities
- "00 00 00 01 "+// max groups
- "00 00 00 02 "+// max groups
- "00 00 00 03 "+// max groups
- "00 00 00 04 "+// max groups
- "00 00 00 00 "+// actions bitmap (all actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 " + //
+ "00 00 00 00 " + // types
+ "00 00 00 00 " + // capabilities
+ "00 00 00 01 " + // max groups
+ "00 00 00 02 " + // max groups
+ "00 00 00 03 " + // max groups
+ "00 00 00 04 " + // max groups
+ "00 00 00 00 " + // actions bitmap (all actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00"// actions bitmap (no actions included)
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false),
message.getCapabilities());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyMeterFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartReplyMeterFeaturesTest {
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
- public void testMultipartReplyMeterFeatures(){
- ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+
+ public void testMultipartReplyMeterFeatures() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 " + //
"00 00 00 0A " + // maxMeter
"00 00 00 06 " + // bandTypes
"00 00 00 0F " + // capabilities
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyMeterFeaturesCase messageCase =
+ (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue());
Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes());
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
- public void testMultipartReplyMeterFeatures2(){
- ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+
+ public void testMultipartReplyMeterFeatures2() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 " + //
"00 00 00 09 " + // maxMeter
"00 00 00 00 " + // bandTypes
"00 00 00 00 " + // capabilities
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyMeterFeaturesCase messageCase =
+ (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes());
- Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities());
+ Assert.assertEquals("Wrong capabilities",
+ new MeterFlags(false, false, false, false), message.getCapabilities());
Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyPortDesc.
*
+ * @author michal.polkorab
*/
public class MultipartReplyPortDescTest {
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testEmptyMultipartReplyPortDesc() {
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyPortDesc() {
- ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " +
+ ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + //
// first port desc
"00 01 02 03 00 00 00 00 " + // portNo, padding
"08 00 27 00 B0 EB 00 00 " + // mac address, padding
Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
- Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false,
+ Assert.assertEquals("Wrong advertisedFeatures",
+ new PortFeatures(false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyTableFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartReplyTableFeaturesTest {
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testEmptyMultipartReplyTableFeatures() {
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyTableFeaturesCase messageCase =
+ (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size());
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures() {
- ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+
+ ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 " + //
// first table feature
- "00 40 01 00 00 00 00 00 "+// length, tableId, padding
- "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+
- "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name
- "00 00 00 00 00 00 00 01 "+// metadata match
- "00 00 00 00 00 00 00 02 "+// metadata write
- "00 00 00 00 "+// config
- "00 00 00 2A "+// max entries
+ "00 40 01 00 00 00 00 00 " + // length, tableId, padding
+ "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + //
+ "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
+ "00 00 00 00 00 00 00 01 " + // metadata match
+ "00 00 00 00 00 00 00 02 " + // metadata write
+ "00 00 00 00 " + // config
+ "00 00 00 2A " + // max entries
// second table feature
- "00 40 02 00 00 00 00 00 "+// length, tableId, padding
+ "00 40 02 00 00 00 00 00 " + // length, tableId, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00"
- + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name
- "00 00 00 00 00 00 00 03 "+// metadata match
- "00 00 00 00 00 00 00 04 "+// metadata write
- "00 00 00 03 "+// config
+ + " 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
+ "00 00 00 00 00 00 00 03 " + // metadata match
+ "00 00 00 00 00 00 00 04 " + // metadata write
+ "00 00 00 03 " + // config
"00 00 00 2B" // max entries
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyTableFeaturesCase messageCase =
+ (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
- Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch());
- Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite());
+ Assert.assertArrayEquals("Wrong metadata match",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch());
+ Assert.assertArrayEquals("Wrong metadata write",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
feature = message.getTableFeatures().get(1);
Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
- Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch());
- Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite());
+ Assert.assertArrayEquals("Wrong metadata match",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch());
+ Assert.assertArrayEquals("Wrong metadata write",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures2() {
- ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+
- "00 B0 01 00 00 00 00 00 "+// length, tableId, padding
- "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+
- "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name
- "00 00 00 00 00 00 00 01 "+// metadata match
- "00 00 00 00 00 00 00 02 "+// metadata write
- "00 00 00 00 "+// config
- "00 00 00 2A "+// max entries
- "00 00 00 04 00 00 00 00 "+
- "00 01 00 04 00 00 00 00 "+
- "00 02 00 08 01 02 03 04 "+
- "00 03 00 07 05 06 07 00 "+
- "00 04 00 04 00 00 00 00 "+
- "00 05 00 04 00 00 00 00 "+
- "00 06 00 04 00 00 00 00 "+
- "00 07 00 04 00 00 00 00 "+
- "00 08 00 04 00 00 00 00 "+
- "00 0A 00 04 00 00 00 00 "+
- "00 0C 00 04 00 00 00 00 "+
- "00 0D 00 04 00 00 00 00 "+
- "00 0E 00 04 00 00 00 00 "+
+ ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 " + //
+ "00 B0 01 00 00 00 00 00 " + // length, tableId, padding
+ "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + //
+ "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
+ "00 00 00 00 00 00 00 01 " + // metadata match
+ "00 00 00 00 00 00 00 02 " + // metadata write
+ "00 00 00 00 " + // config
+ "00 00 00 2A " + // max entries
+ "00 00 00 04 00 00 00 00 " + //
+ "00 01 00 04 00 00 00 00 " + //
+ "00 02 00 08 01 02 03 04 " + //
+ "00 03 00 07 05 06 07 00 " + //
+ "00 04 00 04 00 00 00 00 " + //
+ "00 05 00 04 00 00 00 00 " + //
+ "00 06 00 04 00 00 00 00 " + //
+ "00 07 00 04 00 00 00 00 " + //
+ "00 08 00 04 00 00 00 00 " + //
+ "00 0A 00 04 00 00 00 00 " + //
+ "00 0C 00 04 00 00 00 00 " + //
+ "00 0D 00 04 00 00 00 00 " + //
+ "00 0E 00 04 00 00 00 00 " + //
"00 0F 00 04 00 00 00 00"
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
- MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyTableFeaturesCase messageCase =
+ (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
- Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch());
- Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite());
+ Assert.assertArrayEquals("Wrong metadata match",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch());
+ Assert.assertArrayEquals("Wrong metadata write",
+ new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
feature.getTableFeatureProperties().get(13).getType());
}
-}
\ No newline at end of file
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
/**
- * @author michal.polkorab
+ * Unit tests for OF10StatsReplyExperimenter.
*
+ * @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
public class OF10StatsReplyExperimenterTest {
@Mock private OFDeserializer<ExperimenterDataOfChoice> vendorDeserializer;
/**
- * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation
+ * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation.
*/
@Test
public void test() {
Mockito.verify(vendorDeserializer).deserialize(bb);
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
- * @author michal.polkorab
+ * Unit tests for AbstractInstructionDeserializer.
*
+ * @author michal.polkorab
*/
public class AbstractInstructionDeserializerTest {
/**
* Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
- * instruction types
+ * instruction types.
*/
@Test
public void test() {
instruction = new MeterInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase);
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmIpv6ExtHdrDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmIpv6ExtHdrDeserializerTest {
/**
- * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
.getIpv6Exthdr().getMask());
Assert.assertTrue("Unread data", buffer.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmIpv6FlabelDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmIpv6FlabelDeserializerTest {
/**
- * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
}
/**
- * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void testWithMask() {
Assert.assertArrayEquals("Wrong entry mask", new byte[]{0, 0, 0, 5},
((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel().getMask());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmMetadataDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmMetadataDeserializerTest {
/**
- * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"),
((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMetadata());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmMplsBosDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmMplsBosDeserializerTest {
/**
- * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
Assert.assertEquals("Wrong entry value", false,
((MplsBosCase) entry.getMatchEntryValue()).getMplsBos().isBos());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmPbbIsidDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmPbbIsidDeserializerTest {
/**
- * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
Assert.assertEquals("Wrong entry value", 2, ((PbbIsidCase) entry.getMatchEntryValue())
.getPbbIsid().getIsid().intValue());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
/**
- * @author michal.polkorab
+ * Unit tests for OxmVlanVidDeserializer.
*
+ * @author michal.polkorab
*/
public class OxmVlanVidDeserializerTest {
/**
- * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)}
+ * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)}.
*/
@Test
public void test() {
Assert.assertEquals("Wrong entry value", false,
((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowjava.protocol.impl.serialization;
import static org.junit.Assert.assertEquals;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
-
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for SerializationFactory.
*
+ * @author michal.polkorab
*/
public class SerializationFactoryTest {
/**
- * Test serializer lookup & serialization
+ * Test serializer lookup & serialization.
*/
@Test
public void test() {
registry.init();
SerializationFactory factory = new SerializationFactory();
factory.setSerializerTable(registry);
- ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+ final ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
HelloInputBuilder helloBuilder = new HelloInputBuilder();
helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
helloBuilder.setXid(123456L);
}
/**
- * Test serializer not found scenario
+ * Test serializer not found scenario.
*/
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testNotExistingSerializer() {
SerializerRegistry registry = new SerializerRegistryImpl();
registry.init();
SerializationFactory factory = new SerializationFactory();
factory.setSerializerTable(registry);
- ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
+ final ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
HelloInputBuilder helloBuilder = new HelloInputBuilder();
helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
helloBuilder.setXid(123456L);
helloBuilder.setElements(null);
factory.messageToBuffer((short) 0, buffer, helloBuilder.build());
}
-}
\ No newline at end of file
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
/**
+ * Unit tests for SerializerRegistryImpl.
*
* @author madamjak
- *
*/
public class SerializerRegistryImplTest {
private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
/**
- * Test - register serializer without arguments
+ * Test - register serializer without arguments.
*/
@Test(expected = IllegalArgumentException.class)
- public void testRegisterSerializerNoArgs(){
+ public void testRegisterSerializerNoArgs() {
SerializerRegistryImpl serReg = new SerializerRegistryImpl();
serReg.registerSerializer(null, null);
}
/**
- * Test - unregister serializer without MessageTypeKye
+ * Test - unregister serializer without MessageTypeKey.
*/
@Test(expected = IllegalArgumentException.class)
- public void testUnRegisterSerializerNoMessageTypeKey(){
+ public void testUnRegisterSerializerNoMessageTypeKey() {
SerializerRegistryImpl serReg = new SerializerRegistryImpl();
serReg.init();
serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
}
/**
- * Test - unregister serializer
+ * Test - unregister serializer.
*/
@Test
- public void testUnRegisterSerializer(){
+ public void testUnRegisterSerializer() {
SerializerRegistryImpl serReg = new SerializerRegistryImpl();
serReg.init();
serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
- Assert.assertTrue("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF13, Match.class)));
+ Assert.assertTrue("Wrong - unregister serializer",
+ serReg.unregisterSerializer(new MessageTypeKey<>(OF13, Match.class)));
serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer());
- Assert.assertFalse("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF10, Match.class)));
+ Assert.assertFalse("Wrong - unregister serializer",
+ serReg.unregisterSerializer(new MessageTypeKey<>(OF10, Match.class)));
}
}
package org.opendaylight.openflowjava.protocol.impl.serialization.action;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
/**
- * @author madamjak
+ * Unit tests for OF13SetFieldActionSerializer.
*
+ * @author madamjak
*/
public class OF13SetFieldActionSerializerTest {
@Mock OFSerializer<MatchEntry> serializerMock;
/**
- * Initialize registry and mock
+ * Initialize registry and mock.
*/
@Before
public void startUp() {
}
/**
- * Test identify ExperimenterClass serializer
+ * Test identify ExperimenterClass serializer.
*/
@Test
- public void test(){
+ public void test() {
OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer();
ser.injectSerializerRegistry(registry);
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping
+ .ActionBuilder actionBuilder = new ActionBuilder();
long experimenterId = 12L;
ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
registry.registerSerializer(key, serializerMock);
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ser.serialize(actionBuilder.build(), out);
- Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry)Mockito.anyObject(), (ByteBuf)Mockito.anyObject());
+ Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry)Mockito.anyObject(),
+ (ByteBuf)Mockito.anyObject());
int lenght = out.readableBytes();
Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort());
Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort());
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestExperimenter.
*
+ * @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
public class MultipartRequestExperimenterTest {
@Mock ExperimenterDataOfChoice vendorData;
/**
- * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization
- * @throws Exception
+ * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
- Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any()))
- .thenReturn(serializer);
+ Mockito.when(mockRegistry.getSerializer(
+ Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
- MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
+ final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestGroupDesc.
*
+ * @author michal.polkorab
*/
public class MultipartRequestGroupDescTest {
private OFSerializer<MultipartRequestInput> multipartFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link MultipartRequestInputFactory} - GroupDesc case
- * @throws Exception
+ * Tests {@link MultipartRequestInputFactory} - GroupDesc case.
*/
@Test
public void test() throws Exception {
out.skipBytes(4); // skip padding
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestGroupFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartRequestGroupFeaturesTest {
private OFSerializer<MultipartRequestInput> multipartFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link MultipartRequestInputFactory} - GroupFeatures case
- * @throws Exception
+ * Tests {@link MultipartRequestInputFactory} - GroupFeatures case.
*/
@Test
public void test() throws Exception {
out.skipBytes(4); // skip padding
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestMeterFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartRequestMeterFeaturesTest {
private OFSerializer<MultipartRequestInput> multipartFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link MultipartRequestInputFactory} - MeterFeatures case
- * @throws Exception
+ * Tests {@link MultipartRequestInputFactory} - MeterFeatures case.
*/
@Test
public void test() throws Exception {
out.skipBytes(4); // skip padding
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestPortDesc.
*
+ * @author michal.polkorab
*/
public class MultipartRequestPortDescTest {
private OFSerializer<MultipartRequestInput> multipartFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link MultipartRequestInputFactory} - PortDesc case
- * @throws Exception
+ * Tests {@link MultipartRequestInputFactory} - PortDesc case.
*/
@Test
public void test() throws Exception {
out.skipBytes(4); // skip padding
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestTableFeatures.
*
+ * @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
public class MultipartRequestTableFeaturesTest {
@Mock OFSerializer<TableFeatureProperties> serializer;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
- Mockito.when(mockRegistry.getSerializer((MessageTypeKey<?>)Matchers.any()))
- .thenReturn(serializer);
+ Mockito.when(mockRegistry.getSerializer((MessageTypeKey<?>)Matchers.any())).thenReturn(serializer);
registry = new SerializerRegistryImpl();
registry.init();
multipartFactory = registry.getSerializer(
}
/**
- * @throws Exception
- * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(12));
builder.setFlags(new MultipartRequestFlags(true));
- MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
- MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
- List<TableFeatures> tableFeaturesList = new ArrayList<>();
+ final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
+ final MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
- tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
- tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
+ tableFeaturesBuilder.setMetadataMatch(new BigInteger(
+ new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
+ tableFeaturesBuilder.setMetadataWrite(new BigInteger(
+ new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(65L);
- List<TableFeatureProperties> properties = new ArrayList<>();
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES);
NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder =
nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
nextPropBuilder.setNextTableIds(nextIds);
propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
+ List<TableFeatureProperties> properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
- InstructionRelatedTableFeaturePropertyBuilder insPropBuilder =
- new InstructionRelatedTableFeaturePropertyBuilder();
List<Instruction> insIds = new ArrayList<>();
InstructionBuilder insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
insIds.add(insBuilder.build());
+ InstructionRelatedTableFeaturePropertyBuilder insPropBuilder =
+ new InstructionRelatedTableFeaturePropertyBuilder();
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
properties.add(propBuilder.build());
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
+ List<TableFeatures> tableFeaturesList = new ArrayList<>();
tableFeaturesList.add(tableFeaturesBuilder.build());
tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
- tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
- tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
+ tableFeaturesBuilder.setMetadataMatch(new BigInteger(
+ new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
+ tableFeaturesBuilder.setMetadataWrite(new BigInteger(
+ new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(67L);
properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
- OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
- List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
+ List<MatchEntry> entries = new ArrayList<>();
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPort.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
+ OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
}
/**
- * @throws Exception
- * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO
+ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(12));
builder.setFlags(new MultipartRequestFlags(true));
- MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
- MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
- List<TableFeatures> tableFeaturesList = new ArrayList<>();
TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
- tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
- tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
+ tableFeaturesBuilder.setMetadataMatch(new BigInteger(
+ new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}));
+ tableFeaturesBuilder.setMetadataWrite(new BigInteger(
+ new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}));
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(65L);
- List<TableFeatureProperties> properties = new ArrayList<>();
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
+ List<TableFeatureProperties> properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
+ List<TableFeatures> tableFeaturesList = new ArrayList<>();
tableFeaturesList.add(tableFeaturesBuilder.build());
+ MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
featuresBuilder.setTableFeatures(tableFeaturesList);
+ MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class),
Matchers.any(ByteBuf.class));
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartRequestTable.
*
+ * @author michal.polkorab
*/
public class MultipartRequestTableTest {
private OFSerializer<MultipartRequestInput> multipartFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link MultipartRequestInputFactory} - Table case
- * @throws Exception
+ * Tests {@link MultipartRequestInputFactory} - Table case.
*/
@Test
public void test() throws Exception {
out.skipBytes(4); // skip padding
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
-}
\ No newline at end of file
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for OF10StatsRequestAggregate.
*
+ * @author michal.polkorab
*/
public class OF10StatsRequestAggregateTest {
private OFSerializer<MultipartRequestInput> statsFactory;
/**
- * Initializes serializer registry and stores correct factory in field
+ * Initializes serializer registry and stores correct factory in field.
*/
@Before
public void startUp() {
}
/**
- * Tests {@link OF10StatsRequestInputFactory} for correct serialization
- * @throws Exception
+ * Tests {@link OF10StatsRequestInputFactory} for correct serialization.
*/
@Test
public void test() throws Exception {
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPAGGREGATE);
builder.setFlags(new MultipartRequestFlags(false));
- MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
- MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
+ final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
+ final MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true,
true, true, true, true));
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for OF10StatsRequestExperimenter.
*
+ * @author michal.polkorab
*/
@RunWith(MockitoJUnitRunner.class)
public class OF10StatsRequestExperimenterTest {
private ExperimenterDataOfChoice vendorData;
/**
- * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization
- * @throws Exception
+ * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
- Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any()))
- .thenReturn(serializer);
+ Mockito.when(mockRegistry.getSerializer(
+ Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
- MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
+ final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
-}
\ No newline at end of file
+}
import org.slf4j.LoggerFactory;
/**
- * General tests for StatisticsCounters class
- * @author madamjak
+ * General tests for StatisticsCounters class.
*
+ * @author madamjak
*/
public class StatisticsCountersTest {
private StatisticsCounters statCounters;
/**
- * Initialize StatisticsCounters before each test, reset counters
+ * Initialize StatisticsCounters before each test, reset counters.
*/
@Before
- public void initTest(){
+ public void initTest() {
statCounters = StatisticsCounters.getInstance();
statCounters.startCounting(false, 0);
}
/**
- * Stop counting after each test
+ * Stop counting after each test.
*/
@After
- public void tierDown(){
+ public void tierDown() {
statCounters.stopCounting();
}
/**
- * Basic test of increment and reset counters
+ * Basic test of increment and reset counters.
*/
@Test
public void testCounterAll() {
int testCount = 4;
- for(CounterEventTypes cet : CounterEventTypes.values()){
- if(statCounters.isCounterEnabled(cet)){
- incrementCounter(cet,testCount);
- Assert.assertEquals("Wrong - bad counter value " + cet, testCount, statCounters.getCounter(cet).getCounterValue());
+ for (CounterEventTypes cet : CounterEventTypes.values()) {
+ if (statCounters.isCounterEnabled(cet)) {
+ incrementCounter(cet, testCount);
+ Assert.assertEquals("Wrong - bad counter value " + cet, testCount,
+ statCounters.getCounter(cet).getCounterValue());
} else {
Assert.assertNull("Wrong - not enabled counter give not null value", statCounters.getCounter(cet));
}
-
}
statCounters.resetCounters();
- for(CounterEventTypes cet : CounterEventTypes.values()){
- if(statCounters.isCounterEnabled(cet)){
- Assert.assertEquals("Wrong - bad counter value after reset " + cet, 0, statCounters.getCounter(cet).getCounterValue());
+ for (CounterEventTypes cet : CounterEventTypes.values()) {
+ if (statCounters.isCounterEnabled(cet)) {
+ Assert.assertEquals("Wrong - bad counter value after reset " + cet, 0,
+ statCounters.getCounter(cet).getCounterValue());
}
}
}
/**
- * Test to store current and last read value of counter (at least one counter has to be enabled)
+ * Test to store current and last read value of counter (at least one counter has to be enabled).
*/
@Test
public void testCounterLastRead() {
int testCount = 4;
CounterEventTypes firstEnabledCET = null;
- for(CounterEventTypes cet : CounterEventTypes.values()){
- if(statCounters.isCounterEnabled(cet)){
+ for (CounterEventTypes cet : CounterEventTypes.values()) {
+ if (statCounters.isCounterEnabled(cet)) {
firstEnabledCET = cet;
break;
}
}
- if(firstEnabledCET == null){
+ if (firstEnabledCET == null) {
Assert.fail("No counter is enabled");
}
- incrementCounter(firstEnabledCET,testCount);
+ incrementCounter(firstEnabledCET, testCount);
LOG.debug("Waiting to process event queue");
- Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
- Assert.assertEquals("Wrong - bad value", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue(false));
- Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
- Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue());
- Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
- incrementCounter(firstEnabledCET,testCount);
- Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
- Assert.assertEquals("Wrong - bad last read value.", 2*testCount,statCounters.getCounter(firstEnabledCET).getCounterValue());
+ Assert.assertEquals("Wrong - bad last read value.", 0,
+ statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
+ Assert.assertEquals("Wrong - bad value", testCount,
+ statCounters.getCounter(firstEnabledCET).getCounterValue(false));
+ Assert.assertEquals("Wrong - bad last read value.", 0,
+ statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
+ Assert.assertEquals("Wrong - bad last read value.", testCount,
+ statCounters.getCounter(firstEnabledCET).getCounterValue());
+ Assert.assertEquals("Wrong - bad last read value.", testCount,
+ statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
+ incrementCounter(firstEnabledCET, testCount);
+ Assert.assertEquals("Wrong - bad last read value.", testCount,
+ statCounters.getCounter(firstEnabledCET).getCounterLastReadValue());
+ Assert.assertEquals("Wrong - bad last read value.", 2 * testCount,
+ statCounters.getCounter(firstEnabledCET).getCounterValue());
}
/**
- * Test start and stop log reporter
+ * Test start and stop log reporter.
*/
@Test
- public void testStartStopLogReporter(){
+ public void testStartStopLogReporter() {
int testDelay = 10000;
statCounters.startLogReport(testDelay);
Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport());
Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport());
statCounters.startLogReport(StatisticsCounters.MINIMAL_LOG_REPORT_PERIOD / 2);
Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport());
- Assert.assertEquals("Wrong - bad logReportPeriod", StatisticsCounters.MINIMAL_LOG_REPORT_PERIOD, statCounters.getLogReportPeriod());
+ Assert.assertEquals("Wrong - bad logReportPeriod",
+ StatisticsCounters.MINIMAL_LOG_REPORT_PERIOD, statCounters.getLogReportPeriod());
statCounters.stopCounting();
Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport());
}
/**
- * Test start log report with bad logReportDealy
+ * Test start log report with bad logReportDealy.
*/
@Test(expected = IllegalArgumentException.class)
- public void testLogReportBadPeriod(){
+ public void testLogReportBadPeriod() {
statCounters.startLogReport(0);
}
/**
- * Test to get counter with null key
+ * Test to get counter with null key.
*/
@Test(expected = IllegalArgumentException.class)
- public void testGetCounterbyNull(){
+ public void testGetCounterbyNull() {
statCounters.getCounter(null);
}
- private void incrementCounter(CounterEventTypes cet, int count){
- if(!statCounters.isCounterEnabled(cet)){
+ private void incrementCounter(CounterEventTypes cet, int count) {
+ if (!statCounters.isCounterEnabled(cet)) {
return;
}
- for(int i = 0; i< count; i++){
+ for (int i = 0; i < count; i++) {
statCounters.incrementCounter(cet);
}
}