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

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

本文整理了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

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

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

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

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

  1. @Test
  2. public void testGetField_Author_TEXT_Partial_Found() throws Exception {
  3. InputStream stream = ClassLoader.getSystemResourceAsStream(TikaResourceTest.TEST_DOC);
  4. Response response = WebClient.create(endPoint + META_PATH + "/"+TikaCoreProperties.CREATOR.getName())
  5. .type("application/msword")
  6. .accept(MediaType.TEXT_PLAIN).put(copy(stream, 12000));
  7. Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
  8. String s = IOUtils.readStringFromStream((InputStream) response.getEntity());
  9. assertEquals("Maxim Valyanskiy", s);
  10. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. @POST
  2. @Path("/bookform")
  3. @Consumes("application/xml")
  4. @Produces("application/xml")
  5. public String echoBookFormXml(@Context HttpServletRequest req) throws IOException {
  6. InputStream is = req.getInputStream();
  7. return IOUtils.readStringFromStream(is);
  8. }

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

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

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

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

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

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

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

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

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

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

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

  1. @Test
  2. public void testGetAllBooks() throws Exception {
  3. final Response response = createWebClient("/bookstore", MediaType.TEXT_PLAIN).get();
  4. try {
  5. assertEquals(200, response.getStatus());
  6. assertThat(response.readEntity(String.class), equalTo(IOUtils.readStringFromStream(
  7. getClass().getResourceAsStream("/files/books.txt"))));
  8. } finally {
  9. response.close();
  10. }
  11. }

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

  1. private void doInvoke(String actualBookName, String actualHeaderName) throws Exception {
  2. Response response = client.post(actualBookName);
  3. assertEquals(actualHeaderName,
  4. response.getMetadata().getFirst("CustomHeader").toString());
  5. String responseValue = IOUtils.readStringFromStream((InputStream)response.getEntity());
  6. assertEquals(actualBookName, responseValue);
  7. }
  8. }

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

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

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

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

相关文章