Search in sources :

Example 91 with StringWriter

use of java.io.StringWriter in project hive by apache.

the class FileSinkOperator method logOutputFormatError.

private void logOutputFormatError(Configuration hconf, HiveException ex) {
    StringWriter errorWriter = new StringWriter();
    errorWriter.append("Failed to create output format; configuration: ");
    try {
        Configuration.dumpConfiguration(hconf, errorWriter);
    } catch (IOException ex2) {
        errorWriter.append("{ failed to dump configuration: " + ex2.getMessage() + " }");
    }
    Properties tdp = null;
    if (this.conf.getTableInfo() != null && (tdp = this.conf.getTableInfo().getProperties()) != null) {
        errorWriter.append(";\n table properties: { ");
        for (Map.Entry<Object, Object> e : tdp.entrySet()) {
            errorWriter.append(e.getKey() + ": " + e.getValue() + ", ");
        }
        errorWriter.append('}');
    }
    LOG.error(errorWriter.toString(), ex);
}
Also used : StringWriter(java.io.StringWriter) IOException(java.io.IOException) Properties(java.util.Properties) Map(java.util.Map) HashMap(java.util.HashMap)

Example 92 with StringWriter

use of java.io.StringWriter in project hbase by apache.

the class TestExecutorService method checkStatusDump.

private void checkStatusDump(ExecutorStatus status) throws IOException {
    StringWriter sw = new StringWriter();
    status.dumpTo(sw, "");
    String dump = sw.toString();
    LOG.info("Got status dump:\n" + dump);
    assertTrue(dump.contains("Waiting on java.util.concurrent.atomic.AtomicBoolean"));
}
Also used : StringWriter(java.io.StringWriter)

Example 93 with StringWriter

use of java.io.StringWriter in project hbase by apache.

the class TestConfServlet method testWriteXml.

@Test
public void testWriteXml() throws Exception {
    StringWriter sw = new StringWriter();
    ConfServlet.writeResponse(getTestConf(), sw, "xml");
    String xml = sw.toString();
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
    Document doc = builder.parse(new InputSource(new StringReader(xml)));
    NodeList nameNodes = doc.getElementsByTagName("name");
    boolean foundSetting = false;
    for (int i = 0; i < nameNodes.getLength(); i++) {
        Node nameNode = nameNodes.item(i);
        String key = nameNode.getTextContent();
        System.err.println("xml key: " + key);
        if (TEST_KEY.equals(key)) {
            foundSetting = true;
            Element propertyElem = (Element) nameNode.getParentNode();
            String val = propertyElem.getElementsByTagName("value").item(0).getTextContent();
            assertEquals(TEST_VAL, val);
        }
    }
    assertTrue(foundSetting);
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) StringWriter(java.io.StringWriter) DocumentBuilder(javax.xml.parsers.DocumentBuilder) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) StringReader(java.io.StringReader) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 94 with StringWriter

use of java.io.StringWriter in project hbase by apache.

the class TestMemoryBoundedLogMessageBuffer method testNonAsciiEncoding.

@Test
public void testNonAsciiEncoding() {
    MemoryBoundedLogMessageBuffer buf = new MemoryBoundedLogMessageBuffer(TEN_KB);
    buf.add(JP_TEXT);
    StringWriter sw = new StringWriter();
    buf.dumpTo(new PrintWriter(sw));
    String dump = sw.toString();
    assertTrue(dump.contains(JP_TEXT));
}
Also used : StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 95 with StringWriter

use of java.io.StringWriter in project hive by apache.

the class TestGenericMR method testIdentityReduce.

public void testIdentityReduce() throws Exception {
    final String in = "a\tb\nc\td";
    final StringWriter out = new StringWriter();
    new GenericMR().reduce(new StringReader(in), out, identityReducer());
    assertEquals(in + "\n", out.toString());
}
Also used : StringWriter(java.io.StringWriter) StringReader(java.io.StringReader)

Aggregations

StringWriter (java.io.StringWriter)3175 PrintWriter (java.io.PrintWriter)1057 Test (org.junit.Test)612 IOException (java.io.IOException)516 StringReader (java.io.StringReader)232 Writer (java.io.Writer)211 StreamResult (javax.xml.transform.stream.StreamResult)207 File (java.io.File)194 InputStreamReader (java.io.InputStreamReader)140 HashMap (java.util.HashMap)136 Transformer (javax.xml.transform.Transformer)125 InputStream (java.io.InputStream)119 Map (java.util.Map)116 ArrayList (java.util.ArrayList)106 DOMSource (javax.xml.transform.dom.DOMSource)99 BufferedReader (java.io.BufferedReader)96 ByteArrayInputStream (java.io.ByteArrayInputStream)84 Reader (java.io.Reader)77 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)75 HttpServletResponse (javax.servlet.http.HttpServletResponse)73