List of usage examples for java.io StringWriter getBuffer
public StringBuffer getBuffer()
From source file:com.controlj.addon.weather.service.WeatherServiceUIBase.java
public String getServiceConfigHTML() { StringWriter result = new StringWriter(); copyHTMLTemplate(WeatherServiceUIBase.class, "baseserviceconfig.html", result); return result.getBuffer().toString(); /*/* ww w . jav a 2 s .c om*/ return " <p>pick service here</p>\n" + " <h2>Refresh Rates</h2>\n" + " <div class=\"indent\">\n" + " <div class=\"nobr\">\n" + " <label>Current Conditions:</label>\n" + " <input type=\"text\" id=\"conditionrefresh\" name=\"conditionrefresh\" size=\"4\" value=\"\"/>\n" + " minutes\n" + " </div>\n" + " <div class=\"nobr\">\n" + " <label>Forecast:</label>\n" + " <input type=\"text\" id=\"forecastrefresh\" name=\"forecastrefresh\" size=\"4\" value=\"\"/>\n" + " minutes\n" + " </div>\n" + " </div>"; */ }
From source file:org.dataconservancy.packaging.tool.ser.PackageMetadataConverterTest.java
@Test public void testMarshal() throws Exception { StringWriter writer = new StringWriter(); underTest.marshal(testMap, new PrettyPrintWriter(writer), getMarshalingContext()); assertTrue(writer.getBuffer().length() > 1); String result = writer.getBuffer().toString(); assertTrue(result.contains(PackageMetadataConverter.E_PACKAGE_METADATA)); assertTrue(result.contains("foo")); assertTrue(result.contains("bar")); assertTrue(result.contains("baz")); }
From source file:org.dataconservancy.packaging.tool.ser.UserPropertyConverterTest.java
@Test public void testMarshal() throws Exception { StringWriter writer = new StringWriter(); underTest.marshal(testMap, new PrettyPrintWriter(writer), getMarshalingContext()); assertTrue(writer.getBuffer().length() > 1); String result = writer.getBuffer().toString(); assertTrue(result.contains(UserPropertyConverter.E_USER_PROPERTY)); assertTrue(result.contains("foo")); assertTrue(result.contains("value:foo")); assertTrue(result.contains("bar")); }
From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParserTest.java
private void assertNoThrowable(StringWriter capture) { String buf = capture.getBuffer().toString(); Assert.assertThat(buf, not(containsString("Throwable"))); Assert.assertThat(buf, not(containsString("Exception"))); }
From source file:jflowmap.JFlowMapApplet.java
public String exportToSvg() { blockingGlassPane.setVisible(true);//from w w w. ja v a2 s .c o m String svg = null; VisualCanvas canvas = getCanvas(); if (canvas != null) { try { StringWriter sw = new StringWriter(); canvas.paintToSvg(sw); svg = sw.getBuffer().toString(); } catch (Exception e) { logger.error("SVG export failed", e); JMsgPane.showErrorDialog(this, "SVG export failed: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } } blockingGlassPane.setVisible(false); return svg; }
From source file:SimpleCalcStreamTok.java
public void testIt() throws Exception { BufferedReader is = new BufferedReader(new StringReader(TEST)); StringWriter fluffy = new StringWriter(); PrintWriter ps = new PrintWriter(fluffy); SimpleCalcStreamTok sc = new SimpleCalcStreamTok(is, ps); assertEquals(EXPECT, fluffy.getBuffer().toString()); }
From source file:org.apache.tapestry5.internal.webresources.CSSMinimizer.java
@Override protected InputStream doMinimize(StreamableResource resource) throws IOException { StringWriter writer = new StringWriter(1000); Reader reader = new InputStreamReader(resource.openStream()); try {/* w w w .j av a 2s.c om*/ new CssCompressor(reader).compress(writer, -1); writer.flush(); return IOUtils.toInputStream(writer.getBuffer()); } finally { InternalUtils.close(reader); InternalUtils.close(writer); } }
From source file:org.hexlogic.model.DockerNodeService.java
public IEndpointConfiguration getNode(String id) { try {// w w w .j a v a2s. c o m IEndpointConfiguration endpointConfiguration = service.getEndpointConfiguration(id); if (endpointConfiguration != null) { return endpointConfiguration; } // In case we can not find the saved configuration, return null throw new NullPointerException("No configuration for the DockerNode with id '" + id + "' found."); } catch (IOException e) { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw, true); e.printStackTrace(pw); log.error("Error: " + sw.getBuffer().toString()); } return null; }
From source file:com.controlj.addon.weather.noaa.WeatherServiceUIImpl.java
public String getServiceConfigHTML() { StringWriter result = new StringWriter(); result.append(super.getServiceConfigHTML()); copyHTMLTemplate(WeatherServiceUIImpl.class, "serviceconfig.html", result); return result.getBuffer().toString(); }
From source file:common.MyListener.java
@Override public synchronized void onTestFailure(ITestResult tr) { try {//from w w w. j a v a 2 s . c om time = tr.getEndMillis() - tr.getStartMillis(); time = time / 1000; String testName = null; DateFormat dateFormat = new SimpleDateFormat("dd_MMM_yyyy__hh_mm_ssaa"); String destFile = null; for (Map.Entry<String, String> entry : MyTestContext.getTestStats().entrySet()) { testName = entry.getKey(); destFile = testName + "_" + dateFormat.format(new Date()) + ".png"; String[] err = null; err = tr.getThrowable().getMessage().split("\\n"); err[0] = err[0] + "\n. Screen shot saved at /screenshots/" + destFile; testFailed.put(testName, new Object[] { entry.getValue(), err[0], MyTestContext.getStep(), time }); t = entry.getKey(); } addTestLogs(t); MyTestContext.testStats.remove(); WebDriver driver = new Augmenter().augment(driver()); File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); String destDir = "screenshots"; new File(destDir).mkdirs(); FileUtils.copyFile(scrFile, new File(destDir + "/" + destFile)); } catch (Exception e) { StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s, true); e.printStackTrace(p); log.error(s.getBuffer().toString()); Assert.fail("Check log file for error details"); } }