mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
remove old test protocols
This commit is contained in:
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.PacketWriter;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
import org.apache.tools.ant.BuildEvent;
|
||||
import org.apache.tools.ant.DefaultLogger;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.PacketWriter;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.input.InputHandler;
|
||||
import org.apache.tools.ant.input.InputRequest;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.ant.execution;
|
||||
|
||||
public class Packet extends PacketWriter {
|
||||
public static final char ourSpecialSymbol = '$';
|
||||
public static final char[] ourSymbolsToEncode = new char[] {'\n', '\r', SegmentedStream.SPECIAL_SYMBOL};
|
||||
public static final int CODE_LENGTH = 2;
|
||||
|
||||
public static String encode(String packet) {
|
||||
StringBuffer buffer = new StringBuffer(packet.length());
|
||||
for (int i = 0; i < packet.length(); i++) {
|
||||
char chr = packet.charAt(i);
|
||||
if (chr == ourSpecialSymbol) {
|
||||
buffer.append(chr);
|
||||
buffer.append(chr);
|
||||
continue;
|
||||
}
|
||||
boolean appendChar = true;
|
||||
for (int j = 0; j < ourSymbolsToEncode.length; j++) {
|
||||
if (ourSymbolsToEncode[j] == chr) {
|
||||
buffer.append(ourSpecialSymbol);
|
||||
final String code = String.valueOf((int)chr);
|
||||
for (int count = CODE_LENGTH - code.length(); count > 0; count--) {
|
||||
buffer.append("0");
|
||||
}
|
||||
buffer.append(code);
|
||||
appendChar = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (appendChar) {
|
||||
buffer.append(chr);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.PacketWriter;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.rt.execution.junit.segments;
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
public interface PacketProcessor {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.rt.execution.junit.segments;
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
public class PacketWriter {
|
||||
private final StringBuffer myBody = new StringBuffer();
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.rt.execution.junit.segments;
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
/**
|
||||
* @noinspection HardCodedStringLiteral
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.rt.execution.junit.segments;
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.rt.execution.junit.segments;
|
||||
package com.intellij.rt.ant.execution;
|
||||
|
||||
/**
|
||||
* @noinspection HardCodedStringLiteral
|
||||
+8
-33
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package com.intellij.rt.execution.junit;
|
||||
|
||||
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;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -27,17 +24,19 @@ import java.util.Map;
|
||||
/**
|
||||
* @noinspection HardCodedStringLiteral
|
||||
*/
|
||||
public class ComparisonDetailsExtractor extends ExceptionPacketFactory {
|
||||
public class ComparisonDetailsExtractor {
|
||||
private static Map EXPECTED = new HashMap();
|
||||
private static Map ACTUAL = new HashMap();
|
||||
protected String myActual = "";
|
||||
protected String myExpected = "";
|
||||
|
||||
private final Throwable myAssertion;
|
||||
static {
|
||||
try {
|
||||
init(ComparisonFailure.class);
|
||||
init(org.junit.ComparisonFailure.class);
|
||||
} catch (Throwable e) {}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void init(Class exceptionClass) throws NoSuchFieldException {
|
||||
@@ -51,20 +50,11 @@ public class ComparisonDetailsExtractor extends ExceptionPacketFactory {
|
||||
}
|
||||
|
||||
public ComparisonDetailsExtractor(Throwable assertion, String expected, String actual) {
|
||||
super(PoolOfTestStates.COMPARISON_FAILURE, assertion);
|
||||
myAssertion = assertion;
|
||||
myActual = actual;
|
||||
myExpected = expected;
|
||||
}
|
||||
|
||||
public static ExceptionPacketFactory create(Throwable assertion) {
|
||||
try {
|
||||
return create(assertion, getExpected(assertion), getActual(assertion));
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return new ExceptionPacketFactory(PoolOfTestStates.FAILED_INDEX, assertion);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getActual(Throwable assertion) throws IllegalAccessException, NoSuchFieldException {
|
||||
return get(assertion, ACTUAL, "fActual");
|
||||
}
|
||||
@@ -73,7 +63,8 @@ public class ComparisonDetailsExtractor extends ExceptionPacketFactory {
|
||||
return get(assertion, EXPECTED, "fExpected");
|
||||
}
|
||||
|
||||
private static String get(final Throwable assertion, final Map staticMap, final String fieldName) throws IllegalAccessException, NoSuchFieldException {
|
||||
private static String get(final Throwable assertion, final Map staticMap, final String fieldName)
|
||||
throws IllegalAccessException, NoSuchFieldException {
|
||||
String actual;
|
||||
if (assertion instanceof ComparisonFailure) {
|
||||
actual = (String)((Field)staticMap.get(ComparisonFailure.class)).get(assertion);
|
||||
@@ -88,20 +79,4 @@ public class ComparisonDetailsExtractor extends ExceptionPacketFactory {
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
public static ExceptionPacketFactory create(Throwable assertion, final String expected, String actual) {
|
||||
return new ComparisonDetailsExtractor(assertion, expected, actual);
|
||||
}
|
||||
|
||||
public Packet createPacket(OutputObjectRegistry registry, Object test) {
|
||||
Packet packet = super.createPacket(registry, test);
|
||||
packet.
|
||||
addLimitedString(wrap(myExpected)).
|
||||
addLimitedString(wrap(myActual));
|
||||
return packet;
|
||||
}
|
||||
|
||||
private static String wrap(final String message) {
|
||||
return message != null ? message : "null";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +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;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.Packet;
|
||||
|
||||
public class ExceptionPacketFactory implements PacketFactory {
|
||||
private final Throwable myAssertion;
|
||||
private int myState;
|
||||
|
||||
public ExceptionPacketFactory(int state, Throwable assertion) {
|
||||
myState = state;
|
||||
myAssertion = assertion;
|
||||
}
|
||||
|
||||
public Packet createPacket(OutputObjectRegistry registry, Object test) {
|
||||
return registry.createPacket().
|
||||
setTestState(test, myState).
|
||||
addThrowable(myAssertion);
|
||||
}
|
||||
|
||||
protected void setState(int state) { myState = state; }
|
||||
}
|
||||
@@ -15,11 +15,9 @@
|
||||
*/
|
||||
package com.intellij.rt.execution.junit;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.Packet;
|
||||
import junit.framework.ComparisonFailure;
|
||||
|
||||
public class FileComparisonFailure extends ComparisonFailure implements KnownException {
|
||||
public class FileComparisonFailure extends ComparisonFailure {
|
||||
private final String myExpected;
|
||||
private final String myActual;
|
||||
private final String myFilePath;
|
||||
@@ -54,23 +52,4 @@ public class FileComparisonFailure extends ComparisonFailure implements KnownExc
|
||||
public String getActual() {
|
||||
return myActual;
|
||||
}
|
||||
|
||||
public PacketFactory getPacketFactory() {
|
||||
return new MyPacketFactory(this, myExpected, myActual, myFilePath);
|
||||
}
|
||||
|
||||
private static class MyPacketFactory extends ComparisonDetailsExtractor {
|
||||
private final String myFilePath;
|
||||
|
||||
MyPacketFactory(ComparisonFailure assertion, String expected, String actual, String filePath) {
|
||||
super(assertion, expected, actual);
|
||||
myFilePath = filePath;
|
||||
}
|
||||
|
||||
public Packet createPacket(OutputObjectRegistry registry, Object test) {
|
||||
Packet packet = super.createPacket(registry, test);
|
||||
packet.addLimitedString(myFilePath);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
public interface KnownException {
|
||||
PacketFactory getPacketFactory();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.Packet;
|
||||
|
||||
public interface PacketFactory {
|
||||
Packet createPacket(OutputObjectRegistry registry, Object test);
|
||||
}
|
||||
-123
@@ -1,123 +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.Collection;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public abstract class OutputObjectRegistry {
|
||||
private final Hashtable myKnownKeys = new Hashtable();
|
||||
private int myLastIndex = 0;
|
||||
private PacketProcessor myMainTransport;
|
||||
|
||||
protected OutputObjectRegistry(PacketProcessor mainTransport, int lastIndex) {
|
||||
myLastIndex = lastIndex;
|
||||
myMainTransport = mainTransport;
|
||||
}
|
||||
|
||||
public String referenceTo(Object test) {
|
||||
if (containsKey(test)) return getKey(test);
|
||||
return sendObject(test);
|
||||
}
|
||||
|
||||
public String referenceTo(Object test, Collection packets) {
|
||||
if (containsKey(test)) return getKey(test);
|
||||
return sendObject(test, packets);
|
||||
}
|
||||
|
||||
private boolean containsKey(Object test) {
|
||||
return myKnownKeys.containsKey(createObjectWrapper(test));
|
||||
}
|
||||
|
||||
private String getKey(Object test) {
|
||||
return (String)myKnownKeys.get(createObjectWrapper(test));
|
||||
}
|
||||
|
||||
private void putKey(Object test, String key) {
|
||||
myKnownKeys.put(createObjectWrapper(test), key);
|
||||
}
|
||||
|
||||
public void forget(Object test) {
|
||||
myKnownKeys.remove(createObjectWrapper(test));
|
||||
}
|
||||
|
||||
private String sendObject(Object test, Collection packets) {
|
||||
final String key = String.valueOf(myLastIndex++);
|
||||
putKey(test, key);
|
||||
final Packet packet = createPacket();
|
||||
packet.addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key);
|
||||
addStringRepresentation(test, packet);
|
||||
packet.addLong(getTestCont(test));
|
||||
packet.addString(PoolOfDelimiters.REFERENCE_END_STR);
|
||||
packets.add(packet);
|
||||
return key;
|
||||
}
|
||||
|
||||
public Packet createPacket() {
|
||||
return new Packet(myMainTransport, this);
|
||||
}
|
||||
|
||||
private String sendObject(Object test) {
|
||||
final String key = String.valueOf(myLastIndex++);
|
||||
putKey(test, key);
|
||||
Packet packet = createPacket().addString(PoolOfDelimiters.OBJECT_PREFIX).addReference(key);
|
||||
addStringRepresentation(test, packet);
|
||||
packet.addLong(getTestCont(test));
|
||||
packet.send();
|
||||
return key;
|
||||
}
|
||||
|
||||
protected abstract int getTestCont(Object test);
|
||||
protected abstract void addStringRepresentation(Object test, Packet packet);
|
||||
|
||||
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 int getKnownObject(Object description) {
|
||||
final Object o = getKey(description);
|
||||
if (o instanceof String) {
|
||||
return Integer.parseInt((String)o);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected Object createObjectWrapper(Object object) {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +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 junit.runner.BaseTestRunner;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
public class Packet extends PacketWriter {
|
||||
private final OutputObjectRegistry myRegistry;
|
||||
private final PacketProcessor myTransport;
|
||||
public static final char ourSpecialSymbol = '$';
|
||||
public static final char[] ourSymbolsToEncode = new char[] {'\n', '\r', SegmentedStream.SPECIAL_SYMBOL};
|
||||
public static final int CODE_LENGTH = 2;
|
||||
|
||||
public Packet(PacketProcessor transport, OutputObjectRegistry registry) {
|
||||
myTransport = transport;
|
||||
myRegistry = registry;
|
||||
}
|
||||
|
||||
public Packet addObject(Object test) {
|
||||
return addReference(myRegistry.referenceTo(test));
|
||||
}
|
||||
|
||||
public Packet addObject(Object test, Collection packet) {
|
||||
return addReference(myRegistry.referenceTo(test, packet));
|
||||
}
|
||||
|
||||
public Packet addReference(String reference) {
|
||||
appendString(reference + PoolOfDelimiters.REFERENCE_END);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Packet switchInputTo(Object test) {
|
||||
appendString(PoolOfDelimiters.INPUT_COSUMER);
|
||||
return addObject(test);
|
||||
}
|
||||
|
||||
public Packet addString(String string) {
|
||||
appendString(string);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void send() {
|
||||
sendThrough(myTransport);
|
||||
}
|
||||
|
||||
public Packet addLong(long integer) {
|
||||
appendLong(integer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Packet setTestState(Object test, int state) {
|
||||
return addString(PoolOfDelimiters.CHANGE_STATE).addObject(test).addLong(state);
|
||||
}
|
||||
|
||||
public Packet addLimitedString(String message) {
|
||||
appendLimitedString(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Packet addThrowable(Throwable throwable) {
|
||||
String filteredTrace;
|
||||
try {
|
||||
filteredTrace = BaseTestRunner.getFilteredTrace(throwable);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
filteredTrace = BaseTestRunner.getFilteredTrace(e);
|
||||
}
|
||||
|
||||
String message;
|
||||
try {
|
||||
message = BaseTestRunner.getPreference("filterstack").equals("true") ? makeNewLinesCompatibleWithJUnit(throwableToString(throwable)) : throwableToString(throwable);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
message = throwableToString(e);
|
||||
}
|
||||
|
||||
addLimitedString(message);
|
||||
if (filteredTrace.startsWith(message))
|
||||
filteredTrace = filteredTrace.substring(message.length());
|
||||
addLimitedString(new TraceFilter(filteredTrace).execute());
|
||||
return this;
|
||||
}
|
||||
|
||||
private static String throwableToString(final Throwable throwable) {
|
||||
final String tostring = throwable.toString();
|
||||
return tostring == null ? throwable.getClass().getName() : tostring;
|
||||
}
|
||||
|
||||
private static String makeNewLinesCompatibleWithJUnit(String string) {
|
||||
try {
|
||||
StringWriter buffer = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(buffer);
|
||||
BufferedReader reader = new BufferedReader(new StringReader(string));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
writer.println(line);
|
||||
return buffer.getBuffer().toString();
|
||||
} catch (IOException e) {return null;}
|
||||
}
|
||||
|
||||
public static String encode(String packet) {
|
||||
StringBuffer buffer = new StringBuffer(packet.length());
|
||||
for (int i = 0; i < packet.length(); i++) {
|
||||
char chr = packet.charAt(i);
|
||||
if (chr == ourSpecialSymbol) {
|
||||
buffer.append(chr);
|
||||
buffer.append(chr);
|
||||
continue;
|
||||
}
|
||||
boolean appendChar = true;
|
||||
for (int j = 0; j < ourSymbolsToEncode.length; j++) {
|
||||
if (ourSymbolsToEncode[j] == chr) {
|
||||
buffer.append(ourSpecialSymbol);
|
||||
final String code = String.valueOf((int)chr);
|
||||
for (int count = CODE_LENGTH - code.length(); count > 0; count--) {
|
||||
buffer.append("0");
|
||||
}
|
||||
buffer.append(code);
|
||||
appendChar = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (appendChar) {
|
||||
buffer.append(chr);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public Packet addStrings(Vector vector) {
|
||||
int size = vector.size();
|
||||
addLong(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
addLimitedString((String)vector.elementAt(i));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +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 PoolOfTestTypes {
|
||||
String TEST_METHOD = "TM";
|
||||
String TEST_CLASS = "TC";
|
||||
String ALL_IN_PACKAGE = "TN";
|
||||
|
||||
String UNKNOWN = "TU";
|
||||
}
|
||||
@@ -1,67 +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.*;
|
||||
import java.util.Vector;
|
||||
|
||||
class TraceFilter {
|
||||
private final String myTrace;
|
||||
private final Vector myLines = new Vector();
|
||||
|
||||
public TraceFilter(String trace) {
|
||||
myTrace = trace;
|
||||
}
|
||||
|
||||
public String execute() {
|
||||
try {
|
||||
readLines();
|
||||
} catch (IOException e) {
|
||||
return myTrace;
|
||||
}
|
||||
int traceLastLine = firstJUnitLine(myLines.size() - 1, true);
|
||||
if (traceLastLine < 0) return "";
|
||||
int traceFirstLine = firstJUnitLine(traceLastLine, false);
|
||||
StringWriter buffer = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(buffer);
|
||||
for (int i = 0; i < traceFirstLine; i++) writer.println(myLines.elementAt(i));
|
||||
for (int i = traceLastLine; i < myLines.size(); i++) writer.println(myLines.elementAt(i));
|
||||
writer.flush();
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private int firstJUnitLine(int startFrom, boolean searchForJUnitLines) {
|
||||
for (int i = startFrom; i >= 0; i--) {
|
||||
String line = (String) myLines.elementAt(i);
|
||||
if (isIdeaJUnit(line) == searchForJUnitLines) return i;
|
||||
}
|
||||
return startFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection HardCodedStringLiteral
|
||||
*/
|
||||
private boolean isIdeaJUnit(String line) {
|
||||
return line.indexOf("com.intellij.rt") >= 0;
|
||||
}
|
||||
|
||||
private void readLines() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new StringReader(myTrace));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) { myLines.addElement(line); }
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +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.states;
|
||||
|
||||
public interface PoolOfTestStates {
|
||||
int SKIPPED_INDEX = 0;
|
||||
int COMPLETE_INDEX = 1;
|
||||
int NOT_RUN_INDEX = 2;
|
||||
int RUNNING_INDEX = 3;
|
||||
int TERMINATED_INDEX = 4;
|
||||
int IGNORED_INDEX = 5;
|
||||
int FAILED_INDEX = 6;
|
||||
int COMPARISON_FAILURE = 7;
|
||||
int ERROR_INDEX = 8;
|
||||
int PASSED_INDEX = COMPLETE_INDEX;
|
||||
}
|
||||
-5
@@ -60,10 +60,8 @@ public abstract class ForkedByModuleSplitter {
|
||||
bufferedReader.close();
|
||||
}
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
int result = startSplitting(args, configName, repeatCount);
|
||||
myForkedDebuggerHelper.closeDebugSocket();
|
||||
sendTime(time);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -154,9 +152,6 @@ public abstract class ForkedByModuleSplitter {
|
||||
String repeatCount, int result) throws Exception;
|
||||
|
||||
protected abstract String getStarterName();
|
||||
|
||||
protected void sendTime(long time) {}
|
||||
protected void sendTree(Object rootDescription) {}
|
||||
|
||||
public static File createClasspathJarFile(Manifest manifest, String classpath) throws IOException {
|
||||
final Attributes attributes = manifest.getMainAttributes();
|
||||
|
||||
@@ -39,7 +39,6 @@ public abstract class ForkedSplitter extends ForkedByModuleSplitter {
|
||||
if (myRootDescription == null) {
|
||||
return -1;
|
||||
}
|
||||
sendTree(myRootDescription);
|
||||
if (myWorkingDirsPath == null || new File(myWorkingDirsPath).length() == 0) {
|
||||
final String classpath = System.getProperty("java.class.path");
|
||||
if (repeatCount != null && RepeatCount.getCount(repeatCount) != 0 && myForkMode.equals("repeat")) {
|
||||
|
||||
Reference in New Issue
Block a user