From 53d0cab8c9c2d4666c39c65e532f7e900f34d3be Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 13 Oct 2011 10:56:49 +0200 Subject: [PATCH] Remove some ignored tests and fix some commented-out code --- .../bytecode/check/ArchitectureCheck.java | 3 +- .../java/bytecode/check/BytecodeCheck.java | 30 --- .../check/CallToDeprecatedMethodCheck.java | 3 +- .../check/UnusedPrivateMethodCheck.java | 3 +- .../check/UnusedProtectedMethodCheck.java | 3 +- .../sonar/java/squid/check/SquidCheck.java | 5 - .../org/sonar/batch/bootstrap/Module.java | 13 +- .../sonar/batch/DefaultSensorContextTest.java | 244 ------------------ .../batch/index/MeasurePersisterTest.java | 6 - ...ictWithResourceFromOtherProject-result.xml | 53 ---- ...idConflictWithResourceFromOtherProject.xml | 35 --- .../doNotCacheDatabaseMeasures-result.xml | 20 -- .../doNotCacheDatabaseMeasures.xml | 14 - .../doNotPersistInMemoryMeasures-result.xml | 24 -- .../doNotPersistInMemoryMeasures.xml | 24 -- .../doNotSaveExcludedResources-result.xml | 14 - .../doNotSaveExcludedResources.xml | 14 - .../doNotSaveOptimizedBestValues-result.xml | 39 --- .../doNotSaveOptimizedBestValues.xml | 24 -- .../saveDependency-result.xml | 36 --- .../saveDependency.xml | 22 -- .../saveMeasureOnExistingResource-result.xml | 28 -- .../saveMeasureOnExistingResource.xml | 18 -- ...mizedBestValuesIfOptionalFields-result.xml | 37 --- ...aveOptimizedBestValuesIfOptionalFields.xml | 22 -- .../saveProjectMeasure-result.xml | 20 -- .../saveProjectMeasure.xml | 14 - .../saveResourceTree-result.xml | 30 --- .../saveResourceTree.xml | 14 - ...aveResourcesBeforeBuildingDependencies.xml | 11 - .../saveRuleMeasures-result.xml | 26 -- .../saveRuleMeasures.xml | 14 - .../updateExistingResourceFields-result.xml | 22 -- .../updateExistingResourceFields.xml | 18 -- .../sonar/api/utils/HttpDownloaderTest.java | 5 +- 35 files changed, 13 insertions(+), 895 deletions(-) delete mode 100644 plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/BytecodeCheck.java delete mode 100644 sonar-batch/src/test/java/org/sonar/batch/DefaultSensorContextTest.java delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourcesBeforeBuildingDependencies.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields-result.xml delete mode 100644 sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields.xml diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java index 24d58e6dd9a..0f05863e1c2 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java @@ -31,6 +31,7 @@ import org.sonar.java.PatternUtils; import org.sonar.java.bytecode.asm.AsmClass; import org.sonar.java.bytecode.asm.AsmEdge; import org.sonar.java.bytecode.asm.AsmMethod; +import org.sonar.java.bytecode.visitor.BytecodeVisitor; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; @@ -38,7 +39,7 @@ import org.sonar.squid.api.SourceMethod; import com.google.common.collect.Maps; @Rule(key = "ArchitecturalConstraint", cardinality = Cardinality.MULTIPLE, priority = Priority.MAJOR) -public class ArchitectureCheck extends BytecodeCheck { +public class ArchitectureCheck extends BytecodeVisitor { @RuleProperty private String fromClasses = ""; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/BytecodeCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/BytecodeCheck.java deleted file mode 100644 index 19792e6d29c..00000000000 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/BytecodeCheck.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * 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.java.bytecode.check; - -import org.sonar.java.bytecode.visitor.BytecodeVisitor; -import org.sonar.squid.api.CodeCheck; - -public abstract class BytecodeCheck extends BytecodeVisitor { - -// public String getKey() { -// return getClass().getSimpleName(); -// } -} diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java index 4ed21642c5d..b959769fa4c 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java @@ -24,11 +24,12 @@ import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; import org.sonar.java.bytecode.asm.AsmEdge; import org.sonar.java.bytecode.asm.AsmMethod; +import org.sonar.java.bytecode.visitor.BytecodeVisitor; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; @Rule(key = "CallToDeprecatedMethod", priority = Priority.MINOR) -public class CallToDeprecatedMethodCheck extends BytecodeCheck { +public class CallToDeprecatedMethodCheck extends BytecodeVisitor { private AsmClass asmClass; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java index 5b2d9337a26..da138179f9a 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java @@ -23,12 +23,13 @@ import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; import org.sonar.java.bytecode.asm.AsmMethod; +import org.sonar.java.bytecode.visitor.BytecodeVisitor; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; @Rule(key = "UnusedPrivateMethod", priority = Priority.MAJOR) -public class UnusedPrivateMethodCheck extends BytecodeCheck { +public class UnusedPrivateMethodCheck extends BytecodeVisitor { private AsmClass asmClass; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java index a167205ae3b..b9fdcc41223 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java @@ -23,12 +23,13 @@ import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; import org.sonar.java.bytecode.asm.AsmMethod; +import org.sonar.java.bytecode.visitor.BytecodeVisitor; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; @Rule(key = "UnusedProtectedMethod", priority = Priority.MAJOR) -public class UnusedProtectedMethodCheck extends BytecodeCheck { +public class UnusedProtectedMethodCheck extends BytecodeVisitor { private AsmClass asmClass; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java index ff82b806007..279f808684f 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java @@ -17,7 +17,6 @@ * License along with Sonar; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ - package org.sonar.java.squid.check; import org.sonar.java.squid.visitor.SquidVisitor; @@ -26,10 +25,6 @@ import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; public class SquidCheck implements SquidVisitor { -// -// public String getKey() { -// return getClass().getSimpleName(); -// } public void visitFile(SourceFile sourceFile) { } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java index bba921ab6de..a63177495b4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/Module.java @@ -67,9 +67,6 @@ public abstract class Module { */ public final Module installChild(Module child) { ComponentContainer childContainer = container.createChild(); - // register container as a component, because it used for example in BatchExtensionDictionnary, - // but in fact this is anti-pattern - http://picocontainer.codehaus.org/container-dependency-antipattern.html - //childContainer.addComponent(new IocContainer(childContainer)); child.init(childContainer); return child; } @@ -110,7 +107,7 @@ public abstract class Module { /** * Implementation of this method must not contain conditional logic and just should contain several invocations of - * {@link #addCoreSingleton(Object)}, {@link #addComponent(Object, Object)} or {@link #addAdapter(ComponentAdapter)}. + * {@link #addCoreSingleton(Object)}, {@link #addExtension(org.sonar.api.platform.PluginMetadata, Object)} or {@link #addAdapter(ComponentAdapter)}. */ protected abstract void configure(); @@ -141,12 +138,4 @@ public abstract class Module { public final List getComponents(Class componentType) { return container.getComponentsByType(componentType); } - -// /** -// * TODO should not be used and should be removed -// */ -// public final MutablePicoContainer getContainer() { -// return container; -// } - } diff --git a/sonar-batch/src/test/java/org/sonar/batch/DefaultSensorContextTest.java b/sonar-batch/src/test/java/org/sonar/batch/DefaultSensorContextTest.java deleted file mode 100644 index 096a7e50801..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/DefaultSensorContextTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * 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.batch; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.design.Dependency; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.measures.PersistenceMode; -import org.sonar.api.measures.RuleMeasure; -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.JavaPackage; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; -import org.sonar.api.rules.RulePriority; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import javax.persistence.Query; -import java.text.ParseException; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.core.IsNot.not; -import static org.junit.Assert.assertThat; - -@Ignore -public class DefaultSensorContextTest extends AbstractDbUnitTestCase { - private DefaultSensorContext context; - private Project project; - - @Before - public void before() { - project = null; - context = null; - } - - @Test - public void saveProjectMeasure() throws ParseException { - setup("saveProjectMeasure"); - context.saveMeasure(CoreMetrics.NCLOC, 500.0); - check("saveProjectMeasure", "projects", "snapshots", "project_measures"); - } - - @Test - public void saveMeasureOnExistingResource() throws ParseException { - setup("saveMeasureOnExistingResource"); - context.saveMeasure(new JavaPackage("org.sonar"), CoreMetrics.NCLOC, 200.0); - check("saveMeasureOnExistingResource", "projects", "snapshots", "project_measures"); - } - - @Test - public void avoidConflictWithResourceFromOtherProject() throws ParseException { - setup("avoidConflictWithResourceFromOtherProject"); - context.saveMeasure(new JavaPackage("org.sonar"), CoreMetrics.NCLOC, 200.0); - context.saveMeasure(new JavaPackage("org.sonar"), CoreMetrics.COVERAGE, 80.0); - check("avoidConflictWithResourceFromOtherProject", "projects", "snapshots", "project_measures"); - } - - @Test - public void doNotPersistInMemoryMeasures() throws ParseException { - setup("doNotPersistInMemoryMeasures"); - Measure measure = new Measure(CoreMetrics.NCLOC, 30.0).setPersistenceMode(PersistenceMode.MEMORY); - context.saveMeasure(measure); - - check("doNotPersistInMemoryMeasures", "projects", "snapshots", "project_measures"); - assertThat(context.getMeasure(CoreMetrics.NCLOC).getValue(), is(30.0)); - } - - @Test - public void doNotCacheDatabaseMeasures() throws ParseException { - setup("doNotCacheDatabaseMeasures"); - Measure measure = new Measure(CoreMetrics.NCLOC, 500.0).setPersistenceMode(PersistenceMode.DATABASE); - context.saveMeasure(measure); - - check("doNotCacheDatabaseMeasures", "projects", "snapshots", "project_measures"); - assertThat(context.getMeasure(CoreMetrics.NCLOC), nullValue()); - } - - @Test - public void saveRuleMeasures() throws ParseException { - setup("saveRuleMeasures"); - context.saveMeasure(RuleMeasure.createForPriority(CoreMetrics.VIOLATIONS, RulePriority.CRITICAL, 500.0)); - context.saveMeasure(RuleMeasure.createForCategory(CoreMetrics.VIOLATIONS, 3, 200.0)); - //FIXME context.saveMeasure(RuleMeasure.createForRule(CoreMetrics.VIOLATIONS, 3).setIntValue(50.0)); - check("saveRuleMeasures", "projects", "snapshots", "project_measures"); - } - - @Test - public void saveResourceTree() throws ParseException { -// setup("saveResourceTree"); -// -// assertThat(context.getResource("org.foo.Bar"), nullValue()); -// context.saveResource(new JavaFile("org.foo.Bar")); -// assertThat(context.getResource("org.foo.Bar"), is((Resource) new JavaFile("org.foo.Bar"))); -// -// check("saveResourceTree", "projects", "snapshots"); - } -// -// @Test -// public void doNotSaveExcludedResources() throws ParseException { -// setup("doNotSaveExcludedResources"); -// -// JavaFile javaFile = new JavaFile("org.excluded.Bar"); -// ResourceFilters resourceFilters = mock(ResourceFilters.class); -// when(resourceFilters.isExcluded(javaFile)).thenReturn(true); -// context.setResourceFilters(resourceFilters); -// -// assertThat(context.getResource("org.excluded.Bar"), nullValue()); -// assertThat(context.saveResource(javaFile), nullValue()); -// assertThat(context.getResource("org.excluded.Bar"), nullValue()); -// -// check("doNotSaveExcludedResources", "projects", "snapshots"); -// } - - @Test - public void updateExistingResourceFields() throws ParseException { - setup("updateExistingResourceFields"); - - context.saveResource(new JavaPackage("org.foo")); - - check("updateExistingResourceFields", "projects", "snapshots"); - } - - @Test - public void doNotSaveOptimizedBestValues() throws ParseException { - setup("doNotSaveOptimizedBestValues"); - - // best values of the metrics violations and blocker_violations are set as optimized - assertThat(CoreMetrics.VIOLATIONS.getBestValue(), is(0.0)); - assertThat(CoreMetrics.BLOCKER_VIOLATIONS.getBestValue(), is(0.0)); - assertThat(CoreMetrics.VIOLATIONS.isOptimizedBestValue(), is(true)); - assertThat(CoreMetrics.BLOCKER_VIOLATIONS.isOptimizedBestValue(), is(true)); - - final Resource javaFile = new JavaFile("org.foo.Bar"); - assertThat(context.getMeasure(javaFile, CoreMetrics.VIOLATIONS), nullValue()); - context.saveMeasure(javaFile, CoreMetrics.VIOLATIONS, 60.0); // saved - assertThat(context.getMeasure(javaFile, CoreMetrics.VIOLATIONS).getValue(), is(60.0)); - - assertThat(context.getMeasure(javaFile, CoreMetrics.BLOCKER_VIOLATIONS), nullValue()); - context.saveMeasure(javaFile, CoreMetrics.BLOCKER_VIOLATIONS, 0.0); // not saved in database - assertThat(context.getMeasure(javaFile, CoreMetrics.BLOCKER_VIOLATIONS).getValue(), is(0.0)); - - check("doNotSaveOptimizedBestValues", "projects", "snapshots", "project_measures"); - } - - @Test - public void saveOptimizedBestValuesIfOptionalFields() throws ParseException { - setup("saveOptimizedBestValuesIfOptionalFields"); - - // best value of the metric violations is set as optimized - assertThat(CoreMetrics.VIOLATIONS.getBestValue(), is(0.0)); - assertThat(CoreMetrics.VIOLATIONS.isOptimizedBestValue(), is(true)); - - final Resource javaFile = new JavaFile("org.foo.Bar"); - assertThat(context.getMeasure(javaFile, CoreMetrics.VIOLATIONS), nullValue()); - Measure measure = new Measure(CoreMetrics.VIOLATIONS, 0.0).setTendency(1); - - context.saveMeasure(javaFile, measure); // saved - - assertThat(context.getMeasure(javaFile, CoreMetrics.VIOLATIONS).getValue(), is(0.0)); - assertThat(context.getMeasure(javaFile, CoreMetrics.VIOLATIONS).getTendency(), is(1)); - - check("saveOptimizedBestValuesIfOptionalFields", "projects", "snapshots", "project_measures"); - } - - - @Test - public void saveDependency() throws ParseException { - setup("saveDependency"); - - JavaPackage pac1 = new JavaPackage("org.sonar.source"); - JavaPackage pac2 = new JavaPackage("org.sonar.target"); - context.saveResource(pac1); - context.saveResource(pac2); - - Dependency dep = new Dependency(pac1, pac2) - .setUsage("INHERITS") - .setWeight(3); - context.saveDependency(dep); - - assertThat(dep.getId(), not(nullValue())); - - check("saveDependency", "projects", "snapshots", "dependencies"); - } - - @Test(expected = IllegalArgumentException.class) - public void saveResourcesBeforeBuildingDependencies() throws ParseException { - setup("saveResourcesBeforeBuildingDependencies"); - - JavaPackage pac1 = new JavaPackage("org.sonar.source"); - JavaPackage pac2 = new JavaPackage("org.sonar.target"); - context.saveDependency(new Dependency(pac1, pac2)); - } - - - private void setup(String unitTest) throws ParseException { -// setupData(unitTest); -// project = mock(Project.class); -// when(project.getAnalysisVersion()).thenReturn("1.0"); -// when(project.getAnalysisDate()).thenReturn(new SimpleDateFormat("yyyy-MM-dd").parse("2008-12-25")); -// when(project.getKey()).thenReturn("group:artifact"); -// when(project.getScope()).thenReturn(Resource.SCOPE_SET); -// when(project.getQualifier()).thenReturn(Resource.QUALIFIER_PROJECT); -// when(project.getLanguage()).thenReturn(Java.INSTANCE); -// when(project.getId()).thenReturn(10); -// when(project.getName()).thenReturn("my project"); -// when(project.isRoot()).thenReturn(true); -// ProjectBootstrap projectBootstrap = new ProjectBootstrap(null); -// projectBootstrap.setProject(project); -// projectBootstrap.setSnapshot(getSnapshot(1)); -// context = new DefaultSensorContext(getSession(), projectBootstrap.setProject(project), getDao().getMeasuresDao(), null, null, null); - } - - private void check(String unitTest, String... tables) { - getSession().commit(); - checkTables(unitTest, tables); - } - - private Snapshot getSnapshot(int id) { - Query query = getSession().createQuery("SELECT s FROM Snapshot s WHERE s.id=:id"); - query.setParameter("id", id); - return (Snapshot) query.getSingleResult(); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java index 3753b6752e8..a1bf89534d4 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java @@ -125,12 +125,6 @@ public class MeasurePersisterTest extends AbstractDbUnitTestCase { assertThat(coverageMeasures.get(0).getValue(), is(300.0)); } - @Test - @Ignore("to do") - public void shouldInsertDataMeasure() { - - } - @Test public void shouldDelaySaving() { measurePersister.setDelayedMode(true); diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject-result.xml deleted file mode 100644 index aa282112071..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject-result.xml +++ /dev/null @@ -1,53 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject.xml deleted file mode 100644 index cb9e2a9430f..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/avoidConflictWithResourceFromOtherProject.xml +++ /dev/null @@ -1,35 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures-result.xml deleted file mode 100644 index 62f6c562d50..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures-result.xml +++ /dev/null @@ -1,20 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures.xml deleted file mode 100644 index 4db7b1e98db..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotCacheDatabaseMeasures.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures-result.xml deleted file mode 100644 index 70818fbc752..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures-result.xml +++ /dev/null @@ -1,24 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures.xml deleted file mode 100644 index 70818fbc752..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotPersistInMemoryMeasures.xml +++ /dev/null @@ -1,24 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources-result.xml deleted file mode 100644 index 4db7b1e98db..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources-result.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources.xml deleted file mode 100644 index 4db7b1e98db..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveExcludedResources.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues-result.xml deleted file mode 100644 index 7eb348e0a90..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues-result.xml +++ /dev/null @@ -1,39 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues.xml deleted file mode 100644 index a8507eaf78f..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/doNotSaveOptimizedBestValues.xml +++ /dev/null @@ -1,24 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency-result.xml deleted file mode 100644 index 6f85d74bd73..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency-result.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency.xml deleted file mode 100644 index 3a5ea273906..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveDependency.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource-result.xml deleted file mode 100644 index 2de61e4b383..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource-result.xml +++ /dev/null @@ -1,28 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource.xml deleted file mode 100644 index 3e99318b593..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveMeasureOnExistingResource.xml +++ /dev/null @@ -1,18 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields-result.xml deleted file mode 100644 index 1ae0fc861c7..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields-result.xml +++ /dev/null @@ -1,37 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields.xml deleted file mode 100644 index a5d9ea39798..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveOptimizedBestValuesIfOptionalFields.xml +++ /dev/null @@ -1,22 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure-result.xml deleted file mode 100644 index 62f6c562d50..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure-result.xml +++ /dev/null @@ -1,20 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure.xml deleted file mode 100644 index 4db7b1e98db..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveProjectMeasure.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree-result.xml deleted file mode 100644 index 2db0a3b10cd..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree-result.xml +++ /dev/null @@ -1,30 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree.xml deleted file mode 100644 index af8e184dca6..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourceTree.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourcesBeforeBuildingDependencies.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourcesBeforeBuildingDependencies.xml deleted file mode 100644 index 77dcdba0913..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveResourcesBeforeBuildingDependencies.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures-result.xml deleted file mode 100644 index be6cd1fbbcd..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures-result.xml +++ /dev/null @@ -1,26 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures.xml deleted file mode 100644 index 8e2311c3849..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/saveRuleMeasures.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields-result.xml deleted file mode 100644 index eb01f29cd3d..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields-result.xml +++ /dev/null @@ -1,22 +0,0 @@ - - \ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields.xml b/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields.xml deleted file mode 100644 index d72c2820025..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/DefaultSensorContextTest/updateExistingResourceFields.xml +++ /dev/null @@ -1,18 +0,0 @@ - - \ No newline at end of file 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 257b52b90ab..d0fcc390dea 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 @@ -21,6 +21,7 @@ package org.sonar.api.utils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.SystemUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; @@ -38,12 +39,12 @@ import java.util.Properties; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; import static org.junit.internal.matchers.StringContains.containsString; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@Ignore("Temporarily deactivated because it sometimes freezes on Windows") public class HttpDownloaderTest { private static ServletTester tester; @@ -51,6 +52,8 @@ public class HttpDownloaderTest { @BeforeClass public static void startServer() throws Exception { + assumeThat(SystemUtils.IS_OS_WINDOWS, is(false)); // Temporarily deactivated on Windows because of frequent freezes + tester = new ServletTester(); tester.setContextPath("/"); tester.addServlet(RedirectServlet.class, "/redirect/"); -- 2.39.5