Skip to content

Commit

Permalink
Using failsafe plugin for Integration tests
Browse files Browse the repository at this point in the history
Rename current Integration test to match failsafe default naming pattern and
mismatch surefire default naming pattern.
  • Loading branch information
alecharp committed Jul 29, 2014
1 parent 56d2773 commit 841711a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Expand Up @@ -144,6 +144,20 @@
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Expand Up @@ -11,6 +11,17 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotEquals;

import com.google.common.collect.ImmutableMap;
import com.offbytwo.jenkins.client.JenkinsHttpClient;
import com.offbytwo.jenkins.model.Build;
import com.offbytwo.jenkins.model.BuildResult;
import com.offbytwo.jenkins.model.BuildWithDetails;
import com.offbytwo.jenkins.model.Computer;
import com.offbytwo.jenkins.model.Job;
import com.offbytwo.jenkins.model.JobWithDetails;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
Expand All @@ -37,12 +48,12 @@
import com.offbytwo.jenkins.model.Job;
import com.offbytwo.jenkins.model.JobWithDetails;

public class JenkinsServerIntegration {
public class JenkinsServerIT {

private static final String JENKINS_MASTER = "master";
private static final String JENKINS_TEST_JOB = "jenkins-client-test";
private static final String SAMPLE_JOB_FILE = "sample-job.xml";

private JenkinsHttpClient client;
private JenkinsServer server;
private PoolingClientConnectionManager poolingConnectionManager = new PoolingClientConnectionManager();
Expand Down Expand Up @@ -85,6 +96,20 @@ public void shouldReturnListOfJobs() throws Exception {
assertTrue(server.getJobs().containsKey(JENKINS_TEST_JOB));
}

@Test
public void shouldReturnBuildsForJob() throws Exception {
JobWithDetails job = server.getJobs().get("trunk").details();
assertEquals(5, job.getBuilds().get(0).getNumber());
}

@Test
public void shouldReturnBuildStatusForBuild() throws Exception {
JobWithDetails job = server.getJobs().get("pr").details();
BuildWithDetails build = job.getBuilds().get(0).details();
assertEquals(BuildResult.SUCCESS, build.getResult());
assertEquals("foobar", build.getParameters().get("REVISION"));
}

@Test
public void shouldReturnListOfComputers() throws Exception {
assertTrue(server.getComputers().containsKey(JENKINS_MASTER));
Expand Down Expand Up @@ -184,12 +209,10 @@ public void testUpdateJob() throws Exception {
private class PerformPollingTest implements Callable<Void> {
private final JenkinsServer server;
private final String jobName;

public PerformPollingTest(JenkinsServer server, String jobName) {
this.server = server;
this.jobName = jobName;
}

public Void call() throws InterruptedException, IOException {
while (true) {
Thread.sleep(500);
Expand Down

0 comments on commit 841711a

Please sign in to comment.