diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java index 6606fbeacdef..96963958f61a 100644 --- a/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java +++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java @@ -19,18 +19,11 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.CommandLineBuilder; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.JavaParameters; -import com.intellij.execution.junit2.SegmentedInputStream; -import com.intellij.execution.junit2.segments.DeferedActionsQueue; -import com.intellij.execution.junit2.segments.DispatchListener; -import com.intellij.execution.junit2.segments.PacketExtractorBase; +import com.intellij.execution.junit2.segments.Extractor; import com.intellij.execution.process.OSProcessHandler; import com.intellij.execution.process.ProcessTerminatedListener; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; -import com.intellij.rt.execution.junit.segments.PacketProcessor; -import java.io.InputStream; import java.io.Reader; import java.nio.charset.Charset; @@ -50,18 +43,18 @@ public class JUnitProcessHandler extends OSProcessHandler { } protected Reader createProcessOutReader() { - return myOut.getReader(); + return myOut.createReader(); } protected Reader createProcessErrReader() { - return myErr.getReader(); + return myErr.createReader(); } - public PacketExtractorBase getErr() { + public Extractor getErr() { return myErr; } - public PacketExtractorBase getOut() { + public Extractor getOut() { return myOut; } @@ -83,46 +76,4 @@ public class JUnitProcessHandler extends OSProcessHandler { ProcessTerminatedListener.attach(processHandler); return processHandler; } - - private class Extractor extends PacketExtractorBase { - private final SegmentedInputStream myStream; - - public Extractor(final InputStream stream, final Charset charset) { - myStream = new SegmentedInputStream(stream, charset); - } - - public void setPacketProcessor(final PacketProcessor packetProcessor) { - myStream.setEventsDispatcher(new PacketProcessor() { - public void processPacket(final String packet) { - perform(new Runnable() { - public void run() { - packetProcessor.processPacket(packet); - } - }); - } - }); - } - - public void setFulfilledWorkGate(final DeferedActionsQueue fulfilledWorkGate) { - super.setFulfilledWorkGate(new DeferedActionsQueue() { - public void addLast(final Runnable runnable) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - fulfilledWorkGate.addLast(runnable); - } - }, ModalityState.NON_MODAL); - } - - public void setDispactchListener(final DispatchListener listener) { - fulfilledWorkGate.setDispactchListener(listener); - } - }); - } - - public Reader getReader() { - return new SegmentedInputStreamReader(myStream); - //return new InputStreamReader(myStream, myCharset); - } - } - } diff --git a/java/execution/impl/src/com/intellij/execution/junit2/SegmentedInputStream.java b/java/execution/impl/src/com/intellij/execution/junit2/SegmentedInputStream.java index 1a744e181a94..d15336716a52 100644 --- a/java/execution/impl/src/com/intellij/execution/junit2/SegmentedInputStream.java +++ b/java/execution/impl/src/com/intellij/execution/junit2/SegmentedInputStream.java @@ -62,21 +62,22 @@ public class SegmentedInputStream extends InputStream { while (true) { nextByte = readNext(); if (nextByte != SegmentedStream.SPECIAL_SYMBOL) break; - final boolean packetRead = readControlSequence(); - if (!packetRead) break; + final Integer packetRead = readControlSequence(); + if (packetRead != null) break; } return nextByte; } - private boolean readControlSequence() throws IOException { + private Integer readControlSequence() throws IOException { for (int idx = 1; idx < SegmentedStream.MARKER_PREFIX.length(); idx++) { - if (readNext() != SegmentedStream.MARKER_PREFIX.charAt(idx)) { - return false; + final int readAhead = readNext(); + if (readAhead != SegmentedStream.MARKER_PREFIX.charAt(idx)) { + return readAhead; } } final char[] marker = readMarker(); if(myEventsDispatcher != null) myEventsDispatcher.processPacket(decode(marker)); - return true; + return null; } public void setEventsDispatcher(final PacketProcessor eventsDispatcher) { @@ -127,11 +128,11 @@ public class SegmentedInputStream extends InputStream { mySourceStream.pushBack(b); return 1; } - final boolean packetRead = readControlSequence(); - if (!packetRead) { + final Integer packetRead = readControlSequence(); + if (packetRead != null) { // push back quoted slash mySourceStream.pushBack(b); - mySourceStream.pushBack(b); + mySourceStream.pushBack(packetRead); return 1; } } diff --git a/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueue.java b/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueue.java similarity index 94% rename from java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueue.java rename to java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueue.java index 08017b47d4ff..f4161a10ff19 100644 --- a/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueue.java +++ b/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueue.java @@ -15,7 +15,7 @@ */ package com.intellij.execution.junit2.segments; -public interface DeferedActionsQueue { +public interface DeferredActionsQueue { void addLast(Runnable runnable); void setDispactchListener(DispatchListener listener); diff --git a/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueueImpl.java b/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueueImpl.java similarity index 95% rename from java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueueImpl.java rename to java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueueImpl.java index b4a0d4386c63..64d19c100efe 100644 --- a/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferedActionsQueueImpl.java +++ b/java/execution/impl/src/com/intellij/execution/junit2/segments/DeferredActionsQueueImpl.java @@ -19,7 +19,7 @@ import com.intellij.openapi.diagnostic.Logger; import java.awt.*; -public class DeferedActionsQueueImpl implements DeferedActionsQueue { +public class DeferredActionsQueueImpl implements DeferredActionsQueue { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.DeferedActionsQueueImpl"); private DispatchListener myListener = DispatchListener.DEAF; private int myCounter = 0; diff --git a/java/execution/impl/src/com/intellij/execution/junit2/segments/Extractor.java b/java/execution/impl/src/com/intellij/execution/junit2/segments/Extractor.java new file mode 100644 index 000000000000..c3e32608983d --- /dev/null +++ b/java/execution/impl/src/com/intellij/execution/junit2/segments/Extractor.java @@ -0,0 +1,72 @@ +/* + * 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.segments; + +import com.intellij.execution.junit.SegmentedInputStreamReader; +import com.intellij.execution.junit2.SegmentedInputStream; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; +import com.intellij.rt.execution.junit.segments.PacketProcessor; + +import java.io.InputStream; +import java.io.Reader; +import java.nio.charset.Charset; + +/** + * @author dyoma + */ +public class Extractor { + private DeferredActionsQueue myFulfilledWorkGate = null; + private final SegmentedInputStream myStream; + + public Extractor(final InputStream stream, final Charset charset) { + myStream = new SegmentedInputStream(stream, charset); + } + + public void setDispatchListener(final DispatchListener listener) { + myFulfilledWorkGate.setDispactchListener(listener); + } + + public void setPacketDispatcher(final PacketProcessor packetProcessor, final DeferredActionsQueue queue) { + myFulfilledWorkGate = new DeferredActionsQueue() { //todo make it all later + public void addLast(final Runnable runnable) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + queue.addLast(runnable); + } + }, ModalityState.NON_MODAL); + } + + public void setDispactchListener(final DispatchListener listener) { + queue.setDispactchListener(listener); + } + }; + myStream.setEventsDispatcher(new PacketProcessor() { + public void processPacket(final String packet) { + myFulfilledWorkGate.addLast(new Runnable() { + public void run() { + packetProcessor.processPacket(packet); + } + }); + } + }); + } + + public Reader createReader() { + return new SegmentedInputStreamReader(myStream); + } + +} diff --git a/java/execution/impl/src/com/intellij/execution/junit2/segments/InputConsumer.java b/java/execution/impl/src/com/intellij/execution/junit2/segments/InputConsumer.java index 28c7f5e3d5c0..9539528e769d 100644 --- a/java/execution/impl/src/com/intellij/execution/junit2/segments/InputConsumer.java +++ b/java/execution/impl/src/com/intellij/execution/junit2/segments/InputConsumer.java @@ -18,10 +18,8 @@ package com.intellij.execution.junit2.segments; import com.intellij.execution.ui.ConsoleViewContentType; public interface InputConsumer { - class DeafInputConsumer implements InputConsumer { - public void onOutput(final String text, final ConsoleViewContentType contentType) { - } - } - DeafInputConsumer DEAF = new DeafInputConsumer(); + InputConsumer DEAF = new InputConsumer() { + public void onOutput(String text, ConsoleViewContentType contentType) {} + }; void onOutput(String text, ConsoleViewContentType contentType); } diff --git a/java/execution/impl/src/com/intellij/execution/junit2/segments/PacketExtractorBase.java b/java/execution/impl/src/com/intellij/execution/junit2/segments/PacketExtractorBase.java deleted file mode 100644 index 7b522b89d54a..000000000000 --- a/java/execution/impl/src/com/intellij/execution/junit2/segments/PacketExtractorBase.java +++ /dev/null @@ -1,39 +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.segments; - -import com.intellij.rt.execution.junit.segments.PacketProcessor; - -/** - * @author dyoma - */ -public abstract class PacketExtractorBase { - private DeferedActionsQueue myFulfilledWorkGate = null; - - public void setFulfilledWorkGate(final DeferedActionsQueue fulfilledWorkGate) { - myFulfilledWorkGate = fulfilledWorkGate; - } - - public abstract void setPacketProcessor(PacketProcessor packetProcessor); - - public void setDispatchListener(final DispatchListener listener) { - myFulfilledWorkGate.setDispactchListener(listener); - } - - protected void perform(final Runnable runnable) { - myFulfilledWorkGate.addLast(runnable); - } -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/ExceptionPacketFactory.java b/java/java-runtime/src/com/intellij/rt/execution/junit/ExceptionPacketFactory.java index 485c9a810c61..0d577cb3f0ac 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/ExceptionPacketFactory.java +++ b/java/java-runtime/src/com/intellij/rt/execution/junit/ExceptionPacketFactory.java @@ -15,7 +15,7 @@ */ package com.intellij.rt.execution.junit; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; public class ExceptionPacketFactory implements PacketFactory { @@ -27,7 +27,7 @@ public class ExceptionPacketFactory implements PacketFactory { myAssertion = assertion; } - public Packet createPacket(OutputObjectRegistryEx registry, Object test) { + public Packet createPacket(OutputObjectRegistry registry, Object test) { return registry.createPacket(). setTestState(test, myState). addThrowable(myAssertion); diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/PacketFactory.java b/java/java-runtime/src/com/intellij/rt/execution/junit/PacketFactory.java index 0e65fcd1370f..25f536ebe89c 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/PacketFactory.java +++ b/java/java-runtime/src/com/intellij/rt/execution/junit/PacketFactory.java @@ -15,9 +15,9 @@ */ package com.intellij.rt.execution.junit; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; public interface PacketFactory { - Packet createPacket(OutputObjectRegistryEx registry, Object test); + Packet createPacket(OutputObjectRegistry registry, Object test); } diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/EchoOutputStream.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/EchoOutputStream.java deleted file mode 100644 index 8ecdb7382a41..000000000000 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/EchoOutputStream.java +++ /dev/null @@ -1,34 +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.rt.execution.junit.segments; - -import java.io.OutputStream; -import java.io.IOException; - -public class EchoOutputStream extends OutputStream { - private final OutputStream myOut; - private final OutputStream myEcho; - - public EchoOutputStream(OutputStream out, OutputStream echo) { - myOut = out; - myEcho = echo; - } - - public synchronized void write(int b) throws IOException { - myOut.write(b); - myEcho.write(b); - } -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistry.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistry.java index f7289ceaf5f2..c23c9c520ee4 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistry.java +++ b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistry.java @@ -15,7 +15,81 @@ */ package com.intellij.rt.execution.junit.segments; -public interface OutputObjectRegistry { +import java.util.Hashtable; - String referenceTo(Object object); +public abstract class OutputObjectRegistry { + private final Hashtable myKnownKeys = new Hashtable(); + private int myLastIndex = 0; + private PacketProcessor myMainTransport; + private PacketProcessor myAuxilaryTransport; + + public OutputObjectRegistry(PacketProcessor transport) { + myMainTransport = transport; + } + + public OutputObjectRegistry(PacketProcessor mainTransport, PacketProcessor auxilaryTransport) { + this(mainTransport); + myAuxilaryTransport = auxilaryTransport; + } + + public String referenceTo(Object test) { + if (myKnownKeys.containsKey(test)) + return (String) myKnownKeys.get(test); + return sendObject(test); + } + + public Packet createPacket() { + return new Packet(myMainTransport, this); + } + + private String sendObject(Object test) { + String key = String.valueOf(myLastIndex++); + myKnownKeys.put(test, key); + Packet packet = createPacket().addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key); + addStringRepresentation(test, packet); + packet.addLong(getTestCont(test)); + sendViaAllTransports(packet); + return key; + } + + protected abstract int getTestCont(Object test); + protected abstract void addStringRepresentation(Object test, Packet packet); + + private void sendViaAllTransports(Packet packet) { + packet.send(); + if (myAuxilaryTransport != null) + packet.sendThrough(myAuxilaryTransport); + } + + + + protected static void addTestClass(Packet packet, String className) { + packet. + addLimitedString(PoolOfTestTypes.TEST_CLASS). + addLimitedString(className); + } + + protected void addUnknownTest(Packet packet, Object test) { + packet. + addLimitedString(PoolOfTestTypes.UNKNOWN). + addLong(getTestCont(test)). + addLimitedString(test.getClass().getName()); + } + + protected static void addAllInPackage(Packet packet, String name) { + packet. + addLimitedString(PoolOfTestTypes.ALL_IN_PACKAGE). + addLimitedString(name); + } + + protected static void addTestMethod(Packet packet, String methodName, String className) { + packet. + addLimitedString(PoolOfTestTypes.TEST_METHOD). + addLimitedString(methodName). + addLimitedString(className); + } + + public void forget(Object test) { + myKnownKeys.remove(test); + } } diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistryEx.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistryEx.java deleted file mode 100644 index d48a88966a94..000000000000 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/OutputObjectRegistryEx.java +++ /dev/null @@ -1,95 +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.rt.execution.junit.segments; - -import java.util.Hashtable; - -public abstract class OutputObjectRegistryEx implements OutputObjectRegistry, PacketFactory { - private final Hashtable myKnownKeys = new Hashtable(); - private int myLastIndex = 0; - private PacketProcessor myMainTransport; - private PacketProcessor myAuxilaryTransport; - - public OutputObjectRegistryEx(PacketProcessor transport) { - myMainTransport = transport; - } - - public OutputObjectRegistryEx(PacketProcessor mainTransport, PacketProcessor auxilaryTransport) { - this(mainTransport); - myAuxilaryTransport = auxilaryTransport; - } - - public String referenceTo(Object test) { - if (myKnownKeys.containsKey(test)) - return (String) myKnownKeys.get(test); - return sendObject(test); - } - - public Packet createPacket() { - return new Packet(myMainTransport, this); - } - - private String sendObject(Object test) { - String key = String.valueOf(myLastIndex++); - myKnownKeys.put(test, key); - Packet packet = createPacket().addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key); - addStringRepresentation(test, packet); - packet.addLong(getTestCont(test)); - sendViaAllTransports(packet); - return key; - } - - protected abstract int getTestCont(Object test); - protected abstract void addStringRepresentation(Object test, Packet packet); - - private void sendViaAllTransports(Packet packet) { - packet.send(); - if (myAuxilaryTransport != null) - packet.sendThrough(myAuxilaryTransport); - } - - - - protected static void addTestClass(Packet packet, String className) { - packet. - addLimitedString(PoolOfTestTypes.TEST_CLASS). - addLimitedString(className); - } - - protected void addUnknownTest(Packet packet, Object test) { - packet. - addLimitedString(PoolOfTestTypes.UNKNOWN). - addLong(getTestCont(test)). - addLimitedString(test.getClass().getName()); - } - - protected static void addAllInPackage(Packet packet, String name) { - packet. - addLimitedString(PoolOfTestTypes.ALL_IN_PACKAGE). - addLimitedString(name); - } - - protected static void addTestMethod(Packet packet, String methodName, String className) { - packet. - addLimitedString(PoolOfTestTypes.TEST_METHOD). - addLimitedString(methodName). - addLimitedString(className); - } - - public void forget(Object test) { - myKnownKeys.remove(test); - } -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketFactory.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketFactory.java deleted file mode 100644 index ce1e3ab1834f..000000000000 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketFactory.java +++ /dev/null @@ -1,20 +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.rt.execution.junit.segments; - -public interface PacketFactory { - Packet createPacket(); -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketProcessors.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketProcessors.java deleted file mode 100644 index ae0f68ccae7b..000000000000 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PacketProcessors.java +++ /dev/null @@ -1,28 +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.rt.execution.junit.segments; - -/** - * @author MYakovlev - * Date: Feb 27, 2003 - * Time: 10:48:55 AM - */ -public class PacketProcessors{ - public static final PacketProcessor DEAF = new PacketProcessor() { - public void processPacket(String packet) { - } - }; -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PoolOfKnownObjects.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PoolOfKnownObjects.java deleted file mode 100644 index 542169d7b5f7..000000000000 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/PoolOfKnownObjects.java +++ /dev/null @@ -1,23 +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.rt.execution.junit.segments; - -/** - * @noinspection HardCodedStringLiteral - */ -public interface PoolOfKnownObjects { - String DEFAULT_INPUT_CONSUMER = "K1"; -} diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/SegmentedOutputStream.java b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/SegmentedOutputStream.java index 8bdb42b02887..d6596347971a 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/segments/SegmentedOutputStream.java +++ b/java/java-runtime/src/com/intellij/rt/execution/junit/segments/SegmentedOutputStream.java @@ -75,24 +75,4 @@ public class SegmentedOutputStream extends OutputStream implements PacketProcess writeNext(SegmentedStream.STARTUP_MESSAGE); myStarted = true; } - - public void beNotStarted() { - myStarted = false; - } - - public static interface PrintStreamProvider { - OutputStream getOutputStream(); - } - - public static class SimplePrintStreamProvider implements PrintStreamProvider { - private final PrintStream myPrintStream; - - public SimplePrintStreamProvider(PrintStream printStream) { - myPrintStream = printStream; - } - - public OutputStream getOutputStream() { - return myPrintStream; - } - } } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java index 5026b32acf04..5d5df2edadfc 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.execution.testframework; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.Location; import com.intellij.openapi.actionSystem.DataConstants; import com.intellij.openapi.actionSystem.ex.DataConstantsEx; @@ -23,10 +24,15 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -90,4 +96,22 @@ public class TestsUIUtil { LOG.assertTrue(icon != null, fullIconName); return icon; } + + public static void notifyByBalloon(@NotNull final Project project, final AbstractTestProxy root, final TestConsoleProperties properties, + @NotNull final Filter filter) { + if (project.isDisposed()) return; + final int failed = root != null ? filter.select(root.getAllTests()).size() : -1; + if (properties == null) return; + final String testRunDebugId = properties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN; + final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); + if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) { + toolWindowManager + .notifyByBalloon(testRunDebugId, failed == -1 ? MessageType.WARNING : (failed > 0 ? MessageType.ERROR : MessageType.INFO), + failed == -1 + ? ExecutionBundle.message("test.not.started.progress.text") + : (failed > 0 + ? failed + " " + ExecutionBundle.message("junit.runing.info.tests.failed.label") + : ExecutionBundle.message("junit.runing.info.tests.passed.label")), null, null); + } + } } 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 300ac3587740..6d473e2d8493 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/BaseTestsOutputConsoleView.java @@ -138,7 +138,7 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa return myConsole; } - protected TestsOutputConsolePrinter getPrinter() { + public TestsOutputConsolePrinter getPrinter() { return myPrinter; } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java index 0c63bd95316d..492a79a05618 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser2.java @@ -86,14 +86,9 @@ final class OutputParser2 extends OutputParser implements PacketProcessor, Input final ProgressIndicator progress, final AntBuildFile buildFile) { OutputParser2 parser = new OutputParser2(myProject, handler, errorView, progress, buildFile.getName()); - DeferedActionsQueue queue = new DeferedActionsQueueImpl(); - attach(parser, handler.getOut(), queue); - attach(parser, handler.getErr(), queue); + DeferredActionsQueue queue = new DeferredActionsQueueImpl(); + handler.getOut().setPacketDispatcher(parser, queue); + handler.getErr().setPacketDispatcher(parser, queue); return parser; } - - private static void attach(OutputParser2 parser, PacketExtractorBase packetExtractorBase, DeferedActionsQueue queue) { - packetExtractorBase.setFulfilledWorkGate(queue); - packetExtractorBase.setPacketProcessor(parser); - } } diff --git a/plugins/junit/src/com/intellij/execution/junit/TestObject.java b/plugins/junit/src/com/intellij/execution/junit/TestObject.java index bfb8885eb6cc..895216123718 100644 --- a/plugins/junit/src/com/intellij/execution/junit/TestObject.java +++ b/plugins/junit/src/com/intellij/execution/junit/TestObject.java @@ -19,7 +19,12 @@ package com.intellij.execution.junit; import com.intellij.ExtensionPoints; import com.intellij.execution.*; import com.intellij.execution.configurations.*; +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.segments.DeferredActionsQueue; +import com.intellij.execution.junit2.segments.DeferredActionsQueueImpl; +import com.intellij.execution.junit2.segments.DispatchListener; import com.intellij.execution.junit2.ui.JUnitTreeConsoleView; +import com.intellij.execution.junit2.ui.TestsPacketsReceiver; import com.intellij.execution.junit2.ui.actions.RerunFailedTestsAction; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; @@ -28,7 +33,9 @@ import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ProgramRunner; import com.intellij.execution.testframework.*; +import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.util.JavaParametersUtil; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; @@ -38,21 +45,19 @@ import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.ex.JavaSdkUtil; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Getter; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.psi.PsiElement; import com.intellij.refactoring.listeners.RefactoringElementListener; import com.intellij.rt.execution.junit.IDEAJUnitListener; import com.intellij.rt.execution.junit.JUnitStarter; import com.intellij.util.Function; +import com.intellij.util.IJSwingUtilities; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; -import javax.swing.*; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -229,20 +234,73 @@ public abstract class TestObject implements JavaCommandLine { } public ExecutionResult execute(final Executor executor, @NotNull final ProgramRunner runner) throws ExecutionException { + final JUnitProcessHandler handler = JUnitProcessHandler.runJava(getJavaParameters(), myProject); + for(final RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) { + ext.handleStartProcess(myConfiguration, handler); + } final JUnitConsoleProperties consoleProperties = new JUnitConsoleProperties(myConfiguration); final JUnitTreeConsoleView consoleView = new JUnitTreeConsoleView(consoleProperties, getRunnerSettings(), getConfigurationSettings()); consoleView.initUI(); - final ProcessHandler handler = startProcess(consoleView); consoleView.attachToProcess(handler); + + final TestsPacketsReceiver packetsReceiver = new TestsPacketsReceiver(consoleView) { + @Override + public void notifyStart(TestProxy root) { + super.notifyStart(root); + handler.getOut().setDispatchListener(getModel().getNotifier()); + Disposer.register(getModel(), new Disposable() { + public void dispose() { + handler.getOut().setDispatchListener(DispatchListener.DEAF); + } + }); + consoleView.attachToModel(getModel()); + } + }; + + final DeferredActionsQueue queue = new DeferredActionsQueueImpl(); + handler.getOut().setPacketDispatcher(packetsReceiver, queue); + handler.getErr().setPacketDispatcher(packetsReceiver, queue); + + handler.addProcessListener(new ProcessAdapter() { + @Override + public void processTerminated(ProcessEvent event) { + handler.removeProcessListener(this); + if (myTempFile != null) { + FileUtil.delete(myTempFile); + } + IJSwingUtilities.invoke(new Runnable() { + public void run() { + packetsReceiver.checkTerminated(); + final JUnitRunningModel model = packetsReceiver.getModel(); + TestsUIUtil.notifyByBalloon(myProject, model != null ? model.getRoot() : null, consoleProperties, + Filter.DEFECTIVE_LEAF.and(JavaAwareFilter.METHOD(myProject))); + } + }); + } + + @Override + public void onTextAvailable(final ProcessEvent event, final Key outputType) { + final String text = event.getText(); + final ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(outputType); + final TestProxy currentTest = packetsReceiver.getCurrentTest(); + if (currentTest != null) { + currentTest.onOutput(text, consoleViewType); + } + else { + consoleView.getPrinter().onNewAvailable(new ExternalOutput(text, consoleViewType)); + } + } + }); + if (ApplicationManager.getApplication().isUnitTestMode()) { return new DefaultExecutionResult(null, handler); } - RerunFailedTestsAction rerunFailedTestsAction = new RerunFailedTestsAction(consoleView.getComponent()); + final RerunFailedTestsAction rerunFailedTestsAction = new RerunFailedTestsAction(consoleView.getComponent()); rerunFailedTestsAction.init(consoleProperties, myRunnerSettings, myConfigurationSettings); rerunFailedTestsAction.setModelProvider(new Getter() { public TestFrameworkRunningModel get() { - return consoleView.getModel(); + return packetsReceiver.getModel(); } }); @@ -251,41 +309,8 @@ public abstract class TestObject implements JavaCommandLine { return result; } - private ProcessHandler startProcess(final JUnitTreeConsoleView consoleView) throws ExecutionException { - final JUnitProcessHandler handler = JUnitProcessHandler.runJava(getJavaParameters(), myProject); - for(RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) { - ext.handleStartProcess(myConfiguration, handler); - } - handler.addProcessListener(new ProcessAdapter() { - public void processTerminated(final ProcessEvent event) { - if (myTempFile != null) { - myTempFile.delete(); - } - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (myProject.isDisposed()) return; - final JUnitRunningModel model = consoleView.getModel(); - final int failed = model != null ? Filter.DEFECTIVE_LEAF.and(JavaAwareFilter.METHOD(myProject)).select(model.getRoot().getAllTests()).size() : -1; - final TestConsoleProperties properties = consoleView.getProperties(); - if (properties == null) return; - final String testRunDebugId = properties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN; - final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); - if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) { - toolWindowManager.notifyByBalloon(testRunDebugId, - failed == -1 ? MessageType.WARNING : (failed > 0 ? MessageType.ERROR : MessageType.INFO), - failed == -1 ? ExecutionBundle.message("test.not.started.progress.text") : (failed > 0 ? failed + " " + ExecutionBundle.message("junit.runing.info.tests.failed.label") : ExecutionBundle.message("junit.runing.info.tests.passed.label")) , null, null); - } - } - }); - } - }); - return handler; - } - - - protected void addClassesListToJavaParameters(Collection elements, Function nameFunction, String packageName, + protected void addClassesListToJavaParameters(Collection elements, Function nameFunction, String packageName, boolean createTempFile, boolean junit4) { try { diff --git a/plugins/junit/src/com/intellij/execution/junit2/InputRouter.java b/plugins/junit/src/com/intellij/execution/junit2/InputRouter.java deleted file mode 100644 index f0f9d74f67d8..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/InputRouter.java +++ /dev/null @@ -1,100 +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.segments.InputConsumer; -import com.intellij.execution.junit2.segments.ObjectReader; -import com.intellij.execution.junit2.segments.PacketConsumer; -import com.intellij.execution.process.ProcessAdapter; -import com.intellij.execution.process.ProcessEvent; -import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.ui.ConsoleViewContentType; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.Conditions; -import com.intellij.openapi.util.Key; -import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; - -public class InputRouter implements PacketConsumer { - private InputConsumer myInputConsumer = InputConsumer.DEAF; - private static final Condition ANY_EXCEPT_ERR = new Condition() { - public boolean value(final ConsoleViewContentType consoleViewContentType) { - return consoleViewContentType != ConsoleViewContentType.ERROR_OUTPUT; - } - }; - private static final Condition ERR = Conditions.not(ANY_EXCEPT_ERR); - private final Condition mySourceFilter; - - private InputRouter(final Condition sourceFilter) { - mySourceFilter = sourceFilter; - } - - public void readPacketFrom(final ObjectReader reader) { - myInputConsumer = reader.readObject(); - } - - public void setInputConsumer(final InputConsumer inputConsumer) { - myInputConsumer = inputConsumer; - } - - public void onFinished() { - } - - public String getPrefix() { - return PoolOfDelimiters.INPUT_COSUMER; - } - - public void attachTo(final ProcessHandler process) { - process.addProcessListener(new MyProcessAdapter(mySourceFilter)); - } - - public static InputRouter createOutRouter() { - return new InputRouter(ANY_EXCEPT_ERR); - } - - public static InputRouter createErrRouter() { - return new InputRouter(ERR); - } - - private class MyProcessAdapter extends ProcessAdapter { - private final Condition mySourceFilter; - - public MyProcessAdapter(final Condition sourceFilter) { - mySourceFilter = sourceFilter; - } - - public void processTerminated(ProcessEvent event) { - final ProcessHandler processHandler = event.getProcessHandler(); - ApplicationManager.getApplication().invokeLater(new Runnable(){ - public void run() { - processHandler.removeProcessListener(MyProcessAdapter.this); - } - }); - } - - public void onTextAvailable(final ProcessEvent event, final Key outputType) { - ApplicationManager.getApplication().invokeLater(new Runnable(){ - public void run() { - final ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(outputType); - if (mySourceFilter.value(consoleViewType)) { - myInputConsumer.onOutput(event.getText(), consoleViewType); - } - } - }); - } - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java index 5cb86418e9e7..83139dc60672 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java +++ b/plugins/junit/src/com/intellij/execution/junit2/TestProxy.java @@ -17,6 +17,7 @@ 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; @@ -35,7 +36,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -public class TestProxy extends CompositePrintable implements PrintableTestProxy, InputConsumer, ChangingPrintable, TestProxyParent { +public class TestProxy extends CompositePrintable implements PrintableTestProxy, InputConsumer, ChangingPrintable { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestProxy"); private final TestInfo myInfo; diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestProxyParent.java b/plugins/junit/src/com/intellij/execution/junit2/TestProxyParent.java deleted file mode 100644 index f97d3f713ad5..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/TestProxyParent.java +++ /dev/null @@ -1,21 +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; - -public interface TestProxyParent { - void addChild(TestProxy child); -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestRoot.java b/plugins/junit/src/com/intellij/execution/junit2/TestRoot.java index df721b06af17..81027997c2a7 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestRoot.java +++ b/plugins/junit/src/com/intellij/execution/junit2/TestRoot.java @@ -18,6 +18,8 @@ package com.intellij.execution.junit2; import java.util.List; -public interface TestRoot extends TestProxyParent { +public interface TestRoot { List getAllTests(); + + void addChild(TestProxy child); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java b/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java index 0cd9326035f1..64e6a7fb5d85 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java +++ b/plugins/junit/src/com/intellij/execution/junit2/TestRootImpl.java @@ -62,7 +62,7 @@ public class TestRootImpl implements TestRoot { setClassName(className); } - public void readPacketFrom(final ObjectReader reader) { + public void readFrom(final ObjectReader reader) { } } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestingStatus.java b/plugins/junit/src/com/intellij/execution/junit2/TestingStatus.java deleted file mode 100644 index 06c1dae33f81..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/TestingStatus.java +++ /dev/null @@ -1,120 +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.segments.*; -import com.intellij.execution.junit2.ui.model.CompletionEvent; -import com.intellij.execution.junit2.ui.model.JUnitListener; -import com.intellij.execution.process.ProcessAdapter; -import com.intellij.execution.process.ProcessEvent; -import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.ui.ConsoleViewContentType; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; -import com.intellij.util.IJSwingUtilities; - -import javax.swing.*; -import java.util.ArrayList; - -public class TestingStatus extends ProcessAdapter implements PacketConsumer, InputConsumer { - private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestingStatus"); - - private JUnitListener myListener; - private ProcessHandler myProcess; - private boolean myIsTerminated; - private DeferedActionsQueue myInvoker; - private final ArrayList myDeferedEvents = new ArrayList(); - //private Printer myPrinter = Printer.DEAF; - private InputConsumer myInputConsumer = InputConsumer.DEAF; - private PacketsDispatcher myPacketsDispatcher; - - public TestingStatus() { - } - - public TestingStatus(final DeferedActionsQueue invoker) { - myInvoker = invoker; - } - - public String getPrefix() { - return PoolOfDelimiters.TESTS_DONE; - } - - public void readPacketFrom(final ObjectReader reader) { - final int time = reader.readInt(); - fireOnRunnerStateChanged(new CompletionEvent(true, time)); - } - - public void onFinished() { - } - - private void fireOnRunnerStateChanged(final CompletionEvent event) { - LOG.assertTrue(!myIsTerminated); - LOG.assertTrue(SwingUtilities.isEventDispatchThread()); - myPacketsDispatcher.onFinished(); - if (myListener == null) - myDeferedEvents.add(event); - else - myListener.onRunnerStateChanged(event); - myIsTerminated = !event.isRunning(); - } - - public void setListener(final JUnitListener listener) { - myListener = listener; - for (final CompletionEvent event : myDeferedEvents) { - myListener.onRunnerStateChanged(event); - } - myDeferedEvents.clear(); - } - - public boolean isRunning() { - return !myIsTerminated; - } - - public void processTerminated(ProcessEvent event) { - myProcess.removeProcessListener(this); - myProcess = null; - IJSwingUtilities.invoke(new Runnable() { - public void run() { - myInvoker.addLast(new Runnable() { - public void run() { - if (!myIsTerminated) { - fireOnRunnerStateChanged(new CompletionEvent(false, -1)); - } - } - }); - } - }); - } - - public void attachTo(final ProcessHandler process) { - myIsTerminated = false; - myProcess = process; - myProcess.addProcessListener(this); - } - - public void onOutput(final String text, final ConsoleViewContentType contentType) { - myInputConsumer.onOutput(text, contentType); - } - - public void setInputConsumer(final InputConsumer inputConsumer) { - myInputConsumer = inputConsumer; - } - - public void setPacketsDispatcher(final PacketsDispatcher packetsDispatcher) { - myPacketsDispatcher = packetsDispatcher; - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/TreeConsumer.java b/plugins/junit/src/com/intellij/execution/junit2/TreeConsumer.java deleted file mode 100644 index 37eee6f31ef1..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/TreeConsumer.java +++ /dev/null @@ -1,45 +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.segments.ObjectReader; -import com.intellij.execution.junit2.segments.PacketConsumer; -import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; - -public abstract class TreeConsumer implements PacketConsumer { - public void readPacketFrom(final ObjectReader reader) { - final TestProxy root = readNode(reader); - onTreeAvailable(root); - } - - public String getPrefix() { - return PoolOfDelimiters.TREE_PREFIX; - } - - public void onFinished() { - } - - protected abstract void onTreeAvailable(TestProxy treeRoot); - - private static TestProxy readNode(final ObjectReader reader) { - final TestProxy node = reader.readObject(); - final int childCount = reader.readInt(); - for (int i = 0; i < childCount; i++) - node.addChild(readNode(reader)); - return node; - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/NewChildEvent.java b/plugins/junit/src/com/intellij/execution/junit2/events/NewChildEvent.java similarity index 88% rename from plugins/junit/src/com/intellij/execution/junit2/NewChildEvent.java rename to plugins/junit/src/com/intellij/execution/junit2/events/NewChildEvent.java index 33f0e2b0d06b..b505ca186759 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/NewChildEvent.java +++ b/plugins/junit/src/com/intellij/execution/junit2/events/NewChildEvent.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.events; + +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.events.TestEvent; public class NewChildEvent extends TestEvent { private final TestProxy myChild; diff --git a/plugins/junit/src/com/intellij/execution/junit2/StateChangedEvent.java b/plugins/junit/src/com/intellij/execution/junit2/events/StateChangedEvent.java similarity index 86% rename from plugins/junit/src/com/intellij/execution/junit2/StateChangedEvent.java rename to plugins/junit/src/com/intellij/execution/junit2/events/StateChangedEvent.java index 56e1b37d3bff..97f4acb5dcfb 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/StateChangedEvent.java +++ b/plugins/junit/src/com/intellij/execution/junit2/events/StateChangedEvent.java @@ -14,8 +14,10 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.events; +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.testframework.AbstractTestProxy; public class StateChangedEvent extends TestEvent { diff --git a/plugins/junit/src/com/intellij/execution/junit2/StatisticsChanged.java b/plugins/junit/src/com/intellij/execution/junit2/events/StatisticsChanged.java similarity index 82% rename from plugins/junit/src/com/intellij/execution/junit2/StatisticsChanged.java rename to plugins/junit/src/com/intellij/execution/junit2/events/StatisticsChanged.java index cfed30cd1b7b..3b0691df49e8 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/StatisticsChanged.java +++ b/plugins/junit/src/com/intellij/execution/junit2/events/StatisticsChanged.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.events; + +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.events.TestEvent; public class StatisticsChanged extends TestEvent { public StatisticsChanged(final TestProxy test) { diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestEvent.java b/plugins/junit/src/com/intellij/execution/junit2/events/TestEvent.java similarity index 92% rename from plugins/junit/src/com/intellij/execution/junit2/TestEvent.java rename to plugins/junit/src/com/intellij/execution/junit2/events/TestEvent.java index 76f05457c0e2..b883461c927f 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestEvent.java +++ b/plugins/junit/src/com/intellij/execution/junit2/events/TestEvent.java @@ -14,8 +14,9 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.events; +import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.testframework.AbstractTestProxy; public class TestEvent { diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestEventsConsumer.java b/plugins/junit/src/com/intellij/execution/junit2/events/TestEventsConsumer.java similarity index 93% rename from plugins/junit/src/com/intellij/execution/junit2/TestEventsConsumer.java rename to plugins/junit/src/com/intellij/execution/junit2/events/TestEventsConsumer.java index ba70dbe699dd..21a1429e5a33 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestEventsConsumer.java +++ b/plugins/junit/src/com/intellij/execution/junit2/events/TestEventsConsumer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.events; public interface TestEventsConsumer { void onEvent(TestEvent event); diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/AllInPackageInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/AllInPackageInfo.java index c71e04ba194c..768a9d845917 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/AllInPackageInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/AllInPackageInfo.java @@ -21,10 +21,10 @@ import com.intellij.execution.junit.JUnitConfiguration; import com.intellij.execution.junit2.segments.ObjectReader; import com.intellij.openapi.project.Project; -class AllInPackageInfo extends TestInfoImpl { +class AllInPackageInfo extends TestInfo { private String myName; - public void readPacketFrom(final ObjectReader reader) { + public void readFrom(final ObjectReader reader) { myName = reader.readLimitedString(); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/ClassBasedInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/ClassBasedInfo.java index 6db2ffeecc07..d1dbfb14c7b8 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/ClassBasedInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/ClassBasedInfo.java @@ -21,7 +21,7 @@ import com.intellij.execution.junit2.segments.ObjectReader; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.Nullable; -public abstract class ClassBasedInfo extends TestInfoImpl { +public abstract class ClassBasedInfo extends TestInfo { private final DisplayTestInfoExtractor myClassInfo; private PsiClassLocator myClass; private String myComment = null; diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/DefaultTestInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/DefaultTestInfo.java index db74e10eba29..464692794320 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/DefaultTestInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/DefaultTestInfo.java @@ -24,7 +24,7 @@ class DefaultTestInfo extends ClassBasedInfo { super(DisplayTestInfoExtractor.CLASS_FULL_NAME); } - public void readPacketFrom(final ObjectReader reader) { + public void readFrom(final ObjectReader reader) { reader.readInt(); //TODO remove test count from packet readClass(reader); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/TestCaseInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/TestCaseInfo.java index 709cf9974715..3b911e15a502 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/TestCaseInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/TestCaseInfo.java @@ -30,7 +30,7 @@ class TestCaseInfo extends ClassBasedInfo { super(DisplayTestInfoExtractor.CLASS_FULL_NAME); } - public void readPacketFrom(final ObjectReader reader) { + public void readFrom(final ObjectReader reader) { myMethod = reader.readLimitedString(); readClass(reader); } @@ -59,4 +59,4 @@ class TestCaseInfo extends ClassBasedInfo { return true; } -} \ No newline at end of file +} diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/TestClassInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/TestClassInfo.java index 07ed02ad50f1..438d71e580ca 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/TestClassInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/TestClassInfo.java @@ -23,7 +23,7 @@ class TestClassInfo extends ClassBasedInfo { super(DisplayTestInfoExtractor.FOR_CLASS); } - public void readPacketFrom(final ObjectReader reader) { + public void readFrom(final ObjectReader reader) { readClass(reader); } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfo.java b/plugins/junit/src/com/intellij/execution/junit2/info/TestInfo.java index c2798dbbda65..218160ff72fb 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfo.java +++ b/plugins/junit/src/com/intellij/execution/junit2/info/TestInfo.java @@ -16,10 +16,56 @@ package com.intellij.execution.junit2.info; +import com.intellij.execution.junit2.segments.ObjectReader; +import com.intellij.rt.execution.junit.segments.PoolOfTestTypes; +import com.intellij.util.containers.HashMap; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +public abstract class TestInfo implements PsiLocator { + public static final Map KNOWN_PSI_LOCATOR_CLASSES = new HashMap(); + static { + KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.TEST_METHOD, TestCaseInfo.class); + KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.TEST_CLASS, TestClassInfo.class); + KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.ALL_IN_PACKAGE, AllInPackageInfo.class); + } + + @NotNull + public static TestInfo readInfoFrom(final ObjectReader reader) { + final String testType = reader.readLimitedString(); + Class infoClass = KNOWN_PSI_LOCATOR_CLASSES.get(testType); + if (infoClass == null) + infoClass = DefaultTestInfo.class; + final TestInfo info; + try { + info = (TestInfo) infoClass.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + info.readFrom(reader); + info.setTestCount(reader.readInt()); + return info; + } + + private int myTestCount; + + public boolean shouldRun() { + return false; + } + + public int getTestsCount() { + return myTestCount; + } + + public void setTestCount(final int testCount) { + myTestCount = testCount; + } + + public abstract void readFrom(ObjectReader reader); + + public abstract String getComment(); + + public abstract String getName(); -public interface TestInfo extends PsiLocator { - String getComment(); - String getName(); - boolean shouldRun(); - int getTestsCount(); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoFactory.java b/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoFactory.java deleted file mode 100644 index 86d83186eb23..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoFactory.java +++ /dev/null @@ -1,51 +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.info; - -import com.intellij.execution.junit2.segments.ObjectReader; -import com.intellij.rt.execution.junit.segments.PoolOfTestTypes; -import com.intellij.util.containers.HashMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Map; - -public abstract class TestInfoFactory { - private static final Map KNOWN_PSI_LOCATOR_CLASSES = new HashMap(); - - static { - KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.TEST_METHOD, TestCaseInfo.class); - KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.TEST_CLASS, TestClassInfo.class); - KNOWN_PSI_LOCATOR_CLASSES.put(PoolOfTestTypes.ALL_IN_PACKAGE, AllInPackageInfo.class); - } - - @NotNull - public static TestInfo readInfoFrom(final ObjectReader reader) { - final String testType = reader.readLimitedString(); - Class infoClass = KNOWN_PSI_LOCATOR_CLASSES.get(testType); - if (infoClass == null) - infoClass = DefaultTestInfo.class; - final TestInfoImpl info; - try { - info = (TestInfoImpl) infoClass.newInstance(); - } catch (Exception e) { - throw new RuntimeException(e); - } - info.readPacketFrom(reader); - info.setTestCount(reader.readInt()); - return info; - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoImpl.java b/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoImpl.java deleted file mode 100644 index 58964ef51e2c..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/info/TestInfoImpl.java +++ /dev/null @@ -1,38 +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.info; - -import com.intellij.execution.junit2.segments.PacketReader; - -abstract class TestInfoImpl implements TestInfo, PacketReader { - private int myTestCount; - - public boolean shouldRun() { - return false; - } - - public int getTestsCount() { - return myTestCount; - } - - public void setTestCount(final int testCount) { - myTestCount = testCount; - } - - public void onFinished() { - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistry.java b/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistry.java index d58de8d97300..676a5d4fb418 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistry.java +++ b/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistry.java @@ -17,7 +17,36 @@ package com.intellij.execution.junit2.segments; import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.info.TestInfo; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; +import com.intellij.util.containers.HashMap; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; + +public class InputObjectRegistry { + private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.InputObjectRegistryImpl"); + private final Map myKnownObjects = new HashMap(); + + public TestProxy getByKey(final String key) { + final TestProxy result = myKnownObjects.get(key); + if (result == null) { + LOG.assertTrue(false, "Unknwon key: " + key); + LOG.info("Known keys:"); + final ArrayList knownKeys = new ArrayList(myKnownObjects.keySet()); + Collections.sort(knownKeys); + LOG.info(knownKeys.toString()); + } + return result; + } + + public void readPacketFrom(final ObjectReader reader) { + final String reference = reader.upTo(PoolOfDelimiters.REFERENCE_END); + if (myKnownObjects.containsKey(reference)) return; + final TestProxy test = new TestProxy(TestInfo.readInfoFrom(reader)); + myKnownObjects.put(reference, test); + } -public interface InputObjectRegistry extends PacketConsumer { - TestProxy getByKey(String key); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistryImpl.java b/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistryImpl.java deleted file mode 100644 index f10ad864b98d..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/segments/InputObjectRegistryImpl.java +++ /dev/null @@ -1,58 +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.segments; - -import com.intellij.execution.junit2.TestProxy; -import com.intellij.execution.junit2.info.TestInfoFactory; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; -import com.intellij.util.containers.HashMap; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Map; - -public class InputObjectRegistryImpl implements InputObjectRegistry { - private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.InputObjectRegistryImpl"); - private final Map myKnownObjects = new HashMap(); - - public TestProxy getByKey(final String key) { - final TestProxy result = myKnownObjects.get(key); - if (result == null) { - LOG.assertTrue(false, "Unknwon key: " + key); - LOG.info("Known keys:"); - final ArrayList knownKeys = new ArrayList(myKnownObjects.keySet()); - Collections.sort(knownKeys); - LOG.info(knownKeys.toString()); - } - return result; - } - - public String getPrefix() { - return PoolOfDelimiters.OBJECT_PREFIX; - } - - public void readPacketFrom(final ObjectReader reader) { - final String reference = reader.upTo(PoolOfDelimiters.REFERENCE_END); - if (myKnownObjects.containsKey(reference)) return; - final TestProxy test = new TestProxy(TestInfoFactory.readInfoFrom(reader)); - myKnownObjects.put(reference, test); - } - - public void onFinished() { - } -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketReader.java b/plugins/junit/src/com/intellij/execution/junit2/segments/PacketReader.java deleted file mode 100644 index 8dfbc0523e26..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketReader.java +++ /dev/null @@ -1,22 +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.segments; - -public interface PacketReader { - void readPacketFrom(ObjectReader reader); - void onFinished(); -} diff --git a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketsDispatcher.java b/plugins/junit/src/com/intellij/execution/junit2/segments/PacketsDispatcher.java deleted file mode 100644 index 6e32dc2bb4d0..000000000000 --- a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketsDispatcher.java +++ /dev/null @@ -1,73 +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.segments; - -import com.intellij.openapi.application.Application; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.rt.execution.junit.segments.PacketProcessor; -import com.intellij.util.containers.ContainerUtil; - -import java.util.List; - -public class PacketsDispatcher implements PacketProcessor { - private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.PacketsDispatcher"); - private final List myListeners = ContainerUtil.createEmptyCOWList(); - private final InputObjectRegistry myObjectRegistry; - - public PacketsDispatcher() { - this(new InputObjectRegistryImpl()); - } - - public PacketsDispatcher(final InputObjectRegistry objectRegistry) { - myObjectRegistry = objectRegistry; - addListener(objectRegistry); - } - - public void addListener(final PacketConsumer objectConsumer) { - if (myListeners.contains(objectConsumer)) return; - myListeners.add(objectConsumer); - } - - public void processPacket(final String packet) { - assertIsDispatchThread(); - for (final PacketConsumer listener : myListeners) { - final String prefix = listener.getPrefix(); - if (packet.startsWith(prefix)) { - try { - listener.readPacketFrom(new ObjectReader(packet, prefix.length(), myObjectRegistry)); - } - catch (Throwable e) { - LOG.error("Dispatching: " + packet, e); - } - } - } - } - - public static void assertIsDispatchThread() { - final Application application = ApplicationManager.getApplication(); - if (application != null && !application.isUnitTestMode()) - application.assertIsDispatchThread(); - } - - public void onFinished() { - for (final PacketConsumer listener : myListeners) { - listener.onFinished(); - } - } -} - diff --git a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketConsumer.java b/plugins/junit/src/com/intellij/execution/junit2/segments/TestingStatus.java similarity index 77% rename from plugins/junit/src/com/intellij/execution/junit2/segments/PacketConsumer.java rename to plugins/junit/src/com/intellij/execution/junit2/segments/TestingStatus.java index 87d3299f6917..3561431cf1d8 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/segments/PacketConsumer.java +++ b/plugins/junit/src/com/intellij/execution/junit2/segments/TestingStatus.java @@ -16,6 +16,11 @@ package com.intellij.execution.junit2.segments; -public interface PacketConsumer extends PacketReader { - String getPrefix(); +import com.intellij.openapi.diagnostic.Logger; + +public class TestingStatus { + private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.TestingStatus"); + + + } diff --git a/plugins/junit/src/com/intellij/execution/junit2/CumulativeStatistics.java b/plugins/junit/src/com/intellij/execution/junit2/states/CumulativeStatistics.java similarity index 96% rename from plugins/junit/src/com/intellij/execution/junit2/CumulativeStatistics.java rename to plugins/junit/src/com/intellij/execution/junit2/states/CumulativeStatistics.java index a32436f2be90..19bb6670e300 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/CumulativeStatistics.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/CumulativeStatistics.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.states; import com.intellij.execution.junit2.states.Statistics; diff --git a/plugins/junit/src/com/intellij/execution/junit2/states/IgnoredState.java b/plugins/junit/src/com/intellij/execution/junit2/states/IgnoredState.java index e02f357c1cc5..b79fa97f3cab 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/states/IgnoredState.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/IgnoredState.java @@ -27,7 +27,7 @@ public class IgnoredState extends ReadableState { private TestProxy myPeformedTest; private String myIgnoredMessage; - void initializeFrom(final ObjectReader reader) { + public void initializeFrom(final ObjectReader reader) { myPeformedTest = reader.readObject(); myIgnoredMessage = reader.readLimitedString(); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/states/ReadableState.java b/plugins/junit/src/com/intellij/execution/junit2/states/ReadableState.java index 6e7d36a780b2..b42b3d44f80d 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/states/ReadableState.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/ReadableState.java @@ -18,9 +18,9 @@ package com.intellij.execution.junit2.states; import com.intellij.execution.junit2.segments.ObjectReader; -abstract class ReadableState extends TestState { +public abstract class ReadableState extends TestState { - abstract void initializeFrom(ObjectReader reader); + public abstract void initializeFrom(ObjectReader reader); public int getMagnitude() { return myMagnitude; diff --git a/plugins/junit/src/com/intellij/execution/junit2/states/SkippedState.java b/plugins/junit/src/com/intellij/execution/junit2/states/SkippedState.java index 5d0d180b8a2f..6634c1f74cc3 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/states/SkippedState.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/SkippedState.java @@ -23,10 +23,10 @@ import com.intellij.execution.testframework.Printer; import com.intellij.execution.testframework.ui.PrintableTestProxy; import com.intellij.execution.ui.ConsoleViewContentType; -class SkippedState extends ReadableState { +public class SkippedState extends ReadableState { private TestProxy myPeformedTest; - void initializeFrom(final ObjectReader reader) { + public void initializeFrom(final ObjectReader reader) { myPeformedTest = reader.readObject(); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/SuiteState.java b/plugins/junit/src/com/intellij/execution/junit2/states/SuiteState.java similarity index 95% rename from plugins/junit/src/com/intellij/execution/junit2/SuiteState.java rename to plugins/junit/src/com/intellij/execution/junit2/states/SuiteState.java index 26c541c6707c..2d0f2be5530a 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/SuiteState.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/SuiteState.java @@ -14,8 +14,11 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.states; +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.TestProxyListener; +import com.intellij.execution.junit2.states.CumulativeStatistics; import com.intellij.execution.junit2.states.Statistics; import com.intellij.execution.junit2.states.TestState; import com.intellij.execution.testframework.AbstractTestProxy; diff --git a/plugins/junit/src/com/intellij/execution/junit2/states/TestState.java b/plugins/junit/src/com/intellij/execution/junit2/states/TestState.java index 4feaf2b46ae3..72ef754815fc 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/states/TestState.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/TestState.java @@ -17,7 +17,7 @@ package com.intellij.execution.junit2.states; import com.intellij.execution.Location; -import com.intellij.execution.junit2.SuiteState; +import com.intellij.execution.junit2.states.SuiteState; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.testframework.Printable; import com.intellij.ide.util.EditSourceUtil; diff --git a/plugins/junit/src/com/intellij/execution/junit2/states/TestStateUpdater.java b/plugins/junit/src/com/intellij/execution/junit2/states/TestStateUpdater.java index 50c1c62c57ab..fb26ebcb4853 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/states/TestStateUpdater.java +++ b/plugins/junit/src/com/intellij/execution/junit2/states/TestStateUpdater.java @@ -16,170 +16,15 @@ package com.intellij.execution.junit2.states; -import com.intellij.execution.junit2.*; -import com.intellij.execution.junit2.segments.ObjectReader; -import com.intellij.execution.junit2.segments.PacketConsumer; -import com.intellij.execution.testframework.Filter; import com.intellij.execution.testframework.AbstractTestProxy; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; +import com.intellij.execution.testframework.Filter; import com.intellij.rt.execution.junit.states.PoolOfTestStates; -import com.intellij.util.containers.HashMap; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -public class TestStateUpdater implements PacketConsumer { - private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.states.TestStateUpdater"); - private static final Map STATE_CLASSES = new HashMap(); - private TestRoot myTestRoot = new CollectingRoot(); +public class TestStateUpdater { public static final Filter RUNNING = new Filter() { public boolean shouldAccept(final AbstractTestProxy test) { return test.getMagnitude() == PoolOfTestStates.RUNNING_INDEX; } }; public static final Filter RUNNING_LEAF = RUNNING.and(Filter.LEAF); - - private static abstract class StateChanger { - abstract void changeStateOf(TestProxy testProxy, ObjectReader reader); - - void setMagnitude(final int magnitude) { - } - - void modifyTestStack(final TestProxyParent globalRoot, final TestProxy testProxy) { - } - } - - private static class RunningStateSetter extends StateChanger { - public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { - testProxy.setState(TestState.RUNNING_STATE); - TestProxy parent = testProxy.getParent(); - while (parent != null) { - final TestState state = parent.getState(); - LOG.assertTrue(state instanceof SuiteState); - ((SuiteState)state).setRunning(true); - parent = parent.getParent(); - } - } - - public void modifyTestStack(final TestProxyParent globalRoot, final TestProxy test) { - if (test.getParent() == null) - globalRoot.addChild(test); - } - } - - private static class StateReader extends StateChanger { - private final Class myStateClass; - private int myInstanceMagnitude; - - public StateReader(final Class stateClass) { - myStateClass = stateClass; - } - - public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { - final ReadableState state; - try { - state = myStateClass.newInstance(); - } catch (Exception e) { - LOG.error(e); - return; - } - state.setMagitude(myInstanceMagnitude); - state.initializeFrom(reader); - testProxy.setState(state); - complete(testProxy); - } - - public void setMagnitude(final int magnitude) { - myInstanceMagnitude = magnitude; - } - } - - private static class TestCompleter extends StateChanger { - public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { - TestState state = testProxy.getState(); - if (!testProxy.getState().isFinal()) { - state = NotFailedState.createPassed(); - } - testProxy.setState(state); - testProxy.setStatistics(new Statistics(reader)); - complete(testProxy); - } - } - - private static void complete(TestProxy testProxy) { - final int magnitude = testProxy.getState().getMagnitude(); - - TestProxy parent = testProxy.getParent(); - TestProxy child = testProxy; - while (parent != null) { - final List children = parent.getChildren(); - final TestState parentState = parent.getState(); - LOG.assertTrue(parentState instanceof SuiteState); - if (child.equals(children.get(children.size() - 1))) { - ((SuiteState)parentState).setRunning(false); - } - ((SuiteState)parentState).updateMagnitude(magnitude); - child = parent; - parent = parent.getParent(); - } - } - - static { - mapClass(PoolOfTestStates.RUNNING_INDEX, new RunningStateSetter()); - mapClass(PoolOfTestStates.COMPLETE_INDEX, new TestCompleter()); - mapClass(PoolOfTestStates.FAILED_INDEX, new StateReader(FaultyState.class)); - mapClass(PoolOfTestStates.ERROR_INDEX, new StateReader(FaultyState.class)); - mapClass(PoolOfTestStates.IGNORED_INDEX, new StateReader(IgnoredState.class)); - mapClass(PoolOfTestStates.SKIPPED_INDEX, new StateReader(SkippedState.class)); - mapClass(PoolOfTestStates.COMPARISON_FAILURE, new StateReader(ComparisonFailureState.class)); - } - - private static void mapClass(final int magnitude, final StateChanger factory) { - factory.setMagnitude(magnitude); - STATE_CLASSES.put(new Integer(magnitude), factory); - } - - public void readPacketFrom(final ObjectReader reader) { - final TestProxy testProxy = reader.readObject(); - final StateChanger stateChanger = STATE_CLASSES.get(new Integer(reader.readInt())); - stateChanger.modifyTestStack(myTestRoot, testProxy); - stateChanger.changeStateOf(testProxy, reader); - } - - public void onFinished() { - if (myTestRoot == null) return; - final List runningTests = RUNNING_LEAF.select(myTestRoot.getAllTests()); - for (final Object runningTest : runningTests) { - final TestProxy test = (TestProxy)runningTest; - test.setState(NotFailedState.createTerminated()); - } - } - - public String getPrefix() { - return PoolOfDelimiters.CHANGE_STATE; - } - - public void setRoot(final TestProxy testProxy) { - final TestRootImpl root = new TestRootImpl(testProxy); - final List allTests = myTestRoot.getAllTests(); - for (final TestProxy test : allTests) { - root.addChild(test); - } - myTestRoot = root; - } - - private static class CollectingRoot implements TestRoot { - private final ArrayList myTests = new ArrayList(); - public List getAllTests() { - return Collections.unmodifiableList(myTests); - } - - public void addChild(final TestProxy child) { - myTests.add(child); - } - } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java b/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java index 0532e1e28528..87796a1d853b 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java @@ -16,7 +16,7 @@ package com.intellij.execution.junit2.ui; -import com.intellij.execution.junit2.CumulativeStatistics; +import com.intellij.execution.junit2.states.CumulativeStatistics; import com.intellij.execution.junit2.states.Statistics; class ActualStatistics implements TestStatistics { diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/Animator.java b/plugins/junit/src/com/intellij/execution/junit2/ui/Animator.java index 76c75e45784a..88a66a17eeb3 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/Animator.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/Animator.java @@ -16,8 +16,8 @@ package com.intellij.execution.junit2.ui; -import com.intellij.execution.junit2.StateChangedEvent; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.StateChangedEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.ui.model.JUnitAdapter; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/ConsolePanel.java b/plugins/junit/src/com/intellij/execution/junit2/ui/ConsolePanel.java index cc707c34a1f4..890e40122ed9 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/ConsolePanel.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/ConsolePanel.java @@ -34,7 +34,6 @@ import com.intellij.execution.testframework.ToolbarPanel; import com.intellij.execution.testframework.ui.TestResultsPanel; import com.intellij.execution.testframework.ui.TestStatusLine; import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter; -import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -52,7 +51,7 @@ import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -class ConsolePanel extends TestResultsPanel implements Disposable { +public class ConsolePanel extends TestResultsPanel { @NonNls private static final String PROPORTION_PROPERTY = "test_tree_console_proprtion"; private static final float DEFAULT_PROPORTION = 0.2f; @@ -136,10 +135,6 @@ class ConsolePanel extends TestResultsPanel implements Disposable { myPrinter = null; } - public void attachToModel(final JUnitRunningModel model) { - getTreeView().attachToModel(model); - } - private static class StartingProgress implements Runnable { private final Alarm myAlarm = new Alarm(); private final Tree myTree; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java index 6ab655b0a207..c42237b28c8d 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java @@ -18,6 +18,9 @@ package com.intellij.execution.junit2.ui; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.junit2.*; +import com.intellij.execution.junit2.events.NewChildEvent; +import com.intellij.execution.junit2.events.StateChangedEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.ui.model.CompletionEvent; import com.intellij.execution.junit2.ui.model.JUnitAdapter; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitTreeConsoleView.java b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitTreeConsoleView.java index ee1bc615c9a0..d2311ceb6758 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitTreeConsoleView.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitTreeConsoleView.java @@ -18,29 +18,17 @@ package com.intellij.execution.junit2.ui; import com.intellij.execution.configurations.ConfigurationPerRunnerSettings; import com.intellij.execution.configurations.RunnerSettings; -import com.intellij.execution.junit.JUnitProcessHandler; -import com.intellij.execution.junit2.InputRouter; -import com.intellij.execution.junit2.TestProxy; -import com.intellij.execution.junit2.TestingStatus; -import com.intellij.execution.junit2.TreeConsumer; -import com.intellij.execution.junit2.segments.*; -import com.intellij.execution.junit2.states.TestStateUpdater; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; import com.intellij.execution.junit2.ui.model.TreeCollapser; import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.testframework.ExternalOutput; -import com.intellij.execution.testframework.Printer; import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView; import com.intellij.execution.testframework.ui.TestResultsPanel; -import com.intellij.execution.ui.ConsoleViewContentType; -import com.intellij.openapi.util.Disposer; import javax.swing.*; public class JUnitTreeConsoleView extends BaseTestsOutputConsoleView { private ConsolePanel myConsolePanel; - private JUnitRunningModel myModel; private final JUnitConsoleProperties myProperties; private final RunnerSettings myRunnerSettings; private final ConfigurationPerRunnerSettings myConfigurationSettings; @@ -62,105 +50,25 @@ public class JUnitTreeConsoleView extends BaseTestsOutputConsoleView { } public void attachToProcess(final ProcessHandler processHandler) { - final JUnitProcessHandler jUnitProcessHandler = (JUnitProcessHandler)processHandler; - final PacketExtractorBase out = jUnitProcessHandler.getOut(); - final PacketExtractorBase err = jUnitProcessHandler.getErr(); - final DeferedActionsQueue queue = attachPacketExtractors(out, err); - attachTo(out, err, processHandler, queue); - } - - private static DeferedActionsQueue attachPacketExtractors(final PacketExtractorBase myOutPacketExtractor, - final PacketExtractorBase myErrPacketExtractor) { - final DeferedActionsQueue fulfilledWorkGate = new DeferedActionsQueueImpl(); - myOutPacketExtractor.setFulfilledWorkGate(fulfilledWorkGate); - myErrPacketExtractor.setFulfilledWorkGate(fulfilledWorkGate); - return fulfilledWorkGate; - } - - private void attachTo(final PacketExtractorBase outPacketExtractor, final PacketExtractorBase errPacketExtractor, final ProcessHandler process, final DeferedActionsQueue queue) { - final TestingStatus testingStatus = new TestingStatus(queue); - testingStatus.setInputConsumer(new SystemOutput(myConsolePanel.getPrinter())); - myConsolePanel.onProcessStarted(process); - final TestStateUpdater testStateUpdater = new TestStateUpdater(); - final TreeConsumer treeConsumer = createTreeConsumer(testingStatus, outPacketExtractor, testStateUpdater); - connectOperators(process, outPacketExtractor, errPacketExtractor, testingStatus, treeConsumer, testStateUpdater); - } - - private TreeConsumer createTreeConsumer(final TestingStatus testingStatus, - final PacketExtractorBase outPacketExtractor, - final TestStateUpdater testStateUpdater) { - return new TreeConsumer() { - protected void onTreeAvailable(final TestProxy test) { - if (myModel != null) { - Disposer.dispose(myModel); - } - if (myConsolePanel == null) return; - getPrinter().setCollectOutput(false); - testingStatus.setInputConsumer(test); - myModel = new JUnitRunningModel(test, testingStatus, myProperties); - Disposer.register(JUnitTreeConsoleView.this, myModel); - myModel.attachTo(outPacketExtractor); - myConsolePanel.attachToModel(myModel); - myModel.attachToTree(myConsolePanel.getTreeView()); - myConsolePanel.setModel(myModel); - testStateUpdater.setRoot(test); - myModel.onUIBuilt(); - new TreeCollapser().setModel(myModel); - } - }; - } - - - public static void connectOperators(final ProcessHandler process, final PacketExtractorBase outPacketExtractor, - final PacketExtractorBase errPacketExtractor, final TestingStatus testingStatus, - final TreeConsumer treeConsumer, final TestStateUpdater testStateUpdater) { - testingStatus.attachTo(process); - - final InputObjectRegistry registry = new InputObjectRegistryImpl(); - final PacketsDispatcher packetsDispatcher = installDispatcher(registry, outPacketExtractor, process, InputRouter.createOutRouter(), testingStatus); - testingStatus.setPacketsDispatcher(packetsDispatcher); - installDispatcher(registry, errPacketExtractor, process, InputRouter.createErrRouter(), testingStatus); - packetsDispatcher.addListener(treeConsumer); - packetsDispatcher.addListener(testStateUpdater); - packetsDispatcher.addListener(testingStatus); + myConsolePanel.onProcessStarted(processHandler); } public void dispose() { super.dispose(); - myModel = null; myConsolePanel = null; } - - private static PacketsDispatcher installDispatcher(final InputObjectRegistry registry, - final PacketExtractorBase packetExtractor, - final ProcessHandler process, final InputRouter inputRouter, final InputConsumer defaultConsumer) { - inputRouter.setInputConsumer(defaultConsumer); - final PacketsDispatcher packetsDispatcher = new PacketsDispatcher(registry); - packetExtractor.setPacketProcessor(packetsDispatcher); - packetsDispatcher.addListener(inputRouter); - inputRouter.attachTo(process); - return packetsDispatcher; - } - @Override public JComponent getPreferredFocusableComponent() { return myConsolePanel.getTreeView(); } - public JUnitRunningModel getModel() { - return myModel; - } - - private static class SystemOutput implements InputConsumer { - private final Printer myPrinter; - - public SystemOutput(final Printer printer) { - myPrinter = printer; - } - - public void onOutput(final String text, final ConsoleViewContentType contentType) { - myPrinter.onNewAvailable(new ExternalOutput(text, contentType)); - } + public void attachToModel(JUnitRunningModel model) { + getPrinter().setCollectOutput(false); + myConsolePanel.getTreeView().attachToModel(model); + model.attachToTree(myConsolePanel.getTreeView()); + myConsolePanel.setModel(model); + model.onUIBuilt(); + new TreeCollapser().setModel(model); } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/StatisticsPanel.java b/plugins/junit/src/com/intellij/execution/junit2/ui/StatisticsPanel.java index afe48a6e3dac..98ded48bd0da 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/StatisticsPanel.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/StatisticsPanel.java @@ -16,7 +16,7 @@ package com.intellij.execution.junit2.ui; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.ui.actions.TestContext; import com.intellij.execution.junit2.ui.model.JUnitAdapter; diff --git a/plugins/junit/src/com/intellij/execution/junit2/TestProgress.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java similarity index 92% rename from plugins/junit/src/com/intellij/execution/junit2/TestProgress.java rename to plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java index 63586a9b08fe..24c17c9ca84e 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/TestProgress.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java @@ -14,8 +14,12 @@ * limitations under the License. */ -package com.intellij.execution.junit2; +package com.intellij.execution.junit2.ui; +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.events.NewChildEvent; +import com.intellij.execution.junit2.events.StateChangedEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.ui.model.JUnitAdapter; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; import com.intellij.execution.testframework.Filter; @@ -28,7 +32,7 @@ import javax.swing.*; import org.jetbrains.annotations.NonNls; public class TestProgress extends DefaultBoundedRangeModel { - private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestProgress"); + private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.ui.TestProgress"); private int myProblemsCounter = 0; private TestProxy myCurrentState = null; private final MyJUnitListener myListener = new MyJUnitListener(); diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestsPacketsReceiver.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestsPacketsReceiver.java new file mode 100644 index 000000000000..c22a5f248249 --- /dev/null +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestsPacketsReceiver.java @@ -0,0 +1,263 @@ +/* + * 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. + */ + +/* + * User: anna + * Date: 11-Dec-2009 + */ +package com.intellij.execution.junit2.ui; + +import com.intellij.execution.junit2.TestProxy; +import com.intellij.execution.junit2.segments.InputObjectRegistry; +import com.intellij.execution.junit2.segments.ObjectReader; +import com.intellij.execution.junit2.states.*; +import com.intellij.execution.junit2.ui.model.CompletionEvent; +import com.intellij.execution.junit2.ui.model.JUnitListenersNotifier; +import com.intellij.execution.junit2.ui.model.JUnitRunningModel; +import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; +import com.intellij.execution.testframework.AbstractTestProxy; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Disposer; +import com.intellij.rt.execution.junit.segments.PacketProcessor; +import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; +import com.intellij.rt.execution.junit.states.PoolOfTestStates; +import com.intellij.util.containers.HashMap; + +import java.util.List; +import java.util.Map; + +public class TestsPacketsReceiver implements PacketProcessor, Disposable { + + public static final Map STATE_CLASSES = new HashMap(); + + static { + mapClass(PoolOfTestStates.RUNNING_INDEX, new RunningStateSetter()); + mapClass(PoolOfTestStates.COMPLETE_INDEX, new TestCompleter()); + mapClass(PoolOfTestStates.FAILED_INDEX, new StateReader(FaultyState.class)); + mapClass(PoolOfTestStates.ERROR_INDEX, new StateReader(FaultyState.class)); + mapClass(PoolOfTestStates.IGNORED_INDEX, new StateReader(IgnoredState.class)); + mapClass(PoolOfTestStates.SKIPPED_INDEX, new StateReader(SkippedState.class)); + mapClass(PoolOfTestStates.COMPARISON_FAILURE, new StateReader(ComparisonFailureState.class)); + } + + public static void mapClass(final int magnitude, final StateChanger factory) { + factory.setMagnitude(magnitude); + STATE_CLASSES.put(new Integer(magnitude), factory); + } + + private final InputObjectRegistry myObjectRegistry; + + private TestProxy myCurrentTest; + private boolean myIsTerminated = false; + private JUnitRunningModel myModel; + private final JUnitConsoleProperties myConsoleProperties; + + + public TestsPacketsReceiver(final JUnitTreeConsoleView consoleView) { + myObjectRegistry = new InputObjectRegistry(); + myConsoleProperties = (JUnitConsoleProperties)consoleView.getProperties(); + Disposer.register(consoleView, this); + } + + public TestProxy getCurrentTest() { + return myCurrentTest; + } + + public void processPacket(final String packet) { + ApplicationManager.getApplication().assertIsDispatchThread(); + + if (packet.startsWith(PoolOfDelimiters.TREE_PREFIX)) { + notifyStart(readNode(new ObjectReader(packet, PoolOfDelimiters.TREE_PREFIX.length(), myObjectRegistry))); + } + + else if (packet.startsWith(PoolOfDelimiters.INPUT_COSUMER)) { + notifyTestStart(new ObjectReader(packet, PoolOfDelimiters.INPUT_COSUMER.length(), myObjectRegistry)); + } + + else if (packet.startsWith(PoolOfDelimiters.CHANGE_STATE)) { + notifyTestResult(new ObjectReader(packet, PoolOfDelimiters.CHANGE_STATE.length(), myObjectRegistry)); + } + + else if (packet.startsWith(PoolOfDelimiters.TESTS_DONE)) { + notifyFinish(new ObjectReader(packet, PoolOfDelimiters.TESTS_DONE.length(), myObjectRegistry)); + } + + else if (packet.startsWith(PoolOfDelimiters.OBJECT_PREFIX)) { + myObjectRegistry.readPacketFrom(new ObjectReader(packet, PoolOfDelimiters.OBJECT_PREFIX.length(), myObjectRegistry)); + } + } + + + public void notifyStart(TestProxy root) { + myModel = new JUnitRunningModel(root, myConsoleProperties); + Disposer.register(this, myModel); + } + + private static TestProxy readNode(final ObjectReader reader) { + final TestProxy node = reader.readObject(); + final int childCount = reader.readInt(); + for (int i = 0; i < childCount; i++) { + node.addChild(readNode(reader)); + } + return node; + } + + public void notifyTestStart(ObjectReader reader) { + myCurrentTest = reader.readObject(); + } + + public static void notifyTestResult(ObjectReader reader) { + final TestProxy testProxy = reader.readObject(); + final int state = reader.readInt(); + final StateChanger stateChanger = STATE_CLASSES.get(new Integer(state)); + stateChanger.changeStateOf(testProxy, reader); + } + + public void notifyFinish(ObjectReader reader) { + myIsTerminated = true; + myModel.getNotifier().fireRunnerStateChanged(new CompletionEvent(true, reader.readInt())); + terminateStillRunning(); + } + + public boolean isRunning() { + return !myIsTerminated; + } + + public void setTerminated(boolean terminated) { + myIsTerminated = terminated; + } + + public JUnitRunningModel getModel() { + return myModel; + } + + public void dispose() { + } + + public void checkTerminated() { + if (isRunning()) { + final JUnitRunningModel model = getModel(); + if (model != null) { + final JUnitListenersNotifier notifier = model.getNotifier(); + if (notifier != null) { + notifier.fireRunnerStateChanged(new CompletionEvent(false, -1)); + terminateStillRunning(); + } + } + setTerminated(true); + } + } + + private void terminateStillRunning() { + if (myModel.getRoot() != null) { + final List runningTests = TestStateUpdater.RUNNING_LEAF.select(myModel.getRoot().getAllTests()); + for (final AbstractTestProxy runningTest : runningTests) { + final TestProxy testProxy = (TestProxy)runningTest; + final TestState terminated = NotFailedState.createTerminated(); + testProxy.setState(terminated); + TestProxy parent = testProxy.getParent(); + while (parent != null) { + parent.setState(terminated); + parent = parent.getParent(); + } + + } + } + } + + private static abstract class StateChanger { + static final Logger LOG = Logger.getInstance("#" + StateChanger.class.getName()); + + abstract void changeStateOf(TestProxy testProxy, ObjectReader reader); + + void setMagnitude(final int magnitude) { + } + + static void complete(TestProxy testProxy) { + final int magnitude = testProxy.getState().getMagnitude(); + + TestProxy parent = testProxy.getParent(); + TestProxy child = testProxy; + while (parent != null) { + final List children = parent.getChildren(); + final TestState parentState = parent.getState(); + LOG.assertTrue(parentState instanceof SuiteState); + if (child.equals(children.get(children.size() - 1))) { + ((SuiteState)parentState).setRunning(false); + } + ((SuiteState)parentState).updateMagnitude(magnitude); + child = parent; + parent = parent.getParent(); + } + } + } + + private static class RunningStateSetter extends StateChanger { + public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { + testProxy.setState(TestState.RUNNING_STATE); + TestProxy parent = testProxy.getParent(); + while (parent != null) { + final TestState state = parent.getState(); + LOG.assertTrue(state instanceof SuiteState); + ((SuiteState)state).setRunning(true); + parent = parent.getParent(); + } + } + } + + private static class StateReader extends StateChanger { + private final Class myStateClass; + private int myInstanceMagnitude; + + public StateReader(final Class stateClass) { + myStateClass = stateClass; + } + + public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { + final ReadableState state; + try { + state = myStateClass.newInstance(); + } + catch (Exception e) { + LOG.error(e); + return; + } + state.setMagitude(myInstanceMagnitude); + state.initializeFrom(reader); + testProxy.setState(state); + complete(testProxy); + } + + public void setMagnitude(final int magnitude) { + myInstanceMagnitude = magnitude; + } + } + + private static class TestCompleter extends StateChanger { + public void changeStateOf(final TestProxy testProxy, final ObjectReader reader) { + TestState state = testProxy.getState(); + if (!testProxy.getState().isFinal()) { + state = NotFailedState.createPassed(); + } + testProxy.setState(state); + testProxy.setStatistics(new Statistics(reader)); + complete(testProxy); + } + } + +} diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java index d05116341587..86b3826b3bdd 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java @@ -16,8 +16,8 @@ package com.intellij.execution.junit2.ui.actions; -import com.intellij.execution.junit2.StateChangedEvent; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.StateChangedEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.ui.model.JUnitAdapter; import com.intellij.execution.junit2.ui.model.JUnitRunningModel; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitAdapter.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitAdapter.java index e7fe2219d21c..6b5976b63f11 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitAdapter.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitAdapter.java @@ -16,7 +16,7 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import java.util.List; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListener.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListener.java index e3a51423847e..af4d7edd8d86 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListener.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListener.java @@ -16,7 +16,7 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import java.util.List; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListenersNotifier.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListenersNotifier.java index 74c15e09ffda..28c8df1b3007 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListenersNotifier.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitListenersNotifier.java @@ -16,8 +16,8 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.TestEvent; -import com.intellij.execution.junit2.TestEventsConsumer; +import com.intellij.execution.junit2.events.TestEvent; +import com.intellij.execution.junit2.events.TestEventsConsumer; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.segments.DispatchListener; import com.intellij.openapi.application.ApplicationManager; @@ -30,7 +30,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer, DispatchListener, Runnable { +public class JUnitListenersNotifier implements TestEventsConsumer, DispatchListener, Runnable { private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.ui.model.JUnitListenersNotifier"); private final ArrayList myListeners = new ArrayList(); @@ -53,7 +53,7 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer this(!ApplicationManager.getApplication().isUnitTestMode()); } - public void onTestSelected(final TestProxy test) { + public void fireTestSelected(final TestProxy test) { // MEASURER.start(ON_TEST_SELECTED); final JUnitListener[] listeners = getListeners(); for (final JUnitListener listener : listeners) { @@ -62,17 +62,13 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer // MEASURER.stop(ON_TEST_SELECTED); } - public void onDispose(final JUnitRunningModel model) { + public void fireDisposed(final JUnitRunningModel model) { final JUnitListener[] listeners = getListeners(); for (final JUnitListener listener : listeners) { listener.onDispose(model); } } - public void onTestChanged(final TestEvent event) { - LOG.assertTrue(false); - } - private void dispatchTestEvent(final TestEvent event) { final JUnitListener[] listeners = getListeners(); for (final JUnitListener listener : listeners) { @@ -80,7 +76,7 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer } } - public void onRunnerStateChanged(final StateEvent event) { + public void fireRunnerStateChanged(final StateEvent event) { // if (!event.isRunning()) MEASURER.printAll(); final JUnitListener[] listeners = getListeners(); for (final JUnitListener listener : listeners) { @@ -92,7 +88,7 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer } } - public void onEventsDispatched(final List events) { + public void fireEventsDispatched(final List events) { // MEASURER.start(PACKET_DISPATCH); final JUnitListener[] listeners = getListeners(); for (final JUnitListener listener : listeners) { @@ -105,6 +101,14 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer return myListeners.toArray(new JUnitListener[myListeners.size()]); } + public void addListener(@NotNull JUnitListener listener) { + myListeners.add(listener); + } + + public void removeListener(final JUnitListener listener) { + myListeners.remove(listener); + } + public void onEvent(final TestEvent event) { // MEASURER.start(ON_EVENT); if (myEventsQueue.isEmpty() && myDeferEvents) { @@ -115,14 +119,6 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer // MEASURER.stop(ON_EVENT); } - public void addListener(@NotNull JUnitListener listener) { - myListeners.add(listener); - } - - public void removeListener(final JUnitListener listener) { - myListeners.remove(listener); - } - public void onStarted() { myCollectingEvents.assertValue(false); myCollectingEvents.setValue(true); @@ -149,7 +145,7 @@ public class JUnitListenersNotifier implements JUnitListener, TestEventsConsumer dispatchTestEvent(event); } // MEASURER.stop(DISPATCH_SINGLES); - onEventsDispatched(filteredEvents); + fireEventsDispatched(filteredEvents); //System.out.println("duration = " + (System.currentTimeMillis() - start)); } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitRunningModel.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitRunningModel.java index aa34b5f042bb..4e1a44dc215e 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitRunningModel.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/JUnitRunningModel.java @@ -17,12 +17,9 @@ package com.intellij.execution.junit2.ui.model; import com.intellij.execution.junit.JUnitConfiguration; -import com.intellij.execution.junit2.TestProgress; import com.intellij.execution.junit2.TestProxy; -import com.intellij.execution.junit2.TestingStatus; -import com.intellij.execution.junit2.segments.DispatchListener; -import com.intellij.execution.junit2.segments.PacketExtractorBase; import com.intellij.execution.junit2.ui.Animator; +import com.intellij.execution.junit2.ui.TestProgress; import com.intellij.execution.junit2.ui.TestProxyClient; import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; import com.intellij.execution.testframework.AbstractTestProxy; @@ -47,7 +44,6 @@ import java.awt.event.FocusEvent; public class JUnitRunningModel implements TestFrameworkRunningModel { private final TestProgress myProgress; private final TestProxy myRoot; - private final TestingStatus myStatus; private final JUnitConsoleProperties myProperties; private final MyTreeSelectionListener myTreeListener = new MyTreeSelectionListener(); private JTree myTreeView; @@ -55,22 +51,16 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { private final JUnitListenersNotifier myNotifier = new JUnitListenersNotifier(); private final Animator myAnimator; - private PacketExtractorBase myPacketExtractor; - public JUnitRunningModel(final TestProxy root, final TestingStatus status, final JUnitConsoleProperties properties) { + public JUnitRunningModel(final TestProxy root, final JUnitConsoleProperties properties) { myRoot = root; - myStatus = status; myProperties = properties; - myRoot.setEventsConsumer(myNotifier); - myProgress = new TestProgress(this); - myStatus.setListener(myNotifier); - Disposer.register(this, myTreeListener); Disposer.register(this, new Disposable() { public void dispose() { - myNotifier.onDispose(JUnitRunningModel.this); + myNotifier.fireDisposed(JUnitRunningModel.this); } }); myAnimator = new Animator(this); @@ -80,8 +70,6 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { return myTreeBuilder; } - public TestingStatus getStatus() { return myStatus; } - public void attachToTree(final TestTreeView treeView) { myTreeBuilder = new TestTreeBuilder(treeView, this, myProperties); Disposer.register(this, myTreeBuilder); @@ -112,7 +100,7 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { public void selectAndNotify(final AbstractTestProxy testProxy) { selectTest((TestProxy)testProxy); - myNotifier.onTestSelected((TestProxy)testProxy); + myNotifier.fireTestSelected((TestProxy)testProxy); } public Project getProject() { @@ -136,7 +124,7 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { myTreeView.collapsePath(path); } - public DispatchListener getNotifier() { + public JUnitListenersNotifier getNotifier() { return myNotifier; } @@ -147,7 +135,7 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { } public boolean isRunning() { - return getStatus().isRunning(); + return myRoot.isInProgress(); } private TestTreeStructure getStructure() { @@ -163,7 +151,7 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { } public void onUIBuilt() { - myNotifier.onTestSelected(myRoot); + myNotifier.fireTestSelected(myRoot); } private TreePath pathToTest(final TestProxy test, final boolean expandIfCollapsed) { @@ -181,16 +169,6 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { return getStructure().getFilter().shouldAccept(test); } - public void attachTo(final PacketExtractorBase packetExtractor) { - myPacketExtractor = packetExtractor; - myPacketExtractor.setDispatchListener(myNotifier); - Disposer.register(this, new Disposable() { - public void dispose() { - myPacketExtractor.setDispatchListener(DispatchListener.DEAF); - } - }); - } - public JUnitConfiguration getConfiguration() { return myProperties.getConfiguration(); } @@ -200,14 +178,14 @@ public class JUnitRunningModel implements TestFrameworkRunningModel { public void valueChanged(final TreeSelectionEvent e) { final TestProxy test = TestProxyClient.from(e.getPath()); if (myTreeView.isFocusOwner()) - myNotifier.onTestSelected(test); + myNotifier.fireTestSelected(test); } public void focusGained(final FocusEvent e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (!myTreeBuilder.isDisposed()) { - myNotifier.onTestSelected((TestProxy)getTreeView().getSelectedTest()); + myNotifier.fireTestSelected((TestProxy)getTreeView().getSelectedTest()); } } }); diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/SpecialNode.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/SpecialNode.java index e712c74f31ee..a5e62e2d1cc6 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/SpecialNode.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/SpecialNode.java @@ -18,7 +18,8 @@ package com.intellij.execution.junit2.ui.model; import com.intellij.execution.Location; import com.intellij.execution.ExecutionBundle; -import com.intellij.execution.junit2.TestProgress; +import com.intellij.execution.junit2.segments.ObjectReader; +import com.intellij.execution.junit2.ui.TestProgress; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.info.TestInfo; import com.intellij.execution.junit2.states.NotFailedState; @@ -58,7 +59,7 @@ public class SpecialNode extends TestProxy { updateName(); } - private static class MyTestInfo implements TestInfo { + private static class MyTestInfo extends TestInfo { private String myName = TESTS_IN_PROGRESS; public String getComment() { @@ -77,6 +78,10 @@ public class SpecialNode extends TestProxy { return 0; } + @Override + public void readFrom(ObjectReader reader) { + } + public Location getLocation(final Project project) { return null; } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/TestTreeBuilder.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/TestTreeBuilder.java index 5720d28aa63e..f26d6aa0a1cf 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/TestTreeBuilder.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/TestTreeBuilder.java @@ -16,7 +16,7 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties; import com.intellij.execution.testframework.AbstractTestProxy; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/TreeCollapser.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/TreeCollapser.java index 5b3984d85bac..6e0bb26d34bd 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/TreeCollapser.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/TreeCollapser.java @@ -16,8 +16,8 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.NewChildEvent; -import com.intellij.execution.junit2.TestEvent; +import com.intellij.execution.junit2.events.NewChildEvent; +import com.intellij.execution.junit2.events.TestEvent; import com.intellij.execution.junit2.TestProxy; public class TreeCollapser extends JUnitAdapter { diff --git a/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java b/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java index bf4c36531bb9..acd48cc9fa97 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java +++ b/plugins/junit_rt/src/com/intellij/junit3/JUnit3OutputObjectRegistry.java @@ -20,14 +20,14 @@ */ package com.intellij.junit3; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PacketProcessor; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -public class JUnit3OutputObjectRegistry extends OutputObjectRegistryEx { +public class JUnit3OutputObjectRegistry extends OutputObjectRegistry { public JUnit3OutputObjectRegistry(PacketProcessor mainTransport, PacketProcessor auxilaryTransport) { super(mainTransport, auxilaryTransport); } @@ -64,4 +64,4 @@ public class JUnit3OutputObjectRegistry extends OutputObjectRegistryEx { addUnknownTest(packet, test); } } -} \ No newline at end of file +} diff --git a/plugins/junit_rt/src/com/intellij/junit3/TestResultsSender.java b/plugins/junit_rt/src/com/intellij/junit3/TestResultsSender.java index 54eb7ba2d7ac..3eed7b4689a8 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/TestResultsSender.java +++ b/plugins/junit_rt/src/com/intellij/junit3/TestResultsSender.java @@ -16,7 +16,7 @@ package com.intellij.junit3; import com.intellij.rt.execution.junit.*; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PacketProcessor; import com.intellij.rt.execution.junit.states.PoolOfTestStates; @@ -26,12 +26,12 @@ import junit.framework.Test; import junit.framework.TestListener; public class TestResultsSender implements TestListener { - private final OutputObjectRegistryEx myRegistry; + private final OutputObjectRegistry myRegistry; private final PacketProcessor myErr; private TestMeter myCurrentTestMeter; private Test myCurrentTest; - public TestResultsSender(OutputObjectRegistryEx packetFactory, PacketProcessor segmentedErr) { + public TestResultsSender(OutputObjectRegistry packetFactory, PacketProcessor segmentedErr) { myRegistry = packetFactory; myErr = segmentedErr; } diff --git a/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java b/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java index 4e4efb5c7d0e..5fb3b0ad51fa 100644 --- a/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java +++ b/plugins/junit_rt/src/com/intellij/junit3/TreeSender.java @@ -15,7 +15,7 @@ */ package com.intellij.junit3; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; import com.intellij.rt.execution.junit.segments.Packet; import junit.framework.Test; @@ -48,7 +48,7 @@ public class TreeSender { return testCases; } - public static void sendSuite(OutputObjectRegistryEx registry, Test suite) { + public static void sendSuite(OutputObjectRegistry registry, Test suite) { Packet packet = registry.createPacket(); packet.addString(PoolOfDelimiters.TREE_PREFIX); sendNode(suite, packet); diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java index 7964e35e7d46..3e4a51f0938c 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java @@ -18,7 +18,7 @@ package com.intellij.junit4; import com.intellij.rt.execution.junit.DeafStream; import com.intellij.rt.execution.junit.IDEAJUnitListener; import com.intellij.rt.execution.junit.IdeaTestRunner; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PoolOfDelimiters; import com.intellij.rt.execution.junit.segments.SegmentedOutputStream; @@ -36,7 +36,7 @@ import java.util.Iterator; /** @noinspection UnusedDeclaration*/ public class JUnit4IdeaTestRunner implements IdeaTestRunner { private RunListener myTestsListener; - private OutputObjectRegistryEx myRegistry; + private OutputObjectRegistry myRegistry; private static void sendNode(Description test, Packet packet) { final ArrayList children = test.getChildren(); @@ -46,7 +46,7 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner { } } - public static void sendTree(OutputObjectRegistryEx registry, Description suite) { + public static void sendTree(OutputObjectRegistry registry, Description suite) { Packet packet = registry.createPacket(); packet.addString(PoolOfDelimiters.TREE_PREFIX); sendNode(suite, packet); diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java index 9d244c0a7f5a..8fa3b0acc751 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java @@ -20,13 +20,13 @@ */ package com.intellij.junit4; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PacketProcessor; import org.junit.runner.Description; -public class JUnit4OutputObjectRegistry extends OutputObjectRegistryEx { +public class JUnit4OutputObjectRegistry extends OutputObjectRegistry { public JUnit4OutputObjectRegistry(PacketProcessor mainTransport, PacketProcessor auxilaryTransport) { super(mainTransport, auxilaryTransport); } @@ -53,4 +53,4 @@ public class JUnit4OutputObjectRegistry extends OutputObjectRegistryEx { } } -} \ No newline at end of file +} diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java index 2684a98a3081..9a8142dc152a 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestResultsSender.java @@ -16,7 +16,7 @@ package com.intellij.junit4; import com.intellij.rt.execution.junit.*; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PacketProcessor; import com.intellij.rt.execution.junit.states.PoolOfTestStates; @@ -27,12 +27,12 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; public class JUnit4TestResultsSender extends RunListener { - private final OutputObjectRegistryEx myRegistry; + private final OutputObjectRegistry myRegistry; private final PacketProcessor myErr; private TestMeter myCurrentTestMeter; private Description myCurrentTest; - public JUnit4TestResultsSender(OutputObjectRegistryEx packetFactory, PacketProcessor segmentedErr) { + public JUnit4TestResultsSender(OutputObjectRegistry packetFactory, PacketProcessor segmentedErr) { myRegistry = packetFactory; myErr = segmentedErr; } diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/ComparisonDetailsExtractor.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/ComparisonDetailsExtractor.java index 2d2c621853e0..5a0370a4e241 100644 --- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/ComparisonDetailsExtractor.java +++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/ComparisonDetailsExtractor.java @@ -15,7 +15,7 @@ */ package com.intellij.rt.execution.junit; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.states.PoolOfTestStates; import junit.framework.ComparisonFailure; @@ -75,7 +75,7 @@ public class ComparisonDetailsExtractor extends ExceptionPacketFactory { } } - public Packet createPacket(OutputObjectRegistryEx registry, Object test) { + public Packet createPacket(OutputObjectRegistry registry, Object test) { Packet packet = super.createPacket(registry, test); packet. addLimitedString(myExpected). diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/FileComparisonFailure.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/FileComparisonFailure.java index 1ae3e7d91309..0a66a53106cb 100644 --- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/FileComparisonFailure.java +++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/FileComparisonFailure.java @@ -15,7 +15,7 @@ */ package com.intellij.rt.execution.junit; -import com.intellij.rt.execution.junit.segments.OutputObjectRegistryEx; +import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.Packet; import junit.framework.ComparisonFailure; @@ -43,7 +43,7 @@ public class FileComparisonFailure extends ComparisonFailure implements KnownExc myFilePath = filePath; } - public Packet createPacket(OutputObjectRegistryEx registry, Object test) { + public Packet createPacket(OutputObjectRegistry registry, Object test) { Packet packet = super.createPacket(registry, test); packet.addLimitedString(myFilePath); return packet;