@Override public String toString() { return "KeyUri[" + uri + " for " + Utils.toHexString(address) + ":" + port + "]"; } }
@Override public String toString() { return "KeyMID[" + MID + " for " + Utils.toHexString(address) + ":" + port + "]"; } }
@Override public String toString() { return "KeyToken[" + Utils.toHexString(token) + "]"; } }
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; }
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; }
@Override public String toString() { return new StringBuilder("KeyToken[").append(Utils.toHexString(token)).append(", ") .append(Utils.toHexString(address)).append(":").append(port).append("]").toString(); }
@Override public String toString() { return new StringBuilder("KeyId[").append(Utils.toHexString(id)).append("]").toString(); } }
@Override public String toString() { return new StringBuilder("KeyId[").append(Utils.toHexString(id)).append("]").toString(); } }
@Override public String toString() { return new StringBuilder("KeyMID[").append(MID).append(", ").append(Utils.toHexString(address)).append(":") .append(port).append("]").toString(); }
@Override public String toString() { return new StringBuilder("KeyUri[").append(uri).append(", ").append(Utils.toHexString(address)).append(":") .append(port).append("]").toString(); } }
/** * Gets the 0--8 byte token as string representation. * * @return the token as string */ public String getTokenString() { return Utils.toHexString(getToken()); }
public String toString() { return "Expected token: " + Utils.toHexString(token); } });
@Override public String toString() { return String.format("Expected etag: %s", Utils.toHexString(etag)); } });
public String toString() { Object[] pair = (Object[]) storage.get(var); return "Expected MID: " + pair[0] + " and token " + Utils.toHexString((byte[]) pair[1]); } });
/** * Checks for Token option. * * @param response * the response * @return true, if successful */ protected boolean hasToken(Response response) { boolean success = response.getToken() != null; if (!success) { System.out.println("FAIL: Response without Token"); } else { System.out.printf("PASS: Token (%s)\n", Utils.toHexString(response.getToken())); } return success; }
/** * Helper function that creates a BlockOption with the specified parameters * and serializes them to a byte array. */ private static byte[] toBytes(int szx, boolean m, int num) { byte[] bytes = new BlockOption(szx, m, num).getValue(); System.out.println("(szx="+szx+", m="+m+", num="+num+") => " + Utils.toHexString(bytes)); return bytes; }
protected final void appendEtags(final OptionSet options) { if (options != null && options.getETagCount() > 0) { buffer.append(", ETags("); int i = 0; for (byte[] tag : options.getETags()) { buffer.append(Utils.toHexString(tag)); if (++i < options.getETagCount()) { buffer.append(", "); } } buffer.append(")"); } } protected final void appendRequestDetails(final Request request) {
public void check(Message message) { assertArrayEquals("Wrong token:", token, message.getToken()); print("Correct token: " + Utils.toHexString(token)); }
@Override public void check(Message message) { Object[] pair = (Object[]) storage.get(var); assertEquals("Wrong MID:", pair[0], message.getMID()); assertArrayEquals("Wrong token:", (byte[]) pair[1], message.getToken()); print("Correct MID: " + message.getMID() + " and token: " + Utils.toHexString(message.getToken())); }
/** * Converts a BlockOption with the specified parameters to a byte array and * back and checks that the result is the same as the original. */ private static void testCombined(int szx, boolean m, int num) { BlockOption block = new BlockOption(szx, m, num); BlockOption copy = new BlockOption(block.getValue()); assertEquals(block.getSzx(), copy.getSzx()); assertEquals(block.isM(), copy.isM()); assertEquals(block.getNum(), copy.getNum()); System.out.println(Utils.toHexString(block.getValue()) +" == " + "(szx="+block.getSzx()+", m="+block.isM()+", num="+block.getNum()+")"); }