Source:
<code>public void testSubscribeMessages(TestHarness th) throws IOException { DataEncoder dataEncoder = new DataEncoder("Conv-BEB"); dataEncoder.putStart(14, "event"); dataEncoder.put(13, "name", "Query"); dataEncoder.putStart(15, "subscriptions"); dataEncoder.put(10, "battery", "CurrentStateOnly"); dataEncoder.put(10, "wifi_status", "CurrentStateOnly"); dataEncoder.put(10, "network_status", "CurrentStateOnly"); dataEncoder.putEnd(15, "subscriptions"); dataEncoder.putEnd(14, "event"); byte[] sendData = dataEncoder.getData(); client.send(sendData, 0, sendData.length); LocalMessageProtocolMessage msg = client.newMessage(null); client.receive(msg); byte[] clientData = msg.getData(); DataDecoder dataDecoder = new DataDecoder("Conv-BEB", clientData, 0, clientData.length); dataDecoder.getStart(14); th.check(dataDecoder.getString(13).equals("Query")); th.check(dataDecoder.getString(10).equals("OK")); dataDecoder.getStart(15); while (dataDecoder.listHasMoreItems()) { String name = dataDecoder.getName(); if (name.equals("battery")) { dataDecoder.getStart(14); <START> th.check(dataDecoder.getInteger(2) == 1); <END> th.check(dataDecoder.getBoolean() == true); dataDecoder.getEnd(14); } else if (name.equals("network_status")) { dataDecoder.getStart(14); th.check(dataDecoder.getString(10).equals("")); dataDecoder.getEnd(14); } else if (name.equals("wifi_status")) { dataDecoder.getStart(14); th.check(dataDecoder.getBoolean() == true); dataDecoder.getEnd(14); } } dataDecoder.getEnd(15); }</code><technical_language>Nit: th.check alternatives for variable types, do _th.check(actual, expected)_ instead of _th.check(actual == expected)_ _th.check(actual.equals(expected))_ give more info in case of failures</technical_language>

Target:
public void testSubscribeMessages(TestHarness th) throws IOException { DataEncoder dataEncoder = new DataEncoder("Conv-BEB"); dataEncoder.putStart(14, "event"); dataEncoder.put(13, "name", "Query"); dataEncoder.putStart(15, "subscriptions"); dataEncoder.put(10, "battery", "CurrentStateOnly"); dataEncoder.put(10, "wifi_status", "CurrentStateOnly"); dataEncoder.put(10, "network_status", "CurrentStateOnly"); dataEncoder.putEnd(15, "subscriptions"); dataEncoder.putEnd(14, "event"); byte[] sendData = dataEncoder.getData(); client.send(sendData, 0, sendData.length); LocalMessageProtocolMessage msg = client.newMessage(null); client.receive(msg); byte[] clientData = msg.getData(); DataDecoder dataDecoder = new DataDecoder("Conv-BEB", clientData, 0, clientData.length); dataDecoder.getStart(14); th.check(dataDecoder.getString(13), "Query"); th.check(dataDecoder.getString(10), "OK"); dataDecoder.getStart(15); while (dataDecoder.listHasMoreItems()) { String name = dataDecoder.getName(); if (name.equals("battery")) { dataDecoder.getStart(14); th.check(dataDecoder.getInteger(2), 1); th.check(dataDecoder.getBoolean(), true); dataDecoder.getEnd(14); } else if (name.equals("network_status")) { dataDecoder.getStart(14); th.check(dataDecoder.getString(10), ""); dataDecoder.getEnd(14); } else if (name.equals("wifi_status")) { dataDecoder.getStart(14); th.check(dataDecoder.getBoolean(), true); dataDecoder.getEnd(14); } } dataDecoder.getEnd(15); }