javax.ws.rs.core.Response.getEntityTag()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中javax.ws.rs.core.Response.getEntityTag方法的一些代码示例,展示了Response.getEntityTag的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getEntityTag方法的具体详情如下:
包路径:javax.ws.rs.core.Response
类名称:Response
方法名:getEntityTag

Response.getEntityTag介绍

[英]Get the entity tag.
[中]获取实体标签。

代码示例

代码示例来源:origin: SAP/cloud-s4-sdk-examples

@Override
public EntityTag getEntityTag()
{
  return delegate.getEntityTag();
}

代码示例来源:origin: trellis-ldp/trellis

/**
 * Get the EntityTag for a given resource.
 * @param url the URL
 * @return the entity tag
 */
default EntityTag getETag(final String url) {
  try (final Response res = target(url).request().get()) {
    return res.getEntityTag();
  }
}

代码示例来源:origin: org.trellisldp/trellis-test

/**
 * Get the EntityTag for a given resource.
 * @param url the URL
 * @return the entity tag
 */
default EntityTag getETag(final String url) {
  try (final Response res = target(url).request().get()) {
    return res.getEntityTag();
  }
}

代码示例来源:origin: org.apache.syncope.client/syncope-client-lib

/**
 * Fetches {@code ETag} header value from latest service run (if available).
 *
 * @param <T> any service class
 * @param service service class instance
 * @return {@code ETag} header value from latest service run (if available)
 */
public <T> EntityTag getLatestEntityTag(final T service) {
  return WebClient.client(service).getResponse().getEntityTag();
}

代码示例来源:origin: apache/syncope

/**
 * Fetches {@code ETag} header value from latest service run (if available).
 *
 * @param <T> any service class
 * @param service service class instance
 * @return {@code ETag} header value from latest service run (if available)
 */
public <T> EntityTag getLatestEntityTag(final T service) {
  return WebClient.client(service).getResponse().getEntityTag();
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfNoneMatchWeak() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-None-Match", "W/\"" + etag + "\"").get();
  assertEquals(SC_NOT_MODIFIED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfMatchBinary() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-Match", "\"" + etag + "\"").get();
  assertEquals(SC_OK, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfNoneMatchBinary() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-None-Match", "\"" + etag + "\"").get();
  assertEquals(SC_NOT_MODIFIED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfNoneMatchWeakBinary() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-None-Match", "W/\"" + etag + "\"").get();
  assertEquals(SC_NOT_MODIFIED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfMatchWeak() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-Match", "W/\"" + etag + "\"").get();
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfMatch() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-Match", "\"" + etag + "\"").get();
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfNoneMatch() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-None-Match", "\"" + etag + "\"").get();
  assertEquals(SC_NOT_MODIFIED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetIfMatchBinaryWeak() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-Match", "W/\"" + etag + "\"").get();
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfNoneMatchWeakEtag() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-None-Match", "W/\"" + etag + "\"")
    .put(entity("some different data.", TEXT_PLAIN_TYPE));
  assertEquals(SC_NO_CONTENT, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfMatch() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-Match", "\"" + etag + "\"")
    .put(entity("some different data.", TEXT_PLAIN_TYPE));
  assertEquals(SC_NO_CONTENT, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfNoneMatchEtag() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-None-Match", "\"" + etag + "\"")
    .put(entity("some different data.", TEXT_PLAIN_TYPE));
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfNoneMatchRdfEtag() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-None-Match", "\"" + etag + "\"")
    .put(entity("<> <http://purl.org/dc/terms/title> \"A title\" .", TEXT_TURTLE_TYPE));
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfNoneMatchRdfWeakEtag() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-None-Match", "W/\"" + etag + "\"")
    .put(entity("<> <http://purl.org/dc/terms/title> \"A title\" .", TEXT_TURTLE_TYPE));
  assertEquals(SC_NO_CONTENT, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfMatchMultiple() {
  final String etag = target(BINARY_PATH).request().get().getEntityTag().getValue();
  final Response res = target(BINARY_PATH).request().header("If-Match", "\"blah\", \"" + etag + "\"")
    .put(entity("some different data.", TEXT_PLAIN_TYPE));
  assertEquals(SC_NO_CONTENT, res.getStatus(), "Unexpected response code!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testPutIfMatchWeak() {
  final String etag = target("").request().get().getEntityTag().getValue();
  final Response res = target("").request().header("If-Match", "W/\"" + etag + "\"")
    .put(entity("some different data.", TEXT_PLAIN_TYPE));
  assertEquals(SC_PRECONDITION_FAILED, res.getStatus(), "Unexpected response code!");
}

相关文章