public void check(Response response) { Type type = response.getType(); storage.put(key, type); } });
/** * Returns true if the specified response is still in transit. A response is * in transit if it has not yet been acknowledged, rejected or its current * transmission has not yet timed out. */ private static boolean isInTransit(final Response response) { Type type = response.getType(); boolean acked = response.isAcknowledged(); boolean timeout = response.isTimedOut(); boolean result = type == Type.CON && !acked && !timeout; return result; }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.NON, response.getType()); // Code = 68 (2.04 Changed) or 65 (2.01 Created) success &= checkInts(expectedResponseCodes, response.getCode().value, "code"); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.NON, response.getType()); // Code = 65(2.01 Created) or 68 (2.04 changed) success &= checkInts(expectedResponseCodes, response.getCode().value, "code"); return success; } }
@Override public String toString() { String payload = getPayloadTracingString(); return String.format("%s-%-6s MID=%5d, Token=%s, OptionSet=%s, %s", getType(), getCode(), getMID(), getTokenString(), getOptions(), payload); }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkTypes(new Type[] { Type.ACK, Type.CON }, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkTypes(new Type[] { Type.ACK, Type.CON }, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasNoToken(response); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkInt(request.getMID(), response.getMID(), "MID"); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); // Token value = the same value as in the request sent by the client // in step 2 success &= checkToken(request.getToken(), response.getToken()); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkOption(MediaTypeRegistry.APPLICATION_LINK_FORMAT, response.getOptions().getContentFormat(), "Content-Format"); success &= checkDiscoveryAttributes(EXPECTED_HREF, response.getPayloadString()); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkOption(MediaTypeRegistry.APPLICATION_LINK_FORMAT, response.getOptions().getContentFormat(), "Content-Format"); success &= checkDiscoveryAttributes(EXPECTED_IF, response.getPayloadString()); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkToken(request.getToken(), response.getToken()); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); success &= hasObserve(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkOption(MediaTypeRegistry.APPLICATION_LINK_FORMAT, response.getOptions().getContentFormat(), "Content format"); success &= hasNonEmptyPalyoad(response); success &= checkDiscoveryAttributes(EXPECTED_RT, response.getPayloadString()); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkToken(request.getToken(), response.getToken()); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); success &= hasObserve(response); return success; } }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.CON, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= checkToken(request.getToken(), response.getToken()); success &= hasContentType(response); success &= hasNonEmptyPalyoad(response); success &= hasObserve(response); return success; } }
@Test public void testAdvancedUsesTypeFromRequest() throws Exception { String uri = TestTools.getUri(serverEndpoint, TARGET); CoapClient client = new CoapClient(uri).useExecutor(); // Set NONs but expecting CONs as specified in request client.useNONs(); Request request = new Request(Code.GET, Type.CON); CoapResponse resp = client.advanced(request); Assert.assertEquals(Type.ACK, resp.advanced().getType()); Assert.assertEquals(CONTENT_1, resp.getResponseText()); }