diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
commit | aeadc1f9129274949daaa57738c7c4550bdfbc7b (patch) | |
tree | 08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /tests/volume | |
download | sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip |
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'tests/volume')
-rw-r--r-- | tests/volume/README.txt | 7 | ||||
-rw-r--r-- | tests/volume/build.xml | 71 | ||||
-rw-r--r-- | tests/volume/duplicate_project.rb | 83 | ||||
-rw-r--r-- | tests/volume/lib/ant-contrib-1.0b3.jar | bin | 0 -> 224277 bytes | |||
-rw-r--r-- | tests/volume/pom.xml | 273 | ||||
-rw-r--r-- | tests/volume/project/Template.java | 38 | ||||
-rw-r--r-- | tests/volume/project/pom.template | 10 | ||||
-rw-r--r-- | tests/volume/src/it/java/org/sonar/tests/volume/HomepageTest.java | 50 |
8 files changed, 532 insertions, 0 deletions
diff --git a/tests/volume/README.txt b/tests/volume/README.txt new file mode 100644 index 00000000000..fbb3bfbdf4f --- /dev/null +++ b/tests/volume/README.txt @@ -0,0 +1,7 @@ +---------- +Scenario 1 : test the Oracle limitation on the number of elements in the clause 'IN' (1 000 elements) + +# generate and analyze 1010 projects. Each project has 5 packages and 5*10 classes +mvn clean install -Pfirefox,oracle -DprojectsCount=1010 -DpackagesCount=5 -DclassesCount=10 + +# NOTE FOR MAC OS : add the parameter -Djava.io.tmpdir=/tmp
\ No newline at end of file diff --git a/tests/volume/build.xml b/tests/volume/build.xml new file mode 100644 index 00000000000..46df0e0b89d --- /dev/null +++ b/tests/volume/build.xml @@ -0,0 +1,71 @@ +<project name="Volumetry tests" basedir="."> + <property environment="env"/> + + <taskdef resource="net/sf/antcontrib/antlib.xml"> + <classpath> + <pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar"/> + </classpath> + </taskdef> + + <target name="analyze-projects"> + <exec executable="ruby" failonerror="true" dir="${basedir}"> + <!-- >1000 in order to test SONAR-1339 : pb with Oracle when more than 1000 projects --> + <arg line="duplicate_project.rb ${projectsCount} ${packagesCount} ${classesCount}"/> + </exec> + + <mvn args="clean install" dir="${basedir}/project" /> + <mvnsonar pom="${basedir}/project/pom.xml"/> + + <for param="pom"> + <path> + <fileset dir="${basedir}/project" includes="pom.xml.*"/> + </path> + <sequential> + <mvnsonar pom="@{pom}"/> + </sequential> + </for> + </target> + + + <macrodef name="mvn"> + <attribute name="failonerror" default="true"/> + <attribute name="args" default=""/> + <attribute name="dir"/> + + <sequential> + <echo>Executing ${maven.home}/bin/mvn @{args}</echo> + <exec dir="@{dir}" failonerror="@{failonerror}" executable="${maven.home}/bin/mvn.bat" osfamily="Windows"> + <arg line="@{args} -B -e"/> + </exec> + <exec dir="@{dir}" failonerror="@{failonerror}" executable="${maven.home}/bin/mvn" osfamily="unix"> + <arg line="@{args} -B -e"/> + </exec> + </sequential> + </macrodef> + + <macrodef name="mvnsonar"> + <attribute name="failonerror" default="true"/> + <attribute name="args" default=""/> + <attribute name="pom"/> + + <sequential> + <exec failonerror="@{failonerror}" executable="${maven.home}/bin/mvn.bat" osfamily="Windows"> + <arg line="org.codehaus.mojo:sonar-maven-plugin:1.0-beta-1:sonar @{args} -B -e"/> + <arg line="-f @{pom}"/> + <arg value='-Dsonar.jdbc.url="${jdbcUrl}"'/> + <arg value="-Dsonar.jdbc.driver=${jdbcDriver}"/> + <arg value="-Dsonar.jdbc.username=${jdbcUsername}"/> + <arg value="-Dsonar.jdbc.password=${jdbcPassword}"/> + </exec> + <exec failonerror="@{failonerror}" executable="${maven.home}/bin/mvn" osfamily="unix"> + <arg line="org.codehaus.mojo:sonar-maven-plugin:1.0-beta-1:sonar @{args} -B -e"/> + <arg line="-f @{pom}"/> + <arg value='-Dsonar.jdbc.url=${jdbcUrl}'/> + <arg value="-Dsonar.jdbc.driver=${jdbcDriver}"/> + <arg value="-Dsonar.jdbc.username=${jdbcUsername}"/> + <arg value="-Dsonar.jdbc.password=${jdbcPassword}"/> + </exec> + </sequential> + </macrodef> + +</project>
\ No newline at end of file diff --git a/tests/volume/duplicate_project.rb b/tests/volume/duplicate_project.rb new file mode 100644 index 00000000000..80bf61c5b09 --- /dev/null +++ b/tests/volume/duplicate_project.rb @@ -0,0 +1,83 @@ +require 'fileutils.rb' + +class SourceGenerator + + def initialize + FileUtils.remove_dir "project/src/main/java", true + end + + def template + if @template.nil? + @template = '' + f = File.open("project/Template.java", "r") + f.each_line do |line| + @template += line + end + end + @template + end + + def sources(package_name, class_name) + template.gsub(/#PACKAGE/,package_name).gsub(/#CLASS/, class_name) + end + + def generate(package_name, class_name) + content=sources(package_name, class_name) + dir="project/src/main/java/" + package_name.gsub(/\./, '/') + save(dir, "#{class_name}.java", content) + end + + private + def save(dir, filename,content) + FileUtils::mkdir_p dir + my_file = File.new("#{dir}/#{filename}", 'w') + my_file<<content + my_file.close + end +end + + +class ProjectDuplicator + def initialize + FileUtils.rm_f 'project/pom.xml' + FileUtils.rm Dir.glob('project/pom.xml.*') + end + def duplicate_pom(index) + pom=template().gsub(/#ID/,index.to_s) + filename=(index==1 ? "project/pom.xml" : "project/pom.xml.#{index}") + pom_file = File.new(filename, 'w') + pom_file<<pom + pom_file.close + end + + def template + if @template.nil? + @template = '' + f = File.open("project/pom.template", "r") + f.each_line do |line| + @template += line + end + end + @template + end + +end + +projects_count=(ARGV.size>0 ? ARGV[0].to_i : 10) +packages_count=(ARGV.size>1 ? ARGV[1].to_i : 10) +classes_count=(ARGV.size>2 ? ARGV[2].to_i : 10) + + +source_generator=SourceGenerator.new +for index_package in (1..packages_count) + for index_class in (1..classes_count) + source_generator.generate("org.sonar.tests.volume#{index_package}", "Class#{index_class}") + end +end +puts "#{classes_count * packages_count} classes saved in #{packages_count} packages." + +duplicator=ProjectDuplicator.new +for index in (1..projects_count) + puts "Generating project #{index}..." + duplicator.duplicate_pom(index) +end
\ No newline at end of file diff --git a/tests/volume/lib/ant-contrib-1.0b3.jar b/tests/volume/lib/ant-contrib-1.0b3.jar Binary files differnew file mode 100644 index 00000000000..062537661a5 --- /dev/null +++ b/tests/volume/lib/ant-contrib-1.0b3.jar diff --git a/tests/volume/pom.xml b/tests/volume/pom.xml new file mode 100644 index 00000000000..ba88a14a9ba --- /dev/null +++ b/tests/volume/pom.xml @@ -0,0 +1,273 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar</artifactId> + <version>2.3-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + <groupId>org.codehaus.sonar.tests</groupId> + <artifactId>volume</artifactId> + <name>Sonar :: Volume Testing</name> + <description>High volume testing, for example to check the Oracle constraint on max number of elements in the clause IN.</description> + + <properties> + <sonar.url>http://localhost:9000/</sonar.url> + <sonar.runtimeVersion>${project.version}</sonar.runtimeVersion> + <projectsCount>1010</projectsCount> + <packagesCount>5</packagesCount> + <classesCount>5</classesCount> + </properties> + + + <build> + <testSourceDirectory>src/it/java</testSourceDirectory> + <testResources> + <testResource> + <filtering>false</filtering> + <directory>src/it/resources</directory> + </testResource> + </testResources> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.1</version> + <executions> + <execution> + <id>copy</id> + + <!-- must be executed after the ant task that builds the directory target/extensions --> + <phase>package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>com.oracle</groupId> + <artifactId>ojdbc14</artifactId> + <version>10.2.0.3.0</version> + <type>jar</type> + <overWrite>false</overWrite> + <outputDirectory>${basedir}/target/extensions/jdbc-driver/oracle</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-dev-maven-plugin</artifactId> + <version>0.3</version> + <executions> + <execution> + <id>start-server</id> + <phase>pre-integration-test</phase> + <configuration> + <sonar.background>true</sonar.background> + <sonar.runtimeVersion>${sonar.runtimeVersion}</sonar.runtimeVersion> + <sonar.dropDatabase>false</sonar.dropDatabase> + <sonar.extensionsDir>${basedir}/target/extensions</sonar.extensionsDir> + </configuration> + <goals> + <goal>start-war</goal> + </goals> + </execution> + <execution> + <id>stop-server</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop-war</goal> + </goals> + <configuration> + <sonar.runtimeVersion>${sonar.runtimeVersion}</sonar.runtimeVersion> + </configuration> + </execution> + </executions> + </plugin> + + + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.4</version> + <dependencies> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-nodeps</artifactId> + <version>1.7.1</version> + </dependency> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-junit</artifactId> + <version>1.7.1</version> + </dependency> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-trax</artifactId> + <version>1.7.1</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>analyze-projects</id> + <phase>pre-integration-test</phase> + <configuration> + <tasks> + <ant dir="${basedir}" inheritRefs="true"> + <property name="projectsCount" value="${projectsCount}" /> + <property name="packagesCount" value="${packagesCount}" /> + <property name="classesCount" value="${classesCount}" /> + <property name="jdbcDriver" value="${sonar.jdbc.driver}" /> + <property name="jdbcUrl" value="${sonar.jdbc.url}" /> + <property name="jdbcUsername" value="${sonar.jdbc.username}" /> + <property name="jdbcPassword" value="${sonar.jdbc.password}" /> + <property name="sonarVersion" value="${sonar.runtimeVersion}" /> + <target name="analyze-projects" /> + </ant> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>selenium-maven-plugin</artifactId> + <version>1.0.1</version> + <executions> + <execution> + <id>start-selenium</id> + <phase>pre-integration-test</phase> + <goals> + <goal>start-server</goal> + </goals> + <configuration> + <background>true</background> + </configuration> + </execution> + <execution> + <id>stop-selenium</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop-server</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <!-- Skip the normal tests, we'll run them in the integration-test phase --> + <skip>true</skip> + </configuration> + <executions> + <execution> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <skip>false</skip> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-nodeps</artifactId> + <version>1.7.1</version> + </dependency> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-junit</artifactId> + <version>1.7.1</version> + </dependency> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant-trax</artifactId> + <version>1.7.1</version> + </dependency> + <dependency> + <groupId>com.oracle</groupId> + <artifactId>ojdbc14</artifactId> + <version>10.2.0.3.0</version> + </dependency> + <dependency> + <groupId>org.seleniumhq.selenium.client-drivers</groupId> + <artifactId>selenium-java-client-driver</artifactId> + <version>1.0.2</version> + </dependency> + </dependencies> + + <profiles> + + <!-- BROWSERS --> + <profile> + <id>firefox</id> + <properties> + <selenium.browser>*firefox</selenium.browser> + </properties> + </profile> + <profile> + <id>ie</id> + <properties> + <selenium.browser>*iexplore</selenium.browser> + </properties> + </profile> + + <profile> + <id>oracle</id> + <properties> + <sonar.jdbc.url>jdbc:oracle:thin:@localhost/XE</sonar.jdbc.url> + <sonar.jdbc.username>sonar_volume</sonar.jdbc.username> + <sonar.jdbc.password>sonar_volume</sonar.jdbc.password> + <sonar.jdbc.driver>oracle.jdbc.driver.OracleDriver</sonar.jdbc.driver> + </properties> + </profile> + + <profile> + <id>postgresql</id> + <properties> + <sonar.jdbc.url>jdbc:postgresql://localhost/sonar</sonar.jdbc.url> + <sonar.jdbc.username>sonar</sonar.jdbc.username> + <sonar.jdbc.password>sonar</sonar.jdbc.password> + <sonar.jdbc.driver>org.postgresql.Driver</sonar.jdbc.driver> + </properties> + </profile> + + <profile> + <id>mssql</id> + <properties> + <sonar.jdbc.url>jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor</sonar.jdbc.url> + <sonar.jdbc.username>sonar</sonar.jdbc.username> + <sonar.jdbc.password>sonar</sonar.jdbc.password> + <sonar.jdbc.driver>net.sourceforge.jtds.jdbc.Driver</sonar.jdbc.driver> + </properties> + </profile> + + <profile> + <id>mysql</id> + <properties> + <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url> + <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> + <sonar.jdbc.username>sonar</sonar.jdbc.username> + <sonar.jdbc.password>sonar</sonar.jdbc.password> + </properties> + </profile> + </profiles> + +</project>
\ No newline at end of file diff --git a/tests/volume/project/Template.java b/tests/volume/project/Template.java new file mode 100644 index 00000000000..94e7e574b55 --- /dev/null +++ b/tests/volume/project/Template.java @@ -0,0 +1,38 @@ +package #PACKAGE; + +import java.util.*; + +public class #CLASS { + public void hello( ) { + System.out.println("hello");; + int index=333; + } + + public void Hello( ) { + for (int i=0 ; i<1000 ; i++) { + int j=i*2; + } + } + + public static final int FOO() { + int j=111; + j++; + Vector v = new Vector(); + Vector v2 = new Vector(); + String s=null; + System.out.println(s); + return 222; + } + + public Object clone() { + return new Object(); + } + + public String toString() { + return "xxxxxxxxxxxxxxxx"; + } + + public String toString(String s) { + return s; + } +}
\ No newline at end of file diff --git a/tests/volume/project/pom.template b/tests/volume/project/pom.template new file mode 100644 index 00000000000..5381b7707e3 --- /dev/null +++ b/tests/volume/project/pom.template @@ -0,0 +1,10 @@ +<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.sonar.tests</groupId>
+ <artifactId>volume-#ID</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Volume #ID</name>
+ <properties>
+ <sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
+ </properties>
+</project>
\ No newline at end of file diff --git a/tests/volume/src/it/java/org/sonar/tests/volume/HomepageTest.java b/tests/volume/src/it/java/org/sonar/tests/volume/HomepageTest.java new file mode 100644 index 00000000000..71f339b6284 --- /dev/null +++ b/tests/volume/src/it/java/org/sonar/tests/volume/HomepageTest.java @@ -0,0 +1,50 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.tests.volume; + +import com.thoughtworks.selenium.DefaultSelenium; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class HomepageTest { + private DefaultSelenium selenium; + + @Before + public void before() throws Exception { + selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:9000"); + selenium.start(); + } + + @After + public void after() { + selenium.stop(); + } + + @Test + public void testHomepage() throws Exception { + selenium.open("/"); + selenium.waitForPageToLoad("30000"); + assertTrue(selenium.isElementPresent("results")); + } + +} |