*/
package org.opendaylight.openflowplugin.libraries.liblldp;
+import com.google.common.io.BaseEncoding;
+import com.google.common.primitives.Bytes;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.io.BaseEncoding;
-import com.google.common.primitives.Bytes;
-
-/**
- *
- */
+@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public class LLDPTLVTest {
- /** dummy custom tlv value */
+ /** dummy custom tlv value. */
private static final String CUSTOM_TLV_ULTIMATE = "What do you get when you multiply 6 by 9?";
- /** dummy custom tlv value in binary form */
+ /** dummy custom tlv value in binary form. */
private static final byte[] CUSTOM_TLV_ULTIMATE_BIN = new byte[] {
0x57, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x67, 0x65, 0x74,
0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69,
byte[] tlv = LLDPTLV.createCustomTLVValue(CUSTOM_TLV_ULTIMATE);
byte[] expectedCustomTlv = Bytes.concat(new byte[] {
- // custom type (7b) + length (9b) = 16b = 2B (skipped)
- // 0x7f, 24,
- // openflow OUI
- 0x00, 0x26, (byte) 0xe1,
- // subtype
- 0x00},
- // custom value
- CUSTOM_TLV_ULTIMATE_BIN);
+ // custom type (7b) + length (9b) = 16b = 2B (skipped)
+ // 0x7f, 24,
+ // openflow OUI
+ 0x00, 0x26, (byte) 0xe1,
+ // subtype
+ 0x00},
+ // custom value
+ CUSTOM_TLV_ULTIMATE_BIN);
BaseEncoding be = BaseEncoding.base16().withSeparator(" ", 2).lowerCase();
LOG.debug("expected: {}", be.encode(expectedCustomTlv));
/**
* Test method for
- * {@link org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV#getCustomString(byte[], int)}
- * .
- * @throws Exception
+ * {@link org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV#getCustomString(byte[], int)}.
*/
@Test
- public void testGetCustomString() throws Exception {
+ public void testGetCustomString() {
byte[] inputCustomTlv = Bytes.concat(new byte[] {
- // custom type (7b) + length (9b) = 16b = 2B (skipped)
- // 0x7f, 24,
- // openflow OUI
- 0x00, 0x26, (byte) 0xe1,
- // subtype
- 0x00},
- // custom value
- CUSTOM_TLV_ULTIMATE_BIN);
+ // custom type (7b) + length (9b) = 16b = 2B (skipped)
+ // 0x7f, 24,
+ // openflow OUI
+ 0x00, 0x26, (byte) 0xe1,
+ // subtype
+ 0x00},
+ // custom value
+ CUSTOM_TLV_ULTIMATE_BIN);
String actual = LLDPTLV.getCustomString(inputCustomTlv, inputCustomTlv.length);
LOG.debug("actual custom TLV value as string: {}", actual);