aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-dbcleaner-plugin/src/test
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-18 15:02:54 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-18 15:02:54 +0000
commit4bfd79e52cea465f226c78abb253c2073f4c1d4c (patch)
treed3812db183fbd869e2451148c32b2bd583f1112a /plugins/sonar-dbcleaner-plugin/src/test
parentf8ba14ececd0a5b60ec7112d4df3266f105541f5 (diff)
downloadsonarqube-4bfd79e52cea465f226c78abb253c2073f4c1d4c.tar.gz
sonarqube-4bfd79e52cea465f226c78abb253c2073f4c1d4c.zip
SONAR-1663 include the dbcleaner plugin + move all purges in this plugin
Diffstat (limited to 'plugins/sonar-dbcleaner-plugin/src/test')
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java33
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/Utils.java57
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/IntegrationTest.java67
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLastSnapshotFilterTest.java46
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilterTest.java48
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneSnapshotByPeriodBetweenTwoDatesFilterTest.java50
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepSnapshotsBetweenTwoDatesFilterTest.java51
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/PeriodCleanerTest.java51
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest.java44
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest.java40
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest.java37
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest.java49
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest.java37
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest.java40
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest.java38
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest.java42
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest.java38
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest.java44
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest.java37
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java38
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest.java121
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest.java54
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent-result.xml167
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent.xml142
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml68
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml68
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml33
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies-result.xml102
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies.xml102
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast-result.xml71
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml71
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml33
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge-result.xml89
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml89
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml75
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml78
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml106
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml112
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml9
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities-result.xml141
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml141
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml33
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans-result.xml16
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans.xml16
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources-result.xml23
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources.xml23
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans-result.xml13
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans.xml11
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans-result.xml10
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans.xml8
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles-result.xml27
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles.xml27
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures-result.xml91
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml92
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml28
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed-result.xml141
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml141
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml33
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml34
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml68
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml68
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest/shared.xml53
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots-result.xml111
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots.xml111
64 files changed, 3937 insertions, 0 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java
new file mode 100644
index 00000000000..607be2e770e
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+
+public class DbCleanerPluginTest {
+
+ @Test
+ public void shouldGetExtensions() {
+ assertThat(new DbCleanerPlugin().getExtensions().size(), greaterThan(5));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/Utils.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/Utils.java
new file mode 100644
index 00000000000..17590cf2ed7
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/Utils.java
@@ -0,0 +1,57 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.sonar.api.database.model.Snapshot;
+
+public class Utils {
+
+ public static Snapshot createSnapshot(int id, String version) {
+ Snapshot snapshot = new Snapshot();
+ snapshot.setId(id);
+ snapshot.setVersion(version);
+ snapshot.setCreatedAt(new GregorianCalendar().getTime());
+ return snapshot;
+ }
+
+ public static Snapshot createSnapshot(int id, Date createdAt) {
+ Snapshot snapshot = new Snapshot();
+ snapshot.setId(id);
+ snapshot.setCreatedAt(createdAt);
+ return snapshot;
+ }
+
+ public static Date day(int delta) {
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.add(GregorianCalendar.DAY_OF_YEAR, delta);
+ return calendar.getTime();
+ }
+
+ public static Date week(int delta, int dayOfWeek) {
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.add(GregorianCalendar.WEEK_OF_YEAR, delta);
+ calendar.set(GregorianCalendar.DAY_OF_WEEK, dayOfWeek);
+ return calendar.getTime();
+ }
+
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/IntegrationTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/IntegrationTest.java
new file mode 100644
index 00000000000..5c70a57162b
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/IntegrationTest.java
@@ -0,0 +1,67 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.GregorianCalendar;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.resources.Project;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+import org.sonar.plugins.dbcleaner.api.PurgeContext;
+
+public class IntegrationTest extends AbstractDbUnitTestCase {
+
+ PeriodCleaner purge;
+
+ @Before
+ public void init() {
+
+ Project project = new Project("myproject");
+ project.setConfiguration(new PropertiesConfiguration());
+ purge = new PeriodCleaner(getSession(), project);
+ GregorianCalendar calendar = new GregorianCalendar(2010, 10, 1);
+ purge.dateToStartKeepingOneSnapshotByWeek = calendar.getTime();
+ calendar.set(2010, 7, 1);
+ purge.dateToStartKeepingOneSnapshotByMonth = calendar.getTime();
+ calendar.set(2010, 2, 1);
+ purge.dateToStartDeletingAllSnapshots = calendar.getTime();
+ }
+
+ @Test
+ public void dbCleanerITTest() {
+ setupData("dbContent");
+ PurgeContext context = mock(PurgeContext.class);
+ when(context.getSnapshotId()).thenReturn(1010);
+ purge.purge(context);
+ checkTables("dbContent", "snapshots");
+
+ //After a first run, no more snapshot should be deleted
+ setupData("dbContent-result");
+ context = mock(PurgeContext.class);
+ when(context.getSnapshotId()).thenReturn(1010);
+ purge.purge(context);
+ checkTables("dbContent");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLastSnapshotFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLastSnapshotFilterTest.java
new file mode 100644
index 00000000000..57f8853bd62
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLastSnapshotFilterTest.java
@@ -0,0 +1,46 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import com.google.common.collect.Lists;
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.sonar.plugins.dbcleaner.Utils.createSnapshot;
+
+public class KeepLastSnapshotFilterTest {
+
+ @Test
+ public void testFilter() {
+ List<Snapshot> snapshots = Lists.newLinkedList();
+ snapshots.add(createSnapshot(1, "0.1"));
+ Snapshot lastSnapshot = createSnapshot(2, "0.1");
+ lastSnapshot.setLast(true);
+ snapshots.add(lastSnapshot);
+
+ assertThat(new KeepLastSnapshotFilter().filter(snapshots), is(1));
+ assertThat(snapshots.size(), is(1));
+ assertThat(snapshots.get(0).getId(), is(1));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilterTest.java
new file mode 100644
index 00000000000..61aa1e93df6
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepLibrarySnapshotFilterTest.java
@@ -0,0 +1,48 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import com.google.common.collect.Lists;
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.sonar.plugins.dbcleaner.Utils.createSnapshot;
+
+public class KeepLibrarySnapshotFilterTest {
+
+ @Test
+ public void testFilter() {
+ List<Snapshot> snapshots = Lists.newLinkedList();
+ Snapshot snapshot = createSnapshot(2, "0.1");
+ snapshots.add(snapshot);
+ snapshot.setQualifier("TRK");
+ snapshot = createSnapshot(2, "0.1");
+ snapshot.setQualifier("LIB");
+ snapshots.add(snapshot);
+
+ assertThat(new KeepLibrarySnapshotFilter().filter(snapshots), is(1));
+ assertThat(snapshots.size(), is(1));
+ assertThat(snapshots.get(0).getId(), is(2));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneSnapshotByPeriodBetweenTwoDatesFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneSnapshotByPeriodBetweenTwoDatesFilterTest.java
new file mode 100644
index 00000000000..4f9888a645e
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneSnapshotByPeriodBetweenTwoDatesFilterTest.java
@@ -0,0 +1,50 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import com.google.common.collect.Lists;
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.plugins.dbcleaner.Utils;
+
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class KeepOneSnapshotByPeriodBetweenTwoDatesFilterTest {
+
+ @Test
+ public void testFilter() {
+ List<Snapshot> snapshots = Lists.newLinkedList();
+ snapshots.add(Utils.createSnapshot(1, Utils.week(-7, 1)));
+ snapshots.add(Utils.createSnapshot(2, Utils.week(-7, 2)));
+ snapshots.add(Utils.createSnapshot(3, Utils.week(-7, 3)));
+ snapshots.add(Utils.createSnapshot(4, Utils.week(-6, 3)));
+ snapshots.add(Utils.createSnapshot(5, Utils.week(-6, 4)));
+
+ assertThat(new KeepOneSnapshotByPeriodBetweenTwoDatesFilter(GregorianCalendar.WEEK_OF_YEAR, Utils.week(-3, 1), Utils.week(-9, 1)).filter(snapshots), is(2));
+ assertThat(snapshots.size(), is(3));
+ assertThat(snapshots.get(0).getId(), is(2));
+ assertThat(snapshots.get(1).getId(), is(3));
+ assertThat(snapshots.get(2).getId(), is(5));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepSnapshotsBetweenTwoDatesFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepSnapshotsBetweenTwoDatesFilterTest.java
new file mode 100644
index 00000000000..7fffd2b85be
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepSnapshotsBetweenTwoDatesFilterTest.java
@@ -0,0 +1,51 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import com.google.common.collect.Lists;
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+
+import java.util.Date;
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.sonar.plugins.dbcleaner.Utils.createSnapshot;
+import static org.sonar.plugins.dbcleaner.Utils.day;
+
+public class KeepSnapshotsBetweenTwoDatesFilterTest {
+
+ @Test
+ public void testFilter() {
+ List<Snapshot> snapshots = Lists.newLinkedList();
+ snapshots.add(createSnapshot(1, day(-100)));
+ snapshots.add(createSnapshot(2, day(-70)));
+ snapshots.add(createSnapshot(3, day(-40)));
+ snapshots.add(createSnapshot(4, day(-10)));
+
+ assertThat(new KeepSnapshotsBetweenTwoDatesFilter(new Date(), day(-1)).filter(snapshots), is(0));
+ assertThat(snapshots.size(), is(4));
+
+ assertThat(new KeepSnapshotsBetweenTwoDatesFilter(new Date(), day(-80)).filter(snapshots), is(3));
+ assertThat(snapshots.size(), is(1));
+ assertThat(snapshots.get(0).getId(), is(1));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/PeriodCleanerTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/PeriodCleanerTest.java
new file mode 100644
index 00000000000..dd3d1963c50
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/PeriodCleanerTest.java
@@ -0,0 +1,51 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2010 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.plugins.dbcleaner.period;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+import org.sonar.api.resources.Project;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class PeriodCleanerTest {
+
+ @Test
+ public void getDateShouldReturnCurrentTimeMinusDesiredMonths() {
+ Project project = new Project("myproject");
+ PropertiesConfiguration conf = new PropertiesConfiguration();
+ conf.setProperty("KEY", "2");
+ project.setConfiguration(conf);
+
+ PeriodCleaner purge = new PeriodCleaner(null, project);
+
+ Date date = purge.getDate(conf, "KEY", "2");
+
+ GregorianCalendar calendar = new GregorianCalendar();
+ calendar.add(GregorianCalendar.MONTH, -2);
+ Date expectedDate = calendar.getTime();
+
+ assertThat(date.getMonth(), is(expectedDate.getMonth()));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest.java
new file mode 100644
index 00000000000..867d6f2a984
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class PurgeDeletedResourcesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeDeletedResources() throws SQLException {
+ setupData("sharedFixture", "purgeDeletedResources");
+
+ final Connection c = getConnection().getConnection();
+ c.prepareStatement("SET REFERENTIAL_INTEGRITY FALSE; ").execute();
+ c.prepareStatement("delete from projects where id=3").executeUpdate();
+ c.commit();
+
+ final PurgeDeletedResources purge = new PurgeDeletedResources(getSession());
+ purge.purge(null);
+
+ checkTables("purgeDeletedResources", "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest.java
new file mode 100644
index 00000000000..7983b474f5a
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeDependenciesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeDependencies() throws SQLException {
+ assertPurge("purgeDependencies");
+ }
+
+ private void assertPurge(String testName) {
+ setupData(testName);
+ new PurgeDependencies(getSession()).purge(null);
+ checkTables(testName, "dependencies");
+ }
+
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest.java
new file mode 100644
index 00000000000..63712b04496
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeDeprecatedLastTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeDeprecatedLast() throws SQLException {
+ setupData("sharedFixture", "purgeDeprecatedLast");
+
+ new PurgeDeprecatedLast(getSession()).purge(null);
+
+ checkTables("purgeDeprecatedLast", "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest.java
new file mode 100644
index 00000000000..f83d8527957
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeDisabledResourcesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeDisabledModule() throws SQLException {
+ assertPurge("purgeDisabledModule");
+ }
+
+ @Test
+ public void purgeDisabledProject() throws SQLException {
+ assertPurge("purgeDisabledProject");
+ }
+
+ @Test
+ public void nothingToPurge() throws SQLException {
+ assertPurge("nothingToPurge");
+ }
+
+ private void assertPurge(String testName) {
+ setupData("sharedFixture", testName);
+ new PurgeDisabledResources(getSession()).purge(null);
+ checkTables(testName, "snapshots", "project_measures");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest.java
new file mode 100644
index 00000000000..ab7e63eef83
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+public class PurgeEntitiesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeEntities() {
+ setupData("sharedFixture", "purgeEntities");
+
+ final PurgeEntities purge = new PurgeEntities(getSession(), new PropertiesConfiguration());
+ purge.purge(null);
+
+ checkTables("purgeEntities", "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest.java
new file mode 100644
index 00000000000..7418ec6dcee
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeEventOrphansTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeEventOrphans() throws SQLException {
+ assertPurge("purgeEventOrphans");
+ }
+
+ private void assertPurge(String testName) {
+ setupData(testName);
+ new PurgeEventOrphans(getSession()).purge(null);
+ checkTables(testName, "events");
+ }
+
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest.java
new file mode 100644
index 00000000000..fcc9073156c
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeOrphanResourcesTest extends AbstractDbUnitTestCase {
+ @Test
+ public void purgeOrphanResources() throws SQLException {
+ assertPurge("purgeOrphanResources");
+ }
+
+ private void assertPurge(String testName) {
+ setupData(testName);
+ new PurgeOrphanResources(getSession()).purge(null);
+ checkTables(testName, "projects");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest.java
new file mode 100644
index 00000000000..373117d7829
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgePropertyOrphansTest extends AbstractDbUnitTestCase {
+ @Test
+ public void purgeResourceOrphans() throws SQLException {
+ setupData("purgeResourceOrphans");
+ new PurgePropertyOrphans(getSession()).purgeResourceOrphans();
+ checkTables("purgeResourceOrphans", "properties");
+ }
+
+ @Test
+ public void purgeUserOrphans() throws SQLException {
+ setupData("purgeUserOrphans");
+ new PurgePropertyOrphans(getSession()).purgeUserOrphans();
+ checkTables("purgeUserOrphans", "properties");
+ }
+
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest.java
new file mode 100644
index 00000000000..af037daa59e
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class PurgeResourceRolesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeResourceRoles() throws SQLException {
+ setupData("purgeResourceRoles");
+
+ new PurgeResourceRoles(getSession()).purge(null);
+
+ checkTables("purgeResourceRoles", "projects", "user_roles", "group_roles");
+ }
+}
+
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest.java
new file mode 100644
index 00000000000..a3e715157e4
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+import org.sonar.plugins.dbcleaner.api.PurgeContext;
+
+public class PurgeRuleMeasuresTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeRuleMeasures() {
+ setupData("sharedFixture", "purgeRuleMeasures");
+
+ new PurgeRuleMeasures(getSession()).purge(new PurgeContext() {
+ public Integer getSnapshotId() {
+ return 4;
+ }
+ public Integer getPreviousSnapshotId() {
+ return 1;
+ }
+
+ });
+
+ checkTables("purgeRuleMeasures", "snapshots", "project_measures", "measure_data");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest.java
new file mode 100644
index 00000000000..0848a69c5de
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+public class PurgeUnprocessedTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void purgeUnprocessed() {
+ setupData("sharedFixture", "purgeUnprocessed");
+
+ new PurgeUnprocessed(getSession(), new PropertiesConfiguration()).purge(null);
+
+ checkTables("purgeUnprocessed", "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources");
+ }
+}
+
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java
new file mode 100644
index 00000000000..0be4e984e4c
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugins.dbcleaner.purges;
+
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+
+public class UnflagLastDoublonsTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void unflagLastDoublons() throws SQLException {
+ setupData("sharedFixture", "unflagLastDoublons");
+
+ new UnflagLastDoublons(getSession()).purge(null);
+
+ checkTables("unflagLastDoublons", "snapshots");
+ }
+}
+
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest.java
new file mode 100644
index 00000000000..37832b2d7df
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.plugins.dbcleaner.runner;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.junit.Test;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Project;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+import org.sonar.plugins.dbcleaner.api.Purge;
+import org.sonar.plugins.dbcleaner.api.PurgeContext;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class PurgeRunnerTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void shouldExecutePurges() {
+ setupData("shared");
+ final int currentSID = 400;
+ final int previousSID = 300;
+ Snapshot snapshot = getSession().getSingleResult(Snapshot.class, "id", currentSID);
+
+ Purge purge1 = mock(Purge.class);
+ Purge purge2 = mock(Purge.class);
+ Purge[] purges = new Purge[]{purge1, purge2};
+
+ new PurgeRunner(getSession(), snapshot, purges).purge();
+
+ verify(purge1).purge(argThat(new BaseMatcher<PurgeContext>() {
+ public boolean matches(Object o) {
+ PurgeContext context = (PurgeContext) o;
+ return context.getSnapshotId() == currentSID && context.getPreviousSnapshotId() == previousSID;
+ }
+
+ public void describeTo(Description description) {
+ }
+ }));
+ }
+
+ @Test
+ public void shouldExecutePurgesEvenIfSingleAnalysis() {
+ setupData("shared");
+ final int currentSID = 1000;
+ Snapshot snapshot = getSession().getSingleResult(Snapshot.class, "id", currentSID);
+
+ Purge purge1 = mock(Purge.class);
+ Purge purge2 = mock(Purge.class);
+ Purge[] purges = new Purge[]{purge1, purge2};
+
+ new PurgeRunner(getSession(), snapshot, purges).purge();
+
+ verify(purge1).purge(argThat(new BaseMatcher<PurgeContext>() {
+ public boolean matches(Object o) {
+ PurgeContext context = (PurgeContext) o;
+ return context.getSnapshotId() == currentSID && context.getPreviousSnapshotId() == null;
+ }
+
+ public void describeTo(Description description) {
+ }
+ }));
+ }
+
+
+ @Test
+ public void shouldExecuteDeprecatedPurges() {
+ setupData("shared");
+ final int currentSID = 400;
+ final int previousSID = 300;
+ Snapshot snapshot = getSession().getSingleResult(Snapshot.class, "id", currentSID);
+
+
+ org.sonar.api.batch.Purge deprecated1 = mock(org.sonar.api.batch.Purge.class), deprecated2 = mock(org.sonar.api.batch.Purge.class);
+ org.sonar.api.batch.Purge[] deprecatedPurges = new org.sonar.api.batch.Purge[]{deprecated1, deprecated2};
+
+ new PurgeRunner(getSession(), snapshot, new Purge[0], deprecatedPurges).purge();
+
+ verify(deprecated1).purge(argThat(new BaseMatcher<org.sonar.api.batch.PurgeContext>() {
+ public boolean matches(Object o) {
+ org.sonar.api.batch.PurgeContext context = (org.sonar.api.batch.PurgeContext) o;
+ return context.getLastSnapshotId() == currentSID && context.getPreviousSnapshotId() == previousSID;
+ }
+
+ public void describeTo(Description description) {
+ }
+ }));
+ }
+
+ @Test
+ public void shouldExecuteOnlyOnRootProjects() {
+ Project project = mock(Project.class);
+ when(project.isRoot()).thenReturn(true);
+ assertTrue(PurgeRunner.shouldExecuteOn(project));
+
+ when(project.isRoot()).thenReturn(false);
+ assertFalse(PurgeRunner.shouldExecuteOn(project));
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest.java
new file mode 100644
index 00000000000..31de15a3824
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.plugins.dbcleaner.util;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.Test;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class PurgeUtilsTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void shouldReturnDefaultMinimumPeriod() {
+ assertThat(PurgeUtils.getMinimumPeriodInHours(new PropertiesConfiguration()), is(PurgeUtils.DEFAULT_MINIMUM_PERIOD_IN_HOURS));
+ }
+
+ @Test
+ public void shouldReturnMinimumPeriod() {
+ PropertiesConfiguration conf = new PropertiesConfiguration();
+ conf.setProperty(PurgeUtils.PROP_KEY_MINIMUM_PERIOD_IN_HOURS, "9");
+ assertThat(PurgeUtils.getMinimumPeriodInHours(conf), is(9));
+ }
+
+ @Test
+ public void purgeSnapshots() throws SQLException {
+ setupData("purgeSnapshots");
+
+ PurgeUtils.deleteSnapshotsData(getSession(), Arrays.asList(3, 4));
+
+ checkTables("purgeSnapshots", "snapshots", "project_measures", "measure_data", "rule_failures", "snapshot_sources", "dependencies");
+ }
+}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent-result.xml
new file mode 100644
index 00000000000..042878aa032
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent-result.xml
@@ -0,0 +1,167 @@
+<dataset>
+ <!-- projects -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="myproject"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:org.sonar" name="org.osnar"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:org.sonar.MyClass"
+ name="org.osnar.MyClass"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!-- snapshots older than the dateToStartDeletingAllSnapshots-->
+ <!-- keep this one because version event -->
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2009-11-02 13:58:00.00" version="0.9"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]"
+ diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+ <!--<snapshots depth="[null]" id="2" scope="PRJ" qualifier="TRK" created_at="2010-01-01 13:58:00.00"-->
+ <!--version="1.0-SNAPSHOT"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+ <!--<project_measures ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2"/>-->
+ <!--<snapshots depth="1" id="10" scope="DIR" qualifier="PAC" created_at="2010-01-01 13:58:00.00" version="[null]"-->
+ <!--project_id="2"-->
+ <!--parent_snapshot_id="2" root_project_id="1" root_snapshot_id="2" status="P" islast="false"-->
+ <!--path="1"/>-->
+ <!--<snapshots depth="2" id="20" scope="FIL" qualifier="CLA" created_at="2010-01-01 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="10" root_project_id="1" root_snapshot_id="2" status="P" islast="false"-->
+ <!--path="1.10"/>-->
+
+
+
+
+
+ <!-- snapshots between dateToStartKeepingOneSnapshotByMonth and dateToStartDeletingAllSnapshots-->
+ <!-- single snapshot on this month (except version events) -->
+ <snapshots depth="[null]" id="100" scope="PRJ" qualifier="TRK" created_at="2010-03-01 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <!--<snapshots depth="[null]" id="110" scope="PRJ" qualifier="TRK" created_at="2010-03-02 13:58:00.00"-->
+ <!--version="1.0-SNAPSHOT"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="120" scope="PRJ" qualifier="TRK" created_at="2010-03-03 13:58:00.00"-->
+ <!--version="1.0-SNAPSHOT"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!-- this one has a version event -->
+ <snapshots depth="[null]" id="130" scope="PRJ" qualifier="TRK" created_at="2010-04-01 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- keep this one -->
+ <snapshots depth="[null]" id="140" scope="PRJ" qualifier="TRK" created_at="2010-04-15 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+
+
+
+ <!-- snapshots whose qualifier = LIB must not be deleted -->
+ <snapshots depth="[null]" id="150" scope="PRJ" qualifier="LIB" created_at="2010-04-22 13:58:00.00" version="0.1"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="160" scope="PRJ" qualifier="LIB" created_at="2010-04-23 13:58:00.00" version="0.2"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+
+
+
+
+ <!-- snapshots between dateToStartKeepingOneSnapshotByWeek and dateToStartKeepingOneSnapshotByMonth-->
+ <!-- keep this one -->
+ <snapshots depth="[null]" id="500" scope="PRJ" qualifier="TRK" created_at="2010-08-15 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!--<snapshots depth="[null]" id="510" scope="PRJ" qualifier="TRK" created_at="2010-08-16 13:58:00.00"-->
+ <!--version="1.1-SNAPSHOT"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!-- this one has a version event -->
+ <snapshots depth="[null]" id="520" scope="PRJ" qualifier="TRK" created_at="2010-08-25 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <!-- this one has a version event -->
+ <snapshots depth="[null]" id="530" scope="PRJ" qualifier="TRK" created_at="2010-08-26 13:58:00.00"
+ version="1.2-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+
+ <!--
+ snapshots before dateToStartKeepingOneSnapshotByWeek : nothing is currently purged
+ It will be improved later by keeping only one daily snapshot : snapshot 1010 should be removed -->
+ -->
+ <snapshots depth="[null]" id="1000" scope="PRJ" qualifier="TRK" created_at="2010-11-02 13:58:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="1010" scope="PRJ" qualifier="TRK" created_at="2010-11-03 13:58:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+ <!-- same day than 1010 -->
+ <snapshots depth="[null]" id="1020" scope="PRJ" qualifier="TRK" created_at="2010-11-03 20:26:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+
+
+ <events id="1" name="Version 0.9" resource_id="1" snapshot_id="1" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="2" name="Version 1.0-SNAPSHOT" resource_id="1" snapshot_id="130" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="3" name="Version 1.1-SNAPSHOT" resource_id="1" snapshot_id="520" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="4" name="Version 1.2-SNAPSHOT" resource_id="1" snapshot_id="530" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent.xml
new file mode 100644
index 00000000000..0a66a38e452
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/period/IntegrationTest/dbContent.xml
@@ -0,0 +1,142 @@
+<dataset>
+ <!-- projects -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="myproject"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:org.sonar" name="org.osnar"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:org.sonar.MyClass"
+ name="org.osnar.MyClass"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!-- snapshots older than the dateToStartDeletingAllSnapshots-->
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2009-11-02 13:58:00.00" version="0.9"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]"
+ diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+ <snapshots depth="[null]" id="2" scope="PRJ" qualifier="TRK" created_at="2010-01-01 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <project_measures ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2"/>
+ <snapshots depth="1" id="10" scope="DIR" qualifier="PAC" created_at="2010-01-01 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="1" root_snapshot_id="2" status="P" islast="false"
+ path="1"/>
+ <snapshots depth="2" id="20" scope="FIL" qualifier="CLA" created_at="2010-01-01 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="10" root_project_id="1" root_snapshot_id="2" status="P" islast="false"
+ path="1.10"/>
+
+
+
+
+ <!-- snapshots between dateToStartKeepingOneSnapshotByMonth and dateToStartDeletingAllSnapshots-->
+ <snapshots depth="[null]" id="100" scope="PRJ" qualifier="TRK" created_at="2010-03-01 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="110" scope="PRJ" qualifier="TRK" created_at="2010-03-02 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="120" scope="PRJ" qualifier="TRK" created_at="2010-03-03 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="130" scope="PRJ" qualifier="TRK" created_at="2010-04-01 13:58:00.00"
+ version="1.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="140" scope="PRJ" qualifier="TRK" created_at="2010-04-15 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+
+
+ <!-- snapshots whose qualifier = LIB must not be deleted -->
+ <snapshots depth="[null]" id="150" scope="PRJ" qualifier="LIB" created_at="2010-04-22 13:58:00.00" version="0.1"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="160" scope="PRJ" qualifier="LIB" created_at="2010-04-23 13:58:00.00" version="0.2"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- snapshots between dateToStartKeepingOneSnapshotByWeek and dateToStartKeepingOneSnapshotByMonth-->
+ <snapshots depth="[null]" id="500" scope="PRJ" qualifier="TRK" created_at="2010-08-15 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="510" scope="PRJ" qualifier="TRK" created_at="2010-08-16 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="520" scope="PRJ" qualifier="TRK" created_at="2010-08-25 13:58:00.00"
+ version="1.1-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="530" scope="PRJ" qualifier="TRK" created_at="2010-08-26 13:58:00.00"
+ version="1.2-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- snapshots before dateToStartKeepingOneSnapshotByWeek-->
+ <snapshots depth="[null]" id="1000" scope="PRJ" qualifier="TRK" created_at="2010-11-02 13:58:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+ <snapshots depth="[null]" id="1010" scope="PRJ" qualifier="TRK" created_at="2010-11-03 13:58:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+ <!-- same day than 1010 -->
+ <snapshots depth="[null]" id="1020" scope="PRJ" qualifier="TRK" created_at="2010-11-03 20:26:00.00"
+ version="3.0-SNAPSHOT"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+
+
+ <events id="1" name="Version 0.9" resource_id="1" snapshot_id="1" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="2" name="Version 1.0-SNAPSHOT" resource_id="1" snapshot_id="130" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="3" name="Version 1.1-SNAPSHOT" resource_id="1" snapshot_id="520" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <events id="4" name="Version 1.2-SNAPSHOT" resource_id="1" snapshot_id="530" category="Version" description="[null]"
+ event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml
new file mode 100644
index 00000000000..e9bcbeea46c
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources-result.xml
@@ -0,0 +1,68 @@
+<dataset>
+
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <!--<snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!--<SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>-->
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
+
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>-->
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <!--<measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>-->
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml
new file mode 100644
index 00000000000..a67a05e5291
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/purgeDeletedResources.xml
@@ -0,0 +1,68 @@
+<dataset>
+
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
+
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml
new file mode 100644
index 00000000000..8d4d27778c7
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest/sharedFixture.xml
@@ -0,0 +1,33 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- file -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project copy for views -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="TRK" kee="cp-mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies-result.xml
new file mode 100644
index 00000000000..6b0bf1b88c4
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies-result.xml
@@ -0,0 +1,102 @@
+<dataset>
+ <!-- first project with one package -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- second project with two packages -->
+ <projects long_name="[null]" id="3" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact2" name="project2"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="5" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package2" name="package2"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!-- old snapshots -->
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="5"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- last snapshots -->
+ <snapshots depth="[null]" id="6" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="7" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="6" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="9" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="10" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true"
+ path="[null]"/>
+
+
+ <!-- old dependencies -->
+ <!--<dependencies id="1" from_resource_id="3" from_snapshot_id="3" to_resource_id="1" to_snapshot_id="1"-->
+ <!--parent_dependency_id="[null]" project_snapshot_id="3"-->
+ <!--dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/>-->
+
+ <!--<dependencies id="2" from_resource_id="4" from_snapshot_id="4" to_resource_id="5" to_snapshot_id="5"-->
+ <!--parent_dependency_id="[null]" project_snapshot_id="3"-->
+ <!--dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/>-->
+
+
+ <!-- last dependencies -->
+ <dependencies id="3" from_resource_id="3" from_snapshot_id="8" to_resource_id="1" to_snapshot_id="6"
+ parent_dependency_id="[null]" project_snapshot_id="8"
+ dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/>
+
+ <dependencies id="4" from_resource_id="4" from_snapshot_id="9" to_resource_id="5" to_snapshot_id="10"
+ parent_dependency_id="[null]" project_snapshot_id="8"
+ dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies.xml
new file mode 100644
index 00000000000..5ffbb85ac9f
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDependenciesTest/purgeDependencies.xml
@@ -0,0 +1,102 @@
+<dataset>
+ <!-- first project with one package -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- second project with two packages -->
+ <projects long_name="[null]" id="3" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact2" name="project2"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="5" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package2" name="package2"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!-- old snapshots -->
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="5"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- last snapshots -->
+ <snapshots depth="[null]" id="6" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="7" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="6" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="9" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="10" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true"
+ path="[null]"/>
+
+
+ <!-- old dependencies -->
+ <dependencies id="1" from_resource_id="3" from_snapshot_id="3" to_resource_id="1" to_snapshot_id="1"
+ parent_dependency_id="[null]" project_snapshot_id="3"
+ dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/>
+
+ <dependencies id="2" from_resource_id="4" from_snapshot_id="4" to_resource_id="5" to_snapshot_id="5"
+ parent_dependency_id="[null]" project_snapshot_id="3"
+ dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/>
+
+
+ <!-- last dependencies -->
+ <dependencies id="3" from_resource_id="3" from_snapshot_id="8" to_resource_id="1" to_snapshot_id="6"
+ parent_dependency_id="[null]" project_snapshot_id="8"
+ dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/>
+
+ <dependencies id="4" from_resource_id="4" from_snapshot_id="9" to_resource_id="5" to_snapshot_id="10"
+ parent_dependency_id="[null]" project_snapshot_id="8"
+ dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast-result.xml
new file mode 100644
index 00000000000..5c3493f167f
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast-result.xml
@@ -0,0 +1,71 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last but project is not last -->
+ <!--<snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="true"-->
+ <!--path="[null]"/>-->
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!--<SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>-->
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>-->
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <!--<measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>-->
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml
new file mode 100644
index 00000000000..baad4416b01
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/purgeDeprecatedLast.xml
@@ -0,0 +1,71 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last but project is not last -->
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="foo"/>
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml
new file mode 100644
index 00000000000..8d4d27778c7
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDeprecatedLastTest/sharedFixture.xml
@@ -0,0 +1,33 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- file -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project copy for views -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="TRK" kee="cp-mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge-result.xml
new file mode 100644
index 00000000000..c7125729940
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge-result.xml
@@ -0,0 +1,89 @@
+<dataset>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- module -->
+ <projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- class -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="Class1" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+ <snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+ <snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1."/>
+
+ <snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2."/>
+
+ <snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2.3."/>
+
+ <snapshots depth="0" id="5" scope="PRJ" qualifier="TRK" created_at="2009-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml
new file mode 100644
index 00000000000..c7125729940
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/nothingToPurge.xml
@@ -0,0 +1,89 @@
+<dataset>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- module -->
+ <projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- class -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="Class1" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+ <snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+ <snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1."/>
+
+ <snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2."/>
+
+ <snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2.3."/>
+
+ <snapshots depth="0" id="5" scope="PRJ" qualifier="TRK" created_at="2009-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml
new file mode 100644
index 00000000000..fbe36205e74
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule-result.xml
@@ -0,0 +1,75 @@
+<dataset>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- disabled module -->
+ <!--<projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="false" language="java" copy_resource_id="[null]"/>-->
+
+ <!-- package -->
+ <!--<projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+ <!-- class -->
+ <!--<projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1" name="Class1" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="1"/>-->
+
+
+ <snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+ <!--<snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="2"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1."/>-->
+
+ <!--<snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1.2."/>-->
+
+ <!--<snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="4"-->
+ <!--parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1.2.3."/>-->
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml
new file mode 100644
index 00000000000..90abf33096c
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledModule.xml
@@ -0,0 +1,78 @@
+<dataset>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- disabled module -->
+ <projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module"
+ root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="[null]"/>
+
+ <!-- class -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="Class1" root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="1"/>
+
+
+ <snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+ <snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1."/>
+
+ <snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2."/>
+
+ <snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2.3."/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml
new file mode 100644
index 00000000000..e99e5ca29af
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject-result.xml
@@ -0,0 +1,106 @@
+<dataset>
+
+ <!-- disabled project -->
+ <!--<projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="false" language="java" copy_resource_id="[null]"/>-->
+
+ <!-- disabled module -->
+ <!--<projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="false" language="java" copy_resource_id="[null]"/>-->
+
+ <!-- package -->
+ <!--<projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+ <!-- class -->
+ <!--<projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1" name="Class1" root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="1"/>-->
+
+
+ <!-- the same enabled project -->
+ <projects long_name="[null]" id="5" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!--<snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path=""/>-->
+
+ <!--<snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="2"-->
+ <!--parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1."/>-->
+
+ <!--<snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1.2."/>-->
+
+ <!--<snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="4"-->
+ <!--parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="1.2.3."/>-->
+
+ <!--<snapshots depth="0" id="5" scope="PRJ" qualifier="TRK" created_at="2009-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path=""/>-->
+
+
+ <!-- enabled -->
+ <snapshots depth="0" id="6" scope="PRJ" qualifier="TRK" created_at="2009-02-14 13:58:00.00" version="[null]"
+ project_id="5"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path=""/>
+
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml
new file mode 100644
index 00000000000..884a048a5fb
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/purgeDisabledProject.xml
@@ -0,0 +1,112 @@
+<dataset>
+
+ <!-- disabled project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="[null]"/>
+
+ <!-- disabled module -->
+ <projects long_name="[null]" id="2" scope="PRJ" qualifier="BRC" kee="mygroup:mymoduleartifact" name="module"
+ root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="3" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="[null]"/>
+
+ <!-- class -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="Class1" root_id="[null]"
+ description="[null]"
+ enabled="false" language="java" copy_resource_id="1"/>
+
+
+ <!-- the same enabled project -->
+ <projects long_name="[null]" id="5" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <!-- disabled -->
+ <snapshots depth="0" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+ <snapshots depth="1" id="2" scope="PRJ" qualifier="BRC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1."/>
+
+ <snapshots depth="2" id="3" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2."/>
+
+ <snapshots depth="3" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="1.2.3."/>
+
+ <snapshots depth="0" id="5" scope="PRJ" qualifier="TRK" created_at="2009-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path=""/>
+
+
+ <!-- enabled -->
+ <snapshots depth="0" id="6" scope="PRJ" qualifier="TRK" created_at="2009-02-14 13:58:00.00" version="[null]"
+ project_id="5"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path=""/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml
new file mode 100644
index 00000000000..eee1bfaad3c
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeDisabledResourcesTest/sharedFixture.xml
@@ -0,0 +1,9 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities-result.xml
new file mode 100644
index 00000000000..796b6b9e576
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities-result.xml
@@ -0,0 +1,141 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <!--<snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="4"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+
+ <!-- last snapshots -->
+
+ <snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="7" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="5" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+
+ <!-- old source -->
+ <!--<SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>-->
+
+ <!-- last source -->
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="7" DATA="foo"/>
+
+
+ <!-- old violations -->
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>-->
+ <!--<RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>-->
+
+
+ <!-- last violations -->
+ <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" COST="[null]"/>
+ <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" COST="[null]"/>
+ <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" COST="[null]"/>
+ <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" COST="[null]"/>
+
+ <!-- old measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+ <!-- last measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="7" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="7" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="8" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="8" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- old measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <!--<measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>-->
+ <!--<measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>-->
+
+ <!-- last measure data -->
+ <measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>
+ <measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>
+ <measure_data id="7" measure_id="7" snapshot_id="7" data="[null]"/>
+ <measure_data id="8" measure_id="8" snapshot_id="8" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml
new file mode 100644
index 00000000000..6f34d16ace9
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/purgeEntities.xml
@@ -0,0 +1,141 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last snapshots -->
+
+ <snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="7" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="5" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+
+ <!-- old source -->
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
+
+ <!-- last source -->
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="7" DATA="foo"/>
+
+
+ <!-- old violations -->
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <!-- last violations -->
+ <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+ <!-- old measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- last measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="7" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="7" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="8" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="8" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- old measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+ <!-- last measure data -->
+ <measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>
+ <measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>
+ <measure_data id="7" measure_id="7" snapshot_id="7" data="[null]"/>
+ <measure_data id="8" measure_id="8" snapshot_id="8" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml
new file mode 100644
index 00000000000..8d4d27778c7
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEntitiesTest/sharedFixture.xml
@@ -0,0 +1,33 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- file -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project copy for views -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="TRK" kee="cp-mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans-result.xml
new file mode 100644
index 00000000000..46bd9b39c93
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans-result.xml
@@ -0,0 +1,16 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
+
+ <!-- global event -->
+ <events id="1" name="Upgrade" resource_id="[null]" snapshot_id="[null]" category="SYSTEM" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]" />
+
+ <!-- project event -->
+ <events id="2" name="Version 1.0" resource_id="1" snapshot_id="[null]" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <!-- orphan : the project does not exist-->
+ <!--<events id="3" name="Version 0.9" resource_id="5" snapshot_id="[null]" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/> -->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans.xml
new file mode 100644
index 00000000000..6e462083c40
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeEventOrphansTest/purgeEventOrphans.xml
@@ -0,0 +1,16 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
+
+ <!-- global event -->
+ <events id="1" name="Upgrade" resource_id="[null]" snapshot_id="[null]" category="SYSTEM" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <!-- project event -->
+ <events id="2" name="Version 1.0" resource_id="1" snapshot_id="[null]" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+ <!-- orphan : the project does not exist-->
+ <events id="3" name="Version 0.9" resource_id="5" snapshot_id="[null]" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources-result.xml
new file mode 100644
index 00000000000..7b43ac967c3
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources-result.xml
@@ -0,0 +1,23 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="other-project" name="other-project"
+ root_id="[null]" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project1 has been removed from UI -->
+ <!--<projects long_name="[null]" id="2" scope="PRJ" qualifier="TRK" kee="project1" name="project1"-->
+ <!--root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+ <!--<projects long_name="[null]" id="3" scope="PRJ" qualifier="BRC" kee="sub-project1" name="sub-project1"-->
+ <!--root_id="2"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+ <!--<projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="package" name="package of sup-project1"-->
+ <!--root_id="2"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources.xml
new file mode 100644
index 00000000000..0be6420e8d1
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeOrphanResourcesTest/purgeOrphanResources.xml
@@ -0,0 +1,23 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="other-project" name="other-project"
+ root_id="[null]" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project1 has been removed from UI -->
+ <!--<projects long_name="[null]" id="2" scope="PRJ" qualifier="TRK" kee="project1" name="project1"-->
+ <!--root_id="[null]"-->
+ <!--description="[null]"-->
+ <!--enabled="true" language="java" copy_resource_id="[null]"/>-->
+
+ <projects long_name="[null]" id="3" scope="PRJ" qualifier="BRC" kee="sub-project1" name="sub-project1"
+ root_id="2" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="package" name="package of sup-project1"
+ root_id="2" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans-result.xml
new file mode 100644
index 00000000000..e2cf33e7e40
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans-result.xml
@@ -0,0 +1,13 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="other-project" name="other-project"
+ root_id="[null]" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <properties id="1" prop_key="one" text_value="one" resource_id="[null]" user_id="[null]"/>
+ <properties id="2" prop_key="one" text_value="one" resource_id="1" user_id="[null]"/>
+
+ <!-- resource 2 does not exist anymore -->
+ <!--<properties id="3" prop_key="one" text_value="one" resource_id="2" user_id="[null]"/>-->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans.xml
new file mode 100644
index 00000000000..35b75197444
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeResourceOrphans.xml
@@ -0,0 +1,11 @@
+<dataset>
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="other-project" name="other-project"
+ root_id="[null]" profile_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <properties id="1" prop_key="one" text_value="one" resource_id="[null]" user_id="[null]"/>
+ <properties id="2" prop_key="one" text_value="one" resource_id="1" user_id="[null]"/>
+ <properties id="3" prop_key="one" text_value="one" resource_id="2" user_id="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans-result.xml
new file mode 100644
index 00000000000..44ac13dd9d6
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans-result.xml
@@ -0,0 +1,10 @@
+<dataset>
+ <users id="1" login="me" name="Me" email="me@you.com" />
+
+ <properties id="1" prop_key="one" text_value="one" resource_id="[null]" user_id="[null]"/>
+ <properties id="2" prop_key="one" text_value="one" resource_id="[null]" user_id="1"/>
+
+ <!-- user 2 has been deleted -->
+ <!--<properties id="3" prop_key="one" text_value="one" resource_id="[null]" user_id="2"/>-->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans.xml
new file mode 100644
index 00000000000..1b595f06123
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgePropertyOrphansTest/purgeUserOrphans.xml
@@ -0,0 +1,8 @@
+<dataset>
+ <users id="1" login="me" name="Me" email="me@you.com" />
+
+ <properties id="1" prop_key="one" text_value="one" resource_id="[null]" user_id="[null]"/>
+ <properties id="2" prop_key="one" text_value="one" resource_id="[null]" user_id="1"/>
+ <properties id="3" prop_key="one" text_value="one" resource_id="[null]" user_id="2"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles-result.xml
new file mode 100644
index 00000000000..c4c0be5ed7a
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles-result.xml
@@ -0,0 +1,27 @@
+<dataset>
+
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]" />
+
+ <!-- existing project -->
+ <user_roles id="1" user_id="30" resource_id="1" role="admin" />
+ <user_roles id="2" user_id="31" resource_id="1" role="user" />
+
+ <!-- deleted project -->
+ <!--<user_roles id="3" user_id="30" resource_id="90" role="admin" />-->
+ <!--<user_roles id="4" user_id="31" resource_id="90" role="user" />-->
+
+
+ <!-- existing project -->
+ <group_roles id="1" group_id="40" resource_id="1" role="admin" />
+ <group_roles id="2" group_id="44" resource_id="1" role="user" />
+
+ <!-- deleted project -->
+ <!--<group_roles id="3" group_id="60" resource_id="90" role="admin" />-->
+ <!--<group_roles id="4" group_id="61" resource_id="90" role="user" />-->
+
+ <!-- global roles -->
+ <group_roles id="5" group_id="60" resource_id="[null]" role="admin" />
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles.xml
new file mode 100644
index 00000000000..0678e9ec63b
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeResourceRolesTest/purgeResourceRoles.xml
@@ -0,0 +1,27 @@
+<dataset>
+
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]" profile_id="[null]"/>
+
+ <!-- existing project -->
+ <user_roles id="1" user_id="30" resource_id="1" role="admin" />
+ <user_roles id="2" user_id="31" resource_id="1" role="user" />
+
+ <!-- deleted project -->
+ <user_roles id="3" user_id="30" resource_id="90" role="admin" />
+ <user_roles id="4" user_id="31" resource_id="90" role="user" />
+
+
+ <!-- existing project -->
+ <group_roles id="1" group_id="40" resource_id="1" role="admin" />
+ <group_roles id="2" group_id="44" resource_id="1" role="user" />
+
+ <!-- deleted project -->
+ <group_roles id="3" group_id="60" resource_id="90" role="admin" />
+ <group_roles id="4" group_id="61" resource_id="90" role="user" />
+
+ <!-- global roles -->
+ <group_roles id="5" group_id="60" resource_id="[null]" role="admin" />
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures-result.xml
new file mode 100644
index 00000000000..86dbc05aba1
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures-result.xml
@@ -0,0 +1,91 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last snapshots -->
+
+ <snapshots depth="[null]" id="4" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="4" root_project_id="[null]" root_snapshot_id="4" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="4" status="P" islast="true"
+ path="[null]"/>
+
+ <!-- old measures -->
+ <project_measures characteristic_id="[null]" rule_priority="[null]" RULE_ID="[null]" RULES_CATEGORY_ID="[null]"
+ url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="4"-->
+ <!--alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="[null]"-->
+ <!--RULE_ID="[null]"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="[null]"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+ <!-- last measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="[null]"
+ RULE_ID="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="4"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="[null]"
+ RULE_ID="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!-- old measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <!--<measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>-->
+ <!--<measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>-->
+
+ <!-- last measure data -->
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+ <measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>
+ <measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml
new file mode 100644
index 00000000000..87f10a699e1
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/purgeRuleMeasures.xml
@@ -0,0 +1,92 @@
+<dataset>
+
+ <!-- old snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last snapshots -->
+
+ <snapshots depth="[null]" id="4" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="4" root_project_id="[null]" root_snapshot_id="4" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="4" status="P" islast="true"
+ path="[null]"/>
+
+ <!-- old measures -->
+ <project_measures characteristic_id="[null]" rule_priority="[null]" RULE_ID="[null]" RULES_CATEGORY_ID="[null]"
+ url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="4"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="[null]"
+ RULE_ID="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="[null]"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- last measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="[null]"
+ RULE_ID="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="4"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="[null]"
+ RULE_ID="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!-- old measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+
+ <!-- last measure data -->
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+ <measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>
+ <measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml
new file mode 100644
index 00000000000..d4e59f25a41
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasuresTest/sharedFixture.xml
@@ -0,0 +1,28 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- file -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed-result.xml
new file mode 100644
index 00000000000..c86354320cd
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed-result.xml
@@ -0,0 +1,141 @@
+<dataset>
+
+ <!-- valid snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- unprocessed snapshots -->
+
+ <!--<snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="1"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="U" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="2"-->
+ <!--parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="U" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="7" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="5" status="U" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="8" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="4"-->
+ <!--parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="U" islast="false"-->
+ <!--path="[null]"/>-->
+
+
+ <!-- valid source -->
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
+
+ <!-- unprocessed source -->
+ <!--<SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="7" DATA="foo"/>-->
+
+
+ <!-- valid violations -->
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <!-- unprocessed violations -->
+ <!--<RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>-->
+ <!--<RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>-->
+ <!--<RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>-->
+ <!--<RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>-->
+
+ <!-- valid measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- unprocessed measures -->
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="7" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="7" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="8" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="8" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+ <!-- valid measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+ <!-- unprocessed measure data -->
+ <!--<measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>-->
+ <!--<measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>-->
+ <!--<measure_data id="7" measure_id="7" snapshot_id="7" data="[null]"/>-->
+ <!--<measure_data id="8" measure_id="8" snapshot_id="8" data="[null]"/>-->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml
new file mode 100644
index 00000000000..d0bbb1424bb
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/purgeUnprocessed.xml
@@ -0,0 +1,141 @@
+<dataset>
+
+ <!-- valid snapshots -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- unprocessed snapshots -->
+
+ <snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="U" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="U" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="7" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="5" status="U" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="FIL" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="U" islast="false"
+ path="[null]"/>
+
+
+ <!-- valid source -->
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="3" DATA="foo"/>
+
+ <!-- unprocessed source -->
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="7" DATA="foo"/>
+
+
+ <!-- valid violations -->
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <!-- unprocessed violations -->
+ <RULE_FAILURES ID="5" SNAPSHOT_ID="5" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="6" SNAPSHOT_ID="6" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="7" SNAPSHOT_ID="7" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="8" SNAPSHOT_ID="8" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+ <!-- valid measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- unprocessed measures -->
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="5" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="5" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="6" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="6" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="7" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="7" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="8" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="8" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <!-- valid measure data -->
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+ <!-- unprocessed measure data -->
+ <measure_data id="5" measure_id="5" snapshot_id="5" data="[null]"/>
+ <measure_data id="6" measure_id="6" snapshot_id="6" data="[null]"/>
+ <measure_data id="7" measure_id="7" snapshot_id="7" data="[null]"/>
+ <measure_data id="8" measure_id="8" snapshot_id="8" data="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml
new file mode 100644
index 00000000000..8d4d27778c7
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/PurgeUnprocessedTest/sharedFixture.xml
@@ -0,0 +1,33 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- file -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- project copy for views -->
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="TRK" kee="cp-mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="1"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml
new file mode 100644
index 00000000000..ae4f6b24985
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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
+ -->
+<dataset>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml
new file mode 100644
index 00000000000..e6a3e32080f
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml
@@ -0,0 +1,68 @@
+<!--
+ ~ 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
+ -->
+<dataset>
+
+ <!-- first analysis, not flagged as last -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- second analysis, flag islast => false -->
+ <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2009-02-14 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2009-02-14 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- third analysis, flag islast => false -->
+ <snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2009-04-01 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2009-04-01 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- last analysis -->
+ <snapshots depth="[null]" id="7" scope="PRJ" qualifier="TRK" created_at="2009-05-18 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="DIR" qualifier="PAC" created_at="2009-05-18 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="7" root_project_id="[null]" root_snapshot_id="7" status="P" islast="true"
+ path="[null]"/>
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml
new file mode 100644
index 00000000000..e8a0a7f145d
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml
@@ -0,0 +1,68 @@
+<!--
+ ~ 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
+ -->
+<dataset>
+
+ <!-- first analysis, not flagged as last -->
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!-- second analysis, crazy state : project not last, but package flagged as last -->
+ <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2009-02-14 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2009-02-14 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="true"
+ path="[null]"/>
+
+ <!-- third analysis, flagged as last -->
+ <snapshots depth="[null]" id="5" scope="PRJ" qualifier="TRK" created_at="2009-04-01 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="6" scope="DIR" qualifier="PAC" created_at="2009-04-01 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="5" root_project_id="[null]" root_snapshot_id="5" status="P" islast="true"
+ path="[null]"/>
+
+
+ <!-- last analysis -->
+ <snapshots depth="[null]" id="7" scope="PRJ" qualifier="TRK" created_at="2009-05-18 00:00:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="8" scope="DIR" qualifier="PAC" created_at="2009-05-18 00:00:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="7" root_project_id="[null]" root_snapshot_id="7" status="P" islast="true"
+ path="[null]"/>
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest/shared.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest/shared.xml
new file mode 100644
index 00000000000..d79f7c846c8
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/runner/PurgeRunnerTest/shared.xml
@@ -0,0 +1,53 @@
+<dataset>
+
+ <!--
+
+ PROJECT WITH HISTORIC DATA
+
+ -->
+
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="myproject"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- first snapshot -->
+ <snapshots id="100" scope="PRJ" qualifier="TRK" created_at="2009-11-02 13:58:00.00" version="0.1-SNAPSHOT"
+ project_id="1" depth="[null]"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- unvalid snapshot (status = UNPROCESSED) -->
+ <snapshots id="200" scope="PRJ" qualifier="TRK" created_at="2009-11-03 13:58:00.00" version="0.1-SNAPSHOT"
+ project_id="1" depth="[null]"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="U" islast="false"
+ path="[null]"/>
+
+ <!-- second snapshot -->
+ <snapshots id="300" scope="PRJ" qualifier="TRK" created_at="2009-11-04 13:58:00.00" version="0.1-SNAPSHOT"
+ project_id="1" depth="[null]"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <!-- last snapshot -->
+ <snapshots id="400" scope="PRJ" qualifier="TRK" created_at="2009-11-05 13:58:00.00" version="0.1-SNAPSHOT"
+ project_id="1" depth="[null]"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+
+
+
+
+ <!-- PROJECT WITH ONLY A SINGLE ANALYSIS - NO TIME MACHINE -->
+ <projects long_name="[null]" id="2" scope="PRJ" qualifier="TRK" kee="mygroup2:myartifact2" name="myproject2"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <snapshots id="1000" scope="PRJ" qualifier="TRK" created_at="2009-11-05 13:58:00.00" version="0.1-SNAPSHOT"
+ project_id="2" depth="[null]"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true"
+ path="[null]"/>
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots-result.xml
new file mode 100644
index 00000000000..f5039b0e8ec
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots-result.xml
@@ -0,0 +1,111 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]" />
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- files -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class2"
+ name="class" root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <!--<snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="3"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+ <!--<snapshots depth="[null]" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"-->
+ <!--project_id="4"-->
+ <!--parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"-->
+ <!--path="[null]"/>-->
+
+
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="30" DATA="some sources"/>
+ <!--<SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="some sources"/>-->
+
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <!--<RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>-->
+ <!--<RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>-->
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+ <!--<project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"-->
+ <!--rule_priority="[null]"-->
+ <!--alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"-->
+ <!--RULE_ID="1"-->
+ <!--text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"-->
+ <!--alert_status="[null]" description="[null]"/>-->
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <!--<measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>-->
+ <!--<measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>-->
+
+ <dependencies id="1" from_resource_id="1" from_snapshot_id="1" to_resource_id="30" to_snapshot_id="30"
+ parent_dependency_id="[null]" project_snapshot_id="1"
+ dep_usage="USES" dep_weight="1" from_scope="PRJ" to_scope="LIB"/>
+
+ <!--<dependencies id="2" from_resource_id="3" from_snapshot_id="3" to_resource_id="40" to_snapshot_id="40"-->
+ <!--parent_dependency_id="[null]" project_snapshot_id="1"-->
+ <!--dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL"/>-->
+
+ <!--<dependencies id="3" from_resource_id="50" from_snapshot_id="50" to_resource_id="3" to_snapshot_id="3"-->
+ <!--parent_dependency_id="[null]" project_snapshot_id="1"-->
+ <!--dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL"/>-->
+
+</dataset> \ No newline at end of file
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots.xml
new file mode 100644
index 00000000000..93ef910270a
--- /dev/null
+++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/util/PurgeUtilsTest/purgeSnapshots.xml
@@ -0,0 +1,111 @@
+<dataset>
+ <rules_categories id="1" name="category one" description="[null]"/>
+ <rules id="1" name="foo" rules_category_id="1" plugin_config_key="checker/foo" plugin_rule_key="checkstyle.rule1"
+ plugin_name="maven-checkstyle-plugin" description="description" cardinality="SINGLE" parent_id="[null]"/>
+
+ <metrics id="1" name="ncloc" val_type="INT" description="[null]" domain="[null]"
+ short_name="" qualitative="false" user_managed="false" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
+
+ <!-- project -->
+ <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project"
+ root_id="[null]"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- package -->
+ <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package"
+ root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <!-- files -->
+ <projects long_name="[null]" id="3" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class1"
+ name="class" root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+ <projects long_name="[null]" id="4" scope="FIL" qualifier="CLA" kee="mygroup:myartifact:my.package.Class2"
+ name="class" root_id="1"
+ description="[null]"
+ enabled="true" language="java" copy_resource_id="[null]"/>
+
+
+ <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="1"
+ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="2"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <snapshots depth="[null]" id="3" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="3"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+ <snapshots depth="[null]" id="4" scope="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" version="[null]"
+ project_id="4"
+ parent_snapshot_id="2" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false"
+ path="[null]"/>
+
+
+ <SNAPSHOT_SOURCES ID="1" SNAPSHOT_ID="30" DATA="some sources"/>
+ <SNAPSHOT_SOURCES ID="2" SNAPSHOT_ID="4" DATA="some sources"/>
+
+
+ <RULE_FAILURES ID="1" SNAPSHOT_ID="1" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg1" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="2" SNAPSHOT_ID="2" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg2" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="3" SNAPSHOT_ID="3" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg3" LINE="[null]" COST="[null]"/>
+ <RULE_FAILURES ID="4" SNAPSHOT_ID="4" RULE_ID="1" FAILURE_LEVEL="2" MESSAGE="msg4" LINE="[null]" COST="[null]"/>
+
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="1" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="1" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="2" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="2" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="3" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="3" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+ <project_measures characteristic_id="[null]" url="[null]" diff_value_1="[null]" diff_value_2="[null]" diff_value_3="[null]"
+ rule_priority="[null]"
+ alert_text="[null]" ID="4" VALUE="10.0" METRIC_ID="1" SNAPSHOT_ID="4" RULES_CATEGORY_ID="1"
+ RULE_ID="1"
+ text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+ alert_status="[null]" description="[null]"/>
+
+
+ <measure_data id="1" measure_id="1" snapshot_id="1" data="[null]"/>
+ <measure_data id="2" measure_id="2" snapshot_id="2" data="[null]"/>
+ <measure_data id="3" measure_id="3" snapshot_id="3" data="[null]"/>
+ <measure_data id="4" measure_id="4" snapshot_id="4" data="[null]"/>
+
+ <dependencies id="1" from_resource_id="1" from_snapshot_id="1" to_resource_id="30" to_snapshot_id="30"
+ parent_dependency_id="[null]" project_snapshot_id="1"
+ dep_usage="USES" dep_weight="1" from_scope="PRJ" to_scope="LIB"/>
+
+ <dependencies id="2" from_resource_id="3" from_snapshot_id="3" to_resource_id="40" to_snapshot_id="40"
+ parent_dependency_id="[null]" project_snapshot_id="1"
+ dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL"/>
+
+ <dependencies id="3" from_resource_id="50" from_snapshot_id="50" to_resource_id="3" to_snapshot_id="3"
+ parent_dependency_id="[null]" project_snapshot_id="1"
+ dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL" />
+
+</dataset> \ No newline at end of file