05a33c0fe7712cd6382770f152f572f0c97d05bc
[openflowjava.git] / third-party / openflow-codec / src / test / java / org / openflow / codec / util / HexStringTest.java
1 package org.openflow.codec.util;
2
3 import org.openflow.codec.util.HexString;
4
5 import junit.framework.TestCase;
6
7 /**
8  * Does hexstring conversion work?
9  *
10  * @author Rob Sherwood (rob.sherwood@stanford.edu)
11  *
12  */
13
14 public class HexStringTest extends TestCase {
15
16     public void testMarshalling() throws Exception {
17         String dpidStr = "00:00:00:23:20:2d:16:71";
18         long dpid = HexString.toLong(dpidStr);
19         String testStr = HexString.toHexString(dpid);
20         TestCase.assertEquals(dpidStr, testStr);
21     }
22
23     public void testToStringBytes() {
24         byte[] dpid = { 0, 0, 0, 0, 0, 0, 0, -1 };
25         String valid = "00:00:00:00:00:00:00:ff";
26         String testString = HexString.toHexString(dpid);
27         TestCase.assertEquals(valid, testString);
28     }
29 }