import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import java.util.UUID;
import org.junit.Test;
public class AbstractIetfYangUtilTest {
}
@Test
- public void testPhysToBytes() throws Exception {
+ public void testBytesToHex() {
+ final HexClass hex = UTIL.hexStringFor(BYTES);
+ assertEquals(CANON, hex.getValue());
+ }
+
+ @Test
+ public void testHexToBytes() {
+ final byte[] bytes1 = UTIL.hexStringBytes(new HexClass(CANON));
+ assertArrayEquals(BYTES, bytes1);
+
+ final byte[] bytes2 = UTIL.hexStringBytes(new HexClass("01:02:1E:5a:Fb:88"));
+ assertArrayEquals(BYTES, bytes2);
+ }
+
+ @Test
+ public void testPhysToBytes() {
final byte[] bytes1 = UTIL.physAddressBytes(new PhysClass(CANON));
assertArrayEquals(BYTES, bytes1);
assertArrayEquals(new byte[] { (byte) 0xaa, (byte) 0xbb }, UTIL.physAddressBytes(new PhysClass("aa:bb")));
}
+ @Test
+ public void testQuadBits() {
+ assertEquals(0x01020304, UTIL.dottedQuadBits(new QuadClass("1.2.3.4")));
+ assertEquals(0xFFFFFFFF, UTIL.dottedQuadBits(new QuadClass("255.255.255.255")));
+ }
+
+ @Test
+ public void testQuadBytes() {
+ assertArrayEquals(new byte[] { 1, 2, 3, 4 }, UTIL.dottedQuadBytes(new QuadClass("1.2.3.4")));
+ }
+
+ @Test
+ public void testQuadForBits() {
+ assertEquals("1.2.3.4", UTIL.dottedQuadFor(0x01020304).getValue());
+ assertEquals("255.255.255.255", UTIL.dottedQuadFor(0xFFFFFFFF).getValue());
+ }
+
+ @Test
+ public void testQuadForBytes() {
+ assertEquals("1.2.3.4", UTIL.dottedQuadFor(new byte[] { 1, 2, 3, 4 }).getValue());
+ }
+
+ @Test
+ public void testUuidFor() {
+ final UUID uuid = UUID.fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
+ assertEquals("f81d4fae-7dec-11d0-a765-00a0c91e6bf6", UTIL.uuidFor(uuid).getValue());
+ }
+
@Test
public void canonizeMACTest() throws Exception {
assertEquals(CANON, UTIL.canonizeMacAddress(new MacClass("01:02:1E:5A:FB:88")).getValue());