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

Java TempDirTestFixture类代码示例

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

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



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

示例1: testNoGotoImplementationOutsideSourceRoot

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testNoGotoImplementationOutsideSourceRoot() throws Throwable {
  final TempDirTestFixture dirFixture = new TempDirTestFixtureImpl();
  dirFixture.setUp();

  new WriteCommandAction(getProject()) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      final VirtualFile outside = dirFixture.getFile("").createChildDirectory(this, "outside");
      PsiTestUtil.addContentRoot(myModule, outside);
      VirtualFile out = outside.createChildData(this, "Outside.groovy");
      VfsUtil.saveText(out, "class Bar {}\n class Goo extends Bar {}");
      PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    }
  }.execute();

  try {
    PsiFile inProject = myFixture.addFileToProject("Foo.groovy", "class <caret>Foo {}\n class Bar extends Foo {}");
    myFixture.configureFromExistingVirtualFile(inProject.getVirtualFile());

    final PsiElement[] impls = new GotoImplementationHandler().getSourceAndTargetElements(myFixture.getEditor(), inProject).targets;
    assertEquals(1, impls.length);
  }
  finally {
    dirFixture.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GroovyGotoImplementationTest.java


示例2: createCodeInsightFixture

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
protected CodeInsightTestFixture createCodeInsightFixture(final String relativeTestDataPath)
    throws Exception {
  final String testDataPath = new File(getTestDataPath(), relativeTestDataPath).getAbsolutePath();
  final CodeInsightTestFixture codeInsightFixture =
      JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(myProjectFixture);
  codeInsightFixture.setTestDataPath(testDataPath);
  final TempDirTestFixture tempDir = codeInsightFixture.getTempDirFixture();
  myModuleBuilder.addSourceContentRoot(tempDir.getTempDirPath());
  codeInsightFixture.setUp();
  final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByPath(testDataPath);
  Assert.assertNotNull("Test data directory not found: " + testDataPath, dir);
  VfsUtil.processFilesRecursively(dir, new CommonProcessors.CollectProcessor<VirtualFile>());
  dir.refresh(false, true);
  tempDir.copyAll(
      testDataPath,
      "",
      new VirtualFileFilter() {
        @Override
        public boolean accept(VirtualFile file) {
          return !file.getName().contains("_after");
        }
      });
  return codeInsightFixture;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:25,代码来源:AppEngineCodeInsightTestCase.java


示例3: testNoGotoImplementationOutsideSourceRoot

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testNoGotoImplementationOutsideSourceRoot() throws Throwable {
  final TempDirTestFixture dirFixture = new TempDirTestFixtureImpl();
  dirFixture.setUp();

  new WriteCommandAction(getProject()) {
    @Override
    protected void run(Result result) throws Throwable {
      final VirtualFile outside = dirFixture.getFile("").createChildDirectory(this, "outside");
      PsiTestUtil.addContentRoot(myModule, outside);
      VirtualFile out = outside.createChildData(this, "Outside.groovy");
      VfsUtil.saveText(out, "class Bar {}\n class Goo extends Bar {}");
    }
  }.execute();

  try {
    PsiFile inProject = myFixture.addFileToProject("Foo.groovy", "class <caret>Foo {}\n class Bar extends Foo {}");
    myFixture.configureFromExistingVirtualFile(inProject.getVirtualFile());

    final PsiElement[] impls = new GotoImplementationHandler().getSourceAndTargetElements(myFixture.getEditor(), inProject).targets;
    assertEquals(1, impls.length);
  }
  finally {
    dirFixture.tearDown();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:GroovyGotoImplementationTest.java


示例4: testSameSourceRoot

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testSameSourceRoot() throws Throwable {
  final TempDirTestFixture root1 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  final TempDirTestFixture root2 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();

  root1.setUp();
  root2.setUp();

  try {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(@NotNull Result result) throws Throwable {
        PsiTestUtil.addSourceContentToRoots(myModule, root1.getFile(""));
        PsiTestUtil.addSourceContentToRoots(myModule, root2.getFile(""));
      }
    }.execute();

    final VirtualFile file1 = root1.createFile("buy.txt", "");
    final VirtualFile file2 = root2.createFile("buy.txt", "");
    final VirtualFile ctx = root2.createFile("ctx.txt", "");

    final PsiProximityComparator comparator = new PsiProximityComparator(getPsiManager().findFile(ctx));
    assertTrue(comparator.compare(getPsiManager().findFile(file1), getPsiManager().findFile(file2)) > 0);
    assertTrue(comparator.compare(getPsiManager().findFile(file2), getPsiManager().findFile(file1)) < 0);
  }
  finally {
    root1.tearDown();
    root2.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ProximityTest.java


示例5: testLocalScopeSearchPerformance

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testLocalScopeSearchPerformance() throws Exception {
  final int fileCount = 3000;
  final int lineCount = 500;
  TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
  fixture.setUp();

  try {
    String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount);
    for (int i = 0; i < fileCount; i++) {
      fixture.createFile("a" + i + ".txt", sampleText);
    }
    PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));

    VirtualFile file = fixture.createFile("target.txt", sampleText);
    PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
    assertNotNull(psiFile);
    final FindModel findModel = new FindModel();
    findModel.setStringToFind("TargetWord");
    findModel.setWholeWordsOnly(true);
    findModel.setFromCursor(false);
    findModel.setGlobal(true);
    findModel.setMultipleFiles(true);
    findModel.setCustomScope(true);

    ThrowableRunnable test = () -> assertSize(lineCount, findUsages(findModel));

    findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
    PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();

    findModel.setCustomScope(new LocalSearchScope(psiFile));
    PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
  }
  finally {
    fixture.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:FindManagerTest.java


示例6: testFindInCurrentFileOutsideProject

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testFindInCurrentFileOutsideProject() throws Exception {
  final TempDirTestFixture tempDirFixture = new TempDirTestFixtureImpl();
  tempDirFixture.setUp();
  try {
    VirtualFile file = tempDirFixture.createFile("a.txt", "foo bar foo");
    FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
    findModel.setWholeWordsOnly(true);
    findModel.setCustomScope(true);
    findModel.setCustomScope(new LocalSearchScope(PsiManager.getInstance(myProject).findFile(file)));
    assertSize(2, findUsages(findModel));
  }
  finally {
    tempDirFixture.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FindManagerTest.java


示例7: testFindInDirectoryOutsideProject

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testFindInDirectoryOutsideProject() throws Exception {
  final TempDirTestFixture tempDirFixture = new TempDirTestFixtureImpl();
  tempDirFixture.setUp();
  try {
    tempDirFixture.createFile("a.txt", "foo bar foo");
    FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
    findModel.setWholeWordsOnly(true);
    findModel.setProjectScope(false);
    findModel.setDirectoryName(tempDirFixture.getFile("").getPath());
    assertSize(2, findUsages(findModel));
  }
  finally {
    tempDirFixture.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FindManagerTest.java


示例8: create

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
/**
 * Creates a new Mercurial repository in a new temporary test directory.
 * @param test reference to the test case instance.
 * @return created repository.
 */
public static HgTestRepository create(HgTest test) throws Exception {
  final TempDirTestFixture dirFixture = createFixtureDir();
  final File repo = new File(dirFixture.getTempDirPath());
  final ProcessOutput processOutput = test.runHg(repo, "init");
  AbstractVcsTestCase.verify(processOutput);
  return new HgTestRepository(test, dirFixture);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:HgTestRepository.java


示例9: cloneRepository

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
/**
 * Clones a repository from this one. New repository is located in a new temporary test directory.
 * @return New repository cloned from this one.
 */
public HgTestRepository cloneRepository() throws Exception {
  final TempDirTestFixture dirFixture = createFixtureDir();
  final ProcessOutput processOutput = myTest.runHg(null, "clone", getDirFixture().getTempDirPath(), dirFixture.getTempDirPath());
  AbstractVcsTestCase.verify(processOutput);
  return new HgTestRepository(myTest, dirFixture);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:HgTestRepository.java


示例10: testSameSourceRoot

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testSameSourceRoot() throws Throwable {
  final TempDirTestFixture root1 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  final TempDirTestFixture root2 = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();

  root1.setUp();
  root2.setUp();

  try {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(Result result) throws Throwable {
        PsiTestUtil.addSourceContentToRoots(myModule, root1.getFile(""));
        PsiTestUtil.addSourceContentToRoots(myModule, root2.getFile(""));
      }
    }.execute();

    final VirtualFile file1 = root1.createFile("buy.txt", "");
    final VirtualFile file2 = root2.createFile("buy.txt", "");
    final VirtualFile ctx = root2.createFile("ctx.txt", "");

    final PsiProximityComparator comparator = new PsiProximityComparator(getPsiManager().findFile(ctx));
    assertTrue(comparator.compare(getPsiManager().findFile(file1), getPsiManager().findFile(file2)) > 0);
    assertTrue(comparator.compare(getPsiManager().findFile(file2), getPsiManager().findFile(file1)) < 0);
  }
  finally {
    root1.tearDown();
    root2.tearDown();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:ProximityTest.java


示例11: testLocalScopeSearchPerformance

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testLocalScopeSearchPerformance() throws Throwable {
  final int fileCount = 3000;
  final int lineCount = 500;
  TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
  fixture.setUp();

  try {
    String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount);
    for (int i = 0; i < fileCount; i++) {
      fixture.createFile("a" + i + ".txt", sampleText);
    }
    PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));

    VirtualFile file = fixture.createFile("target.txt", sampleText);
    PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
    final FindModel findModel = new FindModel();
    findModel.setStringToFind("TargetWord");
    findModel.setWholeWordsOnly(true);
    findModel.setFromCursor(false);
    findModel.setGlobal(true);
    findModel.setMultipleFiles(true);

    ThrowableRunnable test = new ThrowableRunnable() {
      @Override
      public void run() throws Throwable {
        assertSize(lineCount, findUsages(findModel));
      }
    };

    findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
    PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();

    findModel.setCustomScope(new LocalSearchScope(psiFile));
    PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
  }
  finally {
    fixture.tearDown();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:FindManagerTest.java


示例12: ImportProjectTestFixture

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public ImportProjectTestFixture(String projectDirectoryPath, String projectFileName, TempDirTestFixture tempDirTestFixture) {
  this.projectFileName = projectFileName;
  this.tempDirTestFixture = tempDirTestFixture;
  this.projectDirectoryPath = projectDirectoryPath;
}
 
开发者ID:seanhenry,项目名称:TearDownGenerator,代码行数:6,代码来源:ImportProjectTestFixture.java


示例13: JavaCodeInsightTestFixtureImpl

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public JavaCodeInsightTestFixtureImpl(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirFixture) {
  super(projectFixture, tempDirFixture);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaCodeInsightTestFixtureImpl.java


示例14: testNonCodeClassUsages

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testNonCodeClassUsages() throws Exception {
  final TempDirTestFixture tdf = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  tdf.setUp();

  try {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(@NotNull Result result) throws Throwable {
        final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
        moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
        moduleModel.commit();

        tdf.createFile("plugin.xml", "<document>\n" +
                                     "  <action class=\"com.Foo\" />\n" +
                                     "  <action class=\"com.Foo.Bar\" />\n" +
                                     "  <action class=\"com.Foo$Bar\" />\n" +
                                     "</document>");

        PsiTestUtil.addContentRoot(ModuleManager.getInstance(getProject()).findModuleByName("independent"), tdf.getFile(""));
      }
    }.execute();

    GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    PsiClass foo = myJavaFacade.findClass("com.Foo", scope);
    PsiClass bar = myJavaFacade.findClass("com.Foo.Bar", scope);

    final int[] count = {0};
    Processor<UsageInfo> processor = new Processor<UsageInfo>() {
      @Override
      public boolean process(UsageInfo usageInfo) {
        int navigationOffset = usageInfo.getNavigationOffset();
        assertTrue(navigationOffset > 0);
        String textAfter = usageInfo.getFile().getText().substring(navigationOffset);
        assertTrue(textAfter, textAfter.startsWith("Foo") || textAfter.startsWith("Bar") ||
                              textAfter.startsWith("com.Foo.Bar") // sorry, can't get references with dollar-dot mismatch to work now
        );
        count[0]++;
        return true;
      }
    };
    JavaFindUsagesHandler handler = new JavaFindUsagesHandler(bar, JavaFindUsagesHandlerFactory.getInstance(getProject()));

    count[0] = 0;
    handler.processUsagesInText(foo, processor, scope);
    assertEquals(3, count[0]);

    count[0] = 0;
    handler.processUsagesInText(bar, processor, scope);
    assertEquals(2, count[0]);
  }
  finally {
    tdf.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:FindUsagesTest.java


示例15: HgTestRepository

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public HgTestRepository(@NotNull HgTest test, @NotNull TempDirTestFixture dir) {
  this(test, dir, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:HgTestRepository.java


示例16: createFixtureDir

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
private static TempDirTestFixture createFixtureDir() throws Exception {
  final TempDirTestFixture fixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  fixture.setUp();
  return fixture;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:HgTestRepository.java


示例17: getDirFixture

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
@NotNull
public TempDirTestFixture getDirFixture() {
  return myDirFixture;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:HgTestRepository.java


示例18: TestFileSystem

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public TestFileSystem(Project project, TempDirTestFixture tempDirTestFixture) {
  this.project = project;
  this.tempDirTestFixture = tempDirTestFixture;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:5,代码来源:TestFileSystem.java


示例19: testNonCodeClassUsages

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
public void testNonCodeClassUsages() throws Exception {
  final TempDirTestFixture tdf = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  tdf.setUp();

  try {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(Result result) throws Throwable {
        final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
        moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
        moduleModel.commit();

        tdf.createFile("plugin.xml", "<document>\n" +
                                     "  <action class=\"com.Foo\" />\n" +
                                     "  <action class=\"com.Foo.Bar\" />\n" +
                                     "  <action class=\"com.Foo$Bar\" />\n" +
                                     "</document>");

        PsiTestUtil.addContentRoot(ModuleManager.getInstance(getProject()).findModuleByName("independent"), tdf.getFile(""));
      }
    }.execute();

    GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    PsiClass foo = myJavaFacade.findClass("com.Foo", scope);
    PsiClass bar = myJavaFacade.findClass("com.Foo.Bar", scope);

    final int[] count = {0};
    Processor<UsageInfo> processor = new Processor<UsageInfo>() {
      @Override
      public boolean process(UsageInfo usageInfo) {
        int navigationOffset = usageInfo.getNavigationOffset();
        assertTrue(navigationOffset > 0);
        String textAfter = usageInfo.getFile().getText().substring(navigationOffset);
        assertTrue(textAfter, textAfter.startsWith("Foo") || textAfter.startsWith("Bar") ||
                              textAfter.startsWith("com.Foo.Bar") // sorry, can't get references with dollar-dot mismatch to work now
        );
        count[0]++;
        return true;
      }
    };
    JavaFindUsagesHandler handler = new JavaFindUsagesHandler(bar, JavaFindUsagesHandlerFactory.getInstance(getProject()));

    count[0] = 0;
    handler.processUsagesInText(foo, processor, scope);
    assertEquals(3, count[0]);

    count[0] = 0;
    handler.processUsagesInText(bar, processor, scope);
    assertEquals(2, count[0]);
  }
  finally {
    tdf.tearDown();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:55,代码来源:FindUsagesTest.java


示例20: createCodeInsightFixture

import com.intellij.testFramework.fixtures.TempDirTestFixture; //导入依赖的package包/类
@Override
public JavaCodeInsightTestFixture createCodeInsightFixture(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirFixture) {
  return new JavaCodeInsightTestFixtureImpl(projectFixture, tempDirFixture);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:5,代码来源:JavaTestFixtureFactoryImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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