public void onOutput(long classId, long testId, TestOutputEvent outputEvent) { boolean stdout = outputEvent.getDestination() == TestOutputEvent.Destination.StdOut; mark(classId, testId, stdout); output.writeBoolean(stdout); output.writeSmallLong(classId); output.writeSmallLong(testId); byte[] bytes; try { bytes = outputEvent.getMessage().getBytes(messageStorageCharset.name()); } catch (UnsupportedEncodingException e) { throw UncheckedException.throwAsUncheckedException(e); } output.writeSmallInt(bytes.length); output.writeBytes(bytes, 0, bytes.length); }
@Override protected void registerTabs() { addFailuresTab(); addTab("Tests", new ErroringAction<SimpleHtmlWriter>() { public void doExecute(SimpleHtmlWriter writer) throws IOException { renderTests(writer); } }); final long classId = getModel().getId(); if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdOut)) { addTab("Standard output", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter htmlWriter) throws IOException { htmlWriter.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdOut, htmlWriter); htmlWriter.endElement() .endElement(); } }); } if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdErr)) { addTab("Standard error", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter element) throws Exception { element.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdErr, element); element.endElement() .endElement(); } }); } }
/** * @param output The destination, unbuffered */ public void write(TestClassResult result, OutputStream output) { String className = result.getClassName(); long classId = result.getId(); try { SimpleXmlWriter writer = new SimpleXmlWriter(output, " "); writer.startElement("testsuite") .attribute("name", className) .attribute("tests", String.valueOf(result.getTestsCount())) .attribute("skipped", String.valueOf(result.getSkippedCount())) .attribute("failures", String.valueOf(result.getFailuresCount())) .attribute("errors", "0") .attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN)) .attribute("hostname", hostName) .attribute("time", String.valueOf(result.getDuration() / 1000.0)); writer.startElement("properties"); writer.endElement(); writeTests(writer, result.getResults(), className, classId); writer.startElement("system-out"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr); writer.endElement(); writer.endElement(); } catch (IOException e) { throw UncheckedException.throwAsUncheckedException(e); } }
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); if (allClassOutput) { testResultsProvider.writeAllOutput(classId, destination, writer); } else { testResultsProvider.writeNonTestOutput(classId, destination, writer); } writer.endCDATA(); }
private void writeTests(SimpleXmlWriter writer, Iterable<TestMethodResult> methodResults, String className, long classId) throws IOException { for (TestMethodResult methodResult : methodResults) { writer.startElement("testcase") .attribute("name", methodResult.getName()) .attribute("classname", className) .attribute("time", String.valueOf(methodResult.getDuration() / 1000.0)); if (methodResult.getResultType() == TestResult.ResultType.SKIPPED) { writer.startElement("skipped"); writer.endElement(); } else { for (TestFailure failure : methodResult.getFailures()) { writer.startElement("failure") .attribute("message", failure.getMessage()) .attribute("type", failure.getExceptionType()); writer.characters(failure.getStackTrace()); writer.endElement(); } } if (outputAssociation.equals(TestOutputAssociation.WITH_TESTCASE)) { writer.startElement("system-out"); writeOutputs(writer, classId, methodResult.getId(), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, methodResult.getId(), TestOutputEvent.Destination.StdErr); writer.endElement(); } writer.endElement(); } }
@Override public boolean hasOutput(long id, final TestOutputEvent.Destination destination) { return Iterables.any( classOutputProviders.get(id), new Predicate<DelegateProvider>() { public boolean apply(DelegateProvider delegateProvider) { return delegateProvider.provider.hasOutput(delegateProvider.id, destination); } }); }
public boolean hasOutput(long classId, TestOutputEvent.Destination destination) { if (dataFile == null) { return false; } Index classIndex = index.children.get(classId); if (classIndex == null) { return false; } else { Region region = destination == TestOutputEvent.Destination.StdOut ? classIndex.stdOut : classIndex.stdErr; return region.start >= 0; } }
@Override public void writeAllOutput(final long id, final TestOutputEvent.Destination destination, final Writer writer) { withReader(new Action<TestOutputStore.Reader>() { @Override public void execute(TestOutputStore.Reader reader) { reader.writeAllOutput(id, destination, writer); } }); }
@Override public void writeNonTestOutput(final long id, final TestOutputEvent.Destination destination, final Writer writer) { withReader(new Action<TestOutputStore.Reader>() { @Override public void execute(TestOutputStore.Reader reader) { reader.writeNonTestOutput(id, destination, writer); } }); }
@Override public void writeTestOutput(final long classId, final long testId, final TestOutputEvent.Destination destination, final Writer writer) { withReader(new Action<TestOutputStore.Reader>() { @Override public void execute(TestOutputStore.Reader reader) { reader.writeTestOutput(classId, testId, destination, writer); } }); }
@Override public synchronized void testFailed(int status, String testId, String testName, String trace, String expected, String actual) { String message = testName + " failed"; if (expected != null || actual != null) { message += " (expected=" + expected + ", actual=" + actual + ")"; } this.resultProcessor.output(this.currentTestMethod.getId(), new DefaultTestOutputEvent(TestOutputEvent.Destination.StdOut, message)); this.resultProcessor.failure(this.currentTestMethod.getId(), new EclipseTestFailure(message, trace)); }
public void write(TestClassResult result, OutputStream output) { String className = result.getClassName(); long classId = result.getId(); try { SimpleXmlWriter writer = new SimpleXmlWriter(output, " "); writer.startElement("testsuite") .attribute("name", className) .attribute("tests", String.valueOf(result.getTestsCount())) .attribute("skipped", String.valueOf(result.getSkippedCount())) .attribute("failures", String.valueOf(result.getFailuresCount())) .attribute("errors", "0") .attribute("timestamp", DateUtils.format(result.getStartTime(), DateUtils.ISO8601_DATETIME_PATTERN)) .attribute("hostname", hostName) .attribute("time", String.valueOf(result.getDuration() / 1000.0)); writer.startElement("properties"); writer.endElement(); writeTests(writer, result.getResults(), className, classId); writer.startElement("system-out"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdOut); writer.endElement(); writer.startElement("system-err"); writeOutputs(writer, classId, outputAssociation.equals(TestOutputAssociation.WITH_SUITE), TestOutputEvent.Destination.StdErr); writer.endElement(); writer.endElement(); } catch (IOException e) { throw UncheckedException.throwAsUncheckedException(e); } }
public boolean hasOutput(long id, final TestOutputEvent.Destination destination) { return Iterables.any( classOutputProviders.get(id), new Predicate<DelegateProvider>() { public boolean apply(DelegateProvider delegateProvider) { return delegateProvider.provider.hasOutput(delegateProvider.id, destination); } }); }
@Override protected void registerTabs() { addFailuresTab(); addTab("Tests", new ErroringAction<SimpleHtmlWriter>() { public void doExecute(SimpleHtmlWriter writer) throws IOException { renderTests(writer); } }); if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdOut)) { addTab("Standard output", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter htmlWriter) throws IOException { htmlWriter.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdOut, htmlWriter); htmlWriter.endElement() .endElement(); } }); } if (resultsProvider.hasOutput(classId, TestOutputEvent.Destination.StdErr)) { addTab("Standard error", new ErroringAction<SimpleHtmlWriter>() { @Override protected void doExecute(SimpleHtmlWriter element) throws Exception { element.startElement("span").attribute("class", "code") .startElement("pre") .characters(""); resultsProvider.writeAllOutput(classId, TestOutputEvent.Destination.StdErr, element); element.endElement() .endElement(); } }); } }
@Override public void output(Object testId, TestOutputEvent event) { processor.output(testId, event); }
TestOutputRedirector(TestResultProcessor processor, StandardOutputRedirector redirector) { this.redirector = redirector; this.outForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdOut); this.errForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdErr); }
public Forwarder(TestResultProcessor processor, TestOutputEvent.Destination dest) { this.processor = processor; this.dest = dest; }
@Override public DefaultTestOutputEvent read(Decoder decoder) throws Exception { TestOutputEvent.Destination destination = destinationSerializer.read(decoder); String message = decoder.readString(); return new DefaultTestOutputEvent(destination, message); }
@Override public void output(TestDescriptorInternal test, TestOutputEvent event) { testOutputListener.onOutput(test, event); }
@Override public final void output(Object testId, TestOutputEvent event) { delegate.output(findDescriptor(testId), event); }
@Override public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) { // Don't forward }
@Override public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) { }
@Override public void output(Object testId, TestOutputEvent event) { resultProcessor.output(testId, event); }
private void writeOutputs(SimpleXmlWriter writer, long classId, long testId, TestOutputEvent.Destination destination) throws IOException { writer.startCDATA(); testResultsProvider.writeTestOutput(classId, testId, destination, writer); writer.endCDATA(); }
@Override public void writeAllOutput(long id, TestOutputEvent.Destination destination, Writer writer) { for (DelegateProvider delegateProvider : classOutputProviders.get(id)) { delegateProvider.provider.writeAllOutput(delegateProvider.id, destination, writer); } }