]> source.dussan.org Git - sonarqube.git/commitdiff
Remove HSQLDB from unit tests
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 10 Nov 2011 15:22:12 +0000 (16:22 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 10 Nov 2011 15:22:12 +0000 (16:22 +0100)
plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/PurgeDeletedResourcesTest.java
pom.xml
sonar-core/pom.xml
sonar-core/src/main/java/org/sonar/jpa/dialect/DialectRepository.java
sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java [deleted file]
sonar-core/src/test/java/org/sonar/jpa/dialect/HsqlDbTest.java [deleted file]
sonar-core/src/test/java/org/sonar/jpa/test/AbstractDbUnitTestCase.java
sonar-core/src/test/java/org/sonar/persistence/HsqlDatabase.java [deleted file]
sonar-plugin-api/pom.xml
sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseProperties.java
sonar-testing-harness/pom.xml

index a912f142b6a6b51c03bfd925109ef61a473a721f..40cbed111dbeb6ed32f845c35e6ef57a183ece17 100644 (file)
@@ -32,8 +32,6 @@ public class PurgeDeletedResourcesTest extends AbstractDbUnitTestCase {
     setupData("sharedFixture", "purgeDeletedResources");
 
     final Connection c = getConnection().getConnection();
-    // TODO Godin: next line was here with HSQL
-    //c.prepareStatement("SET REFERENTIAL_INTEGRITY FALSE; ").execute();
     c.prepareStatement("delete from projects where id=3").executeUpdate();
     c.commit();
 
diff --git a/pom.xml b/pom.xml
index 88d890f962d83932c91f22c6383098aaf0054d0f..30525de0f3d59698bf307d515f7616b41f8bb864 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <artifactId>jetty-util</artifactId>
         <version>${jetty.version}</version>
       </dependency>
-      <dependency>
-        <groupId>hsqldb</groupId>
-        <artifactId>hsqldb</artifactId>
-        <version>1.8.0.10</version>
-      </dependency>
       <dependency>
         <groupId>org.jdom</groupId>
         <artifactId>jdom</artifactId>
index dba6c874164aeff98c076584bc3756e97ab39481..bf523da6e2cd473a46636b7bfb1aa642a8a66d43 100644 (file)
       <artifactId>dbunit</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-      <scope>test</scope>
-    </dependency>
 
     <!--
          JDBC drivers for MyBatis integration tests.
index aa025b056e416d669c38898167de14bcbf559497..80394a8834a9813de47ab08dd616cbc227671805 100644 (file)
@@ -88,6 +88,6 @@ public final class DialectRepository {
   }
 
   private static List<Dialect> getSupportedDialects() {
-    return Arrays.asList(new Derby(), new HsqlDb(), new MySql(), new Oracle(), new PostgreSql(), new MsSql());
+    return Arrays.asList(new Derby(), new MySql(), new Oracle(), new PostgreSql(), new MsSql());
   }
 }
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java
deleted file mode 100644 (file)
index 4a7d2d2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.jpa.dialect;
-
-import org.apache.commons.lang.StringUtils;
-import org.hibernate.dialect.HSQLDialect;
-
-/**
- * @since 1.12
- */
-public class HsqlDb implements Dialect {
-
-  public String getId() {
-    return "hsqldb";
-  }
-
-  public String getActiveRecordDialectCode() {
-    return "hsqldb";
-  }
-
-  public String getActiveRecordJdbcAdapter() {
-    return "jdbc";
-  }
-
-  public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
-    return HSQLDialect.class;
-  }
-
-  public boolean matchesJdbcURL(String jdbcConnectionURL) {
-    return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:hsqldb:");
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/jpa/dialect/HsqlDbTest.java b/sonar-core/src/test/java/org/sonar/jpa/dialect/HsqlDbTest.java
deleted file mode 100644 (file)
index 440500d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.jpa.dialect;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
-public class HsqlDbTest {
-  @Test
-  public void matchesJdbcURL() {
-    assertThat(new HsqlDb().matchesJdbcURL("jdbc:hsqldb:hsql:foo"), is(true));
-    assertThat(new HsqlDb().matchesJdbcURL("jdbc:hsql:foo"), is(false));
-  }
-}
index 4bc3dd8f68100afb39afeda25f5f693bdc296de3..da7b2fca1c73277c37d772d4b2562e2a2b5be4d1 100644 (file)
  */
 package org.sonar.jpa.test;
 
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
 import org.apache.commons.io.IOUtils;
 import org.dbunit.Assertion;
 import org.dbunit.DataSourceDatabaseTester;
 import org.dbunit.DatabaseUnitException;
 import org.dbunit.IDatabaseTester;
-import org.dbunit.database.DatabaseConfig;
 import org.dbunit.database.IDatabaseConnection;
 import org.dbunit.dataset.*;
 import org.dbunit.dataset.filter.DefaultColumnFilter;
 import org.dbunit.dataset.xml.FlatXmlDataSet;
-import org.dbunit.ext.hsqldb.HsqldbDataTypeFactory;
 import org.dbunit.operation.DatabaseOperation;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.jpa.dao.DaoFacade;
 import org.sonar.jpa.dao.MeasuresDao;
@@ -48,11 +41,18 @@ import org.sonar.jpa.session.DatabaseSessionFactory;
 import org.sonar.jpa.session.DefaultDatabaseConnector;
 import org.sonar.jpa.session.JpaDatabaseSession;
 import org.sonar.jpa.session.MemoryDatabaseConnector;
-import org.sonar.persistence.*;
+import org.sonar.persistence.Database;
+import org.sonar.persistence.InMemoryDatabase;
+import org.sonar.persistence.MyBatis;
 
-public abstract class AbstractDbUnitTestCase {
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.sql.ResultSet;
+import java.sql.SQLException;
 
-  private static final boolean USE_HSQL = false;
+import static org.junit.Assert.fail;
+
+public abstract class AbstractDbUnitTestCase {
 
   private DefaultDatabaseConnector dbConnector;
   private JpaDatabaseSession session;
@@ -64,11 +64,7 @@ public abstract class AbstractDbUnitTestCase {
 
   @Before
   public void startDatabase() throws Exception {
-    if (USE_HSQL) {
-      database = new HsqlDatabase();
-    } else {
-      database = new InMemoryDatabase();
-    }
+    database = new InMemoryDatabase();
     database.start();
 
     myBatis = new MyBatis(database);
@@ -156,19 +152,8 @@ public abstract class AbstractDbUnitTestCase {
       databaseTester.setDataSet(compositeDataSet);
       connection = databaseTester.getConnection();
 
-      if (USE_HSQL) {
-        connection.getConnection().prepareStatement("set referential_integrity FALSE").execute(); // HSQL DB
-        DatabaseConfig config = connection.getConfig();
-        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqldbDataTypeFactory());
-      }
-
       DatabaseOperation.CLEAN_INSERT.execute(connection, databaseTester.getDataSet());
-
-      if (USE_HSQL) {
-        connection.getConnection().prepareStatement("set referential_integrity TRUE").execute(); // HSQL DB
-      } else {
-        resetDerbySequence(compositeDataSet);
-      }
+      resetDerbySequence(compositeDataSet);
 
     } catch (Exception e) {
       throw translateException("Could not setup DBUnit data", e);
@@ -194,7 +179,7 @@ public abstract class AbstractDbUnitTestCase {
   }
 
   protected final void checkTables(String testName, String... tables) {
-    checkTables(testName, new String[] {}, tables);
+    checkTables(testName, new String[]{}, tables);
   }
 
   protected final void checkTables(String testName, String[] excludedColumnNames, String... tables) {
diff --git a/sonar-core/src/test/java/org/sonar/persistence/HsqlDatabase.java b/sonar-core/src/test/java/org/sonar/persistence/HsqlDatabase.java
deleted file mode 100644 (file)
index 1313750..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.persistence;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.commons.dbcp.BasicDataSourceFactory;
-import org.hibernate.cfg.Environment;
-import org.sonar.jpa.dialect.Derby;
-import org.sonar.jpa.dialect.Dialect;
-import org.sonar.jpa.dialect.HsqlDb;
-import org.sonar.jpa.session.CustomHibernateConnectionProvider;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * In-memory database used for Hibernate unit tests only. For information MyBatis tests use Derby.
- *
- * @since 2.12
- */
-public class HsqlDatabase implements Database {
-
-  private BasicDataSource datasource;
-
-  public HsqlDatabase start() {
-    startDatabase();
-    return this;
-  }
-
-  void startDatabase() {
-    try {
-      Properties properties = new Properties();
-      properties.put("driverClassName", "org.hsqldb.jdbcDriver");
-      properties.put("username", "sa");
-      properties.put("password", "");
-      properties.put("url", "jdbc:hsqldb:mem:sonar");
-
-      properties.put("maxActive", "3");
-      properties.put("maxIdle", "3");
-      datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties);
-
-    } catch (Exception e) {
-      throw new IllegalStateException("Fail to start HSQL", e);
-    }
-  }
-
-  public HsqlDatabase stop() {
-    try {
-      if (datasource != null) {
-        datasource.close();
-      }
-      DriverManager.getConnection("jdbc:derby:memory:sonar;drop=true");
-
-    } catch (SQLException e) {
-      // silently ignore stop failure
-    }
-    return this;
-  }
-
-  public DataSource getDataSource() {
-    return datasource;
-  }
-
-  public Dialect getDialect() {
-    return new HsqlDb();
-  }
-
-  public String getSchema() {
-    return null;
-  }
-
-  public Properties getHibernateProperties() {
-    Properties properties = new Properties();
-    properties.put("hibernate.hbm2ddl.auto", "create-drop");
-    properties.put(Environment.DIALECT, getDialect().getHibernateDialectClass().getName());
-    properties.put(Environment.CONNECTION_PROVIDER, CustomHibernateConnectionProvider.class.getName());
-    return properties;
-  }
-}
index c6dd85a848fb088935bf6f8d1f9724484888309f..5c400a14bf888f23c31068cb474e20b77cc6e58d 100644 (file)
       <artifactId>dbunit</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty-servlet-tester</artifactId>
index 97d9bd3004f4f7a729d5a9f8264fe300d5445728..ebfddc3bd281bc6cdd6edd1fb8204b6e83942a2c 100644 (file)
@@ -44,6 +44,11 @@ public interface DatabaseProperties {
 
   String PROP_EMBEDDED_DATA_DIR = "sonar.embeddedDatabase.dataDir";
   String DIALECT_DERBY = "derby";
+  
+  /**
+   * @deprecated not supported anymore since v.2.13.
+   */
+  @Deprecated
   String DIALECT_HSQLDB = "hsqldb";
   String DIALECT_MYSQL = "mysql";
   String DIALECT_POSTGRESQL = "postgresql";
index 42f240e03c9ce439ba0637095519a2834ed00488..4185c8c0ce62afa26963335139fcc13556200ba5 100644 (file)
         </exclusion>
       </exclusions>
     </dependency>
-    <dependency>
-      <groupId>hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.codehaus.sonar</groupId>
       <artifactId>sonar-plugin-api</artifactId>