#91 - Polishing.

Guard tests requiring connectivity to GitHub with assumptions.
This commit is contained in:
Mark Paluch
2018-12-10 14:10:59 +01:00
parent d5bfe81d18
commit 628da8bd4e
3 changed files with 57 additions and 19 deletions

View File

@@ -15,8 +15,13 @@
*/ */
package org.springframework.data.release.build; package org.springframework.data.release.build;
import java.io.IOException; import static org.junit.Assume.*;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@@ -24,12 +29,7 @@ import org.springframework.data.release.AbstractIntegrationTests;
import org.springframework.data.release.git.GitOperations; import org.springframework.data.release.git.GitOperations;
import org.springframework.data.release.io.Workspace; import org.springframework.data.release.io.Workspace;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.Projects; import org.springframework.data.release.model.Projects;
import org.springframework.data.release.model.ReleaseTrains;
import org.springframework.data.release.model.TrainIteration;
import org.xmlbeam.ProjectionFactory; import org.xmlbeam.ProjectionFactory;
import org.xmlbeam.io.XBFileIO; import org.xmlbeam.io.XBFileIO;
@@ -43,6 +43,19 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
@Autowired MavenBuildSystem maven; @Autowired MavenBuildSystem maven;
@Autowired GitOperations git; @Autowired GitOperations git;
@BeforeClass
public static void beforeClass() {
try {
URL url = new URL("https://github.com");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
urlConnection.getInputStream().close();
} catch (IOException e) {
assumeTrue("Test requires connectivity to GitHub:" + e.toString(), false);
}
}
@Test @Test
public void modifiesParentPomCorrectly() throws IOException { public void modifiesParentPomCorrectly() throws IOException {
@@ -67,19 +80,6 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
// System.out.println(projection.asString(pom)); // System.out.println(projection.asString(pom));
} }
@Test
public void testname() throws Exception {
git.update(ReleaseTrains.HOPPER);
TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
ModuleIteration build = iteration.getModule(Projects.BUILD);
UpdateInformation information = UpdateInformation.of(iteration, Phase.PREPARE);
maven.updateProjectDescriptors(build, information);
maven.prepareVersion(build, Phase.PREPARE);
}
@Test @Test
public void findsSnapshotDependencies() throws Exception { public void findsSnapshotDependencies() throws Exception {

View File

@@ -17,7 +17,13 @@ package org.springframework.data.release.cli;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.*;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
@@ -32,6 +38,19 @@ public class ReleaseCommandsIntegrationTests extends AbstractIntegrationTests {
@Autowired ReleaseCommands releaseCommands; @Autowired ReleaseCommands releaseCommands;
@Autowired GitOperations git; @Autowired GitOperations git;
@BeforeClass
public static void beforeClass() {
try {
URL url = new URL("https://github.com");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
urlConnection.getInputStream().close();
} catch (IOException e) {
assumeTrue("Test requires connectivity to GitHub:" + e.toString(), false);
}
}
@Test @Test
public void predictsReleaseTrainCorrectly() throws Exception { public void predictsReleaseTrainCorrectly() throws Exception {

View File

@@ -17,8 +17,14 @@ package org.springframework.data.release.git;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.junit.Assume.*;
import static org.springframework.data.release.model.Projects.*; import static org.springframework.data.release.model.Projects.*;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.release.AbstractIntegrationTests; import org.springframework.data.release.AbstractIntegrationTests;
@@ -32,6 +38,19 @@ public class GitOperationsIntegrationTests extends AbstractIntegrationTests {
@Autowired GitOperations gitOperations; @Autowired GitOperations gitOperations;
@BeforeClass
public static void beforeClass() {
try {
URL url = new URL("https://github.com");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
urlConnection.getInputStream().close();
} catch (IOException e) {
assumeTrue("Test requires connectivity to GitHub:" + e.toString(), false);
}
}
@Test @Test
public void updatesGitRepositories() throws Exception { public void updatesGitRepositories() throws Exception {
gitOperations.update(ReleaseTrains.GOSLING); gitOperations.update(ReleaseTrains.GOSLING);