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 bfb5f8bc6f28..ec194dc184a9 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,9 +15,6 @@ */ package com.intellij.rt.execution.junit.segments; -import org.junit.runner.Description; - -import java.util.ArrayList; import java.util.Collection; import java.util.Hashtable; @@ -42,19 +39,19 @@ public abstract class OutputObjectRegistry { } private boolean containsKey(Object test) { - return myKnownKeys.containsKey(new ObjectWrapper(test)); + return myKnownKeys.containsKey(createObjectWrapper(test)); } private String getKey(Object test) { - return (String)myKnownKeys.get(new ObjectWrapper(test)); + return (String)myKnownKeys.get(createObjectWrapper(test)); } private void putKey(Object test, String key) { - myKnownKeys.put(new ObjectWrapper(test), key); + myKnownKeys.put(createObjectWrapper(test), key); } public void forget(Object test) { - myKnownKeys.remove(new ObjectWrapper(test)); + myKnownKeys.remove(createObjectWrapper(test)); } private String sendObject(Object test, Collection packets) { @@ -120,40 +117,7 @@ public abstract class OutputObjectRegistry { return 0; } - private static class ObjectWrapper { - private Object myObject; - - private ObjectWrapper(Object object) { - myObject = object; - } - - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ObjectWrapper that = (ObjectWrapper)o; - if (!myObject.equals(that.myObject)) return false; - if (myObject instanceof Description && that.myObject instanceof Description) { - final ArrayList children = ((Description)myObject).getChildren(); - final ArrayList thatChildren = ((Description)that.myObject).getChildren(); - if (children.size() != thatChildren.size()) return false; - for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { - if (!children.get(i).equals(thatChildren.get(i))) return false; - } - } - - return true; - } - - public int hashCode() { - int hash = myObject.hashCode(); - if (myObject instanceof Description) { - final ArrayList children = ((Description)myObject).getChildren(); - for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { - hash = 31 * hash + children.get(i).hashCode(); - } - } - return hash; - } + protected Object createObjectWrapper(Object object) { + return object; } } diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java index 2d5366b44130..74f8ecaa9595 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4OutputObjectRegistry.java @@ -25,6 +25,8 @@ import com.intellij.rt.execution.junit.segments.Packet; import com.intellij.rt.execution.junit.segments.PacketProcessor; import org.junit.runner.Description; +import java.util.ArrayList; + public class JUnit4OutputObjectRegistry extends OutputObjectRegistry { @@ -60,4 +62,44 @@ public class JUnit4OutputObjectRegistry extends OutputObjectRegistry { } } + protected Object createObjectWrapper(Object object) { + return new ObjectWrapper(object); + } + + private static class ObjectWrapper { + private Object myObject; + + private ObjectWrapper(Object object) { + myObject = object; + } + + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ObjectWrapper that = (ObjectWrapper)o; + if (!myObject.equals(that.myObject)) return false; + if (myObject instanceof Description && that.myObject instanceof Description) { + final ArrayList children = ((Description)myObject).getChildren(); + final ArrayList thatChildren = ((Description)that.myObject).getChildren(); + if (children.size() != thatChildren.size()) return false; + for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { + if (!children.get(i).equals(thatChildren.get(i))) return false; + } + } + + return true; + } + + public int hashCode() { + int hash = myObject.hashCode(); + if (myObject instanceof Description) { + final ArrayList children = ((Description)myObject).getChildren(); + for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { + hash = 31 * hash + children.get(i).hashCode(); + } + } + return hash; + } + } }