/** * Formats a {@link CoapResponse} into a readable String representation. * * @param r the CoapResponse * @return the pretty print */ public static String prettyPrint(CoapResponse r) { return prettyPrint(r.advanced()); }
@Override public String toString() { return "KeyUri[" + uri + " for " + Utils.toHexString(address) + ":" + port + "]"; } }
return Utils.toHexText(payload, 256);
return Utils.toHexText(payload, 256);
@Override public String toString() { return "KeyMID[" + MID + " for " + Utils.toHexString(address) + ":" + port + "]"; } }
/** * Formats a {@link CoapResponse} into a readable String representation. * * @param r the CoapResponse * @return the pretty print */ public static String prettyPrint(CoapResponse r) { return prettyPrint(r.advanced()); }
@Override public String toString() { return "KeyToken[" + Utils.toHexString(token) + "]"; } }
System.out.println(Utils.prettyPrint(response));
protected boolean checkDifferentOption(byte[] expected, byte[] actual, String optionName) { boolean success = !Arrays.equals(expected, actual); if (!success) { System.out.println("FAIL: Option " + optionName + ": expected " + Utils.toHexString(expected) + " but was " + Utils.toHexString(actual)); } else { System.out.println("PASS: Correct option " + optionName); } return success; }
@Override public void onResponse(Response response) { System.out.println(); System.out.println("**** TEST: " + testName + " ****"); // checking the response if (response != null) { // print response info if (verbose) { System.out.println("Response received"); System.out.println("Time elapsed (ms): " + response.getRTT()); Utils.prettyPrint(response); } System.out.println("**** BEGIN CHECK ****"); if (checkResponse(request, response)) { System.out.println("**** TEST PASSED ****"); addSummaryEntry(testName + ": PASSED"); } else { System.out.println("**** TEST FAILED ****"); addSummaryEntry(testName + ": --FAILED--"); } tickOffTest(); } } }
protected boolean checkOption(byte[] expectedOption, byte[] actualOption, String optionName) { boolean success = Arrays.equals(expectedOption, actualOption); if (!success) { System.out.println("FAIL: Option " + optionName + ": expected " + Utils.toHexString(expectedOption) + " but was " + Utils.toHexString(actualOption)); } else { System.out.printf("PASS: Correct option %s\n", optionName); } return success; }
public void test() { CoapResponse response = null; try { URI uri = new URI(SERVER_URI); CoapClient client = new CoapClient(uri); client.setEndpoint(new CoapEndpoint(dtlsConnector, NetworkConfig.getStandard())); response = client.get(); } catch (URISyntaxException e) { System.err.println("Invalid URI: " + e.getMessage()); System.exit(-1); } if (response != null) { System.out.println(response.getCode()); System.out.println(response.getOptions()); System.out.println(response.getResponseText()); System.out.println("\nADVANCED\n"); System.out.println(Utils.prettyPrint(response)); } else { System.out.println("No response received."); } }
@Override public String toString() { return new StringBuilder("KeyToken[").append(Utils.toHexString(token)).append(", ") .append(Utils.toHexString(address)).append(":").append(port).append("]").toString(); }
System.out.println("Request for test " + this.testName + " sent"); Utils.prettyPrint(request);
@Override public String toString() { return new StringBuilder("KeyId[").append(Utils.toHexString(id)).append("]").toString(); } }
System.out.println("Request for test " + this.testName + " sent"); Utils.prettyPrint(request);
@Override public String toString() { return new StringBuilder("KeyId[").append(Utils.toHexString(id)).append("]").toString(); } }
System.out.println("Request for test " + this.testName + " sent"); Utils.prettyPrint(request); System.out.println("Time elapsed (ms): " + response.getRTT()); Utils.prettyPrint(response);
@Override public String toString() { return new StringBuilder("KeyMID[").append(MID).append(", ").append(Utils.toHexString(address)).append(":") .append(port).append("]").toString(); }
System.out.println(Utils.prettyPrint(response)); System.out.println("Time elapsed (ms): " + response.getRTT());