org.apache.cxf.jaxrs.client.WebClient.put()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(213)

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

WebClient.put介绍

[英]Does HTTP PUT invocation
[中]HTTP是否将调用

代码示例

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

private String detect(String content) {
  String language = null;
  try {
    Response response = WebClient
        .create(restHostUrlStr + TEXT_LID_PATH)
        .put(content);
    String json = response.readEntity(String.class);
    language = new JsonParser().parse(json).getAsJsonObject().get("language").getAsString();
  } catch (Exception e) {
    LOG.warn("problem detecting", e);
  }
  return language;
}

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

@Test
public void testExeDOCX() throws Exception {
  String TEST_DOCX_EXE = "2exe.docx";
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .accept("application/zip")
      .put(ClassLoader.getSystemResourceAsStream(TEST_DOCX_EXE));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(DOCX_EXE1_MD5, data.get(DOCX_EXE1_NAME));
  assertEquals(DOCX_EXE2_MD5, data.get(DOCX_EXE2_NAME));
}

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

@Test
public void testImageXSL() throws Exception {
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .accept("application/zip")
      .put(ClassLoader.getSystemResourceAsStream("pic.xls"));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(XSL_IMAGE1_MD5, data.get("0.jpg"));
  assertEquals(XSL_IMAGE2_MD5, data.get("1.jpg"));
}

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

@Test
public void testGetField_XXX_NotFound() throws Exception {
  Response response = WebClient.create(endPoint + META_PATH + "/xxx").type("application/msword")
      .accept(MediaType.APPLICATION_JSON).put(ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_DOC));
  Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}

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

@Test
public void testTextMain() throws Exception {
  //boilerpipe
  Response response = WebClient.create(endPoint + TIKA_PATH + "/main")
      .accept("text/plain")
      .put(ClassLoader.getSystemResourceAsStream("testHTML.html"));
  String responseMsg = getStringFromInputStream((InputStream) response
      .getEntity());
  assertTrue(responseMsg.contains("Title : Test Indexation Html"));
  assertFalse(responseMsg.contains("Indexation du fichier"));
}

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

@Test
public void testImageDOCX() throws Exception {
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .accept("application/zip").put(
          ClassLoader.getSystemResourceAsStream(TEST_DOCX_IMAGE));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(DOCX_IMAGE1_MD5, data.get(DOCX_IMAGE1_NAME));
  assertEquals(DOCX_IMAGE2_MD5, data.get(DOCX_IMAGE2_NAME));
}

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

@Test
public void testPasswordXLSHTML() throws Exception {
  Response response = WebClient.create(endPoint + TIKA_PATH)
      .type("application/vnd.ms-excel")
      .accept("text/html")
      .put(ClassLoader.getSystemResourceAsStream("password.xls"));
  assertEquals(UNPROCESSEABLE, response.getStatus());
}

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

@Test
public void testDocWAV() throws Exception {
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .type(APPLICATION_MSWORD).accept("application/zip")
      .put(ClassLoader.getSystemResourceAsStream(TEST_DOC_WAV));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(WAV1_MD5, data.get(WAV1_NAME));
  assertEquals(WAV2_MD5, data.get(WAV2_NAME));
  assertFalse(data.containsKey(UnpackerResource.TEXT_FILENAME));
}

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

@Test
public void testSimpleWordXML() throws Exception {
  Response response = WebClient.create(endPoint + TIKA_PATH)
      .type("application/msword")
      .accept("text/xml")
      .put(ClassLoader.getSystemResourceAsStream(TEST_DOC));
  String responseMsg = getStringFromInputStream((InputStream) response
      .getEntity());
  assertTrue(responseMsg.contains("test"));
}

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

@Test
public void testPasswordXLSXML() throws Exception {
  Response response = WebClient.create(endPoint + TIKA_PATH)
      .type("application/vnd.ms-excel")
      .accept("text/xml")
      .put(ClassLoader.getSystemResourceAsStream("password.xls"));
  assertEquals(UNPROCESSEABLE, response.getStatus());
}

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

@Test
public void testDocPicture() throws Exception {
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .type(APPLICATION_MSWORD).accept("application/zip")
      .put(ClassLoader.getSystemResourceAsStream(TEST_DOC_WAV));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(JPG_MD5, data.get(JPG_NAME));
}

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

@Test
public void testDocPictureNoOle() throws Exception {
  Response response = WebClient.create(endPoint + UNPACKER_PATH)
      .type(APPLICATION_MSWORD).accept("application/zip")
      .put(ClassLoader.getSystemResourceAsStream("2pic.doc"));
  Map<String, String> data = readZipArchive((InputStream) response.getEntity());
  assertEquals(JPG2_MD5, data.get(JPG2_NAME));
}

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

@Test
  public void testMeta() throws Exception {
    InputStream stream = ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_DOC);

    Response response = WebClient.create(endPoint + "/meta" + "/Author").type("application/msword")
        .accept(MediaType.TEXT_PLAIN).put(copy(stream, 8000));
    Assert.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
    String msg = getStringFromInputStream((InputStream) response.getEntity());
    assertEquals("Failed to get metadata field Author", msg);
  }
}

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

@Test
public void testGetField_Author_XMP_Partial_Found() throws Exception {
  InputStream stream = ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_DOC);
  Response response = WebClient.create(endPoint + META_PATH + "/dc:creator").type("application/msword")
      .accept("application/rdf+xml").put(copy(stream, 12000));
  Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  String s = IOUtils.readStringFromStream((InputStream) response.getEntity());
  assertContains("<rdf:li>Maxim Valyanskiy</rdf:li>", s);
}

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

@Test
public void testXMP() throws Exception {
  Response response = WebClient
      .create(endPoint + META_PATH)
      .type("application/msword")
      .accept("application/rdf+xml")
      .put(ClassLoader
          .getSystemResourceAsStream(TikaResourceTest.TEST_DOC));
  String result = IOUtils.readStringFromStream((InputStream) response.getEntity());
  assertContains("<rdf:li>Maxim Valyanskiy</rdf:li>", result);
}

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

@Test
public void testDetectEnglishFile() throws Exception {
  String url = endPoint + LANG_STREAM_PATH;
  Response response = WebClient.create(url).type("text/plain")
      .accept("text/plain")
      .put(ClassLoader.getSystemResourceAsStream("english.txt"));
  assertNotNull(response);
  String readLang = getStringFromInputStream((InputStream) response
      .getEntity());
  assertEquals("en", readLang);
}

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

@Test
public void testGetField_Author_JSON_Partial_Found() throws Exception {
  InputStream stream = ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_DOC);
  Response response = WebClient.create(endPoint + META_PATH + "/"+TikaCoreProperties.CREATOR.getName())
      .type("application/msword")
      .accept(MediaType.APPLICATION_JSON).put(copy(stream, 12000));
  Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  Metadata metadata = JsonMetadata.fromJson(new InputStreamReader(
      (InputStream) response.getEntity(), UTF_8));
  assertEquals("Maxim Valyanskiy", metadata.get(TikaCoreProperties.CREATOR));
  assertEquals(1, metadata.names().length);
}

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

@Test
public void testDetectFrenchString() throws Exception {
  String url = endPoint + LANG_STRING_PATH;
  Response response = WebClient.create(url).type("text/plain")
      .accept("text/plain").put(FRENCH_STRING);
  assertNotNull(response);
  String readLang = getStringFromInputStream((InputStream) response
      .getEntity());
  assertEquals("fr", readLang);
}

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

@Test
public void testTranslateFull() throws Exception {
  String url = endPoint + TRANSLATE_ALL_PATH + LINGO_PATH + SRCDEST;
  Response response = WebClient.create(url).type("text/plain")
      .accept("*/*").put(TRANSLATE_TXT);
  assertNotNull(response);
  String translated = getStringFromInputStream((InputStream) response
      .getEntity());
  assertEquals(TRANSLATE_TXT, translated);
}

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

@Test
public void testDetectEnglishString() throws Exception {
  String url = endPoint + LANG_STRING_PATH;
  Response response = WebClient.create(url).type("text/plain")
      .accept("text/plain").put(ENGLISH_STRING);
  assertNotNull(response);
  String readLang = getStringFromInputStream((InputStream) response
      .getEntity());
  assertEquals("en", readLang);
}

相关文章

WebClient类方法