コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
    final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder =
        factory.createLightFixtureBuilder(getProjectDescriptor());

    final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
    final LightTempDirTestFixtureImpl tempDirTestFixture = new LightTempDirTestFixtureImpl(true);
    myFixture =
        IdeaTestFixtureFactory.getFixtureFactory()
            .createCodeInsightFixture(fixture, tempDirTestFixture);
    myFixture.setUp();

    setupFixtureWhenInitialized();
  }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    Runner.initLogger();
    myTempDirFixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
    myTempDirFixture.setUp();

    FileUtil.copyDir(PathManagerEx.findFileUnderCommunityHome("updater/testData"), getDataDir());

    boolean windowsLineEnds = new File(getDataDir(), "Readme.txt").length() == 7132;
    CHECKSUMS = new CheckSums(windowsLineEnds);
  }
コード例 #3
0
  @Before
  public void setUp() throws Throwable {
    IdeaTestApplication.getInstance();

    myTestName = createTestName();
    myProjectFixture =
        IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(myTestName).getFixture();

    edt(
        new ThrowableRunnable<Exception>() {
          @Override
          public void run() throws Exception {
            myProjectFixture.setUp();
          }
        });

    myProject = myProjectFixture.getProject();

    myProjectRoot = myProject.getBasePath();
    myProjectDir = myProject.getBaseDir();
    myTestRoot = myProjectRoot;

    myGit = ServiceManager.getService(myProject, Git.class);
    mySettings = GitVcsSettings.getInstance(myProject);
    mySettings.getAppSettings().setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE);

    // dynamic overriding is used instead of making it in plugin.xml,
    // because MockVcsHelper is not ready to be a full featured implementation for all tests.
    myVcsHelper =
        GitTestUtil.overrideService(myProject, AbstractVcsHelper.class, MockVcsHelper.class);
    myChangeListManager = ChangeListManagerImpl.getInstanceImpl(myProject);
    myNotificator = (TestVcsNotifier) ServiceManager.getService(myProject, VcsNotifier.class);
    myVcs = GitVcs.getInstance(myProject);
    myRepositoryManager = GitUtil.getRepositoryManager(myProject);

    virtualCommits = new GitTestVirtualCommitsHolder();
    myAsyncTasks = new ArrayList<>();

    cd(myProjectRoot);
    myRepository = GitTestUtil.createRepository(myProject, myProjectRoot);

    ProjectLevelVcsManagerImpl vcsManager =
        (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(myProject);
    AbstractVcs vcs = vcsManager.findVcsByName("Git");
    Assert.assertEquals(1, vcsManager.getRootsUnderVcs(vcs).length);

    GitTestUtil.assumeSupportedGitVersion(myVcs);
    LOG.info(getStartTestMarker());
  }
コード例 #4
0
  @Override
  public void setUp() throws Exception {
    super.setUp();
    final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder =
        IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());

    myFixture =
        JavaTestFixtureFactory.getFixtureFactory()
            .createCodeInsightFixture(projectBuilder.getFixture());
    final String dataPath = PathManagerEx.getTestDataPath() + "/codeInsight/externalAnnotations";
    myFixture.setTestDataPath(dataPath);
    final JavaModuleFixtureBuilder builder =
        projectBuilder.addModule(JavaModuleFixtureBuilder.class);
    builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);

    myFixture.setUp();
    myModule = builder.getFixture().getModule();
    myProject = myFixture.getProject();
  }
コード例 #5
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    myProjectFixture =
        IdeaTestFixtureFactory.getFixtureFactory()
            .createFixtureBuilder(getTestName(true))
            .getFixture();
    myProjectFixture.setUp();

    myProject = myProjectFixture.getProject();
    myProjectRoot = myProject.getBaseDir();
    cd(myProjectRoot);
    Module module = doCreateRealModuleIn("foo", myProject, EmptyModuleType.getInstance());
    myRootModel = ((ModuleRootManagerImpl) ModuleRootManager.getInstance(module)).getRootModel();
    mkdir(myRepositoryFolderName);
    myProjectRoot.refresh(false, true);
    myRepository = myProjectRoot.findChild(myRepositoryFolderName);
    myVcs = new MockAbstractVcs(myProject);
    myVcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(myProject);
    ExtensionPoint<VcsRootChecker> point = getExtensionPoint();
    myExtension =
        new VcsRootChecker() {
          @Override
          public VcsKey getSupportedVcs() {
            return myVcs.getKeyInstanceMethod();
          }

          @Override
          public boolean isRoot(@NotNull String path) {
            return new File(path, DOT_MOCK).exists();
          }

          @Override
          public boolean isVcsDir(@Nullable String path) {
            return path != null && path.toLowerCase().endsWith(DOT_MOCK);
          }
        };
    point.registerExtension(myExtension);
    myVcsManager.registerVcs(myVcs);
    myVcsName = myVcs.getName();
    myRepository.refresh(false, true);
  }
コード例 #6
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
    final TestFixtureBuilder<IdeaProjectTestFixture> builder =
        fixtureFactory.createFixtureBuilder(getName());

    myFixture = fixtureFactory.createCodeInsightFixture(builder.getFixture());
    myFixture.setTestDataPath(getTestDataPath());
    myFixture.setUp();

    final Project project = myFixture.getProject();

    new WriteCommandAction(project) {
      @Override
      protected void run(Result result) throws Throwable {
        FileTypeManager.getInstance()
            .registerFileType(RegExpFileType.INSTANCE, new String[] {"regexp"});
      }
    }.execute();
  }
コード例 #7
0
  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();
    }
  }