Significant Java 8 updates and Spring Boot integration.
Moved to Spring Boot 1.3 and leverage the new configuration properties mechanism (see GitProperties and IoProperties). Improved ArtifactVersion to be a better value object. Introduced usage of Java 8's CompletableFuture to execute most of the Git operations in parallel. Started to use Lambdas where possible. Git configuration is now supposed to be done using a application-local.properties (Git ignored) file containing the relevant properties (see readme). The test configuration now uses a separate workspace location and a Sample release train to make sure the integration tests run without interfering a local workspace. Added train declaration for Hopper. Integrated BootShim (see [0], [1]) to run the shell on top of Spring Boot. [0] https://github.com/jeffellin/springshellwithboot [1] https://github.com/spring-projects/spring-shell/issues/34
This commit is contained in:
@@ -16,14 +16,14 @@
|
||||
package org.springframework.data.release;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ActiveProfiles({ "test", "local" })
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = TestConfig.class)
|
||||
public abstract class AbstractIntegrationTests {
|
||||
|
||||
}
|
||||
@SpringApplicationConfiguration(classes = Application.class)
|
||||
public abstract class AbstractIntegrationTests {}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ArtifactUnitTests {
|
||||
Artifact artifact = new Artifact(ReleaseTrains.DIJKSTRA.getModuleIteration(Iteration.M1, "JPA"));
|
||||
|
||||
assertThat(artifact.getArtifactId(), is("spring-data-jpa"));
|
||||
assertThat(artifact.getVersion(), is(ArtifactVersion.parse("1.6.0.M1")));
|
||||
assertThat(artifact.getNextDevelopmentVersion(), is(ArtifactVersion.parse("1.6.0.BUILD-SNAPSHOT")));
|
||||
assertThat(artifact.getVersion(), is(ArtifactVersion.of("1.6.0.M1")));
|
||||
assertThat(artifact.getNextDevelopmentVersion(), is(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ public class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests {
|
||||
@Test
|
||||
public void predictsReleaseTrainCorrectly() throws Exception {
|
||||
|
||||
git.update(ReleaseTrains.DIJKSTRA);
|
||||
git.update(ReleaseTrains.GOSLING);
|
||||
|
||||
assertThat(releaseCommands.predictTrainAndIteration(), is("Dijkstra"));
|
||||
assertThat(releaseCommands.predictTrainAndIteration(), is("Gosling"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ public class BranchUnitTests {
|
||||
@Test
|
||||
public void testname() {
|
||||
|
||||
IterationVersion iterationVersion = new SimpleIterationVersion(new Version(1, 4), Iteration.RC1);
|
||||
IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.RC1);
|
||||
assertThat(Branch.from(iterationVersion).toString(), is("master"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsBugfixBranchForServiceRelease() {
|
||||
|
||||
IterationVersion iterationVersion = new SimpleIterationVersion(new Version(1, 4), Iteration.SR1);
|
||||
IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR1);
|
||||
assertThat(Branch.from(iterationVersion).toString(), is("1.4.x"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,15 @@
|
||||
*/
|
||||
package org.springframework.data.release.git;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.data.release.model.Projects.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.data.release.model.TestReleaseTrains;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -32,22 +33,25 @@ public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
|
||||
@Autowired GitOperations gitOperations;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testname() throws Exception {
|
||||
gitOperations.update(ReleaseTrains.CODD);
|
||||
public void updatesGitRepositories() throws Exception {
|
||||
gitOperations.update(ReleaseTrains.GOSLING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showTags() throws Exception {
|
||||
|
||||
Tags tags = gitOperations.getTags(COMMONS);
|
||||
System.out.println(StringUtils.collectionToDelimitedString(tags.asList(), "\n"));
|
||||
gitOperations.update(TestReleaseTrains.SAMPLE);
|
||||
|
||||
assertThat(gitOperations.getTags(BUILD).asList(), is(not(emptyIterable())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foo() throws Exception {
|
||||
gitOperations.update(TestReleaseTrains.SAMPLE);
|
||||
}
|
||||
|
||||
gitOperations.update(ReleaseTrains.EVANS);
|
||||
@Test
|
||||
public void obtainsVersionTagsForRepoThatAlsoHasOtherTags() {
|
||||
gitOperations.getTags(MONGO_DB);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,20 +19,31 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.Module;
|
||||
import org.springframework.data.release.model.Project;
|
||||
import org.springframework.data.release.model.ReleaseTrains;
|
||||
import org.springframework.data.release.model.Train;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GitProject}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GitProjectUnitTests {
|
||||
|
||||
@Test
|
||||
public void testname() {
|
||||
public void buildsGitHubRepositoryUriCorrectly() {
|
||||
|
||||
Train codd = ReleaseTrains.CODD;
|
||||
GitProject project = new GitProject(codd.getModule("Commons").getProject(), new GitServer());
|
||||
GitServer server = new GitServer();
|
||||
Module module = codd.getModule("Commons");
|
||||
Project project = module.getProject();
|
||||
|
||||
assertThat(project.getProjectUri(), is("https://www.github.com/spring-projects/spring-data-commons"));
|
||||
GitProject gitProject = new GitProject(project, server);
|
||||
|
||||
String projectUri = gitProject.getProjectUri();
|
||||
|
||||
assertThat(projectUri, startsWith(server.getUri()));
|
||||
assertThat(projectUri, endsWith("spring-data-commons"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.git;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class GitPropertiesIntegrationTests extends AbstractIntegrationTests {
|
||||
|
||||
@Autowired GitProperties gitProperties;
|
||||
|
||||
@Test
|
||||
public void hasBasicPropertiesConfigured() {
|
||||
assertThat(gitProperties.getAuthor(), is(notNullValue()));
|
||||
assertThat(gitProperties.getEmail(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
@@ -21,38 +21,16 @@ import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class CommonsExecOsCommandOperationsIntegegrationTests extends AbstractIntegrationTests {
|
||||
public class IoPropertiesIntegrationTests extends AbstractIntegrationTests {
|
||||
|
||||
@Autowired OsCommandOperations operations;
|
||||
@Autowired IoProperties ioProperties;
|
||||
|
||||
@Test
|
||||
public void testname() throws Exception {
|
||||
|
||||
// CommandResult result = operations
|
||||
// .executeCommand("export GIT_TRACE=1 && git clone https://github.com/spring-projects/spring-data-build").get();
|
||||
|
||||
// CommandResult result = operations.executeCommand("git pull", Projects.BUILD).get();
|
||||
|
||||
CommandResult result = operations.executeCommand("git remote -v", Projects.BUILD).get();
|
||||
// .get();
|
||||
|
||||
if (result.hasError()) {
|
||||
|
||||
System.out.println(result.getStatus());
|
||||
System.out.println(result.getOutput());
|
||||
System.out.println(result.getException().getMessage());
|
||||
|
||||
throw result.getException();
|
||||
} else {
|
||||
System.out.println(result.getOutput());
|
||||
}
|
||||
|
||||
assertThat(result.hasError(), is(false));
|
||||
|
||||
public void configuresWorkingDirectoryFromApplicationProperties() {
|
||||
assertThat(ioProperties.getWorkDir(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,7 @@ package org.springframework.data.release.maven;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.release.AbstractIntegrationTests;
|
||||
@@ -36,15 +34,13 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
|
||||
@Autowired Workspace workspace;
|
||||
@Autowired ProjectionFactory projection;
|
||||
|
||||
public @Rule TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void modifiesParentPomCorrectly() throws IOException {
|
||||
|
||||
XBFileIO io = projection.io().file(new ClassPathResource("parent-pom.xml").getFile());
|
||||
|
||||
ParentPom pom = io.read(ParentPom.class);
|
||||
pom.setSharedResourcesVersion(ArtifactVersion.parse("1.2.0.RELEASE"));
|
||||
pom.setSharedResourcesVersion(ArtifactVersion.of("1.2.0.RELEASE"));
|
||||
|
||||
// System.out.println(projection.asString(pom));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.Iteration;
|
||||
import org.springframework.data.release.model.IterationVersion;
|
||||
import org.springframework.data.release.model.Version;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -31,22 +27,22 @@ public class ArtifactVersionUnitTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsInvalidVersionSuffix() {
|
||||
ArtifactVersion.parse("1.4.5.GA");
|
||||
ArtifactVersion.of("1.4.5.GA");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesReleaseVersionCorrectly() {
|
||||
|
||||
ArtifactVersion version = ArtifactVersion.parse("1.4.5.RELEASE");
|
||||
ArtifactVersion version = ArtifactVersion.of("1.4.5.RELEASE");
|
||||
|
||||
assertThat(version.isReleaseVersion(), is(true));
|
||||
assertThat(version.getNextDevelopmentVersion(), is(ArtifactVersion.parse("1.4.6.BUILD-SNAPSHOT")));
|
||||
assertThat(version.getNextDevelopmentVersion(), is(ArtifactVersion.of("1.4.6.BUILD-SNAPSHOT")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsMilestoneVersionCorrectly() {
|
||||
|
||||
ArtifactVersion version = ArtifactVersion.parse("1.4.5.M1");
|
||||
ArtifactVersion version = ArtifactVersion.of("1.4.5.M1");
|
||||
|
||||
assertThat(version.isReleaseVersion(), is(false));
|
||||
assertThat(version.isMilestoneVersion(), is(true));
|
||||
@@ -55,7 +51,7 @@ public class ArtifactVersionUnitTests {
|
||||
@Test
|
||||
public void createsReleaseVersionByDefault() {
|
||||
|
||||
ArtifactVersion version = new ArtifactVersion(new Version(1, 4, 5));
|
||||
ArtifactVersion version = ArtifactVersion.of(Version.of(1, 4, 5));
|
||||
|
||||
assertThat(version.isReleaseVersion(), is(true));
|
||||
assertThat(version.toString(), is("1.4.5.RELEASE"));
|
||||
@@ -64,8 +60,8 @@ public class ArtifactVersionUnitTests {
|
||||
@Test
|
||||
public void createsMilestoneVersionFromIteration() {
|
||||
|
||||
IterationVersion oneFourMilestoneOne = new SimpleIterationVersion(new Version(1, 4), Iteration.M1);
|
||||
ArtifactVersion version = ArtifactVersion.from(oneFourMilestoneOne);
|
||||
IterationVersion oneFourMilestoneOne = new SimpleIterationVersion(Version.of(1, 4), Iteration.M1);
|
||||
ArtifactVersion version = ArtifactVersion.of(oneFourMilestoneOne);
|
||||
|
||||
assertThat(version.isMilestoneVersion(), is(true));
|
||||
assertThat(version.toString(), is("1.4.0.M1"));
|
||||
@@ -74,8 +70,8 @@ public class ArtifactVersionUnitTests {
|
||||
@Test
|
||||
public void createsReleaseVersionFromIteration() {
|
||||
|
||||
IterationVersion oneFourGA = new SimpleIterationVersion(new Version(1, 4), Iteration.GA);
|
||||
ArtifactVersion version = ArtifactVersion.from(oneFourGA);
|
||||
IterationVersion oneFourGA = new SimpleIterationVersion(Version.of(1, 4), Iteration.GA);
|
||||
ArtifactVersion version = ArtifactVersion.of(oneFourGA);
|
||||
|
||||
assertThat(version.isReleaseVersion(), is(true));
|
||||
assertThat(version.toString(), is("1.4.0.RELEASE"));
|
||||
@@ -84,10 +80,48 @@ public class ArtifactVersionUnitTests {
|
||||
@Test
|
||||
public void createsServiceReleaseVersionFromIteration() {
|
||||
|
||||
IterationVersion oneFourServiceReleaseTwo = new SimpleIterationVersion(new Version(1, 4), Iteration.SR2);
|
||||
ArtifactVersion version = ArtifactVersion.from(oneFourServiceReleaseTwo);
|
||||
IterationVersion oneFourServiceReleaseTwo = new SimpleIterationVersion(Version.of(1, 4), Iteration.SR2);
|
||||
ArtifactVersion version = ArtifactVersion.of(oneFourServiceReleaseTwo);
|
||||
|
||||
assertThat(version.isReleaseVersion(), is(true));
|
||||
assertThat(version.toString(), is("1.4.2.RELEASE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsNextMinorSnapshotVersionForGARelease() {
|
||||
|
||||
ArtifactVersion version = ArtifactVersion.of("1.5.0.RELEASE").getNextDevelopmentVersion();
|
||||
|
||||
assertThat(version.isMilestoneVersion(), is(false));
|
||||
assertThat(version.isReleaseVersion(), is(false));
|
||||
assertThat(version, is(ArtifactVersion.of("1.6.0.BUILD-SNAPSHOT")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ordersCorrectly() {
|
||||
|
||||
ArtifactVersion oneNine = ArtifactVersion.of("1.9.0.RELEASE");
|
||||
ArtifactVersion oneTen = ArtifactVersion.of("1.10.0.RELEASE");
|
||||
|
||||
assertThat(oneNine.compareTo(oneTen), is(lessThan(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ordersSnapshotsOfSameVersionSmaller() {
|
||||
|
||||
ArtifactVersion oneTenRelease = ArtifactVersion.of("1.10.0.RELEASE");
|
||||
ArtifactVersion oneTenSnapshot = ArtifactVersion.of("1.10.0.BUILD-SNAPSHOT");
|
||||
|
||||
assertThat(oneTenRelease.compareTo(oneTenSnapshot), is(greaterThan(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsCorrectBugfixVersions() {
|
||||
|
||||
assertThat(ArtifactVersion.of("1.0.0.RELEASE").getNextBugfixVersion(),
|
||||
is(ArtifactVersion.of("1.0.1.BUILD-SNAPSHOT")));
|
||||
assertThat(ArtifactVersion.of("1.0.0.M1").getNextBugfixVersion(), is(ArtifactVersion.of("1.0.0.BUILD-SNAPSHOT")));
|
||||
assertThat(ArtifactVersion.of("1.0.1.RELEASE").getNextBugfixVersion(),
|
||||
is(ArtifactVersion.of("1.0.2.BUILD-SNAPSHOT")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,16 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release;
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Sample release {@link Train} definitions.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
public class TestConfig {
|
||||
public class TestReleaseTrains {
|
||||
|
||||
public static Train SAMPLE = new Train("SAMPLE", Arrays.asList(new Module(Projects.BUILD, "1.0")));
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for release {@link Train}s.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class TrainsUnitTest {
|
||||
|
||||
@Test
|
||||
public void prefersNewVersionOfAdditionalModule() {
|
||||
|
||||
Module module = ReleaseTrains.HOPPER.getModule(Projects.NEO4J);
|
||||
|
||||
assertThat(module.getVersion(), is(Version.parse("4.1")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addsNewlyAddedModule() {
|
||||
assertThat(ReleaseTrains.HOPPER.getModule(Projects.ENVERS), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user