mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wrap vfile writes in tests into write action
This commit is contained in:
+16
-3
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.compiler;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -520,7 +523,7 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
}
|
||||
|
||||
public void testUpdatingWhenPropertiesInFiltersAreChanged() throws Exception {
|
||||
VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1");
|
||||
final VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1");
|
||||
createProjectSubFile("resources/file.properties", "value=${xxx}");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
@@ -541,7 +544,12 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
compileModules("project");
|
||||
assertResult("target/classes/file.properties", "value=1");
|
||||
|
||||
VfsUtil.saveText(filter, "xxx=2");
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
VfsUtil.saveText(filter, "xxx=2");
|
||||
}
|
||||
}.execute().throwException();
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
compileModules("project");
|
||||
assertResult("target/classes/file.properties", "value=2");
|
||||
@@ -1010,7 +1018,12 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
public void testDoNotFilterButCopyBigFiles() throws Exception {
|
||||
assertEquals(FileTypeManager.getInstance().getFileTypeByFileName("file.xyz"), FileTypes.UNKNOWN);
|
||||
|
||||
createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
|
||||
+1
-1
@@ -521,7 +521,7 @@ public class MavenModuleCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
|
||||
importProject(parentPom);
|
||||
|
||||
VfsUtil.saveText(parentPom, createPomXml(
|
||||
myFixture.saveText(parentPom, createPomXml(
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
+5
-6
@@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.importing
|
||||
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
@@ -28,7 +27,7 @@ class EncodingImportingTest extends MavenImportingTestCase {
|
||||
byte[] text = [-12, -59, -53, -45, -44] // Russian text in koi8-r encoding.
|
||||
|
||||
VirtualFile file = createProjectSubFile("src/main/resources/A.txt")
|
||||
file.setBinaryContent(text)
|
||||
ApplicationManager.application.runWriteAction { file.setBinaryContent(text) }
|
||||
|
||||
importProject("""
|
||||
<groupId>test</groupId>
|
||||
@@ -49,7 +48,7 @@ class EncodingImportingTest extends MavenImportingTestCase {
|
||||
byte[] text = [-12, -59, -53, 45, -44] // Russian text in koi8-r encoding.
|
||||
|
||||
VirtualFile file = createProjectSubFile("src/main/resources/A.txt")
|
||||
file.setBinaryContent(text)
|
||||
ApplicationManager.application.runWriteAction { file.setBinaryContent(text) }
|
||||
|
||||
importProject("""
|
||||
<groupId>test</groupId>
|
||||
|
||||
+10
-1
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.MavenCustomRepositoryHelper;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.model.MavenProjectProblem;
|
||||
@@ -34,7 +37,13 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
public void testUnknownProblemWithEmptyFile() throws Exception {
|
||||
createProjectPom("");
|
||||
myProjectPom.setBinaryContent(new byte[0]);
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
myProjectPom.setBinaryContent(new byte[0]);
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
importProject();
|
||||
|
||||
assertModules("project");
|
||||
|
||||
+46
-46
@@ -244,13 +244,13 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
protected void run(Result<VirtualFile> result) throws Throwable {
|
||||
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
|
||||
result.setResult(res);
|
||||
VfsUtil.saveText(res, "<project>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
VfsUtil.saveText(file, "<project>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
MavenModel p = readProject(file);
|
||||
|
||||
@@ -309,49 +309,49 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
protected void run(Result<VirtualFile> result) throws Throwable {
|
||||
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
|
||||
result.setResult(res);
|
||||
VfsUtil.saveText(res, "<project>" +
|
||||
" <modelVersion>1.2.3</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <name>foo</name>" +
|
||||
" <packaging>pom</packaging>" +
|
||||
|
||||
" <parent>" +
|
||||
" <groupId>testParent</groupId>" +
|
||||
" <artifactId>projectParent</artifactId>" +
|
||||
" <version>2</version>" +
|
||||
" <relativePath>../parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
|
||||
" <build>" +
|
||||
" <finalName>xxx</finalName>" +
|
||||
" <defaultGoal>someGoal</defaultGoal>" +
|
||||
" <sourceDirectory>mySrc</sourceDirectory>" +
|
||||
" <testSourceDirectory>myTestSrc</testSourceDirectory>" +
|
||||
" <scriptSourceDirectory>myScriptSrc</scriptSourceDirectory>" +
|
||||
" <resources>" +
|
||||
" <resource>" +
|
||||
" <directory>myRes</directory>" +
|
||||
" <filtering>true</filtering>" +
|
||||
" <targetPath>dir</targetPath>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" <excludes><exclude>**.xml</exclude></excludes>" +
|
||||
" </resource>" +
|
||||
" </resources>" +
|
||||
" <testResources>" +
|
||||
" <testResource>" +
|
||||
" <directory>myTestRes</directory>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" </testResource>" +
|
||||
" </testResources>" +
|
||||
" <directory>myOutput</directory>" +
|
||||
" <outputDirectory>myClasses</outputDirectory>" +
|
||||
" <testOutputDirectory>myTestClasses</testOutputDirectory>" +
|
||||
" </build>" +
|
||||
"</project>");
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
VfsUtil.saveText(file, "<project>" +
|
||||
" <modelVersion>1.2.3</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <name>foo</name>" +
|
||||
" <packaging>pom</packaging>" +
|
||||
|
||||
" <parent>" +
|
||||
" <groupId>testParent</groupId>" +
|
||||
" <artifactId>projectParent</artifactId>" +
|
||||
" <version>2</version>" +
|
||||
" <relativePath>../parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
|
||||
" <build>" +
|
||||
" <finalName>xxx</finalName>" +
|
||||
" <defaultGoal>someGoal</defaultGoal>" +
|
||||
" <sourceDirectory>mySrc</sourceDirectory>" +
|
||||
" <testSourceDirectory>myTestSrc</testSourceDirectory>" +
|
||||
" <scriptSourceDirectory>myScriptSrc</scriptSourceDirectory>" +
|
||||
" <resources>" +
|
||||
" <resource>" +
|
||||
" <directory>myRes</directory>" +
|
||||
" <filtering>true</filtering>" +
|
||||
" <targetPath>dir</targetPath>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" <excludes><exclude>**.xml</exclude></excludes>" +
|
||||
" </resource>" +
|
||||
" </resources>" +
|
||||
" <testResources>" +
|
||||
" <testResource>" +
|
||||
" <directory>myTestRes</directory>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" </testResource>" +
|
||||
" </testResources>" +
|
||||
" <directory>myOutput</directory>" +
|
||||
" <outputDirectory>myClasses</outputDirectory>" +
|
||||
" <testOutputDirectory>myTestClasses</testOutputDirectory>" +
|
||||
" </build>" +
|
||||
"</project>");
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
MavenModel p = readProject(file);
|
||||
|
||||
|
||||
+12
-4
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
@@ -46,9 +49,14 @@ public abstract class MavenProjectsTreeTestCase extends MavenImportingTestCase {
|
||||
myTree.delete(asList(file), getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
|
||||
}
|
||||
|
||||
protected void updateTimestamps(VirtualFile... files) throws IOException {
|
||||
for (VirtualFile each : files) {
|
||||
each.setBinaryContent(each.contentsToByteArray());
|
||||
}
|
||||
protected void updateTimestamps(final VirtualFile... files) throws IOException {
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
for (VirtualFile each : files) {
|
||||
each.setBinaryContent(each.contentsToByteArray());
|
||||
}
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user