예제 #1
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));
  }
예제 #2
0
  /**
   * Tests that the EditStartersModel is parsed and that existing starters already present on the
   * project are initially selected.
   */
  @Test
  public void existingStartersSelected() throws Exception {
    IProject project = harness.createBootProject("foo", withStarters("web", "actuator"));
    ISpringBootProject bootProject = springBootCore.project(project);
    EditStartersModel wizard = createWizard(project);
    assertTrue(wizard.isSupported());

    assertEquals(bootProject.getBootVersion(), wizard.getBootVersion());
    assertStarterDeps(wizard.dependencies.getCurrentSelection(), "web", "actuator");
  }
예제 #3
0
  /** Tests that we are able to remove a starter. */
  @Test
  public void removeStarter() throws Exception {
    IProject project = harness.createBootProject("foo", withStarters("web", "actuator"));
    final ISpringBootProject bootProject = springBootCore.project(project);
    EditStartersModel wizard = createWizard(project);
    assertEquals(bootProject.getBootVersion(), wizard.getBootVersion());
    assertStarterDeps(wizard.dependencies.getCurrentSelection(), "web", "actuator");

    wizard.removeDependency("web");
    assertStarterDeps(wizard.dependencies.getCurrentSelection(), /* removed: "web",*/ "actuator");
    wizard.performOk();

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

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