use of org.eclipse.leshan.tlv.Tlv in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_invalid_multi_resource_2_instance_with_the_same_id.
@Test(expected = CodecException.class)
public void tlv_invalid_multi_resource_2_instance_with_the_same_id() {
Tlv resInstance1 = new Tlv(TlvType.RESOURCE_INSTANCE, null, TlvEncoder.encodeObjlnk(new ObjectLink(100, 1)), 0);
Tlv resInstance2 = new Tlv(TlvType.RESOURCE_INSTANCE, null, TlvEncoder.encodeObjlnk(new ObjectLink(101, 2)), 0);
Tlv multiResource = new Tlv(TlvType.MULTIPLE_RESOURCE, new Tlv[] { resInstance1, resInstance2 }, null, 22);
byte[] content = TlvEncoder.encode(new Tlv[] { multiResource }).array();
decoder.decode(content, ContentFormat.TLV, new LwM2mPath(3, 0, 22), model);
}
use of org.eclipse.leshan.tlv.Tlv in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_manufacturer_resource.
@Test
public void tlv_manufacturer_resource() throws CodecException {
String value = "MyManufacturer";
byte[] content = TlvEncoder.encode(new Tlv[] { new Tlv(TlvType.RESOURCE_VALUE, null, value.getBytes(), 0) }).array();
LwM2mSingleResource resource = (LwM2mSingleResource) decoder.decode(content, ContentFormat.TLV, new LwM2mPath(3, 0, 0), model);
assertEquals(0, resource.getId());
assertFalse(resource.isMultiInstances());
assertEquals(value, resource.getValue());
}
use of org.eclipse.leshan.tlv.Tlv 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.tlv.Tlv in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_empty_instance.
@Test
public void tlv_empty_instance() {
byte[] content = TlvEncoder.encode(new Tlv[] {}).array();
LwM2mObjectInstance instance = (LwM2mObjectInstance) decoder.decode(content, ContentFormat.TLV, new LwM2mPath(2, 0), model);
assertNotNull(instance);
assertEquals(0, instance.getId());
assertTrue(instance.getResources().isEmpty());
}
use of org.eclipse.leshan.tlv.Tlv in project leshan by eclipse.
the class LwM2mNodeDecoderTest method tlv_empty_multi_resource.
@Test
public void tlv_empty_multi_resource() {
byte[] content = TlvEncoder.encode(new Tlv[] {}).array();
LwM2mResource resource = (LwM2mResource) decoder.decode(content, ContentFormat.TLV, new LwM2mPath(3, 0, 6), model);
assertNotNull(resource);
assertTrue(resource instanceof LwM2mMultipleResource);
assertEquals(6, resource.getId());
assertTrue(resource.getValues().isEmpty());
}
Aggregations