Commit 69c0e1a 1 parent 993000d commit 69c0e1a Copy full SHA for 69c0e1a
File tree 4 files changed +52
-0
lines changed
projects/jdkHome/defaultValue
src/test/java/com/sonar/maven/it/suite
4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ <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" >
2
+ <modelVersion >4.0.0</modelVersion >
3
+ <groupId >com.sonarsource.it.samples</groupId >
4
+ <artifactId >extract-jre</artifactId >
5
+ <version >1.0-SNAPSHOT</version >
6
+ <name >Sonar :: Integration Tests :: Extract Jre</name >
7
+
8
+ </project >
Original file line number Diff line number Diff line change
1
+ package sample ;
2
+
3
+ public class Sample {
4
+
5
+ public Sample (int i ) {
6
+ int j = i ++;
7
+ }
8
+
9
+ public String myMethod () {
10
+ return "hello" ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ package sample ;
2
+
3
+ import org .junit .Test ;
4
+
5
+ public class SampleTest {
6
+
7
+ @ Test
8
+ public void test () {
9
+ new Sample (1 ).myMethod ();
10
+ }
11
+
12
+ }
Original file line number Diff line number Diff line change @@ -120,6 +120,26 @@ void setJavaVersionProperties() throws IOException {
120
120
entry ("sonar.java.target" , "1.8" ));
121
121
}
122
122
123
+ @ Test
124
+ void when_java_home_exists_it_is_used_as_default_sonar_java_jdkHome_value () throws IOException {
125
+ //fix value, the plugin should not modify them
126
+ String javaHomeSystem = System .getProperty ("java.home" );
127
+
128
+ File outputProps = temp .resolve ("out.properties" ).toFile ();
129
+ outputProps .createNewFile ();
130
+ File pom = ItUtils .locateProjectPom ("jdkHome/defaultValue" );
131
+
132
+ MavenBuild build = MavenBuild .create (pom )
133
+ .setGoals (sonarGoal ())
134
+ .setProperty ("sonar.scanner.internal.dumpToFile" , outputProps .getAbsolutePath ());
135
+ executeBuildAndValidateWithoutCE (build );
136
+
137
+ Properties props = getProps (outputProps );
138
+ String jdkHome = props .getProperty ("sonar.java.jdkHome" );
139
+ //the jdk is not configured in the project, so default value should be used
140
+ assertThat (jdkHome ).isEqualTo (javaHomeSystem );
141
+ }
142
+
123
143
@ Test
124
144
void setJdkHomeFromCompilerExecutableConfiguration () throws IOException {
125
145
File outputProps = temp .resolve ("out.properties" ).toFile ();
You can’t perform that action at this time.
0 commit comments