-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: exclude integration tests from Infinitest
- Loading branch information
Showing
9 changed files
with
763 additions
and
733 deletions.
There are no files selected for viewing
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 @@ | ||
excludeGroups=IntegrationTest |
145 changes: 73 additions & 72 deletions
145
src/test/java/org/sonar/plugins/findbugs/it/FBContribIT.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 |
---|---|---|
@@ -1,72 +1,73 @@ | ||
/* | ||
* Findbugs :: IT :: Plugin | ||
* Copyright (C) 2014 SonarSource | ||
* [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 | ||
*/ | ||
package org.sonar.plugins.findbugs.it; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.Issues.Issue; | ||
import org.sonarqube.ws.client.issues.IssuesService; | ||
|
||
import java.util.List; | ||
|
||
import com.sonar.orchestrator.Orchestrator; | ||
import com.sonar.orchestrator.build.MavenBuild; | ||
|
||
class FBContribIT { | ||
|
||
private static final String PROJECT_KEY = "org.sonar.tests:fb-contrib"; | ||
public static Orchestrator orchestrator = FindbugsTestSuite.ORCHESTRATOR; | ||
|
||
@BeforeEach | ||
public void setupProfile() { | ||
FindbugsTestSuite.setupProjectAndProfile(PROJECT_KEY, "Findbugs Contrib Integration Tests", "IT", "java"); | ||
} | ||
|
||
@AfterEach | ||
public void deleteProject() { | ||
FindbugsTestSuite.deleteProject(PROJECT_KEY); | ||
} | ||
|
||
@Test | ||
void test() throws Exception { | ||
MavenBuild build = MavenBuild.create() | ||
.setPom(FindbugsTestSuite.projectPom("simple")) | ||
.setProperty("sonar.dynamicAnalysis", "false") | ||
.setProperty("sonar.findbugs.confidenceLevel", "low") | ||
.setCleanPackageSonarGoals(); | ||
orchestrator.executeBuild(build); | ||
|
||
IssuesService issueClient = FindbugsTestSuite.issueClient(); | ||
List<Issue> issues = issueClient.search(IssueQuery.create().projects(PROJECT_KEY)).getIssuesList(); | ||
assertThat(issues).hasSize(3); | ||
|
||
issues = issueClient.search(IssueQuery.create().rules("fb-contrib:IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY")).getIssuesList(); | ||
// SONARJAVA-216: | ||
assertThat(issues).hasSize(1); | ||
assertThat(issues.get(0).getMessage()).isEqualTo("Method Simple.method() uses Properties.put instead of Properties.setProperty"); | ||
|
||
issues = issueClient.search(IssueQuery.create().rules("findsecbugs:PREDICTABLE_RANDOM")).getIssuesList(); | ||
assertThat(issues).hasSize(1); | ||
assertThat(issues.get(0).getMessage()).isEqualTo("This random generator (java.util.Random) is predictable"); | ||
} | ||
} | ||
/* | ||
* Findbugs :: IT :: Plugin | ||
* Copyright (C) 2014 SonarSource | ||
* [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 | ||
*/ | ||
package org.sonar.plugins.findbugs.it; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.Issues.Issue; | ||
import org.sonarqube.ws.client.issues.IssuesService; | ||
|
||
import java.util.List; | ||
|
||
import com.sonar.orchestrator.Orchestrator; | ||
import com.sonar.orchestrator.build.MavenBuild; | ||
|
||
@IntegrationTest | ||
class FBContribIT { | ||
|
||
private static final String PROJECT_KEY = "org.sonar.tests:fb-contrib"; | ||
public static Orchestrator orchestrator = FindbugsTestSuite.ORCHESTRATOR; | ||
|
||
@BeforeEach | ||
public void setupProfile() { | ||
FindbugsTestSuite.setupProjectAndProfile(PROJECT_KEY, "Findbugs Contrib Integration Tests", "IT", "java"); | ||
} | ||
|
||
@AfterEach | ||
public void deleteProject() { | ||
FindbugsTestSuite.deleteProject(PROJECT_KEY); | ||
} | ||
|
||
@Test | ||
void test() throws Exception { | ||
MavenBuild build = MavenBuild.create() | ||
.setPom(FindbugsTestSuite.projectPom("simple")) | ||
.setProperty("sonar.dynamicAnalysis", "false") | ||
.setProperty("sonar.findbugs.confidenceLevel", "low") | ||
.setCleanPackageSonarGoals(); | ||
orchestrator.executeBuild(build); | ||
|
||
IssuesService issueClient = FindbugsTestSuite.issueClient(); | ||
List<Issue> issues = issueClient.search(IssueQuery.create().projects(PROJECT_KEY)).getIssuesList(); | ||
assertThat(issues).hasSize(3); | ||
|
||
issues = issueClient.search(IssueQuery.create().rules("fb-contrib:IPU_IMPROPER_PROPERTIES_USE_SETPROPERTY")).getIssuesList(); | ||
// SONARJAVA-216: | ||
assertThat(issues).hasSize(1); | ||
assertThat(issues.get(0).getMessage()).isEqualTo("Method Simple.method() uses Properties.put instead of Properties.setProperty"); | ||
|
||
issues = issueClient.search(IssueQuery.create().rules("findsecbugs:PREDICTABLE_RANDOM")).getIssuesList(); | ||
assertThat(issues).hasSize(1); | ||
assertThat(issues.get(0).getMessage()).isEqualTo("This random generator (java.util.Random) is predictable"); | ||
} | ||
} |
113 changes: 57 additions & 56 deletions
113
src/test/java/org/sonar/plugins/findbugs/it/FindSecBugsIT.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 |
---|---|---|
@@ -1,56 +1,57 @@ | ||
package org.sonar.plugins.findbugs.it; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; | ||
|
||
import java.io.File; | ||
|
||
import com.sonar.orchestrator.Orchestrator; | ||
import com.sonar.orchestrator.build.MavenBuild; | ||
|
||
/** | ||
* @author gtoison | ||
* | ||
*/ | ||
class FindSecBugsIT { | ||
|
||
private static final String PROJECT_KEY = "com.sonarsource.it.samples:findbugs"; | ||
public static Orchestrator orchestrator = FindbugsTestSuite.ORCHESTRATOR; | ||
|
||
@BeforeEach | ||
public void setupProfile() { | ||
FindbugsTestSuite.setupProjectAndProfile(PROJECT_KEY, "Find Sec Bugs Integration Tests", "IT", "java"); | ||
} | ||
|
||
@AfterEach | ||
public void deleteProject() { | ||
FindbugsTestSuite.deleteProject(PROJECT_KEY); | ||
} | ||
|
||
@Test | ||
void noAnalysisWhenProfileDoesNotHaveSpotBugsRules() throws Exception { | ||
// Set an empty Java quality profile for the project | ||
AddProjectRequest addProjectRequest = new AddProjectRequest(); | ||
addProjectRequest.setLanguage("java"); | ||
addProjectRequest.setProject(PROJECT_KEY); | ||
addProjectRequest.setQualityProfile("empty"); | ||
FindbugsTestSuite.qualityProfileClient().addProject(addProjectRequest); | ||
|
||
MavenBuild build = MavenBuild.create() | ||
.setPom(FindbugsTestSuite.projectPom("findbugs")) | ||
.setProperty("sonar.dynamicAnalysis", "false") | ||
.setProperty("sonar.findbugs.confidenceLevel", "low") | ||
.setCleanPackageSonarGoals(); | ||
orchestrator.executeBuild(build); | ||
|
||
File projectDir = FindbugsTestSuite.projectPom("findbugs").getParentFile(); | ||
File resultFile = new File(projectDir, "target/sonar/findbugs-result.xml"); | ||
|
||
String message = "The analysis must not run because the findbugs sample project does not contain JSP files and there are no spotbugs rules in the profile"; | ||
assertFalse(message, resultFile.exists()); | ||
} | ||
} | ||
package org.sonar.plugins.findbugs.it; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.client.qualityprofiles.AddProjectRequest; | ||
|
||
import java.io.File; | ||
|
||
import com.sonar.orchestrator.Orchestrator; | ||
import com.sonar.orchestrator.build.MavenBuild; | ||
|
||
/** | ||
* @author gtoison | ||
* | ||
*/ | ||
@IntegrationTest | ||
class FindSecBugsIT { | ||
|
||
private static final String PROJECT_KEY = "com.sonarsource.it.samples:findbugs"; | ||
public static Orchestrator orchestrator = FindbugsTestSuite.ORCHESTRATOR; | ||
|
||
@BeforeEach | ||
public void setupProfile() { | ||
FindbugsTestSuite.setupProjectAndProfile(PROJECT_KEY, "Find Sec Bugs Integration Tests", "IT", "java"); | ||
} | ||
|
||
@AfterEach | ||
public void deleteProject() { | ||
FindbugsTestSuite.deleteProject(PROJECT_KEY); | ||
} | ||
|
||
@Test | ||
void noAnalysisWhenProfileDoesNotHaveSpotBugsRules() throws Exception { | ||
// Set an empty Java quality profile for the project | ||
AddProjectRequest addProjectRequest = new AddProjectRequest(); | ||
addProjectRequest.setLanguage("java"); | ||
addProjectRequest.setProject(PROJECT_KEY); | ||
addProjectRequest.setQualityProfile("empty"); | ||
FindbugsTestSuite.qualityProfileClient().addProject(addProjectRequest); | ||
|
||
MavenBuild build = MavenBuild.create() | ||
.setPom(FindbugsTestSuite.projectPom("findbugs")) | ||
.setProperty("sonar.dynamicAnalysis", "false") | ||
.setProperty("sonar.findbugs.confidenceLevel", "low") | ||
.setCleanPackageSonarGoals(); | ||
orchestrator.executeBuild(build); | ||
|
||
File projectDir = FindbugsTestSuite.projectPom("findbugs").getParentFile(); | ||
File resultFile = new File(projectDir, "target/sonar/findbugs-result.xml"); | ||
|
||
String message = "The analysis must not run because the findbugs sample project does not contain JSP files and there are no spotbugs rules in the profile"; | ||
assertFalse(message, resultFile.exists()); | ||
} | ||
} |
Oops, something went wrong.