handle suppressed exceptions

This commit is contained in:
Alexey Kudravtsev
2018-11-29 13:25:06 +03:00
parent 6e58aec999
commit d4cba378ed
80 changed files with 269 additions and 62 deletions
@@ -166,6 +166,9 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
myTestDir.deleteOnExit();
}
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
resetClassFields(getClass());
@@ -133,10 +133,12 @@ public class ConsoleHistoryControllerTest extends LightPlatformCodeInsightTestCa
@Override
public void tearDown() throws Exception {
try {
Disposer.dispose(myConsole);
myVFile = null;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -60,6 +60,9 @@ public class BadPluginTest extends PlatformTestCase {
try {
System.setProperty(PathManager.PROPERTY_CONFIG_PATH, myOldConfigPath);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -55,6 +55,9 @@ public class SelectionQuotingTypedHandlerTest extends LightPlatformCodeInsightFi
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = myPrevValue;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -34,6 +34,9 @@ public class ChangedLinesCounterTest extends LightPlatformCodeInsightFixtureTest
try {
myFixture.getFile().putUserData(FormatChangedTextUtil.TEST_REVISION_CONTENT, null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -62,11 +62,13 @@ public class ReformatFilesWithFiltersTest extends LightPlatformTestCase {
}
if (myWorkingDirectory != null) TestFileStructure.delete(myWorkingDirectory.getVirtualFile());
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myRealCodeStyleManger = null;
myMockCodeStyleManager = null;
myMockPlainTextFormattingModelBuilder = null;
super.tearDown();
}
}
@@ -112,7 +112,11 @@ public class ReformatOnlyVcsChangedTextTest extends LightPlatformTestCase {
LanguageImportStatements.INSTANCE.removeExplicitExtension(PlainTextLanguage.INSTANCE, myMockPlainTextImportOptimizer);
TestFileStructure.delete(myWorkingDirectory.getVirtualFile());
} finally {
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myRealChangeListManager = null;
myRealCodeStyleManger = null;
myRealVcsContextFactory = null;
@@ -48,6 +48,9 @@ public class DuplexConsoleActionsTest extends LightPlatformTestCase {
try {
Disposer.dispose(myDisposable);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myDisposable = null;
super.tearDown();
@@ -40,6 +40,9 @@ public class ProductivityFeaturesTest extends PlatformTestCase {
myRegistry = null;
myTracker = null;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -37,6 +37,7 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TestRule;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -53,7 +54,7 @@ public abstract class LocalHistoryTestCase extends Assert {
}
protected static byte[] b(String s) {
return s.getBytes();
return s.getBytes(StandardCharsets.UTF_8);
}
protected static Content c(String data) {
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -99,13 +100,13 @@ public class TestVirtualFile extends VirtualFile {
@Override
public long getLength() {
return myContent == null ? 0 : myContent.getBytes().length;
return myContent == null ? 0 : myContent.getBytes(StandardCharsets.UTF_8).length;
}
@Override
@NotNull
public byte[] contentsToByteArray() {
return myContent == null ? ArrayUtil.EMPTY_BYTE_ARRAY : myContent.getBytes();
return myContent == null ? ArrayUtil.EMPTY_BYTE_ARRAY : myContent.getBytes(StandardCharsets.UTF_8);
}
@Override
@@ -28,6 +28,7 @@ import com.intellij.util.text.DateFormatUtil;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -54,8 +55,8 @@ public class SelectionReverterTest extends IntegrationTestCase {
" public abstract bar();\n" +
"}\n";
setBinaryContent(f, before.getBytes());
setBinaryContent(f, after.getBytes());
setBinaryContent(f, before.getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, after.getBytes(StandardCharsets.UTF_8));
revertToPreviousRevision(2, 2);
@@ -65,15 +66,15 @@ public class SelectionReverterTest extends IntegrationTestCase {
" }\n" +
" public abstract bar();\n" +
"}\n";
assertEquals(expected, new String(f.contentsToByteArray()));
assertEquals(expected, new String(f.contentsToByteArray(), StandardCharsets.UTF_8));
}
public void testChangeSetName() throws Exception {
long time = new Date(2001, 1, 11, 12, 30).getTime();
Clock.setTime(time);
setBinaryContent(f, "one".getBytes());
setBinaryContent(f, "two".getBytes());
setBinaryContent(f, "one".getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, "two".getBytes(StandardCharsets.UTF_8));
revertToPreviousRevision(0, 0);
@@ -84,9 +85,9 @@ public class SelectionReverterTest extends IntegrationTestCase {
public void testAskingForReadOnlyStatusClearingOnlyForTheSpecifiedFile() throws Exception {
createChildData(myRoot, "foo1.txt");
setBinaryContent(f, "one".getBytes());
setBinaryContent(f, "one".getBytes(StandardCharsets.UTF_8));
createChildData(myRoot, "foo2.txt");
setBinaryContent(f, "two".getBytes());
setBinaryContent(f, "two".getBytes(StandardCharsets.UTF_8));
createChildData(myRoot, "foo3.txt");
final List<VirtualFile> files = new ArrayList<>();
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.DateFormatUtil;
import java.nio.charset.StandardCharsets;
import java.util.Date;
public class FileHistoryDialogTest extends LocalHistoryUITestCase {
@@ -43,10 +44,10 @@ public class FileHistoryDialogTest extends LocalHistoryUITestCase {
long rightTime = new Date(2002 - 1900, 2, 4, 14, 0).getTime();
VirtualFile f = createChildData(myRoot, "old.txt");
setBinaryContent(f, "old".getBytes(), -1, leftTime, this);
setBinaryContent(f, "old".getBytes(StandardCharsets.UTF_8), -1, leftTime, this);
rename(f, "new.txt");
setBinaryContent(f, "new".getBytes(), -1, rightTime, this);
setBinaryContent(f, "new".getBytes(StandardCharsets.UTF_8), -1, rightTime, this);
byte[] content = new byte[0];
setBinaryContent(f, content);
@@ -62,9 +63,9 @@ public class FileHistoryDialogTest extends LocalHistoryUITestCase {
public void testContent() {
VirtualFile f = createChildData(myRoot, "f.txt");
setBinaryContent(f, "old".getBytes());
setBinaryContent(f, "new".getBytes());
setBinaryContent(f, "current".getBytes());
setBinaryContent(f, "old".getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, "new".getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, "current".getBytes(StandardCharsets.UTF_8));
FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 1);
@@ -73,8 +74,8 @@ public class FileHistoryDialogTest extends LocalHistoryUITestCase {
public void testContentWhenOnlyOneRevisionSelected() {
VirtualFile f = createChildData(myRoot, "f.txt");
setBinaryContent(f, "old".getBytes());
setBinaryContent(f, "new".getBytes());
setBinaryContent(f, "old".getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, "new".getBytes(StandardCharsets.UTF_8));
FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 0);
@@ -83,8 +84,8 @@ public class FileHistoryDialogTest extends LocalHistoryUITestCase {
public void testContentForCurrentRevision() {
VirtualFile f = createChildData(myRoot, "f.txt");
setBinaryContent(f, "old".getBytes());
setBinaryContent(f, "current".getBytes());
setBinaryContent(f, "old".getBytes(StandardCharsets.UTF_8));
setBinaryContent(f, "current".getBytes(StandardCharsets.UTF_8));
FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 0);
@@ -28,6 +28,8 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import java.nio.charset.StandardCharsets;
import static org.easymock.EasyMock.*;
public class SelectionHistoryDialogTest extends LocalHistoryUITestCase {
@@ -40,9 +42,9 @@ public class SelectionHistoryDialogTest extends LocalHistoryUITestCase {
super.setUpInWriteAction();
f = createChildData(myRoot, "f.txt");
setBinaryContent(f,"a\nb\nc\n".getBytes(), -1, 123,this);
setBinaryContent(f,"a\nbc\nc\nd\n".getBytes(), -1, 456,this);
setBinaryContent(f,"a\nbcd\nc\ne\n".getBytes(), -1, 789,this);
setBinaryContent(f, "a\nb\nc\n".getBytes(StandardCharsets.UTF_8), -1, 123, this);
setBinaryContent(f,"a\nbc\nc\nd\n".getBytes(StandardCharsets.UTF_8), -1, 456,this);
setBinaryContent(f,"a\nbcd\nc\ne\n".getBytes(StandardCharsets.UTF_8), -1, 789,this);
}
public void testDialogWorks() {
@@ -61,6 +61,9 @@ public abstract class EditorPaintingTestCase extends AbstractEditorTest {
try {
FontLayoutService.setInstance(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -32,6 +32,9 @@ public class CopyActionSimpleHandlerTest extends CopyActionTest {
try {
CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE = myPrevValue;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -65,6 +65,9 @@ public abstract class AbstractEditorTest extends LightPlatformCodeInsightTestCas
try {
FontLayoutService.setInstance(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -50,6 +50,9 @@ public class EditorColorsSchemeDelegateTest extends AbstractEditorTest {
EditorColorsManager.getInstance().setGlobalScheme(mySavedScheme);
((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemeManager().removeScheme(myTestScheme);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myTestScheme = null;
mySavedScheme = null;
@@ -48,10 +48,12 @@ public class EditorLastActionTrackerTest extends LightPlatformCodeInsightFixture
try {
EditorActionManager.getInstance().setActionHandler(SAMPLE_ACTION, mySavedHandler);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myTracker = null;
mySavedHandler = null;
super.tearDown();
}
}
@@ -76,6 +76,9 @@ public class ImmediatePainterTest extends AbstractEditorTest {
getDefaultColorScheme().setColor(EditorColors.CARET_COLOR, myDefaultCaretColor);
KeyboardFocusManager.setCurrentKeyboardFocusManager(myDefaultFocusManager);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -27,6 +27,9 @@ public class NewDocumentHistoryTest extends HeavyFileEditorManagerTestCase {
try {
Disposer.dispose(myHistory);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myHistory = null;
super.tearDown();
@@ -66,9 +66,12 @@ public class NonProjectFileAccessTest extends HeavyFileEditorManagerTestCase {
}
});
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
ProjectManagerEx.getInstanceEx().unblockReloadingProjectOnExternalChanges(); // unblock only after project is disposed
ProjectManagerEx.getInstanceEx().unblockReloadingProjectOnExternalChanges(); // unblock only after project is disposed;
}
}
@@ -71,9 +71,11 @@ public class FileTypesTest extends PlatformTestCase {
FileTypeManagerImpl.reDetectAsync(false);
ApplicationManager.getApplication().runWriteAction(() -> myFileTypeManager.setIgnoredFilesList(myOldIgnoredFilesList));
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myFileTypeManager = null;
super.tearDown();
}
}
@@ -53,6 +53,9 @@ public class VirtualFilePointerRootsTest extends PlatformTestCase {
assertEquals(numberOfPointersBefore, myVirtualFilePointerManager.numberOfPointers());
assertEquals(numberOfListenersBefore, myVirtualFilePointerManager.numberOfListeners());
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myVirtualFilePointerManager = null;
super.tearDown();
@@ -40,9 +40,11 @@ public class PsiModificationTrackerTreeChangesUpdatesTest extends PlatformTestCa
try {
((PsiManagerImpl)PsiManager.getInstance(getProject())).removeTreeChangePreprocessor(myTracker);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myTracker = null;
super.tearDown();
}
}
@@ -33,6 +33,9 @@ public class SSRCodeInsightTest extends UsefulTestCase {
try {
myFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myFixture = null;
myInspection = null;
@@ -24,12 +24,13 @@ import com.intellij.openapi.util.io.ByteArraySequence;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class StorageTest extends StorageTestBase {
public void testSmoke() throws Exception {
final int record = myStorage.createNewRecord();
myStorage.writeBytes(record, new ByteArraySequence("Hello".getBytes()), false);
assertEquals("Hello", new String(myStorage.readBytes(record)));
myStorage.writeBytes(record, new ByteArraySequence("Hello".getBytes(StandardCharsets.UTF_8)), false);
assertEquals("Hello", new String(myStorage.readBytes(record), StandardCharsets.UTF_8));
}
public void testStress() throws Exception {
@@ -45,12 +46,12 @@ public class StorageTest extends StorageTestBase {
for (int i = 0; i < count; i++) {
final int record = myStorage.createNewRecord();
myStorage.writeBytes(record, new ByteArraySequence(hello.getBytes()), true); // fixed size optimization is mor than 50 percents here!
myStorage.writeBytes(record, new ByteArraySequence(hello.getBytes(StandardCharsets.UTF_8)), true); // fixed size optimization is mor than 50 percents here!
records[i] = record;
}
for (int record : records) {
assertEquals(hello, new String(myStorage.readBytes(record)));
assertEquals(hello, new String(myStorage.readBytes(record), StandardCharsets.UTF_8));
}
long timedelta = System.currentTimeMillis() - start;
@@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.CharsetToolkit;
import junit.framework.TestCase;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -61,7 +62,7 @@ public class UpdateableZipTest extends TestCase {
assertEntryWithContentExists(jbZip, "/second", "second");
JBZipEntry newEntry = jbZip.getOrCreateEntry("/third");
newEntry.setData("third".getBytes());
newEntry.setData("third".getBytes(StandardCharsets.UTF_8));
}
try (ZipFile utilZip = new ZipFile(zipFile)) {
@@ -79,7 +80,7 @@ public class UpdateableZipTest extends TestCase {
assertEntryWithContentExists(jbZip, "/second", "second");
JBZipEntry newEntry = jbZip.getOrCreateEntry("/second");
newEntry.setData("Content Replaced".getBytes());
newEntry.setData("Content Replaced".getBytes(StandardCharsets.UTF_8));
}
try (ZipFile utilZip = new ZipFile(zipFile)) {
@@ -207,8 +208,8 @@ public class UpdateableZipTest extends TestCase {
File zipFile = FileUtil.createTempFile("test", ".zip");
try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)))) {
appendEntry(zos, "/first", "first".getBytes());
appendEntry(zos, "/second", "second".getBytes());
appendEntry(zos, "/first", "first".getBytes(StandardCharsets.UTF_8));
appendEntry(zos, "/second", "second".getBytes(StandardCharsets.UTF_8));
}
return zipFile;
}
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -96,7 +97,7 @@ public class Executor {
public static void echo(@NotNull String fileName, @NotNull String content) {
try {
FileUtil.writeToFile(child(fileName), content.getBytes(), true);
FileUtil.writeToFile(child(fileName), content.getBytes(StandardCharsets.UTF_8), true);
}
catch (IOException e) {
throw new RuntimeException(e);
@@ -108,11 +109,11 @@ public class Executor {
}
public static void overwrite(@NotNull File file, @NotNull String content) throws IOException {
FileUtil.writeToFile(file, content.getBytes(), false);
FileUtil.writeToFile(file, content.getBytes(StandardCharsets.UTF_8), false);
}
public static void append(@NotNull File file, @NotNull String content) throws IOException {
FileUtil.writeToFile(file, content.getBytes(), true);
FileUtil.writeToFile(file, content.getBytes(StandardCharsets.UTF_8), true);
}
public static void append(@NotNull String fileName, @NotNull String content) throws IOException {
@@ -53,6 +53,9 @@ public abstract class XDebuggerTestCase extends PlatformTestCase {
getBreakpointTypes().unregisterExtension(MY_LINE_BREAKPOINT_TYPE);
getBreakpointTypes().unregisterExtension(MY_SIMPLE_BREAKPOINT_TYPE);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -249,6 +249,9 @@ public class ReferenceInjectionTest extends AbstractLanguageInjectionTestCase {
try {
myFixture.disableInspections(new InjectedReferencesInspection());
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -72,6 +72,9 @@ public class AntMultiFileCompletionTest extends UsefulTestCase {
try {
myFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myFixture = null;
super.tearDown();
@@ -44,6 +44,9 @@ public class CommanderListBuilderTest extends BaseProjectViewTestCase {
Disposer.dispose(myCommander);
myCommander = null;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -54,6 +54,9 @@ public class CreateClassFixTest extends UsefulTestCase {
myFixture.tearDown();
myFixture = null;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -45,6 +45,9 @@ public abstract class EclipseVarsTest extends IdeaTestCase {
PathMacros.getInstance().removeMacro(VARIABLE);
PathMacros.getInstance().removeMacro(SRCVARIABLE);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -69,6 +69,9 @@ public abstract class AppEngineCodeInsightTestCase extends UsefulTestCase {
try {
myCodeInsightFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -76,14 +76,17 @@ public class GradleProjectOpenProcessorTest extends GradleImportingTestCase {
try {
WriteAction.runAndWait(() -> {
Arrays.stream(ProjectJdkTable.getInstance().getAllJdks())
.filter(sdk -> !GRADLE_JDK_NAME.equals(sdk.getName()))
.forEach(ProjectJdkTable.getInstance()::removeJdk);
.filter(sdk -> !GRADLE_JDK_NAME.equals(sdk.getName()))
.forEach(ProjectJdkTable.getInstance()::removeJdk);
for (Sdk sdk : removedSdks) {
SdkConfigurationUtil.addSdk(sdk);
}
removedSdks.clear();
});
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -114,6 +114,9 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
Messages.setTestDialog(TestDialog.DEFAULT);
deleteBuildSystemDirectory();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -85,7 +85,11 @@ public class GradleSettingsImportingTest extends GradleImportingTestCase {
public void tearDown() throws Exception {
try {
Registry.get(EXTERNAL_SYSTEM_CONFIGURATION_IMPORT_ENABLED).resetToDefault();
} finally {
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
}
@@ -73,6 +73,9 @@ public abstract class HgPlatformTest extends VcsPlatformTest {
try {
myVcs.getGlobalSettings().setHgExecutable(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -49,6 +49,9 @@ public class HgAnnotationTest extends HgPlatformTest {
try {
Clock.reset();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -9,6 +9,7 @@ import org.testng.annotations.Test;
import org.zmlx.hg4idea.HgVcs;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.List;
@@ -44,8 +45,8 @@ public class HgHistoryTest extends HgSingleUserTest {
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(1).loadContent(), INITIAL_FILE_CONTENT.getBytes());
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
assertEquals(revisions.get(1).loadContent(), INITIAL_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -78,8 +79,8 @@ public class HgHistoryTest extends HgSingleUserTest {
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(2).loadContent(), INITIAL_FILE_CONTENT.getBytes());
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
assertEquals(revisions.get(2).loadContent(), INITIAL_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
}
@Test
@@ -108,8 +109,8 @@ public class HgHistoryTest extends HgSingleUserTest {
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(1).loadContent(), INITIAL_FILE_CONTENT.getBytes());
assertEquals(revisions.get(0).loadContent(), UPDATED_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
assertEquals(revisions.get(1).loadContent(), INITIAL_FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
}
@@ -42,9 +42,11 @@ public class InconsistentResourceBundleInspectionTest extends JavaCodeInsightFix
try {
myInspection.clearSettings();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myInspection = null;
super.tearDown();
}
}
@@ -68,6 +68,9 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
removeFromLocalRepository("test");
ExternalSystemTestCase.deleteBuildSystemDirectory();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myProjectsManager = null;
myProjectsTree = null;
@@ -38,6 +38,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -478,10 +479,10 @@ public abstract class MavenTestCase extends UsefulTestCase {
try {
WriteAction.runAndWait(() -> {
if (advanceStamps) {
file.setBinaryContent(content.getBytes(), -1, file.getTimeStamp() + 4000);
file.setBinaryContent(content.getBytes(StandardCharsets.UTF_8), -1, file.getTimeStamp() + 4000);
}
else {
file.setBinaryContent(content.getBytes(), file.getModificationStamp(), file.getTimeStamp());
file.setBinaryContent(content.getBytes(StandardCharsets.UTF_8), file.getModificationStamp(), file.getTimeStamp());
}
});
}
@@ -39,6 +39,9 @@ public abstract class MavenDomWithIndicesTestCase extends MavenDomTestCase {
myIndicesFixture = null;
}
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -31,6 +31,9 @@ public class MavenRunConfigurationTest extends IdeaTestCase {
try {
MavenServerManager.getInstance().shutdown(true);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -47,6 +47,9 @@ public class MavenShortcutsManagerTest extends MavenImportingTestCase {
try {
MavenKeymapExtension.clearActions(myProject);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myShortcutsManager = null;
super.tearDown();
@@ -41,6 +41,9 @@ public class MavenIndicesManagerTest extends MavenIndicesTestCase {
try {
myIndicesFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -57,6 +57,9 @@ public class MavenIndicesTest extends MavenIndicesTestCase {
try {
shutdownIndices();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -24,6 +24,9 @@ public abstract class MavenIndicesTestCase extends MavenImportingTestCase {
try {
MavenServerManager.getInstance().shutdown(true);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -32,6 +32,9 @@ public class MavenProjectIndicesManagerTest extends MavenIndicesTestCase {
try {
myIndicesFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -35,6 +35,9 @@ public class MavenSearcherTest extends MavenIndicesTestCase {
try {
myIndicesFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -27,6 +27,9 @@ public class MavenParameterGoalTest extends LightCodeInsightFixtureTestCase {
try {
MavenServerManager.getInstance().shutdown(true);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -32,6 +32,9 @@ public class MavenEmbeddersManagerTest extends MavenTestCase {
try {
myManager.releaseForcefullyInTests();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.maven.project;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.util.SystemInfo;
@@ -27,12 +26,12 @@ import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.MavenTestCase;
import org.jetbrains.idea.maven.model.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -504,7 +503,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
parentFile.getParentFile().mkdirs();
FileUtil.writeToFile(parentFile, createPomXml("<groupId>test</groupId>" +
"<artifactId>parent</artifactId>" +
"<version>1</version>").getBytes());
"<version>1</version>").getBytes(StandardCharsets.UTF_8));
createProjectPom("<groupId>test</groupId>" +
"<artifactId>not-a-project</artifactId>" +
@@ -671,7 +670,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
"<properties>" +
" <prop>value</prop>" +
"</properties>").getBytes());
"</properties>").getBytes(StandardCharsets.UTF_8));
VirtualFile module = createModulePom("module",
"<parent>" +
@@ -776,7 +775,7 @@ public class MavenProjectReaderTest extends MavenTestCase {
"<properties>" +
" <prop>value</prop>" +
"</properties>").getBytes());
"</properties>").getBytes(StandardCharsets.UTF_8));
createProjectPom("<parent>" +
" <groupId>org.test</groupId>" +
@@ -42,6 +42,9 @@ public class MavenSurefireReportInConsoleTest extends LightCodeInsightFixtureTes
try {
MavenServerManager.getInstance().shutdown(true);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -44,6 +44,9 @@ public class MavenTemplateFileProcessorTest extends LightPlatformCodeInsightFixt
try {
MavenServerManager.getInstance().shutdown(true);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -34,6 +34,9 @@ public class MavenImportWizardTest extends ProjectWizardTestCase {
MavenServerManager.getInstance().shutdown(true);
JavaAwareProjectJdkTableImpl.removeInternalJdkInTests();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -45,6 +45,9 @@ public class SvnCachingRevisionsTest extends CodeInsightFixtureTestCase {
myVcs = null;
FileUtil.delete(SvnApplicationSettings.getLoadedRevisionsDir(myFixture.getProject()));
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -49,6 +49,9 @@ public abstract class TaskManagerTestCase extends LightCodeInsightFixtureTestCas
myTaskManager.setRepositories(Collections.emptyList());
removeAllTasks();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myTaskManager = null;
super.tearDown();
@@ -47,7 +47,11 @@ public class GitTaskBranchesTest extends TaskBranchesTest {
protected void tearDown() throws Exception {
try {
GitVcsSettings.getInstance(myProject).getAppSettings().setPathToGit(null);
} finally {
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
}
@@ -508,11 +508,13 @@ public class TaskVcsTest extends CodeInsightFixtureTestCase {
myTaskManager.setRepositories(Collections.emptyList());
AllVcses.getInstance(getProject()).unregisterManually(myVcs);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myTaskManager = null;
myVcs = null;
myChangeListManager = null;
super.tearDown();
}
}
@@ -55,6 +55,9 @@ public abstract class TestBase extends UsefulTestCase {
try {
myFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myFixture = null;
super.tearDown();
@@ -48,6 +48,9 @@ public abstract class YAMLPasteTest extends LightPlatformCodeInsightFixtureTestC
try {
CodeInsightSettings.getInstance().REFORMAT_ON_PASTE = myDefaultReformatOnPaste;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -40,6 +40,9 @@ public abstract class RestFixtureTestCase extends UsefulTestCase {
try {
myFixture.tearDown();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
myFixture = null;
super.tearDown();
@@ -19,6 +19,7 @@ import com.jetbrains.python.sdk.flavors.IronPythonSdkFlavor;
import org.junit.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author traff
@@ -43,7 +44,7 @@ public class PyDynamicTypesTest extends PyEnvTestCase {
@Override
public void doFinally() {
try {
PySignatureCacheManagerImpl.CALL_SIGNATURES_ATTRIBUTE.writeAttributeBytes(getVirtualFile(), "".getBytes());
PySignatureCacheManagerImpl.CALL_SIGNATURES_ATTRIBUTE.writeAttributeBytes(getVirtualFile(), "".getBytes(StandardCharsets.UTF_8));
}
catch (IOException e) {
//pass
@@ -56,6 +56,9 @@ public class Py3ResolveTest extends PyResolveTestCase {
try {
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -39,6 +39,9 @@ public class PyCopyPasteTest extends PyTestCase {
try {
CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE = myOldEnabled;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -43,6 +43,9 @@ public class PyFunctionTypeAnnotationParsingTest extends ParsingTestCase {
PythonVisitorFilter.INSTANCE.removeExplicitExtension(PythonLanguage.INSTANCE, (visitorClass, file) -> false);
PythonVisitorFilter.INSTANCE.removeExplicitExtension(PyFunctionTypeAnnotationDialect.INSTANCE, (visitorClass, file) -> false);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -39,6 +39,9 @@ public class PyQuickDocTest extends LightMarkedTestCase {
final PyDocumentationSettings documentationSettings = PyDocumentationSettings.getInstance(myFixture.getModule());
documentationSettings.setFormat(myFormat);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -53,6 +53,9 @@ public class PyTypingTest extends PyTestCase {
try {
setLanguageLevel(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -48,6 +48,9 @@ public class PyWrapTest extends PyTestCase {
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap;
pythonSettings.RIGHT_MARGIN = myOldMargin;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -186,6 +186,9 @@ public abstract class PyTestCase extends UsefulTestCase {
myFixture = null;
FilePropertyPusher.EP_NAME.findExtensionOrFail(PythonLanguageLevelPusher.class).flushLanguageLevelCache();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
clearFields(this);
@@ -4,7 +4,6 @@ package com.jetbrains.python.intentions;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.PsiTestUtil;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
import com.jetbrains.python.documentation.PyDocumentationSettings;
@@ -36,6 +35,9 @@ public class PyIntentionTest extends PyTestCase {
myDocumentationSettings.setFormat(DocStringFormat.PLAIN);
}
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -32,6 +32,9 @@ public class PyPackageCacheTest extends PyTestCase {
try {
PyPIPackageCache.reset();
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -46,6 +46,9 @@ public class PyiInspectionsTest extends PyTestCase {
PythonVisitorFilter.INSTANCE.removeExplicitExtension(PythonLanguage.INSTANCE, (visitorClass, file) -> false);
PythonVisitorFilter.INSTANCE.removeExplicitExtension(PyiLanguageDialect.getInstance(), (visitorClass, file) -> false);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -78,6 +78,9 @@ public class PyiTypeTest extends PyTestCase {
}
setLanguageLevel(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
@@ -46,7 +46,7 @@ public class PyInvertBooleanTest extends PyTestCase {
private void doTest(List<String> files) {
files.add(0, "refactoring/invertBoolean/" + getTestName(true) + ".before.py");
myFixture.configureByFiles(files.toArray(ArrayUtil.EMPTY_STRING_ARRAY));
myFixture.configureByFiles(ArrayUtil.toStringArray(files));
final PsiElement element = myFixture.getElementAtCaret();
assertTrue(element instanceof PsiNamedElement);
@@ -60,6 +60,9 @@ public class PyMoveTest extends PyTestCase {
try {
SystemProperties.setTestUserName(null);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}