当前位置: 首页>>代码示例>>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;未经允许,请勿转载。