Ejemplo n.º 1
0
  @Test
  public void addDependencyWithRepo() throws Exception {
    // This test uses more 'controlled' parameters:
    String bootVersion = BOOT_1_3_X_RELEASE;
    IProject project =
        harness.createBootProject(
            "foo",
            bootVersion(bootVersion), // boot version fixed
            withStarters("web"));

    initializr.setInputs(
        "sample-with-fakes"); // must use 'fake' data because the situation we are after doesn't
                              // exist in the real data

    EditStartersModel wizard = createWizard(project);
    wizard.addDependency("fake-dep");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);

    // !!! fake data may not produce a project that builds without
    // !!! problem so don't check for build errors in this test

    IDOMDocument pom = parsePom(project);

    // check the dependency got added to the pom
    assertNotNull(findDependency(pom, new MavenId("org.springframework.fake", "spring-fake-dep")));

    // check that just the expected repo got added
    assertNotNull(getRepo(pom, "spring-milestones"));
    assertNull(getRepo(pom, "spring-snapshots"));
    assertRepoCount(1, pom);
  }
Ejemplo n.º 2
0
  /** Tests that we are able to add a basic starter. */
  @Test
  public void addStarter() throws Exception {
    IProject project = harness.createBootProject("foo", withStarters("web"));
    final ISpringBootProject bootProject = springBootCore.project(project);
    EditStartersModel wizard = createWizard(project);
    assertEquals(bootProject.getBootVersion(), wizard.getBootVersion());
    assertStarterDeps(wizard.dependencies.getCurrentSelection(), "web");

    PopularityTracker popularities = new PopularityTracker(prefs);
    assertUsageCounts(bootProject, popularities /*none*/);

    wizard.addDependency("actuator");
    assertStarterDeps(wizard.dependencies.getCurrentSelection(), "web", "actuator");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);

    assertUsageCounts(bootProject, popularities, "actuator:1");

    StsTestUtil.assertNoErrors(project); // force project build

    assertStarters(bootProject.getBootStarters(), "web", "actuator");

    // check that the 'scope' is not set in the pom.xml:
    IDOMDocument pom = parsePom(project);

    Element depEl = findDependency(bootProject, pom, "actuator");
    assertEquals("org.springframework.boot", getGroupId(depEl));
    assertEquals("spring-boot-starter-actuator", getArtifactId(depEl));
    assertEquals(null, getScope(depEl));
  }
Ejemplo n.º 3
0
  @Test
  public void addMultipleStartersWithSameBom() throws Exception {
    // This test uses more 'controlled' parameters:
    IProject project =
        harness.createBootProject(
            "foo",
            bootVersion(BOOT_1_3_X_RELEASE), // boot version fixed
            withStarters("web"));
    initializr.setInputs("sample"); // sample intializr json captured for this version
    final ISpringBootProject bootProject = springBootCore.project(project);
    int initialBomCount = getBomCount(parsePom(project));

    EditStartersModel wizard = createWizard(project);
    wizard.addDependency("cloud-eureka");
    wizard.addDependency("cloud-config-client");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);
    StsTestUtil.assertNoErrors(project); // force project build

    assertStarters(bootProject.getBootStarters(), "web", "cloud-eureka", "cloud-config-client");

    IDOMDocument pom = parsePom(project);
    int finalBomCount = getBomCount(pom);
    assertEquals(initialBomCount + 1, finalBomCount);

    // check that both repos got added
    assertRepoCount(2, pom);

    Element repo = getRepo(pom, "spring-snapshots");
    assertNotNull(repo);
    assertEquals("Spring Snapshots", getTextChild(repo, "name"));
    assertEquals("https://repo.spring.io/snapshot", getTextChild(repo, "url"));
    assertEquals("true", getSnapshotsEnabled(repo));

    repo = getRepo(pom, "spring-milestones");
    assertNotNull(repo);
    assertEquals("Spring Milestones", getTextChild(repo, "name"));
    assertEquals("https://repo.spring.io/milestone", getTextChild(repo, "url"));
    assertEquals("false", getSnapshotsEnabled(repo));
  }
Ejemplo n.º 4
0
  @Test
  public void addMultipleStartersWithDifferentBom() throws Exception {
    // This test uses more 'controlled' parameters:
    IProject project =
        harness.createBootProject(
            "foo",
            bootVersion(BOOT_1_3_X_RELEASE), // boot version fixed
            withStarters("web"));
    initializr.setInputs("sample"); // sample intializr json captured for this version
    final ISpringBootProject bootProject = springBootCore.project(project);
    int initialBomCount = getBomCount(parsePom(project));

    EditStartersModel wizard = createWizard(project);
    wizard.addDependency("cloud-eureka");
    wizard.addDependency("vaadin");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);
    StsTestUtil.assertNoErrors(project); // force project build

    assertStarters(bootProject.getBootStarters(), "web", "cloud-eureka", "vaadin");

    IDOMDocument pom = parsePom(project);
    int finalBomCount = getBomCount(pom);
    assertEquals(initialBomCount + 2, finalBomCount);
    {
      Element bom = getBom(pom, "spring-cloud-starter-parent");
      assertEquals("org.springframework.cloud", getTextChild(bom, GROUP_ID));
      assertEquals("Brixton.M3", getTextChild(bom, VERSION));
      assertEquals("pom", getTextChild(bom, TYPE));
      assertEquals("import", getTextChild(bom, SCOPE));
    }
    {
      Element bom = getBom(pom, "vaadin-bom");
      assertEquals("com.vaadin", getTextChild(bom, GROUP_ID));
      assertEquals("7.5.5", getTextChild(bom, VERSION));
      assertEquals("pom", getTextChild(bom, TYPE));
      assertEquals("import", getTextChild(bom, SCOPE));
    }
  }
Ejemplo n.º 5
0
  @Test
  public void addStarterWithBom() throws Exception {
    // We'll be adding this starter:
    //	      "id": "cloud-eureka",
    //	      "groupId": "org.springframework.cloud",
    //	      "artifactId": "spring-cloud-starter-eureka",
    //	      "scope": "compile",
    //	      "bom": "cloud-bom"

    IProject project = harness.createBootProject("foo", withStarters("web"));
    final ISpringBootProject bootProject = springBootCore.project(project);
    EditStartersModel wizard = createWizard(project);
    wizard.addDependency("cloud-eureka");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);
    StsTestUtil.assertNoErrors(project); // force project build

    assertStarters(bootProject.getBootStarters(), "web", "cloud-eureka");
  }
Ejemplo n.º 6
0
  @Test
  public void addStarterWithTestScope() throws Exception {
    IProject project = harness.createBootProject("foo", withStarters("web"));
    final ISpringBootProject bootProject = springBootCore.project(project);
    EditStartersModel wizard = createWizard(project);
    wizard.addDependency("restdocs");
    wizard.performOk();

    Job.getJobManager().join(EditStartersModel.JOB_FAMILY, null);

    StsTestUtil.assertNoErrors(project); // force project build

    assertStarters(bootProject.getBootStarters(), "web", "restdocs");

    // check that the 'scope' is set properly
    IDOMDocument pom = parsePom(project);
    Element depEl = findDependency(bootProject, pom, "restdocs");
    assertEquals("spring-restdocs-mockmvc", getArtifactId(depEl));
    assertEquals("test", getScope(depEl));
  }