From 5c0fb7bc03f1a4e5d4d737ffd1165bfe16bd5039 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 20:31:02 +0400 Subject: [PATCH] testframework refactoring: inline ExternalOutput; cleanup --- .../testframework/DeferingPrinter.java | 6 +- .../testframework/ExternalOutput.java | 54 --------------- .../ui/BaseTestsOutputConsoleView.java | 11 +-- .../intellij/execution/junit/TestObject.java | 6 +- .../intellij/execution/junit2/TestProxy.java | 11 +-- .../execution/junit2/TestRootImpl.java | 68 ------------------- 6 files changed, 23 insertions(+), 133 deletions(-) delete mode 100644 platform/testRunner/src/com/intellij/execution/testframework/ExternalOutput.java delete mode 100644 plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java diff --git a/platform/testRunner/src/com/intellij/execution/testframework/DeferingPrinter.java b/platform/testRunner/src/com/intellij/execution/testframework/DeferingPrinter.java index 94b7c5ed3e0d..eaee83bad9d0 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/DeferingPrinter.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/DeferingPrinter.java @@ -29,7 +29,11 @@ public class DeferingPrinter implements Printer { } public void print(final String text, final ConsoleViewContentType contentType) { - myCompositePrintable.addLast(new ExternalOutput(text, contentType)); + myCompositePrintable.addLast(new Printable() { + public void printOn(final Printer printer) { + printer.print(text, contentType); + } + }); } public void onNewAvailable(final Printable printable) { diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ExternalOutput.java b/platform/testRunner/src/com/intellij/execution/testframework/ExternalOutput.java deleted file mode 100644 index 49558e6df03e..000000000000 --- a/platform/testRunner/src/com/intellij/execution/testframework/ExternalOutput.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -package com.intellij.execution.testframework; - - - -import com.intellij.execution.ui.ConsoleViewContentType; - - - - - -public class ExternalOutput implements Printable { - - private final ConsoleViewContentType myType; - - private final String myContents; - - - - public ExternalOutput(final String contents, final ConsoleViewContentType type) { - - myType = type; - - myContents = contents; - - } - - - - public void printOn(final Printer printer) { - - printer.print(myContents, myType); - - } - -} - diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java index 6e1880baecc8..3175216d3194 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java @@ -18,10 +18,7 @@ package com.intellij.execution.testframework.ui; import com.intellij.execution.filters.Filter; import com.intellij.execution.filters.HyperlinkInfo; import com.intellij.execution.filters.TextConsoleBuilderFactory; -import com.intellij.execution.testframework.ExternalOutput; -import com.intellij.execution.testframework.HyperLink; -import com.intellij.execution.testframework.Printable; -import com.intellij.execution.testframework.TestConsoleProperties; +import com.intellij.execution.testframework.*; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.ObservableConsoleView; @@ -57,7 +54,11 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa protected abstract TestResultsPanel createTestResultsPanel(); public void print(final String s, final ConsoleViewContentType contentType) { - printNew(new ExternalOutput(s, contentType)); + printNew(new Printable() { + public void printOn(final Printer printer) { + printer.print(s, contentType); + } + }); } public void clear() { diff --git a/plugins/junit/src/com/intellij/execution/junit/TestObject.java b/plugins/junit/src/com/intellij/execution/junit/TestObject.java index 72e4ab484949..35de8646519a 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestObject.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestObject.java @@ -312,7 +312,11 @@ public abstract class TestObject implements JavaCommandLine { currentTest.onOutput(text, consoleViewType); } else { - consoleView.getPrinter().onNewAvailable(new ExternalOutput(text, consoleViewType)); + consoleView.getPrinter().onNewAvailable(new Printable() { + public void printOn(final Printer printer) { + printer.print(text, consoleViewType); + } + }); } } }); diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java index 17a9cc5e0c11..48236aa93170 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java +++ b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java @@ -19,11 +19,11 @@ package com.intellij.execution.junit2; import com.intellij.execution.Location; import com.intellij.execution.junit2.events.*; import com.intellij.execution.junit2.info.TestInfo; -import com.intellij.execution.junit2.segments.InputConsumer; import com.intellij.execution.junit2.states.Statistics; import com.intellij.execution.junit2.states.TestState; import com.intellij.execution.testframework.*; import com.intellij.execution.testframework.ui.PrintableTestProxy; +import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -36,7 +36,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -public class TestProxy extends CompositePrintable implements PrintableTestProxy, InputConsumer, ChangingPrintable { +public class TestProxy extends CompositePrintable implements PrintableTestProxy, ChangingPrintable { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestProxy"); private final TestInfo myInfo; @@ -67,8 +67,11 @@ public class TestProxy extends CompositePrintable implements PrintableTestProxy, myPrinter.mark(); myMarked = true; } - final ExternalOutput printable = new ExternalOutput(text, contentType); - addLast(printable); + addLast(new Printable() { + public void printOn(final Printer printer) { + printer.print(text, contentType); + } + }); } public void addLast(final Printable printable) { diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java b/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java deleted file mode 100644 index 64e6a7fb5d85..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.execution.junit2; - -import com.intellij.execution.junit2.info.ClassBasedInfo; -import com.intellij.execution.junit2.info.DisplayTestInfoExtractor; -import com.intellij.execution.junit2.segments.ObjectReader; -import com.intellij.util.containers.HashMap; - -import java.util.List; - -public class TestRootImpl implements TestRoot { - private final TestProxy myRootTest; - private final HashMap myKnownDynamicParents = new HashMap(); - - public TestRootImpl(final TestProxy rootTest) { - myRootTest = rootTest; - } - - public void addChild(final TestProxy child) { - if (child == myRootTest) - return; - getDynamicParentFor(child).addChild(child); - } - - private TestProxy getDynamicParentFor(final TestProxy child) { - final String parentClass = child.getInfo().getComment(); - TestProxy dynamicParent = myKnownDynamicParents.get(parentClass); - if (dynamicParent == null) { - dynamicParent = new TestProxy(new DynamicParentInfo(parentClass)); - myKnownDynamicParents.put(parentClass, dynamicParent); - myRootTest.addChild(dynamicParent); - } - return dynamicParent; - } - - public TestProxy getRootTest() { - return myRootTest; - } - - public List getAllTests() { - return getRootTest().getAllTests(); - } - - private static class DynamicParentInfo extends ClassBasedInfo { - public DynamicParentInfo(final String className) { - super(DisplayTestInfoExtractor.FOR_CLASS); - setClassName(className); - } - - public void readFrom(final ObjectReader reader) { - } - } -}