use of com.intellij.mock.MockVirtualFile in project intellij-community by JetBrains.
the class FileDocumentManagerImplTest method testRememberSeparators.
public void testRememberSeparators() throws Exception {
final VirtualFile file = new MockVirtualFile("test.txt", "test\rtest");
final Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, "xxx "));
myDocumentManager.saveAllDocuments();
assertEquals("xxx test\rtest", new String(file.contentsToByteArray(), CharsetToolkit.UTF8_CHARSET));
}
use of com.intellij.mock.MockVirtualFile in project intellij-community by JetBrains.
the class VirtualFilePointerTest method testAlienVirtualFileSystemPointerRemovedFromUrlToIdentityCacheOnDispose.
public void testAlienVirtualFileSystemPointerRemovedFromUrlToIdentityCacheOnDispose() throws IOException {
VirtualFile mockVirtualFile = new MockVirtualFile("test_name", "test_text");
Disposable disposable1 = Disposer.newDisposable();
final VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(mockVirtualFile, disposable1, null);
assertInstanceOf(pointer, IdentityVirtualFilePointer.class);
assertTrue(pointer.isValid());
VirtualFile virtualFileWithSameUrl = new MockVirtualFile("test_name", "test_text");
VirtualFilePointer updatedPointer = VirtualFilePointerManager.getInstance().create(virtualFileWithSameUrl, disposable1, null);
assertInstanceOf(updatedPointer, IdentityVirtualFilePointer.class);
assertEquals(1, ((VirtualFilePointerManagerImpl) VirtualFilePointerManager.getInstance()).numberOfCachedUrlToIdentity());
Disposer.dispose(disposable1);
assertEquals(0, ((VirtualFilePointerManagerImpl) VirtualFilePointerManager.getInstance()).numberOfCachedUrlToIdentity());
}
use of com.intellij.mock.MockVirtualFile in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleFrameworkDetectorTest method createSuitableFilePattern_appYml_withInvalidContent_doesNotMatch.
@Test
public void createSuitableFilePattern_appYml_withInvalidContent_doesNotMatch() {
MockVirtualFile invalidYamlFile = new MockVirtualFile("app.yml");
FileContent invalidYamlFileContent = new FileContentImpl(invalidYamlFile, NOT_APP_ENGINE_FLEX_YAML_CONTENT, System.currentTimeMillis());
assertThat(pattern.accepts(invalidYamlFileContent)).isFalse();
}
use of com.intellij.mock.MockVirtualFile in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineFlexibleFrameworkDetectorTest method createSuitableFilePattern_appYaml_withInvalidContent_doesNotMatch.
@Test
public void createSuitableFilePattern_appYaml_withInvalidContent_doesNotMatch() {
MockVirtualFile invalidYamlFile = new MockVirtualFile("app.yaml");
FileContent invalidYamlFileContent = new FileContentImpl(invalidYamlFile, NOT_APP_ENGINE_FLEX_YAML_CONTENT, System.currentTimeMillis());
assertThat(pattern.accepts(invalidYamlFileContent)).isFalse();
}
use of com.intellij.mock.MockVirtualFile in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method createPsiClassesAndSourceToTargetMap.
private void createPsiClassesAndSourceToTargetMap(Container projectServices) {
PsiManager psiManager = new MockPsiManager(project);
VirtualFile independentLibraryView = new MockVirtualFile("src/com/google/example/independent/LibraryView.java");
VirtualFile independentLibraryView2 = new MockVirtualFile("src/com/google/example/independent/LibraryView2.java");
VirtualFile independentLibrary2View = new MockVirtualFile("src/com/google/example/independent/Library2View.java");
VirtualFile dependentLibraryView = new MockVirtualFile("src/com/google/example/dependent/LibraryView.java");
VirtualFile resourceView = new MockVirtualFile("src/com/google/example/ResourceView.java");
ImmutableMap<String, PsiClass> classes = ImmutableMap.of("com.google.example.independent.LibraryView", mockPsiClass(independentLibraryView), "com.google.example.independent.LibraryView2", mockPsiClass(independentLibraryView2), "com.google.example.independent.Library2View", mockPsiClass(independentLibrary2View), "com.google.example.dependent.LibraryView", mockPsiClass(dependentLibraryView), "com.google.example.ResourceView", mockPsiClass(resourceView));
ImmutableMap<File, TargetKey> sourceToTarget = ImmutableMap.of(VfsUtilCore.virtualToIoFile(independentLibraryView), TargetKey.forPlainTarget(Label.create("//com/google/example/independent:library")), VfsUtilCore.virtualToIoFile(independentLibraryView2), TargetKey.forPlainTarget(Label.create("//com/google/example/independent:library")), VfsUtilCore.virtualToIoFile(independentLibrary2View), TargetKey.forPlainTarget(Label.create("//com/google/example/independent:library2")), VfsUtilCore.virtualToIoFile(dependentLibraryView), TargetKey.forPlainTarget(Label.create("//com/google/example/dependent:library")), VfsUtilCore.virtualToIoFile(resourceView), TargetKey.forPlainTarget(Label.create("//com/google/example:resources")));
projectServices.register(JavaPsiFacade.class, new MockJavaPsiFacade(project, psiManager, classes));
projectServices.register(SourceToTargetMap.class, new MockSourceToTargetMap(sourceToTarget));
}
Aggregations