aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-12-06 16:12:47 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2011-12-06 16:13:20 +0100
commit4ce69589edb79ed4a4e4a947925a6f43885b1a1e (patch)
tree0c94c4604b20f0f2bb764ace7b07731d8698ca63
parente45b22cfd77ba58466dfbf024d0fa853bfee8c2f (diff)
downloadsonarqube-4ce69589edb79ed4a4e4a947925a6f43885b1a1e.tar.gz
sonarqube-4ce69589edb79ed4a4e4a947925a6f43885b1a1e.zip
Try to fix Oracle tests
-rw-r--r--sonar-core/src/test/java/org/sonar/persistence/dao/DaoTestCase.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/persistence/dao/DatabaseCommands.java28
2 files changed, 20 insertions, 12 deletions
diff --git a/sonar-core/src/test/java/org/sonar/persistence/dao/DaoTestCase.java b/sonar-core/src/test/java/org/sonar/persistence/dao/DaoTestCase.java
index 9b4f75e0cbf..e066c68812f 100644
--- a/sonar-core/src/test/java/org/sonar/persistence/dao/DaoTestCase.java
+++ b/sonar-core/src/test/java/org/sonar/persistence/dao/DaoTestCase.java
@@ -103,7 +103,9 @@ public abstract class DaoTestCase {
// 2. reset primary keys
try {
- statement.executeUpdate(databaseCommands.resetPrimaryKey(table));
+ for (String resetCommand : databaseCommands.resetPrimaryKey(table)) {
+ statement.executeUpdate(resetCommand);
+ }
connection.commit();
} catch (Exception e) {
// this table has no primary key
diff --git a/sonar-core/src/test/java/org/sonar/persistence/dao/DatabaseCommands.java b/sonar-core/src/test/java/org/sonar/persistence/dao/DatabaseCommands.java
index 7bf85bb5334..421e5a4c957 100644
--- a/sonar-core/src/test/java/org/sonar/persistence/dao/DatabaseCommands.java
+++ b/sonar-core/src/test/java/org/sonar/persistence/dao/DatabaseCommands.java
@@ -27,6 +27,9 @@ import org.dbunit.ext.oracle.Oracle10DataTypeFactory;
import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory;
import org.sonar.jpa.dialect.*;
+import java.util.Arrays;
+import java.util.List;
+
abstract class DatabaseCommands {
private IDataTypeFactory dbUnitFactory;
@@ -37,7 +40,7 @@ abstract class DatabaseCommands {
abstract String truncate(String table);
- abstract String resetPrimaryKey(String table);
+ abstract List<String> resetPrimaryKey(String table);
final IDataTypeFactory dbUnitFactory() {
return dbUnitFactory;
@@ -51,8 +54,8 @@ abstract class DatabaseCommands {
}
@Override
- String resetPrimaryKey(String table) {
- return "ALTER TABLE " + table + " ALTER COLUMN ID RESTART WITH 1";
+ List<String> resetPrimaryKey(String table) {
+ return Arrays.asList("ALTER TABLE " + table + " ALTER COLUMN ID RESTART WITH 1");
}
};
@@ -63,8 +66,8 @@ abstract class DatabaseCommands {
}
@Override
- String resetPrimaryKey(String table) {
- return "DBCC CHECKIDENT('" + table + "', RESEED, 1)";
+ List<String> resetPrimaryKey(String table) {
+ return Arrays.asList("DBCC CHECKIDENT('" + table + "', RESEED, 1)");
}
};
@@ -75,8 +78,8 @@ abstract class DatabaseCommands {
}
@Override
- String resetPrimaryKey(String table) {
- return "ALTER TABLE " + table + " AUTO_INCREMENT = 1";
+ List<String> resetPrimaryKey(String table) {
+ return Arrays.asList("ALTER TABLE " + table + " AUTO_INCREMENT = 1");
}
};
@@ -87,8 +90,11 @@ abstract class DatabaseCommands {
}
@Override
- String resetPrimaryKey(String table) {
- return "ALTER SEQUENCE " + table + "_SEQ INCREMENT BY 1 MINVALUE 1";
+ List<String> resetPrimaryKey(String table) {
+ return Arrays.asList(
+ "DROP SEQUENCE " + table + "_SEQ",
+ "CREATE SEQUENCE " + table + "_SEQ INCREMENT BY 1 MINVALUE 1 START WITH 1 NOORDER CACHE"
+ );
}
};
@@ -99,8 +105,8 @@ abstract class DatabaseCommands {
}
@Override
- String resetPrimaryKey(String table) {
- return "ALTER SEQUENCE " + table + "_id_seq RESTART WITH 1";
+ List<String> resetPrimaryKey(String table) {
+ return Arrays.asList("ALTER SEQUENCE " + table + "_id_seq RESTART WITH 1");
}
};