mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
unify util classes
This commit is contained in:
@@ -20,9 +20,8 @@ import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.JITSensitive;
|
||||
import com.intellij.testFramework.PlatformTestUtilBase;
|
||||
import com.intellij.testFramework.TeamCityLogger;
|
||||
import com.intellij.testFramework.TestRunnerUtilBase;
|
||||
import com.intellij.testFramework.TestFrameworkUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
@@ -126,7 +125,7 @@ public class TestCaseLoader {
|
||||
void addClassIfTestCase(Class testCaseClass, String moduleName) {
|
||||
if (shouldAddTestCase(testCaseClass, moduleName, true) &&
|
||||
testCaseClass != myFirstTestClass && testCaseClass != myLastTestClass &&
|
||||
PlatformTestUtilBase.canRunTest(testCaseClass)) {
|
||||
TestFrameworkUtil.canRunTest(testCaseClass)) {
|
||||
myClassList.add(testCaseClass);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +157,7 @@ public class TestCaseLoader {
|
||||
}
|
||||
catch (NoSuchMethodException ignored) { }
|
||||
|
||||
return TestRunnerUtilBase.isJUnit4TestClass(testCaseClass);
|
||||
return TestFrameworkUtil.isJUnit4TestClass(testCaseClass);
|
||||
}
|
||||
|
||||
private boolean shouldExcludeTestClass(String moduleName, Class testCaseClass) {
|
||||
@@ -171,7 +170,7 @@ public class TestCaseLoader {
|
||||
public static boolean isBombed(final AnnotatedElement element) {
|
||||
final Bombed bombedAnnotation = element.getAnnotation(Bombed.class);
|
||||
if (bombedAnnotation == null) return false;
|
||||
return !PlatformTestUtilBase.bombExplodes(bombedAnnotation);
|
||||
return !TestFrameworkUtil.bombExplodes(bombedAnnotation);
|
||||
}
|
||||
|
||||
public void loadTestCases(final String moduleName, final Collection<String> classNamesIterator) {
|
||||
@@ -263,7 +262,7 @@ public class TestCaseLoader {
|
||||
}
|
||||
|
||||
static boolean isPerformanceTest(String methodName, Class aClass) {
|
||||
return TestRunnerUtilBase.isPerformanceTest(methodName, aClass.getSimpleName());
|
||||
return TestFrameworkUtil.isPerformanceTest(methodName, aClass.getSimpleName());
|
||||
}
|
||||
|
||||
public void fillTestCases(String rootPackage, List<File> classesRoots) {
|
||||
|
||||
+25
-1
@@ -1,14 +1,21 @@
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||
public class PlatformTestUtilBase {
|
||||
public class TestFrameworkUtil {
|
||||
public static final boolean SKIP_HEADLESS = GraphicsEnvironment.isHeadless();
|
||||
public static final boolean SKIP_SLOW = Boolean.getBoolean("skip.slow.tests.locally");
|
||||
|
||||
@@ -46,4 +53,21 @@ public class PlatformTestUtilBase {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static boolean isJUnit4TestClass(final Class aClass) {
|
||||
final int modifiers = aClass.getModifiers();
|
||||
if ((modifiers & Modifier.ABSTRACT) != 0) return false;
|
||||
if ((modifiers & Modifier.PUBLIC) == 0) return false;
|
||||
if (aClass.getAnnotation(RunWith.class) != null) return true;
|
||||
for (Method method : aClass.getMethods()) {
|
||||
if (method.getAnnotation(Test.class) != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPerformanceTest(@Nullable String testName, @Nullable String className) {
|
||||
return testName != null && StringUtil.containsIgnoreCase(testName, "performance") ||
|
||||
className != null && StringUtil.containsIgnoreCase(className, "performance");
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class TestRunnerUtilBase {
|
||||
@TestOnly
|
||||
public static boolean isJUnit4TestClass(final Class aClass) {
|
||||
final int modifiers = aClass.getModifiers();
|
||||
if ((modifiers & Modifier.ABSTRACT) != 0) return false;
|
||||
if ((modifiers & Modifier.PUBLIC) == 0) return false;
|
||||
if (aClass.getAnnotation(RunWith.class) != null) return true;
|
||||
for (Method method : aClass.getMethods()) {
|
||||
if (method.getAnnotation(Test.class) != null) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPerformanceTest(@Nullable String testName, @Nullable String className) {
|
||||
return testName != null && StringUtil.containsIgnoreCase(testName, "performance") ||
|
||||
className != null && StringUtil.containsIgnoreCase(className, "performance");
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class TestAll implements Test {
|
||||
public boolean shouldRun(Description description) {
|
||||
String className = description.getClassName();
|
||||
String methodName = description.getMethodName();
|
||||
return TestRunnerUtilBase.isPerformanceTest(methodName, className);
|
||||
return TestFrameworkUtil.isPerformanceTest(methodName, className);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -394,7 +394,7 @@ public class TestAll implements Test {
|
||||
return null;
|
||||
}
|
||||
Bombed classBomb = testCaseClass.getAnnotation(Bombed.class);
|
||||
if (classBomb != null && PlatformTestUtilBase.bombExplodes(classBomb)) {
|
||||
if (classBomb != null && TestFrameworkUtil.bombExplodes(classBomb)) {
|
||||
return new ExplodedBomb(testCaseClass.getName(), classBomb);
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ public class TestAll implements Test {
|
||||
return (Test)suiteMethod.invoke(null, ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
}
|
||||
|
||||
if (TestRunnerUtilBase.isJUnit4TestClass(testCaseClass)) {
|
||||
if (TestFrameworkUtil.isJUnit4TestClass(testCaseClass)) {
|
||||
boolean isPerformanceTest = isPerformanceTest(null, testCaseClass);
|
||||
boolean runEverything = isIncludingPerformanceTestsRun() || isPerformanceTest && isPerformanceTestsRun();
|
||||
if (runEverything) return new JUnit4TestAdapter(testCaseClass);
|
||||
@@ -450,7 +450,7 @@ public class TestAll implements Test {
|
||||
if (methodBomb == null) {
|
||||
doAddTest(test);
|
||||
}
|
||||
else if (PlatformTestUtilBase.bombExplodes(methodBomb)) {
|
||||
else if (TestFrameworkUtil.bombExplodes(methodBomb)) {
|
||||
doAddTest(new ExplodedBomb(method.getDeclaringClass().getName() + "." + method.getName(), methodBomb));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.Parameterized;
|
||||
import com.intellij.testFramework.TestRunnerUtilBase;
|
||||
import com.intellij.testFramework.TestFrameworkUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import junit.framework.TestCase;
|
||||
@@ -319,7 +319,7 @@ public class PathManagerEx {
|
||||
|
||||
@SuppressWarnings("TestOnlyProblems")
|
||||
private static boolean isJUnitClass(Class<?> clazz) {
|
||||
return TestCase.class.isAssignableFrom(clazz) || TestRunnerUtilBase.isJUnit4TestClass(clazz) || Parameterized.class.isAssignableFrom(clazz);
|
||||
return TestCase.class.isAssignableFrom(clazz) || TestFrameworkUtil.isJUnit4TestClass(clazz) || Parameterized.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -354,7 +354,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
}
|
||||
|
||||
protected boolean shouldRunTest() {
|
||||
return PlatformTestUtilBase.canRunTest(getClass());
|
||||
return TestFrameworkUtil.canRunTest(getClass());
|
||||
}
|
||||
|
||||
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
||||
@@ -850,7 +850,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
public boolean isPerformanceTest() {
|
||||
String testName = getName();
|
||||
String className = getClass().getName();
|
||||
return TestRunnerUtilBase.isPerformanceTest(testName, className);
|
||||
return TestFrameworkUtil.isPerformanceTest(testName, className);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -864,7 +864,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
}
|
||||
|
||||
private static boolean isStressTest(String testName, String className) {
|
||||
return TestRunnerUtilBase.isPerformanceTest(testName, className) ||
|
||||
return TestFrameworkUtil.isPerformanceTest(testName, className) ||
|
||||
containsStressWords(testName) ||
|
||||
containsStressWords(className);
|
||||
}
|
||||
|
||||
+4
-4
@@ -10,15 +10,15 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.SkipInHeadlessEnvironment;
|
||||
import com.intellij.testFramework.SkipSlowTestLocally;
|
||||
import com.intellij.testFramework.TestRunnerUtilBase;
|
||||
import com.intellij.testFramework.TestFrameworkUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
import static com.intellij.testFramework.PlatformTestUtilBase.SKIP_HEADLESS;
|
||||
import static com.intellij.testFramework.PlatformTestUtilBase.SKIP_SLOW;
|
||||
import static com.intellij.testFramework.TestFrameworkUtil.SKIP_HEADLESS;
|
||||
import static com.intellij.testFramework.TestFrameworkUtil.SKIP_SLOW;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
public abstract class BareTestFixtureTestCase {
|
||||
@@ -29,7 +29,7 @@ public abstract class BareTestFixtureTestCase {
|
||||
|
||||
@Before
|
||||
public final void setupFixture() throws Exception {
|
||||
ApplicationInfoImpl.setInStressTest(TestRunnerUtilBase.isPerformanceTest(null, getClass().getName()));
|
||||
ApplicationInfoImpl.setInStressTest(TestFrameworkUtil.isPerformanceTest(null, getClass().getName()));
|
||||
|
||||
boolean headless = SKIP_HEADLESS && getClass().getAnnotation(SkipInHeadlessEnvironment.class) != null;
|
||||
assumeFalse("Class '" + getClass().getName() + "' is skipped because it requires working UI environment", headless);
|
||||
|
||||
Reference in New Issue
Block a user