/** * Returns the number of ETag options. * @return the count */ public int getETagCount() { return getETags().size(); }
/** * Removes a specific ETag from the ETag options. * Returns the current OptionSet object for a fluent API. * @param etag the ETag to remove * @return this OptionSet */ public OptionSet removeETag(byte[] etag) { getETags().remove(etag); return this; }
/** * Removes all ETag options. * Returns the current OptionSet object for a fluent API. * @return this OptionSet */ public OptionSet clearETags() { getETags().clear(); return this; }
/** * Returns the number of ETag options. * @return the count */ public int getETagCount() { return getETags().size(); }
/** * Removes a specific ETag from the ETag options. * Returns the current OptionSet object for a fluent API. * @param etag the ETag to remove * @return this OptionSet */ public OptionSet removeETag(byte[] etag) { getETags().remove(etag); return this; }
/** * Removes all ETag options. * Returns the current OptionSet object for a fluent API. * @return this OptionSet */ public OptionSet clearETags() { getETags().clear(); return this; }
/** * Adds an ETag to the ETag options. * Returns the current OptionSet object for a fluent API. * @param etag the ETag to add * @return this OptionSet */ public OptionSet addETag(byte[] etag) { if (etag==null) throw new IllegalArgumentException("ETag option must not be null"); // TODO: ProxyHttp uses ETags that are larger than 8 bytes (20). // if (opaque.length < 1 || 8 < opaque.length) // throw new IllegalArgumentException("ETag option's length must be between 1 and 8 inclusive but was "+opaque.length); getETags().add(etag); return this; }
/** * Adds an ETag to the ETag options. * Returns the current OptionSet object for a fluent API. * @param etag the ETag to add * @return this OptionSet */ public OptionSet addETag(byte[] etag) { if (etag==null) throw new IllegalArgumentException("ETag option must not be null"); // TODO: ProxyHttp uses ETags that are larger than 8 bytes (20). // if (opaque.length < 1 || 8 < opaque.length) // throw new IllegalArgumentException("ETag option's length must be between 1 and 8 inclusive but was "+opaque.length); getETags().add(etag); return this; }
/** * Checks for ETag option. * * @param response * the response * @return true, if successful */ protected boolean hasEtag(Response response) { // boolean success = response.hasOption(OptionNumberRegistry.ETAG); boolean success = response.getOptions().getETagCount() > 0; if (!success) { System.out.println("FAIL: Response without Etag"); } else { System.out.printf( "PASS: Etag (%s)\n", Utils.toHexString(response.getOptions().getETags() .get(0))); } return success; }
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) {
@Override public void check(final Response response) { assertTrue("Response has no ETag", response.getOptions().getETagCount() > 0); storage.put(var, response.getOptions().getETags().get(0)); } });
@Override public void check(final Response response) { assertTrue("Response has no ETag", response.getOptions().getETagCount() > 0); Object obj = storage.get(var); assertThat("Object stored under " + var + " is not an ETag", obj, is(instanceOf(byte[].class))); assertThat("Response contains wrong ETag", (byte[]) obj, is(response.getOptions().getETags().get(0))); } });
@Override public void check(final Message message) { assertThat(message.getOptions().getETags(), hasItem(etag)); }
response = client.get(); if (response.getOptions().getETagCount()==1) { etag = response.getOptions().getETags().get(0); System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]"); System.out.println(response.getResponseText()); etag = response.getOptions().getETags().get(0); System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]"); System.out.println(response.getResponseText()); etag = response.getOptions().getETags().get(0); System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]"); System.out.println(response.getResponseText()); response = client.get(); if (response.getOptions().getETagCount()==1) { etag = response.getOptions().getETags().get(0); System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]"); System.out.println(response.getResponseText()); etag = response.getOptions().getETags().get(0); System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]"); System.out.println(response.getResponseText());
success &= hasEtag(response); success &= hasNonEmptyPalyoad(response); etagStep3 = response.getOptions().getETags().get(0); success &= hasEtag(response); success &= checkOption(etagStep3, response.getOptions() .getETags().get(0), "ETag"); success &= hasEtag(response); success &= checkDifferentOption(etagStep3, response .getOptions().getETags().get(0), "ETag");