@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); }
@Test public void serviceUnavailable() throws Exception { String bootVersion = BOOT_1_3_X_RELEASE; IProject project = harness.createBootProject( "foo", bootVersion(bootVersion), // boot version fixed withStarters("web")); initializr.makeUnavailable(); EditStartersModel wizard = createWizard(project); assertFalse(wizard.isSupported()); }
@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)); }
@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)); } }