import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class H2Test {
@Test
public void matchesJdbcURL() {
- assertThat(h2.matchesJdbcURL("jdbc:h2:foo"), is(true));
- assertThat(h2.matchesJdbcURL("jdbc:hsql:foo"), is(false));
+ assertThat(h2.matchesJdbcURL("jdbc:h2:foo")).isTrue();
+ assertThat(h2.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(h2.getTrueSqlValue(), is("true"));
- assertThat(h2.getFalseSqlValue(), is("false"));
+ assertThat(h2.getTrueSqlValue()).isEqualTo("true");
+ assertThat(h2.getFalseSqlValue()).isEqualTo("false");
+ }
+
+ @Test
+ public void should_configure() {
+ assertThat(h2.getId()).isEqualTo("h2");
+ assertThat(h2.getActiveRecordDialectCode()).isEqualTo("h2");
+ assertThat(h2.getActiveRecordJdbcAdapter()).isEqualTo("jdbc");
+ assertThat(h2.getDefaultDriverClassName()).isEqualTo("org.h2.Driver");
+ assertThat(h2.getValidationQuery()).isEqualTo("SELECT 1");
}
}
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class MsSqlTest {
@Test
public void matchesJdbcURL() {
- assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor"), is(true));
- assertThat(msSql.matchesJdbcURL("jdbc:microsoft:sqlserver://localhost:1433;databasename=sonar"), is(true));
+ assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isTrue();
+ assertThat(msSql.matchesJdbcURL("jdbc:microsoft:sqlserver://localhost:1433;databasename=sonar")).isTrue();
- assertThat(msSql.matchesJdbcURL("jdbc:hsql:foo"), is(false));
- assertThat(msSql.matchesJdbcURL("jdbc:mysql:foo"), is(false));
+ assertThat(msSql.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(msSql.matchesJdbcURL("jdbc:mysql:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(msSql.getTrueSqlValue(), is("1"));
- assertThat(msSql.getFalseSqlValue(), is("0"));
+ assertThat(msSql.getTrueSqlValue()).isEqualTo("1");
+ assertThat(msSql.getFalseSqlValue()).isEqualTo("0");
+ }
+
+ @Test
+ public void should_configure() {
+ assertThat(msSql.getId()).isEqualTo("mssql");
+ assertThat(msSql.getActiveRecordDialectCode()).isEqualTo("sqlserver");
+ assertThat(msSql.getActiveRecordJdbcAdapter()).isEqualTo("jdbc");
+ assertThat(msSql.getDefaultDriverClassName()).isEqualTo("net.sourceforge.jtds.jdbc.Driver");
+ assertThat(msSql.getValidationQuery()).isEqualTo("SELECT 1");
}
}
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class MySqlTest {
@Test
public void matchesJdbcURL() {
- assertThat(mySql.matchesJdbcURL("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8"), is(true));
- assertThat(mySql.matchesJdbcURL("JDBC:MYSQL://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8"), is(true));
+ assertThat(mySql.matchesJdbcURL("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
+ assertThat(mySql.matchesJdbcURL("JDBC:MYSQL://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8")).isTrue();
- assertThat(mySql.matchesJdbcURL("jdbc:hsql:foo"), is(false));
- assertThat(mySql.matchesJdbcURL("jdbc:oracle:foo"), is(false));
+ assertThat(mySql.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
+ assertThat(mySql.matchesJdbcURL("jdbc:oracle:foo")).isFalse();
}
@Test
public void testBooleanSqlValues() {
- assertThat(mySql.getTrueSqlValue(), is("true"));
- assertThat(mySql.getFalseSqlValue(), is("false"));
+ assertThat(mySql.getTrueSqlValue()).isEqualTo("true");
+ assertThat(mySql.getFalseSqlValue()).isEqualTo("false");
}
-}
+ @Test
+ public void should_configure() {
+ assertThat(mySql.getId()).isEqualTo("mysql");
+ assertThat(mySql.getActiveRecordDialectCode()).isEqualTo("mysql");
+ assertThat(mySql.getActiveRecordJdbcAdapter()).isEqualTo("jdbc");
+ assertThat(mySql.getDefaultDriverClassName()).isEqualTo("com.mysql.jdbc.Driver");
+ assertThat(mySql.getValidationQuery()).isEqualTo("SELECT 1");
+ }
+}
*/
package org.sonar.core.persistence.dialect;
-import org.hamcrest.core.Is;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class OracleTest {
-
+
private Oracle oracle = new Oracle();
@Test
public void matchesJdbcURL() {
- assertThat(oracle.matchesJdbcURL("jdbc:oracle:thin:@localhost/XE"), is(true));
- assertThat(oracle.matchesJdbcURL("jdbc:hsql:foo"), is(false));
+ assertThat(oracle.matchesJdbcURL("jdbc:oracle:thin:@localhost/XE")).isTrue();
+ assertThat(oracle.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
}
/**
public void shouldChangeOracleSchema() {
String initStatement = oracle.getConnectionInitStatement("my_schema");
- assertThat(initStatement, Is.is("ALTER SESSION SET CURRENT_SCHEMA = \"my_schema\""));
+ assertThat(initStatement).isEqualTo("ALTER SESSION SET CURRENT_SCHEMA = \"my_schema\"");
}
@Test
public void shouldNotChangeOracleSchemaByDefault() {
- assertNull(oracle.getConnectionInitStatement(null));
+ assertThat(oracle.getConnectionInitStatement(null)).isNull();
}
@Test
public void testBooleanSqlValues() {
- assertThat(oracle.getTrueSqlValue(), is("1"));
- assertThat(oracle.getFalseSqlValue(), is("0"));
+ assertThat(oracle.getTrueSqlValue()).isEqualTo("1");
+ assertThat(oracle.getFalseSqlValue()).isEqualTo("0");
+ }
+
+ @Test
+ public void should_configure() {
+ assertThat(oracle.getId()).isEqualTo("oracle");
+ assertThat(oracle.getActiveRecordDialectCode()).isEqualTo("oracle");
+ assertThat(oracle.getActiveRecordJdbcAdapter()).isEqualTo("oracle_enhanced");
+ assertThat(oracle.getDefaultDriverClassName()).isEqualTo("oracle.jdbc.OracleDriver");
+ assertThat(oracle.getValidationQuery()).isEqualTo("SELECT 1 FROM DUAL");
}
}
import org.hamcrest.core.Is;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
+import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertThat;
public class PostgreSqlTest {
@Test
public void matchesJdbcURL() {
- assertThat(postgreSql.matchesJdbcURL("jdbc:postgresql://localhost/sonar"), is(true));
- assertThat(postgreSql.matchesJdbcURL("jdbc:hsql:foo"), is(false));
+ assertThat(postgreSql.matchesJdbcURL("jdbc:postgresql://localhost/sonar")).isTrue();
+ assertThat(postgreSql.matchesJdbcURL("jdbc:hsql:foo")).isFalse();
}
- /**
- * Avoid conflicts with other schemas
- */
@Test
- public void shouldChangePostgreSearchPath() {
+ public void should_avoid_conflict_with_other_schemas() {
String initStatement = postgreSql.getConnectionInitStatement("my_schema");
assertThat(initStatement, Is.is("SET SEARCH_PATH TO my_schema"));
@Test
public void shouldNotChangePostgreSearchPathByDefault() {
- assertNull(postgreSql.getConnectionInitStatement(null));
+ assertThat(postgreSql.getConnectionInitStatement(null)).isNull();
}
@Test
public void testBooleanSqlValues() {
- assertThat(postgreSql.getTrueSqlValue(), is("true"));
- assertThat(postgreSql.getFalseSqlValue(), is("false"));
+ assertThat(postgreSql.getTrueSqlValue()).isEqualTo("true");
+ assertThat(postgreSql.getFalseSqlValue()).isEqualTo("false");
+ }
+
+ @Test
+ public void should_configure() {
+ assertThat(postgreSql.getId()).isEqualTo("postgresql");
+ assertThat(postgreSql.getActiveRecordDialectCode()).isEqualTo("postgre");
+ assertThat(postgreSql.getActiveRecordJdbcAdapter()).isEqualTo("jdbc");
+ assertThat(postgreSql.getDefaultDriverClassName()).isEqualTo("org.postgresql.Driver");
+ assertThat(postgreSql.getValidationQuery()).isEqualTo("SELECT 1");
}
}