Ejemplo n.º 1
0
  @Test
  public void shareProjectWithExternalRepo() throws Exception {
    String repoName = "ExternalRepositoryForShare";
    createProject(projectName0);
    String location1 = createProject(projectName1);
    String location2 = createProject(projectName2);
    createProject(projectName3);

    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName1, projectName2);
    SWTBotShell createRepoDialog = existingOrNewPage.clickCreateRepository();
    String repoDir =
        Activator.getDefault().getPreferenceStore().getString(UIPreferences.DEFAULT_REPO_DIR);
    File repoFolder = new File(repoDir, repoName);
    createRepoDialog
        .bot()
        .textWithLabel(UIText.CreateRepositoryPage_DirectoryLabel)
        .setText(repoFolder.getAbsolutePath());
    createRepoDialog.bot().button(IDialogConstants.FINISH_LABEL).click();

    SWTBotCombo combo = bot.comboBoxWithLabel(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    assertTrue(combo.getText().startsWith(repoName));
    Repository targetRepo = lookupRepository(new File(repoFolder, Constants.DOT_GIT));

    assertTrue(combo.getText().endsWith(targetRepo.getDirectory().getPath()));
    assertEquals(
        targetRepo.getWorkTree().getPath(),
        bot.textWithLabel(UIText.ExistingOrNewPage_WorkingDirectoryLabel).getText());
    String[][] contents = new String[2][3];
    contents[0][0] = projectName1;
    contents[0][1] = new Path(location1).toString();
    contents[0][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName1).toString();

    contents[1][0] = projectName2;
    contents[1][1] = new Path(location2).toString();
    contents[1][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);

    existingOrNewPage.setRelativePath("a/b");

    contents[0][2] =
        new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName1).toString();
    contents[1][2] =
        new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);

    bot.button(IDialogConstants.FINISH_LABEL).click();
    Thread.sleep(1000);
    String location1Path =
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName1).getLocation().toString();
    assertEquals(contents[0][2], location1Path);
    String location2Path =
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName2).getLocation().toString();
    assertEquals(contents[1][2], location2Path);
  }
Ejemplo n.º 2
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.º 3
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());
  }