Skip to content

Commit 7446ff7

Browse files
committed
SONARJAVA-1171 Add a test file to check issue by custom rule on test files
1 parent d3a3370 commit 7446ff7

6 files changed

Lines changed: 53 additions & 2 deletions

File tree

its/plugin/plugins/java-extension-plugin/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@
2525
</dependency>
2626

2727
<dependency>
28-
<groupId>org.codehaus.sonar-plugins.java</groupId>
28+
<groupId>org.sonarsource.java</groupId>
2929
<artifactId>sonar-java-plugin</artifactId>
3030
<type>sonar-plugin</type>
3131
<version>3.5-SNAPSHOT</version>
3232
<scope>provided</scope>
3333
</dependency>
34+
35+
<dependency>
36+
<groupId>junit</groupId>
37+
<artifactId>junit</artifactId>
38+
<version>4.10</version>
39+
<scope>test</scope>
40+
</dependency>
3441
</dependencies>
3542

3643
<build>

its/plugin/plugins/java-extension-plugin/src/main/java/org/sonar/samples/java/SubscriptionExampleTestCheck.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Java :: IT :: Plugins :: Java Extension Plugin
3+
* Copyright (C) 2013 SonarSource
4+
* dev@sonar.codehaus.org
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
19+
*/
120
package org.sonar.samples.java;
221

322
import com.google.common.collect.ImmutableList;

its/plugin/projects/java-extension/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
<groupId>com.sonarsource.it.projects</groupId>
55
<artifactId>java-extension</artifactId>
66
<version>1.0-SNAPSHOT</version>
7-
7+
8+
<dependencies>
9+
<dependency>
10+
<groupId>junit</groupId>
11+
<artifactId>junit</artifactId>
12+
<version>4.10</version>
13+
</dependency>
14+
</dependencies>
815
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.sonar.samples.java;
2+
3+
import junit.framework.Assert;
4+
import org.junit.Test;
5+
6+
public class DummyTest {
7+
@Test
8+
public void my_clever_test() throws Exception {
9+
Assert.assertEquals(true, true);
10+
}
11+
}

its/plugin/tests/src/test/java/com/sonar/it/java/suite/JavaExtensionsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public void test() {
5050
assertThat(issues).hasSize(4);
5151
issues = issueClient.find(IssueQuery.create().rules("java-extension:subscriptionexamplecheck").componentRoots("com.sonarsource.it.projects:java-extension")).list();
5252
assertThat(issues).hasSize(3);
53+
issues = issueClient.find(IssueQuery.create().rules("java-extension:subscriptionexampletestcheck").componentRoots("com.sonarsource.it.projects:java-extension")).list();
54+
assertThat(issues).hasSize(1);
5355
}
5456

5557
}

its/plugin/tests/src/test/resources/profile-java-extension.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@
1313
<key>subscriptionexamplecheck</key>
1414
<priority>MAJOR</priority>
1515
</rule>
16+
<rule>
17+
<repositoryKey>java-extension</repositoryKey>
18+
<key>subscriptionexampletestcheck</key>
19+
<priority>MAJOR</priority>
20+
</rule>
1621
</rules>
1722
</profile>

0 commit comments

Comments
 (0)