本文整理汇总了Java中com.intellij.testFramework.PlatformTestUtil类的典型用法代码示例。如果您正苦于以下问题:Java PlatformTestUtil类的具体用法?Java PlatformTestUtil怎么用?Java PlatformTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlatformTestUtil类属于com.intellij.testFramework包,在下文中一共展示了PlatformTestUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
private void doTest(int version) throws IOException, JDOMException, StudySerializationUtils.StudyUnrecognizedFormatException {
final String name = PlatformTestUtil.getTestName(this.name.getMethodName(), true);
final Path before = getTestDataPath().resolve(name + ".xml");
final Path after = getTestDataPath().resolve(name + ".after.xml");
Element element = JdomKt.loadElement(before);
Element converted = element;
switch (version) {
case 1:
converted = StudySerializationUtils.Xml.convertToSecondVersion(element);
break;
case 3:
converted = StudySerializationUtils.Xml.convertToForthVersion(element);
break;
case 4:
converted = StudySerializationUtils.Xml.convertToFifthVersion(element);
break;
}
assertTrue(JDOMUtil.areElementsEqual(converted, JdomKt.loadElement(after)));
}
示例2: testInheritingSettingsFromParentAndAlignCorrectly
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testInheritingSettingsFromParentAndAlignCorrectly() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>parent</artifactId>" +
"<version>1</version>" +
"<build>" +
" <directory>custom</directory>" +
"</build>");
VirtualFile module = createModulePom("module",
"<parent>" +
" <groupId>test</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>1</version>" +
"</parent>");
MavenModel p = readProject(module);
PlatformTestUtil.assertPathsEqual(pathFromBasedir(module.getParent(), "custom"), p.getBuild().getDirectory());
}
示例3: testInfoTestAttributes
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testInfoTestAttributes() throws Exception {
LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
extension.language="TEXT";
extension.implementationClass = TestAnnotator.class.getName();
PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
myFixture.doHighlighting();
MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
RangeHighlighter[] highlighters = model.getAllHighlighters();
assertEquals(1, highlighters.length);
TextAttributes attributes = highlighters[0].getTextAttributes();
assertNotNull(attributes);
assertNull(attributes.getBackgroundColor());
assertNull(attributes.getForegroundColor());
}
示例4: testManyPointersUpdatePerformance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testManyPointersUpdatePerformance() throws IOException {
LoggingListener listener = new LoggingListener();
final List<VFileEvent> events = new ArrayList<VFileEvent>();
final File ioTempDir = createTempDirectory();
final VirtualFile temp = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioTempDir);
for (int i=0; i<100000; i++) {
myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/" + i), disposable, listener);
events.add(new VFileCreateEvent(this, temp, "xxx" + i, false, true));
}
PlatformTestUtil.startPerformanceTest("vfp update", 10000, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
for (int i=0; i<100; i++) {
// simulate VFS refresh events since launching the actual refresh is too slow
myVirtualFilePointerManager.before(events);
myVirtualFilePointerManager.after(events);
}
}
}).assertTiming();
}
示例5: testModulesSelector
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testModulesSelector() throws ConfigurationException {
if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;
Module module1 = getModule1();
Module module2 = getModule2();
JUnitConfigurable editor = new JUnitConfigurable(myProject);
try {
JUnitConfiguration configuration = createConfiguration(findTestA(module2));
editor.getComponent(); // To get all the watchers installed.
Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
JComboBox comboBox = editor.getModulesComponent();
configurable.reset();
assertFalse(configurable.isModified());
assertEquals(module2.getName(), ((Module)comboBox.getSelectedItem()).getName());
assertEquals(ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); //no module
comboBox.setSelectedItem(module1);
assertTrue(configurable.isModified());
configurable.apply();
assertFalse(configurable.isModified());
assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
}
finally {
Disposer.dispose(editor);
}
}
示例6: testCreatingApplicationConfiguration
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testCreatingApplicationConfiguration() throws ConfigurationException {
if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;
ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
try {
editor.getComponent(); // To get all the watchers installed.
Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
configurable.reset();
CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
javaParameters.setProgramParameters("prg");
javaParameters.setVMParameters("vm");
javaParameters.setWorkingDirectory("dir");
assertTrue(configurable.isModified());
configurable.apply();
assertEquals("prg", configuration.getProgramParameters());
assertEquals("vm", configuration.getVMParameters());
assertEquals("dir", configuration.getWorkingDirectory());
}
finally {
Disposer.dispose(editor);
}
}
示例7: testBigFile
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testBigFile() throws Exception {
configureByFiles(null, getVirtualFile(getTestName(false) + ".xml"), getVirtualFile("buildserver.xml"), getVirtualFile("buildserver.properties"));
try {
myIgnoreInfos = true;
PlatformTestUtil.startPerformanceTest("Should be quite performant !", 25000, new ThrowableRunnable() {
@Override
public void run() {
doDoTest(true, false);
}
}).cpuBound().assertTiming();
}
finally {
myIgnoreInfos = false;
}
}
示例8: test
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void test() throws IOException {
File dir = Files.createTempDir();
try {
assertNotNull(FileResourceRepository.get(dir));
// We shouldn't clear it out immediately on GC *eligibility*:
System.gc();
assertNotNull(FileResourceRepository.getCached(dir));
// However, in low memory conditions we should:
try {
PlatformTestUtil.tryGcSoftlyReachableObjects();
} catch (Throwable t) {
// The above method can throw java.lang.OutOfMemoryError; that's fine for this test
}
System.gc();
assertNull(FileResourceRepository.getCached(dir));
}
finally {
FileUtil.delete(dir);
}
}
示例9: testASTBecomesInvalidOnExternalChange
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testASTBecomesInvalidOnExternalChange() {
final String text = "class A{}";
final PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("a.java", text);
PsiElement leaf = file.findElementAt(5);
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedDocument(file));
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VfsUtil.saveText(file.getVirtualFile(), text + " ");
}
}.execute();
assertTrue(file.isValid());
assertFalse(leaf.isValid());
assertNotSame(leaf, file.findElementAt(5));
}
示例10: testClassShouldNotAppearWithoutEvents_WithoutPsi
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotAppearWithoutEvents_WithoutPsi() throws IOException {
final GlobalSearchScope allScope = GlobalSearchScope.allScope(getProject());
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
final PsiManager psiManager = PsiManager.getInstance(getProject());
final PsiModificationTracker tracker = psiManager.getModificationTracker();
final VirtualFile file = myFixture.getTempDirFixture().createFile("Foo.java", "");
final Document document = FileDocumentManager.getInstance().getDocument(file);
assertNotNull(document);
assertNull(facade.findClass("Foo", allScope));
long count1 = tracker.getJavaStructureModificationCount();
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedPsiFile(document));
document.insertString(0, "class Foo {}");
assertFalse(count1 == tracker.getJavaStructureModificationCount());
assertTrue(PsiDocumentManager.getInstance(getProject()).isCommitted(document));
assertNotNull(facade.findClass("Foo", allScope));
PsiJavaFile psiFile = (PsiJavaFile)psiManager.findFile(file);
assertSize(1, psiFile.getClasses());
assertEquals("class Foo {}", psiFile.getText());
assertEquals("class Foo {}", psiFile.getNode().getText());
}
示例11: testClassShouldNotDisappearWithoutEvents_NoDocument
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_NoDocument() throws IOException {
PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
final VirtualFile file = myFixture.addFileToProject("Foo.java", "class Foo {}").getVirtualFile();
assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
long count1 = tracker.getJavaStructureModificationCount();
// gc softly-referenced file and document
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(psiManager.getFileManager().getCachedPsiFile(file));
VfsUtil.saveText(file, "");
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
示例12: testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted() throws IOException {
PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
final VirtualFile file = myFixture.addFileToProject("foo/Foo.java", "package foo; class Foo {}").getVirtualFile();
assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
long count1 = tracker.getJavaStructureModificationCount();
// gc softly-referenced file and document
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(psiManager.getFileManager().getCachedPsiFile(file));
file.getParent().delete(this);
assertNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
示例13: testLanguageLevelChange
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testLanguageLevelChange() {
//noinspection unused
PsiFile psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}");
GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
PlatformTestUtil.tryGcSoftlyReachableObjects();
PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope);
assertNotNull(psiClass);
long count = PsiManager.getInstance(getProject()).getModificationTracker().getJavaStructureModificationCount();
IdeaTestUtil.setModuleLanguageLevel(myFixture.getModule(), LanguageLevel.JDK_1_3);
assertTrue(count != PsiManager.getInstance(getProject()).getModificationTracker().getJavaStructureModificationCount());
psiClass = (JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope));
assertNotNull(psiClass);
assertTrue(psiClass.isValid());
}
示例14: testMultipleClasses
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testMultipleClasses() throws Exception {
String rootBefore = getRoot();
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
final PsiClass aClass = myJavaFacade.findClass("pack1.Klass");
assertNotNull(aClass);
final PsiFile containingFile = aClass.getContainingFile();
assertTrue(CopyHandler.canCopy(new PsiElement[]{containingFile}));
assertFalse(CopyHandler.canClone(new PsiElement[]{containingFile}));
PsiPackage pack2 = myJavaFacade.findPackage("pack2");
final PsiDirectory targetDirectory = pack2.getDirectories()[0];
CopyHandler.doCopy(new PsiElement[]{containingFile}, targetDirectory);
VirtualFile fileAfter = root.findFileByRelativePath("pack2/Klass.java");
VirtualFile fileExpected = root.findFileByRelativePath("pack2/Klass.expected.java");
PlatformTestUtil.assertFilesEqual(fileExpected, fileAfter);
}
示例15: doTest
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
private void doTest(String className) throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass classToInline = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
InlineToAnonymousClassProcessor processor = new InlineToAnonymousClassProcessor(myProject,
classToInline,
null, false, false, false);
UsageInfo[] usages = processor.findUsages();
MultiMap<PsiElement,String> conflicts = processor.getConflicts(usages);
assertEquals(0, conflicts.size());
processor.run();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}