use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.
the class AbstractSenMLTest method getPackWithSingleOpaqueValue.
protected SenMLPack getPackWithSingleOpaqueValue(String path, byte[] value) {
SenMLPack pack = new SenMLPack();
SenMLRecord r = new SenMLRecord();
r.setBaseName(path);
r.setOpaqueValue(value);
pack.addRecord(r);
return pack;
}
use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.
the class SenMLCborSerializerTest method deserialize_device_object_.
@Test
public void deserialize_device_object_() throws Exception {
SenMLPack pack = decoder.fromSenML(Hex.decodeHex(givenSenMLCborExample().toCharArray()));
SenMLTestUtil.assertSenMLPackEquals(givenDeviceObjectInstance(), pack);
}
use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.
the class SenMLCborSerializerTest method deserialize_opaque_resource.
@Test
public void deserialize_opaque_resource() throws Exception {
// value : [{-2: "/0/0/3", 8: h'ABCDEF'}]
byte[] cbor = Hex.decodeHex("81a221662f302f302f330843abcdef".toCharArray());
SenMLPack pack = decoder.fromSenML(cbor);
SenMLTestUtil.assertSenMLPackEquals(getPackWithSingleOpaqueValue("/0/0/3", Hex.decodeHex("ABCDEF".toCharArray())), pack);
}
use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.
the class SenMLCborSerializerTest method serialize_opaque_resource_.
@Test
public void serialize_opaque_resource_() throws Exception {
SenMLPack pack = getPackWithSingleOpaqueValue("/0/0/3", Hex.decodeHex("ABCDEF".toCharArray()));
byte[] cbor = encoder.toSenML(pack);
// value : [{-2: "/0/0/3", 8: h'ABCDEF'}]
String expected = "81a221662f302f302f330843abcdef";
Assert.assertEquals(expected, Hex.encodeHexString(cbor));
}
use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.
the class SenMLJsonSerDesTest method serialize_then_deserialize_device_object.
@Test
public void serialize_then_deserialize_device_object() throws SenMLException {
byte[] json = encoder.toSenML(givenDeviceObjectInstance());
SenMLPack pack = decoder.fromSenML(json);
SenMLTestUtil.assertSenMLPackEquals(givenDeviceObjectInstance(), pack);
}
Aggregations