Java Code Examples for org.apache.cxf.helpers.IOUtils#toString()
The following examples show how to use
org.apache.cxf.helpers.IOUtils#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSAML2SPServlet.java From syncope with Apache License 2.0 | 6 votes |
protected SAML2ReceivedResponseTO extract( final String spEntityID, final String urlContext, final String clientAddress, final InputStream response) throws IOException { String strForm = IOUtils.toString(response); MultivaluedMap<String, String> params = JAXRSUtils.getStructuredParams(strForm, "&", false, false); String samlResponse = params.getFirst(SSOConstants.SAML_RESPONSE); if (StringUtils.isNotBlank(samlResponse)) { samlResponse = URLDecoder.decode(samlResponse, StandardCharsets.UTF_8); LOG.debug("Received SAML Response: {}", samlResponse); } String relayState = params.getFirst(SSOConstants.RELAY_STATE); LOG.debug("Received Relay State: {}", relayState); SAML2ReceivedResponseTO receivedResponseTO = new SAML2ReceivedResponseTO(); receivedResponseTO.setSpEntityID(spEntityID); receivedResponseTO.setUrlContext(urlContext); receivedResponseTO.setSamlResponse(samlResponse); receivedResponseTO.setRelayState(relayState); return receivedResponseTO; }
Example 2
Source File: CrossOriginSimpleTest.java From cxf with Apache License 2.0 | 6 votes |
private void assertAllOrigin(boolean allOrigins, String[] originList, String[] requestOrigins, boolean permitted) throws ClientProtocolException, IOException { configureAllowOrigins(allOrigins, originList); HttpClient httpclient = HttpClientBuilder.create().build(); HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/untest/simpleGet/HelloThere"); if (requestOrigins != null) { StringBuilder ob = new StringBuilder(); for (String requestOrigin : requestOrigins) { ob.append(requestOrigin); ob.append(' '); // extra trailing space won't hurt. } httpget.addHeader("Origin", ob.toString()); } HttpResponse response = httpclient.execute(httpget); assertEquals(200, response.getStatusLine().getStatusCode()); HttpEntity entity = response.getEntity(); String e = IOUtils.toString(entity.getContent()); assertEquals("HelloThere", e); // ensure that we didn't bust the operation itself. assertOriginResponse(allOrigins, requestOrigins, permitted, response); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }
Example 3
Source File: MtomTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testAcceptDataHandler() throws Exception { setupForTest(true); DataHandlerBean dhBean = new DataHandlerBean(); dhBean.setName("some name"); // some day, we might need this to be higher than some threshold. String someData = "This is the cereal shot from guns."; DataHandler dataHandler = new DataHandler(someData, "text/plain;charset=utf-8"); dhBean.setDataHandler(dataHandler); client.acceptDataHandler(dhBean); DataHandlerBean accepted = impl.getLastDhBean(); Assert.assertNotNull(accepted); Object o = accepted.getDataHandler().getContent(); String data = null; if (o instanceof String) { data = (String)o; } else if (o instanceof InputStream) { data = IOUtils.toString((InputStream)o); } Assert.assertNotNull(data); Assert.assertEquals("This is the cereal shot from guns.", data); }
Example 4
Source File: PrimitiveTextProvider.java From cxf with Apache License 2.0 | 6 votes |
public T readFrom(Class<T> type, Type genType, Annotation[] anns, MediaType mt, MultivaluedMap<String, String> headers, InputStream is) throws IOException { String string = IOUtils.toString(is, HttpUtils.getEncoding(mt, StandardCharsets.UTF_8.name())); if (StringUtils.isEmpty(string)) { reportEmptyContentLength(); } if (type == Character.class) { char character = string.charAt(0); return type.cast(Character.valueOf(character)); } return InjectionUtils.handleParameter( string, false, type, genType, anns, ParameterType.REQUEST_BODY, null); }
Example 5
Source File: BatchResponse.java From syncope with Apache License 2.0 | 5 votes |
/** * Parses the given Response into a list of {@link BatchResponseItem}s. * * @param response response to extract items from * @return the Batch Response parsed as list of {@link BatchResponseItem}s * @throws IOException if there are issues when reading the response body */ public static List<BatchResponseItem> getItems(final Response response) throws IOException { String body = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8.name()); LOG.debug("Batch response body:\n{}", body); return BatchPayloadParser.parse( new ByteArrayInputStream(body.getBytes()), response.getMediaType(), new BatchResponseItem()); }
Example 6
Source File: JAXRSClientServerBookTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetBookQueryGZIP() throws Exception { String address = "http://localhost:" + PORT + "/bookstore/"; WebClient wc = WebClient.create(address); wc.acceptEncoding("gzip,deflate"); wc.encoding("gzip"); InputStream r = wc.get(InputStream.class); assertNotNull(r); GZIPInputStream in = new GZIPInputStream(r); String s = IOUtils.toString(in); in.close(); assertTrue(s, s.contains("id>124")); }
Example 7
Source File: SchemaImportTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testImportSchema2() throws Exception { String schemaURL = "http://localhost:" + PORT + "/schemaimport/sayHi2" + "?xsd=../sayhi/sayhi/sayhi-schema1.xsd"; URL url = new URL(schemaURL); try (InputStream ins = url.openStream()) { String output = IOUtils.toString(ins); assertTrue(output.indexOf("sayHiArray") > -1); } catch (Exception e) { e.printStackTrace(); fail("Can not access the import schema"); } }
Example 8
Source File: SchemaImportTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testImportWsdl() throws Exception { String wsdlURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?wsdl=sayhi/sayhi/a.wsdl"; URL url = new URL(wsdlURL); try (InputStream ins = url.openStream()) { String output = IOUtils.toString(ins); assertTrue(output.indexOf("sayHiArray") > -1); } catch (Exception e) { e.printStackTrace(); fail("Can not access the import wsdl"); } }
Example 9
Source File: SchemaImportTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testImportWsdl2() throws Exception { String wsdlURL = "http://localhost:" + PORT + "/schemaimport/sayHi2" + "?wsdl=../sayhi/sayhi/a.wsdl"; URL url = new URL(wsdlURL); try (InputStream ins = url.openStream()) { String output = IOUtils.toString(ins); assertTrue(output.indexOf("sayHiArray") > -1); } catch (Exception e) { e.printStackTrace(); fail("Can not access the import wsdl"); } }
Example 10
Source File: JavaFirstPolicyServiceTest.java From cxf with Apache License 2.0 | 5 votes |
private Document loadWsdl(String serviceName) throws Exception { HttpURLConnection connection = getHttpConnection("http://localhost:" + PORT + "/" + serviceName + "?wsdl"); InputStream is = connection.getInputStream(); String wsdlContents = IOUtils.toString(is); // System.out.println(wsdlContents); return StaxUtils.read(new StringReader(wsdlContents)); }
Example 11
Source File: MtomTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testJaxWsMtomReply() throws Exception { setupForTest(true); DataHandlerBean dhBean = jaxwsClient.produceDataHandlerBean(); Assert.assertNotNull(dhBean); String result = IOUtils.toString(dhBean.getDataHandler().getInputStream()); Assert.assertEquals(MtomTestImpl.STRING_DATA, result); }
Example 12
Source File: HelloWorldIT.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testPing() throws Exception { WebClient client = WebClient.create(endpointUrl + "/hello/echo/SierraTangoNevada"); Response r = client.accept("text/plain").get(); assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); String value = IOUtils.toString((InputStream)r.getEntity()); assertEquals("SierraTangoNevada", value); }
Example 13
Source File: JAXRSClientServerSpringBookTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 14
Source File: JAXRSClientServerResourceJacksonSpringProviderTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 15
Source File: JAXRSClientServerBookTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 16
Source File: JAXRSClientServerNonSpringBookTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 17
Source File: StringTextProvider.java From cxf with Apache License 2.0 | 4 votes |
public String readFrom(Class<String> type, Type genType, Annotation[] anns, MediaType mt, MultivaluedMap<String, String> headers, InputStream is) throws IOException { return IOUtils.toString(is, HttpUtils.getEncoding(mt, StandardCharsets.UTF_8.name())); }
Example 18
Source File: JAXRSClientServerResourceCreatedSpringProviderTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 19
Source File: JAXRSSoapBookTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }
Example 20
Source File: JAXRSAtomBookTest.java From cxf with Apache License 2.0 | 4 votes |
private String getStringFromInputStream(InputStream in) throws Exception { return IOUtils.toString(in); }