2929import com .sonar .orchestrator .locator .MavenLocation ;
3030import java .io .File ;
3131import java .io .IOException ;
32- import java .nio .charset .StandardCharsets ;
3332import java .nio .file .Files ;
3433import java .nio .file .Path ;
3534import java .nio .file .Paths ;
@@ -92,7 +91,8 @@ public static void afterAllAnalysis() throws IOException {
9291 public static void prepare () throws Exception {
9392 Set <String > result = new HashSet <>();
9493 List <String > extraNonDefaultRules = List .of ("S3546" , "S6374" );
95- ProfileGenerator .generate (ORCHESTRATOR , "Sonar Way" , ImmutableMap .of (), new HashSet <>(), SUBSET_OF_ENABLED_RULES , result , extraNonDefaultRules );
94+ ProfileGenerator .generate (ORCHESTRATOR , "Sonar Way" , ImmutableMap .of (), new HashSet <>(), SUBSET_OF_ENABLED_RULES , result ,
95+ extraNonDefaultRules );
9696 assertThat (result ).hasSize (23 ); // ALL symbolic-execution rules
9797
9898 Path allRulesFolder = Paths .get ("src/test/resources" );
@@ -123,7 +123,7 @@ private static void copyFile(Path source, Path targetDir) {
123123 try {
124124 Files .copy (source , targetDir .resolve (source .getFileName ()), StandardCopyOption .REPLACE_EXISTING );
125125 } catch (IOException e ) {
126- throw new IllegalStateException ("Unable to copy file: " + source . toString () );
126+ throw new IllegalStateException ("Unable to copy file: " + source );
127127 }
128128 }
129129
@@ -143,16 +143,15 @@ public void guava() throws Exception {
143143
144144 @ Test
145145 public void eclipse_jetty () throws Exception {
146- List <String > dirs = Arrays .asList ("jetty-http/" , "jetty-io/" , "jetty-jmx/" , "jetty-server/" , "jetty-slf4j-impl/" , "jetty-util/" , "jetty-util-ajax/" , "jetty-xml/" , "tests" +
146+ List <String > dirs = Arrays .asList ("jetty-http/" , "jetty-io/" , "jetty-jmx/" , "jetty-server/" , "jetty-slf4j-impl/" , "jetty-util/" ,
147+ "jetty-util-ajax/" , "jetty-xml/" , "tests" +
147148 "/jetty-http-tools/" );
148149
149150 String mainBranchSourceCode = "eclipse-jetty" ;
150151 String mainBinaries = dirs .stream ().map (dir -> FileLocation .of ("../sources/" + mainBranchSourceCode + "/" + dir + "target/classes" ))
151152 .map (JavaRulingTest ::getFileLocationAbsolutePath )
152153 .collect (Collectors .joining ("," ));
153154
154- final var mainBranch = "eclipse-jetty-main" ;
155-
156155 MavenBuild branchBuild = test_project ("org.eclipse.jetty:jetty-project" , mainBranchSourceCode )
157156 // re-define binaries from initial maven build
158157 .setProperty ("sonar.java.binaries" , mainBinaries )
@@ -234,15 +233,6 @@ private static MavenBuild test_project(String projectKey, @Nullable String path,
234233 return mavenBuild ;
235234 }
236235
237- private static MavenBuild test_existing_project (String projectKey , String projectName ) throws IOException {
238- String pomLocation = "../sources/" + projectName + "/pom.xml" ;
239- File pomFile = FileLocation .of (pomLocation ).getFile ().getCanonicalFile ();
240- //prepareProject(projectKey, projectName);
241- MavenBuild mavenBuild = MavenBuild .create ().setPom (pomFile ).setCleanPackageSonarGoals ().addArgument ("-DskipTests" );
242- mavenBuild .setProperty ("sonar.projectKey" , projectKey );
243- return mavenBuild ;
244- }
245-
246236 private static void prepareProject (String projectKey , String projectName ) {
247237 ORCHESTRATOR .getServer ().provisionProject (projectKey , projectName );
248238 ORCHESTRATOR .getServer ().associateProjectToQualityProfile (projectKey , "java" , "rules" );
@@ -299,9 +289,9 @@ private static void dumpServerLogLastLines(File logFile) throws IOException {
299289 if (nbLines > LOGS_NUMBER_LINES ) {
300290 logs = logs .subList (nbLines - LOGS_NUMBER_LINES , nbLines );
301291 }
302- LOG .error ("=================================== START " + logFile . getName () + " ===================================" );
303- LOG .error (System .lineSeparator () + logs .stream ().collect (Collectors .joining (System .lineSeparator ())));
304- LOG .error ("===================================== END " + logFile . getName () + " ===================================" );
292+ LOG .error ("=================================== START {} ===================================" , logFile . getName () );
293+ LOG .error ("{}{}" , System .lineSeparator (), logs .stream ().collect (Collectors .joining (System .lineSeparator ())));
294+ LOG .error ("===================================== END {} ===================================" , logFile . getName () );
305295 }
306296
307297 private static String litsDifferencesPath (String projectName ) {
@@ -310,7 +300,7 @@ private static String litsDifferencesPath(String projectName) {
310300
311301 private static void assertNoDifferences (String projectName ) throws IOException {
312302
313- String differences = new String ( Files .readAllBytes (Paths .get (litsDifferencesPath (projectName ))), StandardCharsets . UTF_8 );
303+ String differences = Files .readString (Paths .get (litsDifferencesPath (projectName )));
314304 assertThat (differences ).isEmpty ();
315305 }
316306
0 commit comments