當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteArrayOutputStream.toString方法代碼示例

本文整理匯總了Java中org.apache.commons.io.output.ByteArrayOutputStream.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayOutputStream.toString方法的具體用法?Java ByteArrayOutputStream.toString怎麽用?Java ByteArrayOutputStream.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.output.ByteArrayOutputStream的用法示例。


在下文中一共展示了ByteArrayOutputStream.toString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDistributedCachingHeaderSerialization

import org.apache.commons.io.output.ByteArrayOutputStream; //導入方法依賴的package包/類
@Test(groups = "wso2.esb", description = "cache meditor test enabling axis2 clustering.")
public void testDistributedCachingHeaderSerialization() throws Exception {

    String requestXml = "<a>ABC</a>";


    SimpleHttpClient httpClient = new SimpleHttpClient();
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/xml;charset=UTF-8");
    HttpResponse response1 = httpClient.doPost(getApiInvocationURL("CachingTest")+"/test", headers, requestXml, "application/xml;charset=UTF-8");
    ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
    response1.getEntity().writeTo(baos1);
    String actualValue1 = baos1.toString();

    // this is to populate response from cache mediator
    HttpResponse response2 = httpClient.doPost(getApiInvocationURL("CachingTest")+"/test", headers, requestXml, "application/xml;charset=UTF-8");
    ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
    response2.getEntity().writeTo(baos2);
    String actualValue2 = baos2.toString();

    Assert.assertEquals(actualValue1, requestXml);
    Assert.assertEquals(actualValue2, requestXml);
    Assert.assertTrue(stringExistsInLog("CACHEMATCHEDCACHEMATCHED"));
}
 
開發者ID:wso2,項目名稱:product-ei,代碼行數:25,代碼來源:DistributedCachingHeaderSerializationTestcase.java

示例2: testExportToM3U

import org.apache.commons.io.output.ByteArrayOutputStream; //導入方法依賴的package包/類
@Test
public void testExportToM3U() throws Exception {

    when(mediaFileDao.getFilesInPlaylist(eq(23))).thenReturn(getPlaylistFiles());
    when(settingsService.getPlaylistExportFormat()).thenReturn("m3u");

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    playlistService.exportPlaylist(23, outputStream);
    String actual = outputStream.toString();
    Assert.assertEquals(IOUtils.toString(getClass().getResourceAsStream("/PLAYLISTS/23.m3u")), actual);
}
 
開發者ID:airsonic,項目名稱:airsonic,代碼行數:12,代碼來源:PlaylistServiceTestExport.java

示例3: btnConvertOnAction

import org.apache.commons.io.output.ByteArrayOutputStream; //導入方法依賴的package包/類
@FXML
public void btnConvertOnAction() {

	try {

		StreamSource xlstSource = new StreamSource(new ByteArrayInputStream(xeXsltData.getText().getBytes()));
		StreamSource dataSource = new StreamSource(new ByteArrayInputStream(xeXmlData.getText().getBytes()));

		Transformer newTransformer = tFactory.newTransformer(xlstSource);

		ByteArrayOutputStream out = new ByteArrayOutputStream();
		OutputFormat format = OutputFormat.createPrettyPrint();
		
		//이 값은 false로 두어야 데이터 변경이 없음.
		format.setTrimText(false);

		newTransformer.transform(dataSource, new XMLResult(out, format));

		String string = out.toString();
		this.xeTransform.setText(string);
		if (cmiOpenWithWebView.isSelected()) {
			wbOpenWith.getEngine().loadContent(xeTransform.getText());
		}

	} catch (Exception e) {
		LOGGER.error(ValueUtil.toString(e));
	}

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:30,代碼來源:XsltTransformComposite.java

示例4: testCacheMediatorWithPIs

import org.apache.commons.io.output.ByteArrayOutputStream; //導入方法依賴的package包/類
@Test(groups = "wso2.esb", description = "cache meditor with payloads including Processing Insturctions")
public void testCacheMediatorWithPIs() throws Exception {

    String requestXml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://services.samples\" xmlns:xsd=\"http://services.samples/xsd\">\n"
            + "   <soapenv:Header>\n"
            + "      <m:Trans xmlns:m=\"http://www.w3schools.com/transaction/\">234</m:Trans>\n"
            + "   </soapenv:Header>\n" + "   <soapenv:Body>\n" + "      <ser:getFullQuote>\n"
            + "         <ser:request>\n" + "            <xsd:symbol>IBM</xsd:symbol>\n"
            + "         </ser:request>\n" + "      </ser:getFullQuote>\n" + "   </soapenv:Body>\n"
            + "</soapenv:Envelope>";

    final String expectedValue = "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope " +
            "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><b xmlns=\"http://ws" +
            ".apache.org/ns/synapse\"><?xml-multiple  array?><xyz><a xmlns=\"\">after " +
            "cache</a></xyz></b></soapenv:Body></soapenv:Envelope>";

    DefaultHttpClient httpclient = new DefaultHttpClient();

    // this is to populate the cache mediator
    HttpPost httpPost = new HttpPost(getProxyServiceURLHttp("PF"));
    httpPost.addHeader("SOAPAction", "urn:getFullQuote");
    httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "text/xml;charset=UTF-8");
    HttpEntity stringEntity = new StringEntity(requestXml, CharEncoding.UTF_8);
    httpPost.setEntity(stringEntity);
    HttpResponse response = httpclient.execute(httpPost);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    response.getEntity().writeTo(baos);
    String actualValue = baos.toString();

    // this is to get the actual cache response
    HttpPost httpPost2 = new HttpPost(getProxyServiceURLHttp("PF"));
    httpPost2.addHeader("SOAPAction", "urn:getFullQuote");
    httpPost2.setHeader(HttpHeaders.CONTENT_TYPE, "text/xml;charset=UTF-8");
    HttpEntity stringEntity2 = new StringEntity(requestXml, CharEncoding.UTF_8);
    httpPost2.setEntity(stringEntity2);
    HttpResponse response2 = httpclient.execute(httpPost);

    ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
    response2.getEntity().writeTo(baos2);
    String actualValue2 = baos2.toString();
    Assert.assertEquals(actualValue2, expectedValue);
}
 
開發者ID:wso2,項目名稱:product-ei,代碼行數:44,代碼來源:ESBJAVA4318Testcase.java


注:本文中的org.apache.commons.io.output.ByteArrayOutputStream.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。