• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IdeaTestUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.testFramework.IdeaTestUtil的典型用法代码示例。如果您正苦于以下问题:Java IdeaTestUtil类的具体用法?Java IdeaTestUtil怎么用?Java IdeaTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IdeaTestUtil类属于com.intellij.testFramework包,在下文中一共展示了IdeaTestUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doTest

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
private void doTest(String className, String methodName) throws Exception {
  String rootBefore = getRoot() + "/before";
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
  PsiClass aClass = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
  assertTrue(aClass != null);
  PsiElement element = aClass.findMethodsByName(methodName, false)[0];
  assertTrue(element instanceof PsiMethod);
  PsiMethod method = (PsiMethod)element;
  final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
  assertFalse("Bad returns found", condition);

  InlineOptions options = new MockInlineMethodOptions();
  final InlineMethodProcessor processor = new InlineMethodProcessor(getProject(), method, null, myEditor, options.isInlineThisOnly());
  processor.run();

  String rootAfter = getRoot() + "/after";
  VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
  myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:InlineMethodMultifileTest.java


示例2: testMultipleFiles

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testMultipleFiles() throws Exception {
  String rootBefore = getRoot();
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);

  final VirtualFile first = root.findFileByRelativePath("from/1.txt");
  assertNotNull(first);
  final VirtualFile second = root.findFileByRelativePath("from/2.txt");
  assertNotNull(second);

  final PsiFile firstPsi = myPsiManager.findFile(first);
  final PsiFile secondPsi = myPsiManager.findFile(second);

  assertTrue(CopyHandler.canCopy(new PsiElement[]{firstPsi, secondPsi}));

  final VirtualFile toDir = root.findChild("to");
  assertNotNull(toDir);
  final PsiDirectory targetDirectory = myPsiManager.findDirectory(toDir);

  CopyHandler.doCopy(new PsiElement[]{firstPsi, secondPsi}, targetDirectory);

  assertNotNull(root.findFileByRelativePath("to/1.txt"));
  assertNotNull(root.findFileByRelativePath("to/2.txt"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CopyTest.java


示例3: doMultifileTest

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
private void doMultifileTest() throws Exception {
  String root = JavaTestUtil.getJavaTestDataPath() + "/refactoring/copyClass/multifile/" + getTestName(true);
  String rootBefore = root + "/before";
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);

  final HashMap<PsiFile, PsiClass[]> map = new HashMap<>();
  final VirtualFile sourceDir = rootDir.findChild("p1");
  for (VirtualFile file : sourceDir.getChildren()) {
    final PsiFile psiFile = myPsiManager.findFile(file);
    if (psiFile instanceof PsiJavaFile) {
      map.put(psiFile, ((PsiJavaFile)psiFile).getClasses());
    }
  }

  final VirtualFile targetVDir = rootDir.findChild("p2");
  CopyClassesHandler.doCopyClasses(map, null, myPsiManager.findDirectory(targetVDir), myProject);

  String rootAfter = root + "/after";
  VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
  myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CopyClassTest.java


示例4: setUp

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  myJdkHome = IdeaTestUtil.requireRealJdkHome();
  super.setUp();
  assumeThat(gradleVersion, versionMatcherRule.getMatcher());
  new WriteAction() {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      Sdk oldJdk = ProjectJdkTable.getInstance().findJdk(GRADLE_JDK_NAME);
      if (oldJdk != null) {
        ProjectJdkTable.getInstance().removeJdk(oldJdk);
      }
      VirtualFile jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myJdkHome));
      Sdk jdk = SdkConfigurationUtil.setupSdk(new Sdk[0], jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME);
      assertNotNull("Cannot create JDK for " + myJdkHome, jdk);
      ProjectJdkTable.getInstance().addJdk(jdk);
    }
  }.execute();
  myProjectSettings = new GradleProjectSettings();
  GradleSettings.getInstance(myProject).setGradleVmOptions("-Xmx64m -XX:MaxPermSize=64m");
  System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, String.valueOf(GRADLE_DAEMON_TTL_MS));
  configureWrapper();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GradleImportingTestCase.java


示例5: doPackageCopy

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
private void doPackageCopy() throws Exception {
  String root = JavaTestUtil.getJavaTestDataPath() + "/refactoring/copyClass/multifile/" + getTestName(true);
  String rootBefore = root + "/before";
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);

  final VirtualFile targetVDir = rootDir.findChild("p2");
  final PsiDirectory sourceP1Dir = myPsiManager.findDirectory(rootDir.findChild("p1"));
  final PsiDirectory targetP2Dir = myPsiManager.findDirectory(targetVDir);
  new CopyClassesHandler().doCopy(new PsiElement[]{sourceP1Dir}, targetP2Dir);

  String rootAfter = root + "/after";
  VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
  myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CopyClassTest.java


示例6: doTest

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InlineToAnonymousClassMultifileTest.java


示例7: initProject

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
private  void initProject(String folderName, final String... sourceDirs) {
  final String testDir = JavaTestUtil.getJavaTestDataPath() + "/find/" + folderName;
  ApplicationManager.getApplication().runWriteAction(() -> {
    try{
      mySourceDirs = new VirtualFile[sourceDirs.length];
      for (int i = 0; i < sourceDirs.length; i++){
        String sourcePath = testDir + "/" + sourceDirs[i];
        mySourceDirs[i] = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(sourcePath));
      }

      VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(testDir));
      Sdk jdk = IdeaTestUtil.getMockJdk17();
      PsiTestUtil.removeAllRoots(myModule, jdk);
      PsiTestUtil.addContentRoot(myModule, projectDir);
      for (VirtualFile sourceDir : mySourceDirs) {
        PsiTestUtil.addSourceRoot(myModule, sourceDir);
      }
    }
    catch (Exception e){
      throw new RuntimeException(e);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FindManagerTest.java


示例8: testVisibilitySorter

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testVisibilitySorter() throws Exception {
  dotest(new CheckAction() {
    @Override
    public void testClassStructure(StructureViewComponent structureViewComponent) {
      structureViewComponent.setActionActive(JavaInheritedMembersNodeProvider.ID, false);

      IdeaTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                               " -Class2\n" +
                                                               "  __myPrivateFiield: int\n" +
                                                               "  _myProtectedField: int\n" +
                                                               "  myPublicField: int\n");

      structureViewComponent.setActionActive(VisibilitySorter.ID, true);

      IdeaTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                               " -Class2\n" +
                                                               "  myPublicField: int\n" +
                                                               "  _myProtectedField: int\n" +
                                                               "  __myPrivateFiield: int\n");
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaTreeStructureTest.java


示例9: testMembersOrder

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testMembersOrder() throws Exception {
  dotest(new CheckAction() {
    @Override
    public void testClassStructure(StructureViewComponent structureViewComponent) {
      structureViewComponent.setActionActive(JavaInheritedMembersNodeProvider.ID, false);

      IdeaTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                               " -Class2\n" +
                                                               "  Class2()\n" +
                                                               "  af(): void\n" +
                                                               "  zf(): void\n" +
                                                               "  ab: int\n" +
                                                               "  z: int\n"
      );
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaTreeStructureTest.java


示例10: testLanguageLevelChange

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiModificationTrackerTest.java


示例11: testAnnotation

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testAnnotation() throws Exception {
  IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, new Runnable() {
    @Override
    public void run() {
      doTest();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaAPIUsagesInspectionTest.java


示例12: testDefaultMethods

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testDefaultMethods() throws Exception {
  IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, new Runnable() {
    @Override
    public void run() {
      doTest();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaAPIUsagesInspectionTest.java


示例13: testOverrideAnnotation

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testOverrideAnnotation() throws Exception {
  IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, new Runnable() {
    @Override
    public void run() {
      doTest();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaAPIUsagesInspectionTest.java


示例14: testRawInheritFromNewlyGenerified

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testRawInheritFromNewlyGenerified() throws Exception {
  IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, new Runnable() {
    @Override
    public void run() {
      doTest();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaAPIUsagesInspectionTest.java


示例15: tuneFixture

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
@Override
protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception {
  moduleBuilder.setLanguageLevel(LanguageLevel.JDK_1_8);
  moduleBuilder.addLibraryJars("guava-17.0.jar", PathManager.getHomePath().replace(File.separatorChar, '/') + "/community/lib/",
                               "guava-17.0.jar");
  moduleBuilder.addLibraryJars("guava-17.0.jar-2", PathManager.getHomePath().replace(File.separatorChar, '/') + "/lib/",
                               "guava-17.0.jar");
  moduleBuilder.addJdk(IdeaTestUtil.getMockJdk18Path().getPath());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:StaticPseudoFunctionalStyleMethodTest.java


示例16: doTest

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
private void doTest(@NonNls final String className,
                    @NonNls final String newClassName,
                    String[] conflicts,
                    String targetPackageName,
                    RefactoringTestUtil.MemberDescriptor... membersToFind) throws Exception {
  String rootBefore = getRoot() + "/before";
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk14());
  final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
  PsiClass psiClass = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
  assertNotNull(psiClass);
  final MemberInfo[] members = RefactoringTestUtil.findMembers(psiClass, membersToFind);
  doTest(members, newClassName, targetPackageName, rootDir, psiClass, conflicts);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ExtractSuperClassTest.java


示例17: testCloseableAutoCloseable

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
public void testCloseableAutoCloseable() {
  IdeaTestUtil.setModuleLanguageLevel(myJava7Module, LanguageLevel.JDK_1_7);
  ModuleRootModificationUtil.addDependency(myJava7Module, myJava3Module);
  final String name = getTestName(false);
  myFixture.copyFileToProject("java3/p/" + name + ".java");
  myFixture.configureByFiles("java7/p/" + name + ".java");
  myFixture.checkHighlighting();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MultipleJdksHighlightingTest.java


示例18: setUp

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).getLanguageLevel();
  LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
  IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TypeInference18Test.java


示例19: setUp

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  myJdk = IdeaTestUtil.getMockJdk17();

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable.getInstance().addJdk(myJdk);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AndroidFacetImporterTest.java


示例20: setUp

import com.intellij.testFramework.IdeaTestUtil; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  String root = PluginPathManager.getPluginHomePath("ui-designer") + "/testData/binding/" + getTestName(true);
  PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
  myTestProjectRoot = PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:FormEnumUsageTest.java



注:本文中的com.intellij.testFramework.IdeaTestUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VelocityView类代码示例发布时间:2022-05-23
下一篇:
Java DataItemAsset类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap