org.apache.cxf.helpers.IOUtils.readStringFromStream()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(125)

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

IOUtils.readStringFromStream介绍

暂无

代码示例

代码示例来源: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 testGetField_Author_TEXT_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.TEXT_PLAIN).put(copy(stream, 12000));
  Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  String s = IOUtils.readStringFromStream((InputStream) response.getEntity());
  assertEquals("Maxim Valyanskiy", s);
}

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

public static UserApplication getUserApplicationFromStream(InputStream is,
                              ParseConfiguration cfg) throws IOException {
  return getUserApplicationFromJson(IOUtils.readStringFromStream(is), cfg);
}
public static UserApplication getUserApplicationFromJson(String json) {

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

public List<String> readFrom(Class<List<String>> arg0, Type arg1,
  Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
  throws IOException, WebApplicationException {
  return Collections.singletonList(IOUtils.readStringFromStream(arg5));
}

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

@Override
public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3,
           MultivaluedMap<String, String> arg4, InputStream is) throws IOException,
  WebApplicationException {
  return Boolean.valueOf(IOUtils.readStringFromStream(is));
}

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

@Override
public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3,
           MultivaluedMap<String, String> arg4, InputStream is) throws IOException,
  WebApplicationException {
  return Boolean.valueOf(IOUtils.readStringFromStream(is));
}

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

public int[] readFrom(Class<int[]> arg0, Type arg1,
  Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
  throws IOException, WebApplicationException {
  String[] stringArr = IOUtils.readStringFromStream(arg5).split(",");
  int[] intArr = new int[stringArr.length];
  for (int i = 0; i < stringArr.length; i++) {
    intArr[i] = Integer.valueOf(stringArr[i]);
  }
  return intArr;
}

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

public Object readFrom(Class<Object> arg0, Type arg1,
  Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
  throws IOException, WebApplicationException {
  String[] stringArr = IOUtils.readStringFromStream(arg5).split(",");
  double[] intArr = new double[stringArr.length];
  for (int i = 0; i < stringArr.length; i++) {
    intArr[i] = Double.valueOf(stringArr[i]);
  }
  return intArr;
}

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

private static String getExpectedValue(String name, Object... args) throws IOException {
    return String.format(IOUtils.readStringFromStream(
      AbstractSwagger2ServiceDescriptionTest.class.getResourceAsStream(name)), args);
  }
}

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

@POST
@Path("/bookform")
@Consumes("application/xml")
@Produces("application/xml")
public String echoBookFormXml(@Context HttpServletRequest req) throws IOException {
  InputStream is = req.getInputStream();
  return IOUtils.readStringFromStream(is);
}

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

@POST
@Path("/books/istream2")
@Produces("text/xml")
public Book addBookFromInputStreamReadItself(InputStream is) throws Exception {
  String body = IOUtils.readStringFromStream(is);
  if (!body.trim().startsWith("--")) {
    throw new RuntimeException();
  }
  return new Book("432", 432L);
}

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

public static JsonWebKey decryptJwkKey(InputStream is, JweDecryptionProvider jwe)
  throws IOException {
  return new JwkReaderWriter().jsonToJwk(
    jwe.decrypt(IOUtils.readStringFromStream(is)).getContentText());
}
public static JsonWebKeys loadPublicJwkSet(Message m, Properties props) {

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

public static JsonWebKeys decryptJwkSet(InputStream is, JweDecryptionProvider jwe)
  throws IOException {
  return new JwkReaderWriter().jsonToJwkSet(
    jwe.decrypt(IOUtils.readStringFromStream(is)).getContentText());
}
public static String encryptJwkKey(JsonWebKey jwkKey, char[] password) {

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

private void verifyResponse(Response response, String actualBookName, String actualHeaderName)
    throws Exception {
    List<Object> customHeaders = response.getMetadata().get("CustomHeader");
    assertEquals(customHeaders.size(), 1);
    assertEquals(actualHeaderName, customHeaders.get(0).toString());
    String responseValue = IOUtils.readStringFromStream((InputStream)response.getEntity());
    assertEquals(actualBookName, responseValue);
  }
}

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

@Test
public void testGetAllBooksIs() throws Exception {
  final Response response = createWebClient("/bookstore/is", MediaType.TEXT_PLAIN).get();
  try {
    assertEquals(200, response.getStatus());
    assertThat(response.readEntity(String.class), equalTo(IOUtils.readStringFromStream(
      getClass().getResourceAsStream("/files/books.txt"))));
  } finally {
    response.close();
  }
}

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

@Test
public void testGetAllBooks() throws Exception {
  final Response response = createWebClient("/bookstore", MediaType.TEXT_PLAIN).get();
  try {
    assertEquals(200, response.getStatus());
    assertThat(response.readEntity(String.class), equalTo(IOUtils.readStringFromStream(
      getClass().getResourceAsStream("/files/books.txt"))));
  } finally {
    response.close();
  }
}

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

private void doInvoke(String actualBookName, String actualHeaderName) throws Exception {
    Response response = client.post(actualBookName);
    assertEquals(actualHeaderName,
      response.getMetadata().getFirst("CustomHeader").toString());
    String responseValue = IOUtils.readStringFromStream((InputStream)response.getEntity());
    assertEquals(actualBookName, responseValue);
  }
}

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

@Test
public void testNullableParamsPrimitive() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/books/testnullpartprimitive";
  WebClient client = WebClient.create(address);
  client.type("multipart/form-data").accept("text/plain");
  List<Attachment> atts = new LinkedList<>();
  atts.add(new Attachment("somepart", "text/plain", "hello there"));
  Response r = client.postCollection(atts, Attachment.class);
  assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
  assertEquals((Integer)0, Integer.valueOf(IOUtils.readStringFromStream((InputStream)r.getEntity())));
}

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

@Test
public void testGetBookWithoutJsonpCallback() throws Exception {
  String url = "http://localhost:" + PORT + "/the/jsonp/books/123";
  WebClient client = WebClient.create(url);
  client.accept("application/json, application/x-javascript");
  WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000L);
  Response r = client.get();
  assertEquals("application/json", r.getMetadata().getFirst("Content-Type"));
  assertEquals("{\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}}",
         IOUtils.readStringFromStream((InputStream)r.getEntity()));
}

相关文章