This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSONAR-129 sonar.host.url defined in settings.xml not taken into account
- Loading branch information
Showing
10 changed files
with
243 additions
and
309 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.sonarsource.it.samples</groupId> | ||
<artifactId>sonar-host-url</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<sonar.host.url>http://dummy-url.org</sonar.host.url> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/org/codehaus/mojo/sonar/bootstrap/RunnerFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.codehaus.mojo.sonar.bootstrap; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.rtinfo.RuntimeInformation; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.sonar.runner.api.EmbeddedRunner; | ||
import org.sonar.runner.api.LogOutput; | ||
|
||
import java.util.Properties; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
import static org.fest.assertions.MapAssert.entry; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class RunnerFactoryTest | ||
{ | ||
private LogOutput logOutput; | ||
|
||
private RuntimeInformation runtimeInformation; | ||
|
||
private MavenSession mavenSession; | ||
|
||
private MavenProject rootProject; | ||
|
||
@Before | ||
public void setUp() | ||
{ | ||
logOutput = mock( LogOutput.class ); | ||
runtimeInformation = mock( RuntimeInformation.class ); | ||
mavenSession = mock( MavenSession.class ); | ||
rootProject = mock( MavenProject.class ); | ||
|
||
Properties system = new Properties(); | ||
system.put( "system", "value" ); | ||
Properties user = new Properties(); | ||
user.put( "user", "value" ); | ||
Properties root = new Properties(); | ||
root.put( "root", "value" ); | ||
|
||
when( runtimeInformation.getMavenVersion() ).thenReturn( "1.0" ); | ||
when( mavenSession.getSystemProperties() ).thenReturn( system ); | ||
when( mavenSession.getUserProperties() ).thenReturn( user ); | ||
when( rootProject.getProperties() ).thenReturn( root ); | ||
when( mavenSession.getTopLevelProject() ).thenReturn( rootProject ); | ||
} | ||
|
||
@Test | ||
public void testProperties() | ||
{ | ||
RunnerFactory factory = new RunnerFactory( logOutput, false, runtimeInformation, mavenSession ); | ||
EmbeddedRunner runner = factory.create(); | ||
verify( mavenSession ).getUserProperties(); | ||
verify( mavenSession ).getSystemProperties(); | ||
verify( rootProject ).getProperties(); | ||
|
||
assertThat( runner.globalProperties() ).includes( entry( "system", "value" ), entry( "user", "value" ), | ||
entry( "root", "value" ) ); | ||
assertThat( runner.globalProperties() ).includes( entry( "sonar.mojoUseRunner", "true" ) ); | ||
} | ||
|
||
@Test | ||
public void testDebug() | ||
{ | ||
RunnerFactory factoryDebug = new RunnerFactory( logOutput, true, runtimeInformation, mavenSession ); | ||
RunnerFactory factory = new RunnerFactory( logOutput, false, runtimeInformation, mavenSession ); | ||
|
||
EmbeddedRunner runnerDebug = factoryDebug.create(); | ||
EmbeddedRunner runner = factory.create(); | ||
|
||
assertThat( runnerDebug.globalProperties() ).includes( entry( "sonar.verbose", "true" ) ); | ||
assertThat( runner.globalProperties() ).excludes( entry( "sonar.verbose", "true" ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters