List of usage examples for org.apache.commons.io IOUtils toString
public static String toString(byte[] input) throws IOException
byte[]
as a String using the default character encoding of the platform. From source file:com.temenos.useragent.generic.mediatype.AtomPayloadHandlerTest.java
@Test public void testIsCollectionForTrue() throws Exception { handler.setPayload(// www . j a v a 2s. co m IOUtils.toString(AtomPayloadHandler.class.getResourceAsStream("/atom_feed_with_single_entry.txt"))); assertTrue(handler.isCollection()); }
From source file:dk.nsi.minlog.test.utils.TestHelper.java
public static String sendRequest(String url, String action, String docXml, boolean failOnError) throws IOException, ServiceException { URL u = new URL(url); HttpURLConnection uc = (HttpURLConnection) u.openConnection(); uc.setDoOutput(true);// w w w .j av a 2 s .co m uc.setDoInput(true); uc.setRequestMethod("POST"); uc.setRequestProperty("SOAPAction", "\"" + action + "\""); uc.setRequestProperty("Content-Type", "text/xml; charset=utf-8;"); OutputStream os = uc.getOutputStream(); IOUtils.write(docXml, os, "UTF-8"); os.flush(); os.close(); InputStream is; if (uc.getResponseCode() != 200) { is = uc.getErrorStream(); } else { is = uc.getInputStream(); } String res = IOUtils.toString(is); is.close(); if (uc.getResponseCode() != 200 && (uc.getResponseCode() != 500 || failOnError)) { throw new ServiceException(res); } uc.disconnect(); return res; }
From source file:ch.sbb.releasetrain.webui.utils.http.HttpUtilTest.java
@Test public void testGetStream() throws Exception { HttpUtilImpl http = new HttpUtilImpl(); InputStream google = http.getResourceAsStream("https://www.google.ch"); String content = IOUtils.toString(google); Assert.assertTrue(content.contains("google.ch")); }
From source file:gov.nih.nci.cabig.caaers.resolver.OrganizationResolverMockTest_FAILED.java
public void testSearchByNciId() throws Exception { String xml = IOUtils .toString(getClass().getResourceAsStream("organization_correlation_coppa_response.xml")); Metadata mData = new Metadata("searchCorrelationsWithEntities", "externalId", "PO_BUSINESS"); EasyMock.expect(messageBroadcastService.broadcastCOPPA((List<String>) EasyMock.anyObject(), MetadataMatcher.eqMetadata(mData))).andReturn(xml); replayMocks();/*from www .ja v a2 s . c om*/ Organization example = new RemoteOrganization(); example.setNciInstituteCode("HIVNCI"); List<Object> list = organizationResolver.find(example); assertEquals(1, list.size()); Organization orgResult = (Organization) list.get(0); assertEquals("HIVNCI", orgResult.getNciInstituteCode()); assertEquals("National Cancer Institute HIV/AIDS Malignancy Branch", orgResult.getName()); }
From source file:de.erdesignerng.test.sql.mysql.RepositoryIOTest.java
public void testLoadSaveRepository() throws Exception { Connection theConnection = createConnection(); Class theHibernateDialect = MySQLDialect.class; String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm"; String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect, theConnection);/*from w ww. j av a 2s.com*/ String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource)); System.out.println(theOriginalFile); System.out.println(theNewFile); assertTrue(compareStrings(theOriginalFile, theNewFile)); }
From source file:de.erdesignerng.test.sql.oracle.RepositoryIOTest.java
public void testLoadSaveRepository() throws Exception { Connection theConnection = createConnection(); Class theHibernateDialect = Oracle8iDialect.class; String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm"; String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect, theConnection);//from ww w.jav a 2s . c o m String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource)); assertTrue(compareStrings(theOriginalFile, theNewFile)); }
From source file:de.erdesignerng.test.sql.mssql.RepositoryIOTest.java
public void testLoadSaveRepository() throws Exception { Connection theConnection = createConnection(); Class theHibernateDialect = SQLServerDialect.class; String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm"; String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect, theConnection);/* ww w.j ava 2s . c om*/ String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource)); assertTrue(compareStrings(theOriginalFile, theNewFile)); }
From source file:com.adaptris.core.config.DummyConfigurationPreProcessor2.java
@Override public String process(URL urlToXml) throws CoreException { String xml = null;/*from w w w . j a v a 2 s. c om*/ try (InputStream in = urlToXml.openStream()) { xml = IOUtils.toString(in); } catch (IOException e) { ExceptionHelper.rethrowCoreException(e); } return xml; }
From source file:edu.harvard.i2b2.FhirUtilTest.java
@Test public void contain() { try {/*from w ww.j a v a 2 s. c o m*/ // URL path=FhirUtil.class.getResource("validation.zip"); // System.out.println(FhirUtil.isValid(Utils.getFile("example/fhir/singlePatient.xml"))); String mpXml = IOUtils.toString( FhirUtilTest.class.getResourceAsStream("/example/fhir/DSTU2/singleMedicationOrder.xml")); String mXml = IOUtils .toString(FhirUtilTest.class.getResourceAsStream("/example/fhir/DSTU2/singleMedication.xml")); MedicationOrder mp = JAXBUtil.fromXml(mpXml, MedicationOrder.class); Medication m = JAXBUtil.fromXml(mXml, Medication.class); // logger.info("MP:"+JAXBUtil.toXml(mp)); // logger.info("MP:"+JAXBUtil.toXml(m)); logger.info("after containing:" + JAXBUtil.toXml(FhirUtil.containResource(mp, m, m.toString()))); } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:de.erdesignerng.test.sql.postgres.RepositoryIOTest.java
public void testLoadSaveRepository() throws Exception { Connection theConnection = createConnection(); Class theHibernateDialect = PostgreSQLDialect.class; String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm"; String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect, theConnection);//from www . ja v a2 s. co m String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource)); assertTrue(compareStrings(theOriginalFile, theNewFile)); }