Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codecov #656

Merged
merged 7 commits into from
Dec 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
language: java
jdk:
- oraclejdk8
script:
- mvn test -B -Pjacoco
after_success:
- bash <(curl -s https://codecov.io/bash)
after_script:
- "[[ $TRAVIS_PULL_REQUEST == false ]] && mvn -Psonarqube package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONARQUBE_TOKEN}"
- "[[ $TRAVIS_PULL_REQUEST == false ]] && mvn -Pjacoco package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONARQUBE_TOKEN}"


notifications:
webhooks:
Expand Down
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.23</version>
<version>1.29</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -443,10 +444,10 @@

<!-- Enable JaCoCo Test -->
<profile>
<id>sonarqube</id>
<id>jacoco</id>

<properties>
<jacoco.version>0.7.6.201602180812</jacoco.version>
<jacoco.version>0.7.8</jacoco.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -476,7 +477,7 @@
</execution>
<execution>
<id>restore</id>
<phase>prepare-package</phase>
<phase>test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
<goal>report</goal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AuthConfigFactory {
static final String DOCKER_LOGIN_DEFAULT_REGISTRY = "https://index.docker.io/v1/";

private final PlexusContainer container;
public static final String[] DEFAULT_REGISTRIES = new String[]{
private static final String[] DEFAULT_REGISTRIES = new String[]{
"docker.io", "index.docker.io", "registry.hub.docker.com"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,15 @@ public void checkMutlilinePattern() {
private void setupMocks(final InputStream inputStream) throws Exception {
new Expectations() {{
RequestUtil.newGet(anyString);
result = httpUriRequest;

client.execute((HttpUriRequest) any);
result = httpResponse;

httpResponse.getStatusLine();
result = statusLine;

statusLine.getStatusCode();
result = 200;

httpResponse.getEntity();
result = httpEntity;

httpEntity.getContent();
result = inputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public void assemblyFiles(@Injectable final MojoParameters mojoParams,
result = "target/"; times = 3;

mojoParams.getProject();
result = project;

project.getBasedir();
result = ".";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testBuildImageWithNoCleanup() throws Exception {
thenImageIsBuilt();
thenOldImageIsNotRemoved();
}

@Test
public void testCleanupCachedImage() throws Exception {
givenAnImageConfiguration(true);
Expand All @@ -83,7 +83,7 @@ public void testCleanupCachedImage() throws Exception {
thenImageIsBuilt();
thenOldImageIsNotRemoved();
}

@Test
public void testCleanupNoExistingImage() throws Exception {
givenAnImageConfiguration(true);
Expand All @@ -92,12 +92,12 @@ public void testCleanupNoExistingImage() throws Exception {
thenImageIsBuilt();
thenOldImageIsNotRemoved();
}

private void givenAnImageConfiguration(Boolean cleanup) {
BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder()
.cleanup(cleanup.toString())
.build();

imageConfig = new ImageConfiguration.Builder()
.name("build-image")
.alias("build-alias")
Expand All @@ -108,14 +108,15 @@ private void givenAnImageConfiguration(Boolean cleanup) {
private void givenImageIds(final String oldImageId, final String newImageId) throws DockerAccessException {
this.oldImageId = oldImageId;
new Expectations() {{
queryService.getImageId(imageConfig.getName()); returns(oldImageId,newImageId);
queryService.getImageId(imageConfig.getName()); result = new String[] { oldImageId, newImageId };
}};
}

private void thenImageIsBuilt() throws DockerAccessException {
final File dockerBuildTar = new File("docker-build.tar");
new Verifications() {{
docker.buildImage(withEqual(imageConfig.getName()),
withEqual(new File("docker-build.tar")),
docker.buildImage(imageConfig.getName(),
dockerBuildTar,
(String) withNull(),
anyBoolean, anyBoolean, (Map) any);
}};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.fabric8.maven.docker.service;/*
*
*
* Copyright 2014 Roland Huss
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -46,15 +46,12 @@ public class MojoExecutionServiceTest {
@Mocked
MojoExecutionService executionService;

@Mocked
@Injectable
protected MavenProject project;

@Mocked
@Injectable
MavenSession session;

@Mocked
@Injectable
BuildPluginManager pluginManager;

Expand Down Expand Up @@ -143,7 +140,6 @@ private Expectations expectNoDescriptor() {
private Expectations overrideGetPluginDescriptor() throws NoSuchMethodException, InvocationTargetException, InvalidPluginDescriptorException, IllegalAccessException, PluginResolutionException, PluginNotFoundException, PluginDescriptorParsingException, MojoFailureException {
return new Expectations() {{
executionService.getPluginDescriptor((MavenProject) any,(Plugin) any);
result = pluginDescriptor;
}};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import java.util.Date;
import java.util.HashMap;
import java.util.Properties;

import mockit.*;
Expand Down Expand Up @@ -65,6 +66,9 @@ public void invalidFormatChar() throws Exception {
@Test
public void defaultUserName() throws Exception {

new Expectations() {{
project.getProperties(); result = new Properties();
}};
String[] data = {
"io.fabric8", "fabric8",
"io.FABRIC8", "fabric8",
Expand Down Expand Up @@ -102,6 +106,7 @@ public void tag() throws Exception {
project.getArtifactId(); result = "docker-maven-plugin";
project.getGroupId(); result = "io.fabric8";
project.getVersion(); result = "1.2.3-SNAPSHOT";
project.getProperties(); result = new Properties();
}};
assertThat(formatter.format("%g/%a:%l"), equalTo("fabric8/docker-maven-plugin:latest"));
assertThat(formatter.format("%g/%a:%v"), equalTo("fabric8/docker-maven-plugin:1.2.3-SNAPSHOT"));
Expand All @@ -114,6 +119,7 @@ public void nonSnapshotArtifact() throws Exception {
project.getArtifactId(); result = "docker-maven-plugin";
project.getGroupId(); result = "io.fabric8";
project.getVersion(); result = "1.2.3";
project.getProperties(); result = new Properties();
}};

assertThat(formatter.format("%g/%a:%l"), equalTo("fabric8/docker-maven-plugin:1.2.3"));
Expand Down