Ejemplo n.º 1
0
  @Test
  public void shareProjectAndCreateRepo() throws Exception {
    createProject(projectName0);
    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName0);
    existingOrNewPage.setInternalMode(true);

    // initial state
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    String projectPath = workspace.getRoot().getProject(projectName0).getLocation().toOSString();

    existingOrNewPage.assertContents(false, projectName0, projectPath, "", "");
    existingOrNewPage.assertEnabling(false, false, false);

    // select project
    bot.tree().getTreeItem(projectName0).select();
    existingOrNewPage.assertContents(false, projectName0, projectPath, "", projectPath);
    existingOrNewPage.assertEnabling(true, true, false);

    // create repository
    bot.button("Create Repository").click();

    String repopath =
        workspace
            .getRoot()
            .getProject(projectName0)
            .getLocation()
            .append(Constants.DOT_GIT)
            .toOSString();
    existingOrNewPage.assertContents(true, projectName0, projectPath, ".git", "");
    existingOrNewPage.assertEnabling(false, false, true);

    assertTrue((new File(repopath)).exists());

    // share project
    bot.button("Finish").click();
    Thread.sleep(1000);
    assertEquals(
        "org.eclipse.egit.core.GitProvider",
        workspace
            .getRoot()
            .getProject(projectName0)
            .getPersistentProperty(new QualifiedName("org.eclipse.team.core", "repository")));
  }
Ejemplo n.º 2
0
  @Test
  public void shareProjectWithAlreadyCreatedRepos()
      throws IOException, InterruptedException, JGitInternalException, GitAPIException {
    Repository repo1 =
        FileRepositoryBuilder.create(
            new File(new File(createProject(projectName1)).getParent(), ".git"));
    repo1.create();
    repo1.close();
    Repository repo2 = FileRepositoryBuilder.create(new File(createProject(projectName2), ".git"));
    repo2.create();
    repo2.close();
    Repository repo3 = FileRepositoryBuilder.create(new File(createProject(projectName3), ".git"));
    repo3.create();
    Git git = new Git(repo3);
    git.add().addFilepattern(".").call();
    git.commit()
        .setAuthor("A U Thior", "*****@*****.**")
        .setMessage("Created Project 3")
        .call();
    repo3.close();

    ExistingOrNewPage existingOrNewPage =
        sharingWizard.openWizard(projectName1, projectName2, projectName3);
    existingOrNewPage.setInternalMode(true);

    // initial state
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    String projectPath1 = workspace.getRoot().getProject(projectName1).getLocation().toOSString();
    String projectPath2 = workspace.getRoot().getProject(projectName2).getLocation().toOSString();
    String projectPath3 = workspace.getRoot().getProject(projectName3).getLocation().toOSString();
    existingOrNewPage.assertContents(
        new Row[] {
          new Row(true, projectName1, projectPath1, ".." + File.separator + ".git"),
          new Row(
              false,
              projectName2,
              projectPath2,
              "",
              new Row[] {
                new Row(false, ".", "", ".git"),
                new Row(false, "..", "", ".." + File.separator + ".git")
              }),
          new Row(
              false,
              projectName3,
              projectPath3,
              "",
              new Row[] {
                new Row(true, ".", "", ".git"),
                new Row(false, "..", "", ".." + File.separator + ".git")
              })
        },
        "");

    bot.tree().getAllItems()[1].getItems()[0].check();
    existingOrNewPage.assertEnabling(false, false, true);
    bot.button("Finish").click();
    Thread.sleep(1000);
    assertEquals(
        repo1.getDirectory().getAbsolutePath(),
        RepositoryMapping.getMapping(workspace.getRoot().getProject(projectName1))
            .getRepository()
            .getDirectory()
            .toString());
    assertEquals(
        repo2.getDirectory().getAbsolutePath(),
        RepositoryMapping.getMapping(workspace.getRoot().getProject(projectName2))
            .getRepository()
            .getDirectory()
            .toString());
  }