Examples of TestProject


Examples of org.eclipse.egit.core.test.TestProject

  }

  @Test
  public void getFileForLocationShouldNotUseFilesWithoutRepositoryMapping()
      throws Exception {
    TestProject nested = new TestProject(true, "Project-1/Project-0");
    IFile file = nested.createFile("a.txt", new byte[] {});
    IPath location = file.getLocation();

    IFile result = ResourceUtil.getFileForLocation(location);
    assertThat(result, notNullValue());
    assertTrue("Returned IFile should exist", result.exists());
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

    assertEquals("Project-1", p.getDescription().getName());
  }

  @Test
  public void testGetProjectsContains() throws Exception {
    TestProject prj2 = new TestProject(true, "Project-1-sub");

    try {
      repository.createFile(project.getProject(), "xxx");
      repository.createFile(project.getProject(), "zzz");
      repository.createFile(prj2.getProject(), "zzz");

      project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
      prj2.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);

      IProject[] projectsContaining = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-1/xxx"));
      IProject[] projectsEmpty = ProjectUtil.getProjectsContaining(
          repository.getRepository(), Collections.singleton("yyy"));
      IProject[] projectSelf = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-1"));
      Set<String> files = new TreeSet<String>();
      files.add("Project-1/xxx");
      files.add("Project-1/zzz");
      IProject[] multiFile = ProjectUtil.getProjectsContaining(
          repository.getRepository(), files);

      files.clear();
      files.add("Project-1/xxx");
      files.add("Project-1-sub/zzz");
      IProject[] multiProject = ProjectUtil.getProjectsContaining(
          repository.getRepository(), files);
      IProject[] nonExistProject = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-2"));

      assertEquals(1, projectsContaining.length);
      assertEquals(0, projectsEmpty.length);
      assertEquals(1, projectSelf.length);
      assertEquals(1, multiFile.length);
      assertEquals(2, multiProject.length);
      assertEquals(0, nonExistProject.length);

      IProject p = projectsContaining[0];
      assertEquals("Project-1", p.getDescription().getName());
    } finally {
      prj2.dispose();
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

    }
  }

  @Test
  public void testGetNestedProjectsContains() throws Exception {
    TestProject prj2 = new TestProject(true, "Project-1/dir/Project-1-sub");

    try {
      repository.createFile(project.getProject(), "xxx");
      repository.createFile(project.getProject(), "zzz");
      repository.createFile(prj2.getProject(), "zzz");

      project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
      prj2.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);

      IProject[] projectsContaining = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-1/xxx"));
      IProject[] projectsEmpty = ProjectUtil.getProjectsContaining(
          repository.getRepository(), Collections.singleton("yyy"));
      IProject[] projectSelf = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-1"));
      Set<String> files = new TreeSet<String>();
      files.add("Project-1/xxx");
      files.add("Project-1/zzz");
      IProject[] multiFile = ProjectUtil.getProjectsContaining(
          repository.getRepository(), files);

      files.clear();
      files.add("Project-1/dir/Project-1-sub/zzz");
      files.add("Project-1/xxx");
      IProject[] multiProject = ProjectUtil.getProjectsContaining(
          repository.getRepository(), files);
      IProject[] nonExistProject = ProjectUtil.getProjectsContaining(
          repository.getRepository(),
          Collections.singleton("Project-2"));

      assertEquals(1, projectsContaining.length);
      assertEquals(0, projectsEmpty.length);
      assertEquals(1, projectSelf.length);
      assertEquals(1, multiFile.length);
      assertEquals(2, multiProject.length);
      assertEquals(0, nonExistProject.length);

      IProject p = projectsContaining[0];
      assertEquals("Project-1", p.getDescription().getName());
    } finally {
      prj2.dispose();
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

        new NullProgressMonitor()));
  }

  @Test
  public void testFindProjectFilesNested() throws Exception {
    project2 = new TestProject(true, "Project-1/Project-Nested");
    File workingDir = gitDir.getParentFile();

    Collection<File> nestedResult = new ArrayList<File>();
    boolean nestedFound = ProjectUtil.findProjectFiles(nestedResult,
        workingDir, true,
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

        .getLocationURI().getPath(), Constants.DOT_GIT);
    testRepo = new TestRepository(gitDir);
    testRepo.connect(project.getProject());
    testRepo.commit("initial commit");

    project2 = new TestProject(true, "Project-2");
    gitDir2 = new File(project2.getProject()
        .getLocationURI().getPath(), Constants.DOT_GIT);
    testRepo2 = new TestRepository(gitDir2);
    testRepo2.connect(project2.getProject());
    testRepo2.commit("initial commit repo 2");
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

  @Test
  public void testResourceCompare() throws Exception {
    // we just want to test that we can call the JFace resource name
    // comparator which itself is tested by JFace
    TestProject p = new TestProject();
    p.createFolder("test");
    IFile f1 = p.createFile("test/z.txt", "z".getBytes("UTF-8"));
    IFile f2 = p.createFile("test/d.txt", "d".getBytes("UTF-8"));
    IFile f3 = p.createFile("test/a.txt", "a".getBytes("UTF-8"));
    List<IResource> expected = Arrays
        .asList(new IResource[] { f3, f2,
        f1 });
    List<IResource> tmp = new ArrayList<IResource>(expected);
    Collections.shuffle(tmp, new Random(1));
    Collections.sort(tmp, CommonUtils.RESOURCE_NAME_COMPARATOR);
    assertEquals(expected, tmp);

    // Clean up our mess
    IProgressMonitor monitor = new NullProgressMonitor();
    f1.delete(false, monitor);
    f2.delete(false, monitor);
    f3.delete(false, monitor);
    p.getProject().getFolder("test").delete(false, monitor);
    p.getProject().delete(false, monitor);
  }
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

  }

  @Test
  public void testGitFileHistorySingleProjectOk() throws Exception {
    IProgressMonitor progress = new NullProgressMonitor();
    TestProject singleRepoProject = new TestProject(true, "Project-2");
    IProject proj = singleRepoProject.getProject();
    File singleProjectGitDir = new File(proj.getLocation().toFile(), Constants.DOT_GIT);
    if (singleProjectGitDir.exists())
      FileUtils.delete(singleProjectGitDir, FileUtils.RECURSIVE | FileUtils.RETRY);

    Repository singleProjectRepo = FileRepositoryBuilder
        .create(singleProjectGitDir);
    singleProjectRepo.create();

    // Repository must be mapped in order to test the GitFileHistory
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(singleProjectGitDir);
    ConnectProviderOperation connectOp = new ConnectProviderOperation(proj, singleProjectGitDir);
    connectOp.execute(progress);

    try {
      IFile file = proj.getFile("file");
      file.create(new ByteArrayInputStream("data".getBytes("UTF-8")), 0,
          progress);
      Git git = new Git(singleProjectRepo);
      git.add().addFilepattern(".").call();
      RevCommit commit = git.commit().setAuthor("JUnit", "junit@jgit.org").setAll(true).setMessage("First commit").call();

      GitFileHistoryProvider fhProvider = new GitFileHistoryProvider();
      IFileHistory fh = fhProvider.getFileHistoryFor(singleRepoProject.getProject(), 0, null);
      assertNotNull(fh);
      assertEquals(fh.getFileRevisions().length, 1);
      assertNotNull(fh.getFileRevision(commit.getId().getName()));
    } finally {
      DisconnectProviderOperation disconnectOp = new DisconnectProviderOperation(Collections.singletonList(proj));
      disconnectOp.execute(progress);
      Activator.getDefault().getRepositoryUtil().removeDir(singleProjectGitDir);
      singleProjectRepo.close();
      singleRepoProject.dispose();
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

   */
  @Test
  public void shouldReturnTwoRoots() throws Exception {
    // when
    // create second project
    TestProject secondProject = new TestProject(true, "Project-2");
    try {
      IProject secondIProject = secondProject.project;
      // add connect project with repository
      new ConnectProviderOperation(secondIProject, gitDir).execute(null);
      new Git(repo).commit().setAuthor("JUnit", "junit@egit.org")
          .setMessage("Initial commit").call();
      GitSynchronizeData data = new GitSynchronizeData(repo, HEAD, HEAD,
          false);
      GitSynchronizeDataSet dataSet = new GitSynchronizeDataSet(data);

      // given
      GitResourceVariantTree grvt = new GitTestResourceVariantTree(dataSet,
          null, null);

      // then
      IResource[] roots = grvt.roots();
      // sort in order to be able to assert the project instances
      Arrays.sort(roots, new Comparator<IResource>() {
        public int compare(IResource r1, IResource r2) {
          String path1 = r1.getFullPath().toString();
          String path2 = r2.getFullPath().toString();
          return path1.compareTo(path2);
        }
      });
      assertEquals(2, roots.length);
      IResource actualProject = roots[0];
      assertEquals(this.project.project, actualProject);
      IResource actualProject1 = roots[1];
      assertEquals(secondIProject, actualProject1);
    } finally {
      secondProject.dispose();
    }
  }
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

  @Test
  public void testComputeWorkspacePathRepoAboveProject() throws Exception {
    testRepository.disconnect(project.getProject());

    // new setup
    project = new TestProject(true, "repo/bundles/Project-1", true, null);
    File repo = new File(project.getProject().getLocationURI().getPath())
        .getParentFile().getParentFile();
    gitDir = new File(repo, Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());
View Full Code Here

Examples of org.eclipse.egit.core.test.TestProject

  }

  @Test
  public void getFileForLocationShouldReturnExistingFileInCaseOfNestedProject()
      throws Exception {
    TestProject nested = new TestProject(true, "Project-1/Project-0");
    connect(nested.getProject());
    IFile file = nested.createFile("a.txt", new byte[] {});
    IPath location = file.getLocation();

    IFile result = ResourceUtil.getFileForLocation(location);
    assertThat(result, notNullValue());
    assertTrue("Returned IFile should exist", result.exists());
    assertThat(result.getProject(), is(nested.getProject()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.