Java 类org.gradle.api.tasks.testing.TestOutputEvent 实例源码

项目:Reer    文件:TestOutputStore.java   
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);
}
项目:Pushjet-Android    文件:TestOutputStore.java   
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);
}
项目:Pushjet-Android    文件:TestOutputStore.java   
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);
}
项目:Reer    文件:ClassPageRenderer.java   
@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();
            }
        });
    }
}
项目:Reer    文件:JUnitXmlResultWriter.java   
/**
 * @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);
    }
}
项目:Reer    文件:JUnitXmlResultWriter.java   
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();
}
项目:Reer    文件:JUnitXmlResultWriter.java   
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();
    }
}
项目:Reer    文件:AggregateTestResultsProvider.java   
@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);
                }
            });
}
项目:Reer    文件:TestOutputStore.java   
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;
    }
}
项目:Reer    文件:InMemoryTestResultsProvider.java   
@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);
        }
    });
}
项目:Reer    文件:InMemoryTestResultsProvider.java   
@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);
        }
    });
}
项目:Reer    文件:InMemoryTestResultsProvider.java   
@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);
        }
    });
}
项目:Reer    文件:BinaryResultBackedTestResultsProvider.java   
@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);
        }
    });
}
项目:Reer    文件:BinaryResultBackedTestResultsProvider.java   
@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);
        }
    });
}
项目:Reer    文件:BinaryResultBackedTestResultsProvider.java   
@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);
        }
    });
}
项目:ide-plugins    文件:EclipseTestListener.java   
@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));
}
项目:Pushjet-Android    文件:ClassPageRenderer.java   
@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();
            }
        });
    }
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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);
    }
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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();
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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();
    }
}
项目:Pushjet-Android    文件:AggregateTestResultsProvider.java   
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);
                }
            });
}
项目:Pushjet-Android    文件:TestOutputStore.java   
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;
    }
}
项目:Pushjet-Android    文件:ClassPageRenderer.java   
@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();
            }
        });
    }
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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);
    }
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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();
}
项目:Pushjet-Android    文件:JUnitXmlResultWriter.java   
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();
    }
}
项目:Pushjet-Android    文件:AggregateTestResultsProvider.java   
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);
                }
            });
}
项目:Pushjet-Android    文件:TestOutputStore.java   
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;
    }
}
项目:Reer    文件:CaptureTestOutputTestResultProcessor.java   
@Override
public void output(Object testId, TestOutputEvent event) {
    processor.output(testId, event);
}
项目:Reer    文件:TestOutputRedirector.java   
TestOutputRedirector(TestResultProcessor processor, StandardOutputRedirector redirector) {
    this.redirector = redirector;
    this.outForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdOut);
    this.errForwarder = new Forwarder(processor, TestOutputEvent.Destination.StdErr);
}
项目:Reer    文件:TestOutputRedirector.java   
public Forwarder(TestResultProcessor processor, TestOutputEvent.Destination dest) {
    this.processor = processor;
    this.dest = dest;
}
项目:Reer    文件:TestEventSerializer.java   
@Override
public DefaultTestOutputEvent read(Decoder decoder) throws Exception {
    TestOutputEvent.Destination destination = destinationSerializer.read(decoder);
    String message = decoder.readString();
    return new DefaultTestOutputEvent(destination, message);
}
项目:Reer    文件:AttachParentTestResultProcessor.java   
@Override
public void output(Object testId, TestOutputEvent event) {
    processor.output(testId, event);
}
项目:Reer    文件:TestListenerAdapter.java   
@Override
public void output(TestDescriptorInternal test, TestOutputEvent event) {
    testOutputListener.onOutput(test, event);
}
项目:Reer    文件:StateTrackingTestResultProcessor.java   
@Override
public final void output(Object testId, TestOutputEvent event) {
    delegate.output(findDescriptor(testId), event);
}
项目:Reer    文件:ClientForwardingTestListener.java   
@Override
public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) {
    // Don't forward
}
项目:Reer    文件:TestExecutionResultEvaluator.java   
@Override
public void output(TestDescriptorInternal testDescriptor, TestOutputEvent event) {
}
项目:Reer    文件:TestClassExecutionEventGenerator.java   
@Override
public void output(Object testId, TestOutputEvent event) {
    resultProcessor.output(testId, event);
}
项目:Reer    文件:JUnitXmlResultWriter.java   
private void writeOutputs(SimpleXmlWriter writer, long classId, long testId, TestOutputEvent.Destination destination) throws IOException {
    writer.startCDATA();
    testResultsProvider.writeTestOutput(classId, testId, destination, writer);
    writer.endCDATA();
}
项目:Reer    文件:AggregateTestResultsProvider.java   
@Override
public void writeAllOutput(long id, TestOutputEvent.Destination destination, Writer writer) {
    for (DelegateProvider delegateProvider : classOutputProviders.get(id)) {
        delegateProvider.provider.writeAllOutput(delegateProvider.id, destination, writer);
    }
}