<phase>package</phase>
<configuration>
<tasks>
- <ant dir="${basedir}" inheritRefs="true">
+ <ant dir="${project.basedir}" inheritRefs="true">
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<target name="prepare-extensions" />
</ant>
--- /dev/null
+/*
+ * 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.integration;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+public class GzipCompressionIT {
+
+ private HttpClient client;
+ private HttpMethod method;
+
+ @Before
+ public void before() {
+ client = new HttpClient();
+ method = new GetMethod(ITUtils.getSonarURL());
+ }
+
+ @After
+ public void after(){
+ method.releaseConnection();
+ }
+
+ @Test
+ public void responseShouldBeGzipped() throws IOException {
+ client.executeMethod(method);
+ int sizeWithoutGzip = method.getResponseBodyAsString().length();
+ assertThat(sizeWithoutGzip, greaterThan(0));
+ assertThat(method.getResponseHeader("Content-Encoding"), nullValue());
+
+ method.setRequestHeader("Accept-Encoding", "gzip, deflate");
+ client.executeMethod(method);
+ int sizeWithGzip = method.getResponseBodyAsString().length();
+ assertThat(sizeWithGzip, greaterThan(0));
+ assertThat(method.getResponseHeader("Content-Encoding").getValue(), is("gzip"));
+
+ assertThat(sizeWithGzip, lessThan(sizeWithoutGzip));
+ }
+
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.integration;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-public class GzipCompressionTest {
-
- private HttpClient client;
- private HttpMethod method;
-
- @Before
- public void before() {
- client = new HttpClient();
- method = new GetMethod(ITUtils.getSonarURL());
- }
-
- @After
- public void after(){
- method.releaseConnection();
- }
-
- @Test
- public void responseShouldBeGzipped() throws IOException {
- client.executeMethod(method);
- int sizeWithoutGzip = method.getResponseBodyAsString().length();
- assertThat(sizeWithoutGzip, greaterThan(0));
- assertThat(method.getResponseHeader("Content-Encoding"), nullValue());
-
- method.setRequestHeader("Accept-Encoding", "gzip, deflate");
- client.executeMethod(method);
- int sizeWithGzip = method.getResponseBodyAsString().length();
- assertThat(sizeWithGzip, greaterThan(0));
- assertThat(method.getResponseHeader("Content-Encoding").getValue(), is("gzip"));
-
- assertThat(sizeWithGzip, lessThan(sizeWithoutGzip));
- }
-
-}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.integration;
+
+import org.junit.Test;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.Server;
+import org.sonar.wsclient.services.ServerQuery;
+
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class ServerIT {
+
+ @Test
+ public void shouldGetVersion() {
+ Sonar sonar = ITUtils.createSonarWsClient();
+ assertThat(sonar.find(new ServerQuery()).getVersion(), endsWith("-SNAPSHOT"));
+ }
+
+ @Test
+ public void shouldGetStatus() {
+ Sonar sonar = ITUtils.createSonarWsClient();
+ assertThat(sonar.find(new ServerQuery()).getStatus(), is(Server.Status.UP));
+ }
+}
+++ /dev/null
-/*
- * 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.integration;
-
-import org.junit.Test;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.Server;
-import org.sonar.wsclient.services.ServerQuery;
-
-import static org.hamcrest.Matchers.endsWith;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class ServerTest {
-
- @Test
- public void shouldGetVersion() {
- Sonar sonar = ITUtils.createSonarWsClient();
- assertThat(sonar.find(new ServerQuery()).getVersion(), endsWith("-SNAPSHOT"));
- }
-
- @Test
- public void shouldGetStatus() {
- Sonar sonar = ITUtils.createSonarWsClient();
- assertThat(sonar.find(new ServerQuery()).getStatus(), is(Server.Status.UP));
- }
-}
--- /dev/null
+/*
+ * 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.integration;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.*;
+
+import java.util.Date;
+import java.util.List;
+
+import static junit.framework.Assert.assertTrue;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo;
+import static org.hamcrest.number.OrderingComparisons.lessThan;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+/**
+ * To execute these unit tests, just check-out Struts 1.3.9 from subversion:
+ * http://svn.apache.org/repos/asf/struts/struts1/tags/STRUTS_1_3_9
+ * <p/>
+ * The quality profile to use is the default one configured in IT (see the file integration-tests-backup.xml).
+ */
+public class Struts139IT {
+
+ private static Sonar sonar;
+ private static final String PROJECT_STRUTS = "org.apache.struts:struts-parent";
+ private static final String MODULE_CORE = "org.apache.struts:struts-core";
+ private static final String PACKAGE_ACTION = "org.apache.struts:struts-core:org.apache.struts.action";
+ private static final String FILE_ACTION = "org.apache.struts:struts-core:org.apache.struts.action.Action";
+
+ @BeforeClass
+ public static void buildServer() {
+ sonar = ITUtils.createSonarWsClient();
+ }
+
+ @Test
+ public void shouldReturnAnalysisDate() {
+ Date date = sonar.find(new ResourceQuery(PROJECT_STRUTS)).getDate();
+ assertNotNull(date);
+ assertThat(date.getYear(), greaterThanOrEqualTo(110)); // 1900 + 110
+ }
+
+ @Test
+ public void strutsIsAnalyzed() {
+ assertThat(sonar.find(new ResourceQuery(PROJECT_STRUTS)).getName(), is("Struts"));
+ assertThat(sonar.find(new ResourceQuery(PROJECT_STRUTS)).getVersion(), is("1.3.9"));
+ assertThat(sonar.find(new ResourceQuery(MODULE_CORE)).getName(), is("Struts Core"));
+ }
+
+ @Test
+ public void testProjectViolationMeasures() {
+ assertThat(getProjectMeasure(CoreMetrics.VIOLATIONS_KEY).getValue(), closeTo(7726.0, 500.0));
+ assertThat(getProjectMeasure(CoreMetrics.BLOCKER_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
+ assertThat(getProjectMeasure(CoreMetrics.CRITICAL_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
+ assertThat(getProjectMeasure(CoreMetrics.MAJOR_VIOLATIONS_KEY).getValue(), closeTo(2889.0, 200.0));
+ assertThat(getProjectMeasure(CoreMetrics.MINOR_VIOLATIONS_KEY).getValue(), closeTo(0.0, 200.0));
+ assertThat(getProjectMeasure(CoreMetrics.INFO_VIOLATIONS_KEY).getValue(), closeTo(5157.0, 20.0));
+ assertThat(getProjectMeasure(CoreMetrics.VIOLATIONS_DENSITY_KEY).getValue(), closeTo(84.6, 5.0));
+ }
+
+ @Test
+ public void testPackageViolationMeasures() {
+ assertThat(getPackageMeasure(CoreMetrics.VIOLATIONS_KEY).getValue(), closeTo(292.0, 50.0));
+ assertThat(getPackageMeasure(CoreMetrics.BLOCKER_VIOLATIONS_KEY).getValue(), closeTo(0.0, 5.0));
+ assertThat(getPackageMeasure(CoreMetrics.CRITICAL_VIOLATIONS_KEY).getValue(), closeTo(0.0, 5.0));
+ assertThat(getPackageMeasure(CoreMetrics.MAJOR_VIOLATIONS_KEY).getValue(), closeTo(111.0, 20.0));
+ assertThat(getPackageMeasure(CoreMetrics.MINOR_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
+ assertThat(getPackageMeasure(CoreMetrics.INFO_VIOLATIONS_KEY).getValue(), closeTo(181.0, 20.0));
+ assertThat(getPackageMeasure(CoreMetrics.VIOLATIONS_DENSITY_KEY).getValue(), closeTo(87.8, 5.0));
+ }
+
+
+ @Test
+ public void sizeMetrics() {
+ assertThat(getProjectMeasure("lines").getIntValue(), is(114621));
+ assertThat(getProjectMeasure("ncloc").getIntValue(), is(50080));
+ assertThat(getProjectMeasure("functions").getIntValue(), is(4292));
+ assertThat(getProjectMeasure("accessors").getIntValue(), is(1133));
+ assertThat(getProjectMeasure("classes").getIntValue(), is(518));
+ assertThat(getProjectMeasure("packages").getIntValue(), is(49));
+ assertThat(getProjectMeasure("files").getIntValue(), is(494));
+ assertThat(getCoreModuleMeasure("files").getIntValue(), is(134));
+ assertThat(getPackageMeasure("files").getIntValue(), is(21));
+ assertThat(getFileMeasure("files").getIntValue(), is(1));
+ }
+
+ @Test
+ public void unitTestMetrics() {
+ assertThat(getProjectMeasure("coverage").getValue(), is(14.7));
+ assertThat(getProjectMeasure("line_coverage").getValue(), is(15.4));
+ assertThat(getProjectMeasure("branch_coverage").getValue(), is(12.8));
+ assertThat(getProjectMeasure("tests").getIntValue(), is(323));
+ assertThat(getProjectMeasure("test_execution_time").getIntValue(), greaterThan(1000));
+ assertThat(getProjectMeasure("test_errors").getIntValue(), is(0));
+ assertThat(getProjectMeasure("test_failures").getIntValue(), is(0));
+ assertThat(getProjectMeasure("skipped_tests").getIntValue(), is(0));
+ assertThat(getProjectMeasure("test_success_density").getValue(), is(100.0));
+
+ }
+
+ @Test
+ public void complexityMetrics() {
+ assertThat(getProjectMeasure("complexity").getIntValue(), is(11140));
+ assertThat(getProjectMeasure("statements").getIntValue(), is(21896));
+ assertThat(getProjectMeasure("class_complexity").getValue(), is(21.5));
+ assertThat(getProjectMeasure("function_complexity").getValue(), is(2.6));
+ assertThat(getProjectMeasure("class_complexity_distribution").getData(), is("0=172;5=90;10=86;20=55;30=69;60=34;90=17"));
+ }
+
+ @Test
+ public void lcom4() {
+ assertThat(getProjectMeasure("lcom4").getValue(), greaterThan(1.5));
+ assertThat(getProjectMeasure("lcom4").getValue(), lessThan(2.0));
+ assertThat(getFileMeasure("lcom4").getValue(), greaterThan(10.0));
+ }
+
+ @Test
+ public void rfc() {
+ assertThat(getProjectMeasure("rfc").getValue(), greaterThan(10.0));
+ assertThat(getProjectMeasure("rfc").getValue(), lessThan(30.0));
+ }
+
+ @Test
+ public void designMeaures() {
+ assertThat(getCoreModuleMeasure("package_cycles").getIntValue(), greaterThan(10));
+ assertThat(getCoreModuleMeasure("package_cycles").getIntValue(), lessThan(50));
+
+ assertThat(getCoreModuleMeasure("package_feedback_edges").getIntValue(), greaterThan(3));
+ assertThat(getCoreModuleMeasure("package_feedback_edges").getIntValue(), lessThan(10));
+
+ assertThat(getCoreModuleMeasure("package_tangles").getIntValue(), greaterThan(10));
+ assertThat(getCoreModuleMeasure("package_tangles").getIntValue(), lessThan(50));
+
+ assertThat(sonar.find(ResourceQuery.createForMetrics(PROJECT_STRUTS, "dit", "noc")).getMeasures().size(), is(0));
+ }
+
+ @Test
+ public void shouldGetDetailsOfCoverageHits() {
+ Resource resource = sonar.find(ResourceQuery.createForMetrics("org.apache.struts:struts-core:org.apache.struts.action.ActionForward", CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY));
+ Measure coverageData = resource.getMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY);
+ assertNotNull(coverageData);
+ assertThat(coverageData.getData().length(), greaterThan(10));
+ assertTrue(coverageData.getData().matches("(\\d+=\\d+;{0,1})+"));
+ }
+
+ @Test
+ public void dependencyTree() {
+ List<DependencyTree> trees = sonar.findAll(DependencyTreeQuery.createForProject(PROJECT_STRUTS));
+ assertThat(trees.size(), is(0));
+
+ trees = sonar.findAll(DependencyTreeQuery.createForProject(MODULE_CORE));
+ assertThat(trees.size(), greaterThan(0));
+ assertThat(trees.get(0).getResourceName(), is("antlr:antlr"));
+ }
+
+ @Test
+ public void versionEvent() {
+ EventQuery query = new EventQuery(PROJECT_STRUTS);
+ query.setCategories(new String[]{"Version"});
+ List<Event> events = sonar.findAll(query);
+ assertThat(events.size(), is(1));
+
+ Event version = events.get(0);
+ assertThat(version.getName(), is("1.3.9"));
+ assertThat(version.getCategory(), is("Version"));
+ }
+
+ /**
+ * See http://jira.codehaus.org/browse/SONAR-2041
+ */
+ @Test
+ public void unknownMetric() {
+ assertThat(getProjectMeasure("notfound"), nullValue());
+ assertThat(getCoreModuleMeasure("notfound"), nullValue());
+ assertThat(getPackageMeasure("notfound"), nullValue());
+ assertThat(getFileMeasure("notfound"), nullValue());
+ }
+
+ private Measure getFileMeasure(String metricKey) {
+ return sonar.find(ResourceQuery.createForMetrics(FILE_ACTION, metricKey)).getMeasure(metricKey);
+ }
+
+ private Measure getCoreModuleMeasure(String metricKey) {
+ return sonar.find(ResourceQuery.createForMetrics(MODULE_CORE, metricKey)).getMeasure(metricKey);
+ }
+
+ private Measure getProjectMeasure(String metricKey) {
+ return sonar.find(ResourceQuery.createForMetrics(PROJECT_STRUTS, metricKey)).getMeasure(metricKey);
+ }
+
+ private Measure getPackageMeasure(String metricKey) {
+ return sonar.find(ResourceQuery.createForMetrics(PACKAGE_ACTION, metricKey)).getMeasure(metricKey);
+ }
+}
+++ /dev/null
-/*
- * 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.integration;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.*;
-
-import java.util.Date;
-import java.util.List;
-
-import static junit.framework.Assert.assertTrue;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.hamcrest.number.IsCloseTo.closeTo;
-import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo;
-import static org.hamcrest.number.OrderingComparisons.lessThan;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-/**
- * To execute these unit tests, just check-out Struts 1.3.9 from subversion:
- * http://svn.apache.org/repos/asf/struts/struts1/tags/STRUTS_1_3_9
- * <p/>
- * The quality profile to use is the default one configured in IT (see the file integration-tests-backup.xml).
- */
-public class Struts139Test {
-
- private static Sonar sonar;
- private static final String PROJECT_STRUTS = "org.apache.struts:struts-parent";
- private static final String MODULE_CORE = "org.apache.struts:struts-core";
- private static final String PACKAGE_ACTION = "org.apache.struts:struts-core:org.apache.struts.action";
- private static final String FILE_ACTION = "org.apache.struts:struts-core:org.apache.struts.action.Action";
-
- @BeforeClass
- public static void buildServer() {
- sonar = ITUtils.createSonarWsClient();
- }
-
- @Test
- public void shouldReturnAnalysisDate() {
- Date date = sonar.find(new ResourceQuery(PROJECT_STRUTS)).getDate();
- assertNotNull(date);
- assertThat(date.getYear(), greaterThanOrEqualTo(110)); // 1900 + 110
- }
-
- @Test
- public void strutsIsAnalyzed() {
- assertThat(sonar.find(new ResourceQuery(PROJECT_STRUTS)).getName(), is("Struts"));
- assertThat(sonar.find(new ResourceQuery(PROJECT_STRUTS)).getVersion(), is("1.3.9"));
- assertThat(sonar.find(new ResourceQuery(MODULE_CORE)).getName(), is("Struts Core"));
- }
-
- @Test
- public void testProjectViolationMeasures() {
- assertThat(getProjectMeasure(CoreMetrics.VIOLATIONS_KEY).getValue(), closeTo(7726.0, 500.0));
- assertThat(getProjectMeasure(CoreMetrics.BLOCKER_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
- assertThat(getProjectMeasure(CoreMetrics.CRITICAL_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
- assertThat(getProjectMeasure(CoreMetrics.MAJOR_VIOLATIONS_KEY).getValue(), closeTo(2889.0, 200.0));
- assertThat(getProjectMeasure(CoreMetrics.MINOR_VIOLATIONS_KEY).getValue(), closeTo(0.0, 200.0));
- assertThat(getProjectMeasure(CoreMetrics.INFO_VIOLATIONS_KEY).getValue(), closeTo(5157.0, 20.0));
- assertThat(getProjectMeasure(CoreMetrics.VIOLATIONS_DENSITY_KEY).getValue(), closeTo(84.6, 5.0));
- }
-
- @Test
- public void testPackageViolationMeasures() {
- assertThat(getPackageMeasure(CoreMetrics.VIOLATIONS_KEY).getValue(), closeTo(292.0, 50.0));
- assertThat(getPackageMeasure(CoreMetrics.BLOCKER_VIOLATIONS_KEY).getValue(), closeTo(0.0, 5.0));
- assertThat(getPackageMeasure(CoreMetrics.CRITICAL_VIOLATIONS_KEY).getValue(), closeTo(0.0, 5.0));
- assertThat(getPackageMeasure(CoreMetrics.MAJOR_VIOLATIONS_KEY).getValue(), closeTo(111.0, 20.0));
- assertThat(getPackageMeasure(CoreMetrics.MINOR_VIOLATIONS_KEY).getValue(), closeTo(0.0, 20.0));
- assertThat(getPackageMeasure(CoreMetrics.INFO_VIOLATIONS_KEY).getValue(), closeTo(181.0, 20.0));
- assertThat(getPackageMeasure(CoreMetrics.VIOLATIONS_DENSITY_KEY).getValue(), closeTo(87.8, 5.0));
- }
-
-
- @Test
- public void sizeMetrics() {
- assertThat(getProjectMeasure("lines").getIntValue(), is(114621));
- assertThat(getProjectMeasure("ncloc").getIntValue(), is(50080));
- assertThat(getProjectMeasure("functions").getIntValue(), is(4292));
- assertThat(getProjectMeasure("accessors").getIntValue(), is(1133));
- assertThat(getProjectMeasure("classes").getIntValue(), is(518));
- assertThat(getProjectMeasure("packages").getIntValue(), is(49));
- assertThat(getProjectMeasure("files").getIntValue(), is(494));
- assertThat(getCoreModuleMeasure("files").getIntValue(), is(134));
- assertThat(getPackageMeasure("files").getIntValue(), is(21));
- assertThat(getFileMeasure("files").getIntValue(), is(1));
- }
-
- @Test
- public void unitTestMetrics() {
- assertThat(getProjectMeasure("coverage").getValue(), is(14.7));
- assertThat(getProjectMeasure("line_coverage").getValue(), is(15.4));
- assertThat(getProjectMeasure("branch_coverage").getValue(), is(12.8));
- assertThat(getProjectMeasure("tests").getIntValue(), is(323));
- assertThat(getProjectMeasure("test_execution_time").getIntValue(), greaterThan(1000));
- assertThat(getProjectMeasure("test_errors").getIntValue(), is(0));
- assertThat(getProjectMeasure("test_failures").getIntValue(), is(0));
- assertThat(getProjectMeasure("skipped_tests").getIntValue(), is(0));
- assertThat(getProjectMeasure("test_success_density").getValue(), is(100.0));
-
- }
-
- @Test
- public void complexityMetrics() {
- assertThat(getProjectMeasure("complexity").getIntValue(), is(11140));
- assertThat(getProjectMeasure("statements").getIntValue(), is(21896));
- assertThat(getProjectMeasure("class_complexity").getValue(), is(21.5));
- assertThat(getProjectMeasure("function_complexity").getValue(), is(2.6));
- assertThat(getProjectMeasure("class_complexity_distribution").getData(), is("0=172;5=90;10=86;20=55;30=69;60=34;90=17"));
- }
-
- @Test
- public void lcom4() {
- assertThat(getProjectMeasure("lcom4").getValue(), greaterThan(1.5));
- assertThat(getProjectMeasure("lcom4").getValue(), lessThan(2.0));
- assertThat(getFileMeasure("lcom4").getValue(), greaterThan(10.0));
- }
-
- @Test
- public void rfc() {
- assertThat(getProjectMeasure("rfc").getValue(), greaterThan(10.0));
- assertThat(getProjectMeasure("rfc").getValue(), lessThan(30.0));
- }
-
- @Test
- public void designMeaures() {
- assertThat(getCoreModuleMeasure("package_cycles").getIntValue(), greaterThan(10));
- assertThat(getCoreModuleMeasure("package_cycles").getIntValue(), lessThan(50));
-
- assertThat(getCoreModuleMeasure("package_feedback_edges").getIntValue(), greaterThan(3));
- assertThat(getCoreModuleMeasure("package_feedback_edges").getIntValue(), lessThan(10));
-
- assertThat(getCoreModuleMeasure("package_tangles").getIntValue(), greaterThan(10));
- assertThat(getCoreModuleMeasure("package_tangles").getIntValue(), lessThan(50));
-
- assertThat(sonar.find(ResourceQuery.createForMetrics(PROJECT_STRUTS, "dit", "noc")).getMeasures().size(), is(0));
- }
-
- @Test
- public void shouldGetDetailsOfCoverageHits() {
- Resource resource = sonar.find(ResourceQuery.createForMetrics("org.apache.struts:struts-core:org.apache.struts.action.ActionForward", CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY));
- Measure coverageData = resource.getMeasure(CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY);
- assertNotNull(coverageData);
- assertThat(coverageData.getData().length(), greaterThan(10));
- assertTrue(coverageData.getData().matches("(\\d+=\\d+;{0,1})+"));
- }
-
- @Test
- public void dependencyTree() {
- List<DependencyTree> trees = sonar.findAll(DependencyTreeQuery.createForProject(PROJECT_STRUTS));
- assertThat(trees.size(), is(0));
-
- trees = sonar.findAll(DependencyTreeQuery.createForProject(MODULE_CORE));
- assertThat(trees.size(), greaterThan(0));
- assertThat(trees.get(0).getResourceName(), is("antlr:antlr"));
- }
-
- @Test
- public void versionEvent() {
- EventQuery query = new EventQuery(PROJECT_STRUTS);
- query.setCategories(new String[]{"Version"});
- List<Event> events = sonar.findAll(query);
- assertThat(events.size(), is(1));
-
- Event version = events.get(0);
- assertThat(version.getName(), is("1.3.9"));
- assertThat(version.getCategory(), is("Version"));
- }
-
- /**
- * See http://jira.codehaus.org/browse/SONAR-2041
- */
- @Test
- public void unknownMetric() {
- assertThat(getProjectMeasure("notfound"), nullValue());
- assertThat(getCoreModuleMeasure("notfound"), nullValue());
- assertThat(getPackageMeasure("notfound"), nullValue());
- assertThat(getFileMeasure("notfound"), nullValue());
- }
-
- private Measure getFileMeasure(String metricKey) {
- return sonar.find(ResourceQuery.createForMetrics(FILE_ACTION, metricKey)).getMeasure(metricKey);
- }
-
- private Measure getCoreModuleMeasure(String metricKey) {
- return sonar.find(ResourceQuery.createForMetrics(MODULE_CORE, metricKey)).getMeasure(metricKey);
- }
-
- private Measure getProjectMeasure(String metricKey) {
- return sonar.find(ResourceQuery.createForMetrics(PROJECT_STRUTS, metricKey)).getMeasure(metricKey);
- }
-
- private Measure getPackageMeasure(String metricKey) {
- return sonar.find(ResourceQuery.createForMetrics(PACKAGE_ACTION, metricKey)).getMeasure(metricKey);
- }
-}
--- /dev/null
+/*
+ * 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.integration;
+
+import org.apache.commons.lang.StringUtils;
+import org.junit.Test;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.Plugin;
+import org.sonar.wsclient.services.UpdateCenterQuery;
+
+import java.util.List;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.hamcrest.Matchers.startsWith;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
+
+public class UpdateCenterIT {
+
+ @Test
+ public void shouldGetInstalledPlugins() {
+ Sonar sonar = ITUtils.createSonarWsClient();
+ List<Plugin> plugins = sonar.findAll(UpdateCenterQuery.createForInstalledPlugins());
+ assertThat(plugins.size(), greaterThan(0));
+
+ Plugin referencePlugin = findReferencePlugin(plugins, "itreference");
+ assertNotNull(referencePlugin);
+ assertThat(referencePlugin.getName(), is("Sonar :: Integration Tests :: Reference Plugin"));
+ assertThat(referencePlugin.getVersion(), startsWith("2."));
+ }
+
+ private Plugin findReferencePlugin(List<Plugin> plugins, String pluginKey) {
+ for (Plugin plugin : plugins) {
+ if (StringUtils.equals(pluginKey, plugin.getKey())) {
+ return plugin;
+ }
+ }
+ return null;
+ }
+
+}
+++ /dev/null
-/*
- * 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.integration;
-
-import org.apache.commons.lang.StringUtils;
-import org.junit.Test;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.Plugin;
-import org.sonar.wsclient.services.UpdateCenterQuery;
-
-import java.util.List;
-
-import static junit.framework.Assert.assertNotNull;
-import static org.hamcrest.Matchers.startsWith;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
-
-public class UpdateCenterTest {
-
- @Test
- public void shouldGetInstalledPlugins() {
- Sonar sonar = ITUtils.createSonarWsClient();
- List<Plugin> plugins = sonar.findAll(UpdateCenterQuery.createForInstalledPlugins());
- assertThat(plugins.size(), greaterThan(0));
-
- Plugin referencePlugin = findReferencePlugin(plugins, "itreference");
- assertNotNull(referencePlugin);
- assertThat(referencePlugin.getName(), is("Sonar :: Integration Tests :: Reference Plugin"));
- assertThat(referencePlugin.getVersion(), startsWith("2."));
- }
-
- private Plugin findReferencePlugin(List<Plugin> plugins, String pluginKey) {
- for (Plugin plugin : plugins) {
- if (StringUtils.equals(pluginKey, plugin.getKey())) {
- return plugin;
- }
- }
- return null;
- }
-
-}
--- /dev/null
+package org.sonar.tests.integration;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class ViolationsTimeMachineIT {
+
+ private static Sonar sonar;
+ private static final String PROJECT = "org.sonar.tests:violations-timemachine";
+ private static final String FILE = "org.sonar.tests:violations-timemachine:org.sonar.tests.violationstimemachine.Hello";
+
+ @BeforeClass
+ public static void buildServer() {
+ sonar = ITUtils.createSonarWsClient();
+ }
+
+ @Test
+ public void projectIsAnalyzed() {
+ assertThat(sonar.find(new ResourceQuery(PROJECT)).getName(), is("Violations timemachine"));
+ assertThat(sonar.find(new ResourceQuery(PROJECT)).getVersion(), is("1.0-SNAPSHOT"));
+ assertThat(sonar.find(new ResourceQuery(PROJECT)).getDate().getMonth(), is(10)); // November
+ }
+
+ @Test
+ public void timemachine() {
+ TimeMachineQuery query = TimeMachineQuery.createForMetrics(PROJECT,
+ CoreMetrics.BLOCKER_VIOLATIONS_KEY,
+ CoreMetrics.CRITICAL_VIOLATIONS_KEY,
+ CoreMetrics.MAJOR_VIOLATIONS_KEY,
+ CoreMetrics.MINOR_VIOLATIONS_KEY,
+ CoreMetrics.INFO_VIOLATIONS_KEY);
+ List<TimeMachineData> snapshots = sonar.findAll(query);
+ assertThat(snapshots.size(), is(2));
+
+ TimeMachineData snapshot1 = snapshots.get(0);
+ TimeMachineData snapshot2 = snapshots.get(1);
+
+ assertThat(snapshot1.getDate().getMonth(), is(9));
+ assertThat(snapshot1.getValues(), is(Arrays.asList("0.0", "0.0", "3.0", "4.0", "0.0")));
+
+ assertThat(snapshot2.getDate().getMonth(), is(10));
+ assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "4.0", "3.0", "0.0")));
+ }
+
+ @Test
+ public void correctLinesAndDates() {
+ ViolationQuery query = ViolationQuery.createForResource(FILE).setSeverities("MAJOR");
+ List<Violation> violations = sonar.findAll(query);
+
+ assertThat(violations.get(0).getLine(), is(8));
+ assertThat(violations.get(0).getCreatedAt().getMonth(), is(9)); // old violation
+
+ assertThat(violations.get(1).getLine(), is(13));
+ assertThat(violations.get(1).getCreatedAt().getMonth(), is(9)); // old violation
+
+ assertThat(violations.get(2).getLine(), is(18));
+ assertThat(violations.get(2).getCreatedAt().getMonth(), is(10)); // new violation
+ }
+
+}
+++ /dev/null
-package org.sonar.tests.integration;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class ViolationsTimemachineTest {
-
- private static Sonar sonar;
- private static final String PROJECT = "org.sonar.tests:violations-timemachine";
- private static final String FILE = "org.sonar.tests:violations-timemachine:org.sonar.tests.violationstimemachine.Hello";
-
- @BeforeClass
- public static void buildServer() {
- sonar = ITUtils.createSonarWsClient();
- }
-
- @Test
- public void projectIsAnalyzed() {
- assertThat(sonar.find(new ResourceQuery(PROJECT)).getName(), is("Violations timemachine"));
- assertThat(sonar.find(new ResourceQuery(PROJECT)).getVersion(), is("1.0-SNAPSHOT"));
- assertThat(sonar.find(new ResourceQuery(PROJECT)).getDate().getMonth(), is(10)); // November
- }
-
- @Test
- public void timemachine() {
- TimeMachineQuery query = TimeMachineQuery.createForMetrics(PROJECT,
- CoreMetrics.BLOCKER_VIOLATIONS_KEY,
- CoreMetrics.CRITICAL_VIOLATIONS_KEY,
- CoreMetrics.MAJOR_VIOLATIONS_KEY,
- CoreMetrics.MINOR_VIOLATIONS_KEY,
- CoreMetrics.INFO_VIOLATIONS_KEY);
- List<TimeMachineData> snapshots = sonar.findAll(query);
- assertThat(snapshots.size(), is(2));
-
- TimeMachineData snapshot1 = snapshots.get(0);
- TimeMachineData snapshot2 = snapshots.get(1);
-
- assertThat(snapshot1.getDate().getMonth(), is(9));
- assertThat(snapshot1.getValues(), is(Arrays.asList("0.0", "0.0", "3.0", "4.0", "0.0")));
-
- assertThat(snapshot2.getDate().getMonth(), is(10));
- assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "4.0", "3.0", "0.0")));
- }
-
- @Test
- public void correctLinesAndDates() {
- ViolationQuery query = ViolationQuery.createForResource(FILE).setSeverities("MAJOR");
- List<Violation> violations = sonar.findAll(query);
-
- assertThat(violations.get(0).getLine(), is(8));
- assertThat(violations.get(0).getCreatedAt().getMonth(), is(9)); // old violation
-
- assertThat(violations.get(1).getLine(), is(13));
- assertThat(violations.get(1).getCreatedAt().getMonth(), is(9)); // old violation
-
- assertThat(violations.get(2).getLine(), is(18));
- assertThat(violations.get(2).getCreatedAt().getMonth(), is(10)); // new violation
- }
-
-}
--- /dev/null
+/*
+ * 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.integration.selenium;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class CustomizeComponentsPageIT extends SonarTestCase {
+
+ @Test
+ public void defaultTreemapIsCustomizableByAdministrators() {
+ loginAsAdministrator();
+ selenium.open("/components/index/org.apache.struts:struts-parent");
+
+ // configure is OFF
+ assertFalse(selenium.isElementPresent("set_default_treemap"));
+
+ // configure is ON
+ clickAndWait("configure-on");
+ assertTrue(selenium.isElementPresent("set_default_treemap"));
+ }
+
+ @Test
+ public void notCustomizableByAnonymous() {
+ loginAsAnonymous();
+ selenium.open("/components/index/org.apache.struts:struts-parent");
+ assertFalse(selenium.isElementPresent("configure-on"));
+ }
+}
+++ /dev/null
-/*
- * 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.integration.selenium;
-
-import org.junit.Test;
-
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class CustomizeComponentsPageTest extends SonarTestCase {
-
- @Test
- public void defaultTreemapIsCustomizableByAdministrators() {
- loginAsAdministrator();
- selenium.open("/components/index/org.apache.struts:struts-parent");
-
- // configure is OFF
- assertFalse(selenium.isElementPresent("set_default_treemap"));
-
- // configure is ON
- clickAndWait("configure-on");
- assertTrue(selenium.isElementPresent("set_default_treemap"));
- }
-
- @Test
- public void notCustomizableByAnonymous() {
- loginAsAnonymous();
- selenium.open("/components/index/org.apache.struts:struts-parent");
- assertFalse(selenium.isElementPresent("configure-on"));
- }
-}
--- /dev/null
+/*
+ * 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.integration.selenium;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class DeployUIExtensionsIT extends SonarTestCase {
+
+ @Test
+ public void gwtPageIsDisplayedInHomeSidebar() throws Exception {
+ selenium.open("/");
+ assertTrue(selenium.getText("sidebar").contains("GWT sample"));
+ selenium.click("link=GWT sample");
+ selenium.waitForPageToLoad("30000");
+ assertTrue(selenium.isTextPresent("this is a GWT sample"));
+ }
+
+ @Test
+ public void displayHhtmlFooter() throws Exception {
+ selenium.open("/");
+ assertTrue(selenium.getText("ft").contains("Sample footer"));
+ }
+
+}
+++ /dev/null
-/*
- * 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.integration.selenium;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class DeployUIExtensionsTest extends SonarTestCase {
-
- @Test
- public void gwtPageIsDisplayedInHomeSidebar() throws Exception {
- selenium.open("/");
- assertTrue(selenium.getText("sidebar").contains("GWT sample"));
- selenium.click("link=GWT sample");
- selenium.waitForPageToLoad("30000");
- assertTrue(selenium.isTextPresent("this is a GWT sample"));
- }
-
- @Test
- public void displayHhtmlFooter() throws Exception {
- selenium.open("/");
- assertTrue(selenium.getText("ft").contains("Sample footer"));
- }
-
-}