use of org.eclipse.leshan.core.node.LwM2mPath in project leshan by eclipse.
the class LwM2mNodeEncoderTest method text_encode_multiple_instances.
@Test(expected = CodecException.class)
public void text_encode_multiple_instances() {
Map<Integer, Long> values = new HashMap<>();
values.put(0, 1L);
values.put(1, 5L);
encoder.encode(LwM2mMultipleResource.newIntegerResource(6, values), ContentFormat.TEXT, new LwM2mPath("/3/0/6"), model);
}
use of org.eclipse.leshan.core.node.LwM2mPath in project leshan by eclipse.
the class LwM2mNodeEncoderTest method text_encode_date_as_iso_string.
@Test
public void text_encode_date_as_iso_string() {
byte[] encoded = encoder.encode(LwM2mSingleResource.newIntegerResource(13, 1367491215000L), ContentFormat.TEXT, new LwM2mPath("/3/0/13"), model);
Assert.assertEquals("1367491215", new String(encoded, StandardCharsets.UTF_8));
}
use of org.eclipse.leshan.core.node.LwM2mPath in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_empty_single_resource.
@Test(expected = CodecException.class)
public void tlv_empty_single_resource() {
byte[] content = TlvEncoder.encode(new Tlv[] {}).array();
decoder.decode(content, ContentFormat.TLV, new LwM2mPath(2, 0, 0), model);
}
use of org.eclipse.leshan.core.node.LwM2mPath in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_device_object_instance0_from_resources_tlv.
@Test
public void tlv_device_object_instance0_from_resources_tlv() throws CodecException {
LwM2mObjectInstance oInstance = (LwM2mObjectInstance) decoder.decode(ENCODED_DEVICE_WITHOUT_INSTANCE, ContentFormat.TLV, new LwM2mPath(3, 0), model);
assertDeviceInstance(oInstance);
}
use of org.eclipse.leshan.core.node.LwM2mPath in project leshan by eclipse.
the class LwM2mNodeDecoderTest method json_device_object_instance0.
@Test
public void json_device_object_instance0() throws CodecException {
// json content for instance 0 of device object
StringBuilder b = new StringBuilder();
b.append("{\"e\":[");
b.append("{\"n\":\"0\",\"sv\":\"Open Mobile Alliance\"},");
b.append("{\"n\":\"1\",\"sv\":\"Lightweight M2M Client\"},");
b.append("{\"n\":\"2\",\"sv\":\"345000123\"},");
b.append("{\"n\":\"3\",\"sv\":\"1.0\"},");
b.append("{\"n\":\"6/0\",\"v\":1},");
b.append("{\"n\":\"6/1\",\"v\":5},");
b.append("{\"n\":\"7/0\",\"v\":3800},");
b.append("{\"n\":\"7/1\",\"v\":5000},");
b.append("{\"n\":\"8/0\",\"v\":125},");
b.append("{\"n\":\"8/1\",\"v\":900},");
b.append("{\"n\":\"9\",\"v\":100},");
b.append("{\"n\":\"10\",\"v\":15},");
b.append("{\"n\":\"11/0\",\"v\":0},");
b.append("{\"n\":\"13\",\"v\":1367491215},");
b.append("{\"n\":\"14\",\"sv\":\"+02:00\"},");
b.append("{\"n\":\"16\",\"sv\":\"U\"}]}");
LwM2mObjectInstance oInstance = (LwM2mObjectInstance) decoder.decode(b.toString().getBytes(), ContentFormat.JSON, new LwM2mPath(3, 0), model);
assertDeviceInstance(oInstance);
}
Aggregations