Class BaseDatabaseTestCase
- java.lang.Object
-
- junit.framework.Assert
-
- jetbrains.buildServer.MockSupport
-
- jetbrains.buildServer.AfterTestHook
-
- jetbrains.buildServer.BaseTestCase
-
- jetbrains.buildServer.serverSide.db.BaseDatabaseTestCase
-
- All Implemented Interfaces:
WaitForAssertions,org.testng.IHookable,org.testng.ITestNGListener
- Direct Known Subclasses:
BaseDatabaseFunctionsTestCase,BaseDatabaseSchemaTestCase,BaseServerTestCase
public class BaseDatabaseTestCase extends BaseTestCase implements WaitForAssertions
For tests that needs a database (empty or with tables), but don't need started BuildServer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classBaseDatabaseTestCase.SQLWork-
Nested classes/interfaces inherited from class jetbrains.buildServer.BaseTestCase
BaseTestCase.UnderLockedFile
-
-
Field Summary
Fields Modifier and Type Field Description protected static DatabaseTypedbTypeprotected static SQLDialectourDialectprotected static QueryBuilderourQueryBuilder-
Fields inherited from class jetbrains.buildServer.BaseTestCase
IS_WINDOWS, myTestLogger, OS_NAME
-
Fields inherited from class jetbrains.buildServer.MockSupport
ANYTHING, NOT_NULL, NULL
-
-
Constructor Summary
Constructors Constructor Description BaseDatabaseTestCase()BaseDatabaseTestCase(String a)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertNoTableRows(String tableName, String condition, Object... params)protected static voidcleanupTable(DBFunctions dbf, String tableName)Deletes all rows from the specified table.protected static voidcleanupTables(String... tableNames)Deletes all rows from the specified table.protected static voidcleanupTables(DBFunctions dbf, String... tableNames)Deletes all rows from the specified tables.protected intcountTableRows(String tableName, String condition, Object... params)protected ServerPathscreateEmptyServerPath()protected voiddumpTable(String tableName)Dumps the specified table to a standard output, using the current connection.protected static voiddumpTable(String tableName, Connection conn)Dumps the specified table to a standard output, using the specified connection.protected voiddumpTables(String... tableNames)protected voiddumpTables(Collection<String> tableNames)protected voidensureCleanSchema(SchemaDef schema)protected voidensureCleanTable(String... strings)protected voidensureCleanTable(TableDef table)protected voidensureNoTables(String... tableNames)protected voidensureSingleRowTable()protected voidexecuteScript(String script)protected static voidpopulateTablesWithSimpleData()static DatabaseType[][]provideDatabaseHsql2Only()static DatabaseType[][]provideDatabaseMsOnly()static DatabaseType[][]provideDatabaseTypeMySQLOnly()static DatabaseType[][]provideDatabaseTypeNotHSQL()static DatabaseType[][]provideDatabaseTypeNotMySQL()static DatabaseType[][]provideDatabaseTypeSupportI18n()static DatabaseType[][]provideWithCurrentDatabaseType()protected static voidrunTwoQueries(DBFunctions conn1, String query1, DBFunctions conn2, String query2, int waitMillis, Exception[] exceptionCells)protected static voidrunTwoThreads(Runnable work1, String name1, Runnable work2, String name2, int waitMillis)protected voidsetUp()voidsetUpClassStatic()protected voidtearDown()protected <T> TwithDBF(DBAction<T> action, boolean commitOnSuccess)protected voidwithDBF(DBActionNoResults action, boolean commitOnSuccess)-
Methods inherited from class jetbrains.buildServer.BaseTestCase
assertArraysEqual, assertArraysEqual, assertContains, assertContains, assertContains, assertContains, assertContains, assertContainsAll, assertContainsAny, assertContainsWithCount, assertEmpty, assertEmpty, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsIgnoreNonBMP, assertExceptionThrown, assertExceptionThrown, assertExceptionThrown, assertExceptionThrown, assertExceptionThrown, assertGreater, assertGreater, assertGreaterOrEquals, assertHasWithCount, assertInstanceOf, assertListEquals, assertMap, assertMapping, assertMatches, assertMatches, assertMeaningTextEquals, assertNotContains, assertNotContains, assertNotContains, assertNotEmpty, assertNull2, assertSameElements, assertSameElements, assertSameElements, assertSetEquals, assertTime, assertTime, assertTimestampEquals, assertXmlEqual, assertXmlEqual, averageExecutionTime, checkOrderedCollection, checkOrderedCollection, checkUnorderedCollection, checkUnorderedCollection, clearFailure, createMap, createSet, createTempDir, createTempFile, createTempFile, createTempFile, createTestLogger, doUnderLockedDirectory, doUnderLockedFile, doUnderUnreadableLockedFile, dumpCollection, dumpFile, dumpItems, enableAndRecordDebugLog, enableDebug, enableDebug, enableInfo, env, getLoggedFailure, getName, getProjectDir, getTestDataFile, getTestFiles, getTestFilesDataPath, hasCustomInternalProperty, isPropertyDefined, listFilesOrDie, listFilesOrDie, log, performAfterTestVerification, provideWithBooleans, provideWithLinuxMacWindows, provideWithWindowsOnly, registerAsTempFile, removeInternalProperty, resetAllFields, resetFields2Null, runAndReportMemoryAllocations, runAsync, runAsync, runAsyncAndFailOnException, setInternalProperty, setInternalProperty, setInternalProperty, setLogLevel, setName, setUpClass, setupSuite, startThreadsAsync, threadDump, toProvide, trueFalseDataProvider, waitFor, waitFor, waitFor, writeTextToFile
-
Methods inherited from class jetbrains.buildServer.AfterTestHook
finishAfterTestHook, initializeAfterTestHook, run
-
Methods inherited from class jetbrains.buildServer.MockSupport
and, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, atLeastOnce, collectionContaining, collectionContaining, compatibleType, contains, containsInAnyOrder, containsInAnyOrder, containsInOrder, containsInOrder, defaultMockNameForType, doAll, doAll, doAll, doAll, endsWith, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, exactly, hasProperty, hasProperty, isA, isGreaterThan, isIn, isIn, isLessThan, mapContaining, mapContaining, mapWithKey, mapWithKey, mapWithValue, mapWithValue, mock, mock, never, never, newDummy, newDummy, newDummy, not, not, once, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, or, returnIterator, returnIterator, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, same, setUpMocks, startsWith, stringContains, tearDownMocks, throwException, toString, verify
-
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.WaitForAssertions
waitFor, waitFor, waitForAssert, waitForAssert, waitForAssert, waitForAssert
-
-
-
-
Field Detail
-
ourQueryBuilder
protected static QueryBuilder ourQueryBuilder
-
dbType
protected static DatabaseType dbType
-
ourDialect
protected static SQLDialect ourDialect
-
-
Constructor Detail
-
BaseDatabaseTestCase
public BaseDatabaseTestCase()
-
BaseDatabaseTestCase
public BaseDatabaseTestCase(String a)
-
-
Method Detail
-
setUp
@BeforeMethod(alwaysRun=true) protected void setUp() throws Exception- Overrides:
setUpin classBaseTestCase- Throws:
Exception
-
tearDown
@AfterMethod(alwaysRun=true) protected void tearDown() throws Exception- Overrides:
tearDownin classBaseTestCase- Throws:
Exception
-
ensureCleanTable
protected void ensureCleanTable(String... strings)
-
ensureCleanTable
protected void ensureCleanTable(@NotNull TableDef table)
-
ensureCleanSchema
protected void ensureCleanSchema(@NotNull SchemaDef schema)
-
ensureNoTables
protected void ensureNoTables(String... tableNames)
-
withDBF
protected <T> T withDBF(@NotNull DBAction<T> action, boolean commitOnSuccess)
-
withDBF
protected void withDBF(@NotNull DBActionNoResults action, boolean commitOnSuccess)
-
executeScript
protected void executeScript(@NotNull String script) throws DBException- Throws:
DBException
-
cleanupTables
protected static void cleanupTables(@NotNull String... tableNames)Deletes all rows from the specified table.- Parameters:
tableName- table name.
-
cleanupTables
protected static void cleanupTables(DBFunctions dbf, String... tableNames)
Deletes all rows from the specified tables.- Parameters:
dbf- database connectiomn and functions.tableNames- table names.
-
cleanupTable
protected static void cleanupTable(DBFunctions dbf, String tableName)
Deletes all rows from the specified table.- Parameters:
dbf- database connectiomn and functions.tableName- table name.
-
dumpTables
protected void dumpTables(@NotNull Collection<String> tableNames)
-
dumpTables
protected void dumpTables(@NotNull String... tableNames)
-
dumpTable
protected void dumpTable(String tableName)
Dumps the specified table to a standard output, using the current connection.- Parameters:
tableName- name of table to dump.- Throws:
SQLException- when something goes wrong.
-
dumpTable
protected static void dumpTable(String tableName, Connection conn) throws SQLException
Dumps the specified table to a standard output, using the specified connection.- Parameters:
tableName- name of table to dump.conn- db connection.- Throws:
SQLException- when something goes wrong.
-
ensureSingleRowTable
protected void ensureSingleRowTable()
-
countTableRows
protected int countTableRows(@NotNull String tableName, @Nullable String condition, Object... params)
-
assertNoTableRows
protected void assertNoTableRows(@NotNull String tableName, @Nullable String condition, Object... params)
-
createEmptyServerPath
protected ServerPaths createEmptyServerPath()
-
provideWithCurrentDatabaseType
@DataProvider public static DatabaseType[][] provideWithCurrentDatabaseType()
-
provideDatabaseTypeNotHSQL
@DataProvider public static DatabaseType[][] provideDatabaseTypeNotHSQL()
-
provideDatabaseTypeNotMySQL
@DataProvider public static DatabaseType[][] provideDatabaseTypeNotMySQL()
-
provideDatabaseTypeMySQLOnly
@DataProvider public static DatabaseType[][] provideDatabaseTypeMySQLOnly()
-
provideDatabaseMsOnly
@DataProvider public static DatabaseType[][] provideDatabaseMsOnly()
-
provideDatabaseHsql2Only
@DataProvider public static DatabaseType[][] provideDatabaseHsql2Only()
-
provideDatabaseTypeSupportI18n
@DataProvider public static DatabaseType[][] provideDatabaseTypeSupportI18n()
-
populateTablesWithSimpleData
protected static void populateTablesWithSimpleData()
-
runTwoQueries
protected static void runTwoQueries(DBFunctions conn1, String query1, DBFunctions conn2, String query2, int waitMillis, Exception[] exceptionCells)
-
runTwoThreads
protected static void runTwoThreads(Runnable work1, String name1, Runnable work2, String name2, int waitMillis) throws InterruptedException
- Throws:
InterruptedException
-
-