aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-30 09:56:55 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-30 09:56:55 +0200
commitf9b616759e48519bd59f14608fdd3057881de418 (patch)
tree8ec893d4fbffea741d06de3f3d3fbec97c1492b7
parent7a6211086f961e128a3819743c59adf6eb2cd682 (diff)
parentc48b703be87fea2174450cec018b5b3209d6d6fa (diff)
downloadsonarqube-f9b616759e48519bd59f14608fdd3057881de418.tar.gz
sonarqube-f9b616759e48519bd59f14608fdd3057881de418.zip
Merge remote-tracking branch 'remotes/origin/branch-4.5'
Conflicts: plugins/sonar-core-plugin/pom.xml plugins/sonar-cpd-plugin/pom.xml plugins/sonar-dbcleaner-plugin/pom.xml plugins/sonar-design-plugin/pom.xml plugins/sonar-email-notifications-plugin/pom.xml plugins/sonar-l10n-en-plugin/pom.xml plugins/sonar-xoo-plugin/pom.xml pom.xml server/pom.xml server/sonar-process-monitor/pom.xml server/sonar-process/pom.xml server/sonar-search/pom.xml server/sonar-server/pom.xml server/sonar-web/pom.xml server/sonar-ws-client/pom.xml sonar-application/pom.xml sonar-batch-maven-compat/pom.xml sonar-batch-protocol/pom.xml sonar-batch/pom.xml sonar-check-api/pom.xml sonar-colorizer/pom.xml sonar-core/pom.xml sonar-deprecated/pom.xml sonar-duplications/pom.xml sonar-graph/pom.xml sonar-home/pom.xml sonar-java-api/pom.xml sonar-markdown/pom.xml sonar-maven-plugin/pom.xml sonar-maven3-plugin/pom.xml sonar-plugin-api/pom.xml sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java sonar-testing-harness/pom.xml
-rwxr-xr-xfork.sh24
-rw-r--r--plugins/sonar-core-plugin/pom.xml7
-rw-r--r--plugins/sonar-cpd-plugin/pom.xml14
-rw-r--r--plugins/sonar-dbcleaner-plugin/pom.xml8
-rw-r--r--plugins/sonar-l10n-en-plugin/pom.xml7
-rw-r--r--pom.xml58
-rw-r--r--server/sonar-process-monitor/pom.xml12
-rw-r--r--server/sonar-process/pom.xml8
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/LoopbackAddressTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java4
-rw-r--r--server/sonar-search/pom.xml12
-rw-r--r--server/sonar-server/pom.xml7
-rw-r--r--server/sonar-web/pom.xml3
-rw-r--r--server/sonar-ws-client/pom.xml7
-rw-r--r--sonar-application/pom.xml7
-rw-r--r--sonar-application/src/main/assembly/conf/wrapper.conf2
-rw-r--r--sonar-application/src/test/java/org/sonar/application/DefaultSettingsTest.java2
-rw-r--r--sonar-batch-protocol/pom.xml12
-rw-r--r--sonar-batch/pom.xml19
-rw-r--r--sonar-check-api/pom.xml12
-rw-r--r--sonar-duplications/pom.xml12
-rw-r--r--sonar-graph/pom.xml12
-rw-r--r--sonar-java-api/pom.xml12
-rw-r--r--sonar-markdown/pom.xml11
-rw-r--r--sonar-maven-plugin/pom.xml12
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java10
-rw-r--r--sonar-testing-harness/pom.xml27
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java22
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java29
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatcher.java57
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatchers.java40
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/channel/ReaderHasNextCharMatcher.java46
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/channel/package-info.java24
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java15
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java44
37 files changed, 344 insertions, 260 deletions
diff --git a/fork.sh b/fork.sh
deleted file mode 100755
index 47e751c592b..00000000000
--- a/fork.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-mvn clean install -DskipTests -pl :sonar-server,:sonar-search,:sonar-process -amd
-
-if [[ "$OSTYPE" == "darwin"* ]]; then
- OS='macosx-universal-64'
-else
- OS='linux-x86-64'
-fi
-
-cd sonar-application/target/
-if ! ls sonarqube-*/bin/$OS/sonar.sh &> /dev/null; then
- unzip sonarqube-*.zip
-fi
-
-cd sonarqube-*
-touch logs/application.log
-touch logs/search.log
-touch logs/sonar.log
-
-tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar -Dsonar.node.name=forky"
-#tmux new-session "tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar"
-
-#tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; tail -f logs/application.log"
diff --git a/plugins/sonar-core-plugin/pom.xml b/plugins/sonar-core-plugin/pom.xml
index 7641502d016..c8c6029a52b 100644
--- a/plugins/sonar-core-plugin/pom.xml
+++ b/plugins/sonar-core-plugin/pom.xml
@@ -89,6 +89,13 @@
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
diff --git a/plugins/sonar-cpd-plugin/pom.xml b/plugins/sonar-cpd-plugin/pom.xml
index 1008ad0d370..48293a28711 100644
--- a/plugins/sonar-cpd-plugin/pom.xml
+++ b/plugins/sonar-cpd-plugin/pom.xml
@@ -59,6 +59,13 @@
<artifactId>sonar-xoo-plugin</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
@@ -80,6 +87,13 @@
<pluginClass>org.sonar.plugins.cpd.CpdPlugin</pluginClass>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/plugins/sonar-dbcleaner-plugin/pom.xml b/plugins/sonar-dbcleaner-plugin/pom.xml
index c2577052440..5857b5a0f3a 100644
--- a/plugins/sonar-dbcleaner-plugin/pom.xml
+++ b/plugins/sonar-dbcleaner-plugin/pom.xml
@@ -81,6 +81,14 @@
<pluginClass>org.sonar.plugins.dbcleaner.DbCleanerPlugin</pluginClass>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
diff --git a/plugins/sonar-l10n-en-plugin/pom.xml b/plugins/sonar-l10n-en-plugin/pom.xml
index 7714d988541..df5aca9be06 100644
--- a/plugins/sonar-l10n-en-plugin/pom.xml
+++ b/plugins/sonar-l10n-en-plugin/pom.xml
@@ -69,6 +69,13 @@
<pluginDescription><![CDATA[Language pack for English]]></pluginDescription>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/pom.xml b/pom.xml
index 9325d620f16..e1bd848cda0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.sonar</groupId>
@@ -82,6 +83,10 @@
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
+ <skipBatchTests>false</skipBatchTests>
+ <skipServerTests>false</skipServerTests>
+ <skipWebTests>false</skipWebTests>
+
<!-- To configure animal-sniffer to check API compat -->
<animal-sniffer.signature.groupId>org.codehaus.mojo.signature</animal-sniffer.signature.groupId>
<animal-sniffer.signature.artifactId>java16</animal-sniffer.signature.artifactId>
@@ -1333,7 +1338,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
@@ -1346,7 +1351,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
@@ -1360,7 +1365,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
@@ -1373,7 +1378,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
@@ -1412,6 +1417,49 @@
</plugins>
</build>
</profile>
+
+
+ <!--
+ The following profiles optimize the build for each team, according to their
+ stack layers (batch, server and web teams)
+ -->
+ <profile>
+ <!-- disable all tests -->
+ <id>skipTests</id>
+ <activation>
+ <property>
+ <name>skipTests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipWebTests>true</skipWebTests>
+ <skipBatchTests>true</skipBatchTests>
+ <skipServerTests>true</skipServerTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>batch</id>
+ <properties>
+ <skipServerTests>true</skipServerTests>
+ <skipWebTests>true</skipWebTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>server</id>
+ <properties>
+ <skipBatchTests>true</skipBatchTests>
+ <skipWebTests>true</skipWebTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>web</id>
+ <properties>
+ <!-- the web team does not care about java tests -->
+ <skipBatchTests>true</skipBatchTests>
+ <skipServerTests>true</skipServerTests>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/server/sonar-process-monitor/pom.xml b/server/sonar-process-monitor/pom.xml
index e0e78a7fa4d..84b0b85cfb0 100644
--- a/server/sonar-process-monitor/pom.xml
+++ b/server/sonar-process-monitor/pom.xml
@@ -82,4 +82,16 @@
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/server/sonar-process/pom.xml b/server/sonar-process/pom.xml
index 387e5ecc519..4d0308efbad 100644
--- a/server/sonar-process/pom.xml
+++ b/server/sonar-process/pom.xml
@@ -91,6 +91,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
index 4aa072a6eb3..cd92bbf4e7e 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java
@@ -96,6 +96,6 @@ public class ConfigurationUtilsTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(ConfigurationUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(ConfigurationUtils.class)).isTrue();
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/LoopbackAddressTest.java b/server/sonar-process/src/test/java/org/sonar/process/LoopbackAddressTest.java
index b612e24342d..8ccafff1f66 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/LoopbackAddressTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/LoopbackAddressTest.java
@@ -52,6 +52,6 @@ public class LoopbackAddressTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(LoopbackAddress.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(LoopbackAddress.class)).isTrue();
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java
index 0462f76707a..052c67d94fe 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/NetworkUtilsTest.java
@@ -42,6 +42,6 @@ public class NetworkUtilsTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(NetworkUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(NetworkUtils.class)).isTrue();
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
index ae1f53b2653..1a18d5983ae 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java
@@ -22,10 +22,12 @@ package org.sonar.process;
import org.junit.Test;
import org.sonar.test.TestUtils;
+import static org.fest.assertions.Assertions.assertThat;
+
public class ProcessUtilsTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(ProcessUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(ProcessUtils.class)).isTrue();
}
}
diff --git a/server/sonar-search/pom.xml b/server/sonar-search/pom.xml
index f15dd473a3f..4acf667ce50 100644
--- a/server/sonar-search/pom.xml
+++ b/server/sonar-search/pom.xml
@@ -67,4 +67,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml
index 188888b6367..41c98f29168 100644
--- a/server/sonar-server/pom.xml
+++ b/server/sonar-server/pom.xml
@@ -263,6 +263,13 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/server/sonar-web/pom.xml b/server/sonar-web/pom.xml
index 324df14854a..27efe591792 100644
--- a/server/sonar-web/pom.xml
+++ b/server/sonar-web/pom.xml
@@ -173,7 +173,8 @@
<id>js-tests</id>
<activation>
<property>
- <name>!skipTests</name>
+ <name>skipWebTests</name>
+ <value>false</value>
</property>
</activation>
<build>
diff --git a/server/sonar-ws-client/pom.xml b/server/sonar-ws-client/pom.xml
index 4149dbea11b..089c5742d23 100644
--- a/server/sonar-ws-client/pom.xml
+++ b/server/sonar-ws-client/pom.xml
@@ -172,6 +172,13 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index 914c60ebf5a..495631ea4dc 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -258,6 +258,13 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
<profiles>
diff --git a/sonar-application/src/main/assembly/conf/wrapper.conf b/sonar-application/src/main/assembly/conf/wrapper.conf
index 2fb5f96c844..86834b8a80b 100644
--- a/sonar-application/src/main/assembly/conf/wrapper.conf
+++ b/sonar-application/src/main/assembly/conf/wrapper.conf
@@ -28,7 +28,7 @@ wrapper.java.maxmemory=32
wrapper.console.format=PM
wrapper.console.loglevel=INFO
-wrapper.logfile=../../logs/application.log
+wrapper.logfile=../../logs/sonar.log
wrapper.logfile.format=M
wrapper.logfile.loglevel=INFO
diff --git a/sonar-application/src/test/java/org/sonar/application/DefaultSettingsTest.java b/sonar-application/src/test/java/org/sonar/application/DefaultSettingsTest.java
index 49a66bc590c..82969821f62 100644
--- a/sonar-application/src/test/java/org/sonar/application/DefaultSettingsTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/DefaultSettingsTest.java
@@ -60,6 +60,6 @@ public class DefaultSettingsTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(DefaultSettings.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(DefaultSettings.class)).isTrue();
}
}
diff --git a/sonar-batch-protocol/pom.xml b/sonar-batch-protocol/pom.xml
index e0a483626b6..5bb8320253c 100644
--- a/sonar-batch-protocol/pom.xml
+++ b/sonar-batch-protocol/pom.xml
@@ -38,4 +38,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml
index d63d11bea9a..f1be69f94de 100644
--- a/sonar-batch/pom.xml
+++ b/sonar-batch/pom.xml
@@ -109,6 +109,13 @@
<!-- unit tests -->
<dependency>
<groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
@@ -160,4 +167,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-check-api/pom.xml b/sonar-check-api/pom.xml
index bccf2f6557c..0ab319c4546 100644
--- a/sonar-check-api/pom.xml
+++ b/sonar-check-api/pom.xml
@@ -18,4 +18,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-duplications/pom.xml b/sonar-duplications/pom.xml
index d6e5ff2082a..0ec823f57a6 100644
--- a/sonar-duplications/pom.xml
+++ b/sonar-duplications/pom.xml
@@ -79,4 +79,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-graph/pom.xml b/sonar-graph/pom.xml
index 88e9bfaad2f..ffc47c481b4 100644
--- a/sonar-graph/pom.xml
+++ b/sonar-graph/pom.xml
@@ -37,4 +37,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-java-api/pom.xml b/sonar-java-api/pom.xml
index 321e44fbc93..2b1b94ba198 100644
--- a/sonar-java-api/pom.xml
+++ b/sonar-java-api/pom.xml
@@ -29,4 +29,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-markdown/pom.xml b/sonar-markdown/pom.xml
index 9f25eb74902..e36b1369d99 100644
--- a/sonar-markdown/pom.xml
+++ b/sonar-markdown/pom.xml
@@ -47,4 +47,15 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-maven-plugin/pom.xml b/sonar-maven-plugin/pom.xml
index 5a93cf227ad..06e8f96152d 100644
--- a/sonar-maven-plugin/pom.xml
+++ b/sonar-maven-plugin/pom.xml
@@ -61,4 +61,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
index 5dcd2f2b937..50e1e640419 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
@@ -160,12 +160,6 @@ public class HttpDownloaderTest {
new HttpDownloader(new Settings(), 50).readString(new URI(baseUrl + "/timeout/"), Charsets.UTF_8);
}
- @Test(expected = SonarException.class)
- public void failIfServerDown() throws Exception {
- int port = new InetSocketAddress(0).getPort();
- new HttpDownloader(new Settings()).readBytes(new URI("http://localhost:" + port));
- }
-
@Test
public void downloadToFile() throws URISyntaxException, IOException {
File toDir = temporaryFolder.newFolder();
@@ -182,8 +176,8 @@ public class HttpDownloaderTest {
File toFile = new File(toDir, "downloadToFile.txt");
try {
- // I hope that the port 1 is not used !
- new HttpDownloader(new Settings()).download(new URI("http://localhost:1/unknown"), toFile);
+ int port = new InetSocketAddress(0).getPort();
+ new HttpDownloader(new Settings()).download(new URI("http://localhost:" + port), toFile);
} catch (SonarException e) {
assertThat(toFile).doesNotExist();
}
diff --git a/sonar-testing-harness/pom.xml b/sonar-testing-harness/pom.xml
index 1988abb0009..fcb912699a0 100644
--- a/sonar-testing-harness/pom.xml
+++ b/sonar-testing-harness/pom.xml
@@ -20,10 +20,6 @@
<artifactId>jsonassert</artifactId>
</dependency>
<dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
@@ -32,21 +28,22 @@
<artifactId>hamcrest-all</artifactId>
</dependency>
<dependency>
- <!-- used only for org.sonar.test.channel classes -->
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-channel</artifactId>
- <optional>true</optional>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${project.version}</version>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
diff --git a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java
deleted file mode 100644
index a216dca3631..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.server.ws;
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java
index 0a5d8fcaef0..c8522ec3ed8 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/TestUtils.java
@@ -27,9 +27,6 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.net.URL;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
/**
* Utilities for unit tests
*
@@ -73,14 +70,24 @@ public final class TestUtils {
return getResource(resourcePath);
}
- public static void assertPrivateConstructor(Class clazz) {
- try {
- Constructor constructor = clazz.getDeclaredConstructor();
- assertThat(Modifier.isPrivate(constructor.getModifiers())).isTrue();
- constructor.setAccessible(true);
- constructor.newInstance();
- } catch (Exception e) {
- fail("Fail to instantiate " + clazz, e);
+ /**
+ * Asserts that all constructors are private, usually for helper classes with
+ * only static methods. If a constructor does not have any parameters, then
+ * it's instantiated.
+ */
+ public static boolean hasOnlyPrivateConstructors(Class clazz) {
+ boolean ok = true;
+ for (Constructor constructor : clazz.getDeclaredConstructors()) {
+ ok &= Modifier.isPrivate(constructor.getModifiers());
+ if (constructor.getParameterTypes().length == 0) {
+ constructor.setAccessible(true);
+ try {
+ constructor.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(String.format("Fail to instantiate %s", clazz), e);
+ }
+ }
}
+ return ok;
}
}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatcher.java
deleted file mode 100644
index c262cbca65e..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatcher.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.test.channel;
-
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
-public class ChannelMatcher<O> extends BaseMatcher<Channel<O>> {
-
- private final String sourceCode;
- private final O output;
- private final CodeReader reader;
-
- public ChannelMatcher(String sourceCode, O output) {
- this.sourceCode = sourceCode;
- this.output = output;
- this.reader = new CodeReader(sourceCode);
- }
-
- public ChannelMatcher(CodeReader reader, O output) {
- this.output = output;
- this.sourceCode = new String(reader.peek(30));
- this.reader = reader;
- }
-
- public boolean matches(Object arg0) {
- if ( !(arg0 instanceof Channel)) {
- return false;
- }
- Channel<O> channel = (Channel<O>) arg0;
- return channel.consume(reader, output);
- }
-
- public void describeTo(Description description) {
- description.appendText("Channel consumes '" + sourceCode + "'");
- }
-
-}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatchers.java b/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatchers.java
deleted file mode 100644
index b3bce24c591..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ChannelMatchers.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.test.channel;
-
-import org.sonar.channel.CodeReader;
-
-public final class ChannelMatchers {
-
- private ChannelMatchers() {
- }
-
- public static <O> ChannelMatcher<O> consume(String sourceCode, O output) {
- return new ChannelMatcher<O>(sourceCode, output);
- }
-
- public static <O> ChannelMatcher<O> consume(CodeReader codeReader, O output) {
- return new ChannelMatcher<O>(codeReader, output);
- }
-
- public static ReaderHasNextCharMatcher hasNextChar(char nextChar) {
- return new ReaderHasNextCharMatcher(nextChar);
- }
-}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ReaderHasNextCharMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/channel/ReaderHasNextCharMatcher.java
deleted file mode 100644
index 477dc89a29b..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/test/channel/ReaderHasNextCharMatcher.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-package org.sonar.test.channel;
-
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.sonar.channel.CodeReader;
-
-public class ReaderHasNextCharMatcher extends BaseMatcher<CodeReader> {
-
- private final char nextChar;
-
- public ReaderHasNextCharMatcher(char nextChar) {
- this.nextChar = nextChar;
- }
-
- public boolean matches(Object arg0) {
- if ( !(arg0 instanceof CodeReader)) {
- return false;
- }
- CodeReader reader = (CodeReader) arg0;
- return reader.peek() == nextChar;
- }
-
- public void describeTo(Description description) {
- description.appendText("next char is '" + nextChar + "'");
- }
-
-}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/channel/package-info.java b/sonar-testing-harness/src/main/java/org/sonar/test/channel/package-info.java
deleted file mode 100644
index 482c6191040..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/test/channel/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 02110-1301, USA.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.test.channel;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java
index 3bc97ec8e44..360685bec9b 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java
@@ -24,6 +24,7 @@ import org.apache.commons.lang.StringUtils;
import org.sonar.test.TestUtils;
import java.io.File;
+import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -49,7 +50,7 @@ public final class I18nMatchers {
* Checks that all the translation bundles found on the classpath are up to date with the corresponding default ones found in the classpath.
*/
public static void assertBundlesUpToDate() {
- File bundleFolder = TestUtils.getResource(BundleSynchronizedMatcher.L10N_PATH);
+ File bundleFolder = getResource(BundleSynchronizedMatcher.L10N_PATH);
if (bundleFolder == null || !bundleFolder.isDirectory()) {
fail("No bundle found in: " + BundleSynchronizedMatcher.L10N_PATH);
}
@@ -77,4 +78,16 @@ public final class I18nMatchers {
fail(message.toString());
}
}
+
+ private static File getResource(String path) {
+ String resourcePath = path;
+ if (!resourcePath.startsWith("/")) {
+ resourcePath = "/" + resourcePath;
+ }
+ URL url = TestUtils.class.getResource(resourcePath);
+ if (url != null) {
+ return FileUtils.toFile(url);
+ }
+ return null;
+ }
}
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java
index 54a0d903357..f06d434441c 100644
--- a/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java
+++ b/sonar-testing-harness/src/test/java/org/sonar/test/TestUtilsTest.java
@@ -24,6 +24,7 @@ import org.junit.Test;
import java.io.File;
import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
import static org.sonar.test.TestUtils.getResource;
public class TestUtilsTest {
@@ -45,4 +46,47 @@ public class TestUtilsTest {
File file = getResource("org/sonar/test/TestUtilsTest/unknown.txt");
assertThat(file).isNull();
}
+
+ @Test
+ public void hasOnlyPrivateConstructors() {
+ assertThat(TestUtils.hasOnlyPrivateConstructors(TestUtils.class)).isTrue();
+ assertThat(TestUtils.hasOnlyPrivateConstructors(OnlyPrivateConstructors.class)).isTrue();
+ assertThat(TestUtils.hasOnlyPrivateConstructors(MixOfPublicAndPrivateConstructors.class)).isFalse();
+ try {
+ TestUtils.hasOnlyPrivateConstructors(FailToInstantiate.class);
+ fail();
+ } catch (IllegalStateException e) {
+ // ok
+ }
+ }
+
+ public static class OnlyPrivateConstructors {
+ private OnlyPrivateConstructors() {
+ }
+
+ private OnlyPrivateConstructors(int i) {
+ }
+
+ public static void foo() {
+
+ }
+ }
+
+ public static class MixOfPublicAndPrivateConstructors {
+ private MixOfPublicAndPrivateConstructors() {
+ }
+
+ public MixOfPublicAndPrivateConstructors(int i) {
+ }
+
+ public static void foo() {
+
+ }
+ }
+
+ public static class FailToInstantiate {
+ private FailToInstantiate() {
+ throw new IllegalArgumentException();
+ }
+ }
}