Fix GroupKey interpretation in REST
Input string from REST should not be converted into byte array directly.
Before: "1" -> ascii 49 -> 0x31
After: "0x01" -> 0x01
GroupKey is a byte array with arbitrary length and represented by hex string
Change-Id: If27101f0e5522212c7e434fab58b66e67e9676d7
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/GroupCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/GroupCodecTest.java
index 2a3b7d4..93473a5 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/GroupCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/GroupCodecTest.java
@@ -44,6 +44,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.equalTo;
import static org.onosproject.codec.impl.GroupJsonMatcher.matchesGroup;
import static org.onosproject.net.NetTestTools.APP_ID;
@@ -109,6 +110,11 @@
assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.portNumber(2)));
}
+ @Test(expected = IllegalArgumentException.class)
+ public void invalidGroupTest() throws IOException {
+ Group group = getGroup("invalid-group.json");
+ }
+
/**
* Checks that the data shared by all the resource is correct for a given group.
*
@@ -118,7 +124,8 @@
assertThat(group.appId(), is(APP_ID));
assertThat(group.deviceId().toString(), is("of:0000000000000001"));
assertThat(group.type().toString(), is("ALL"));
- assertThat(group.appCookie().key(), is("1".getBytes()));
+ assertThat(group.appCookie().key(),
+ equalTo(new byte[]{(byte) 0x12, (byte) 0x34, (byte) 0xAB, (byte) 0xCD}));
assertThat(group.id().id(), is(1));
}