private static String createTestDbName() {
        String dbName;
        do {
            final String uuid = UUID.randomUUID()
                    .toString()
                    .toLowerCase()
                    .replace("-", "");

            // Include the gradle worker id (unique to the JVM) and the thread ID to ensure there
            // is no clash between JVMs or threads
            dbName = String.join("_",
                    "test",
                    getGradleWorker(),
                    Long.toString(Thread.currentThread().threadId()),
                    uuid);

            // Truncate to max 64 chars to ensure we don't blow db name limit
            if (dbName.length() > 64) {
                dbName = dbName.substring(0, 64);
            }

            // We use the pattern to drop dbs after all tests have run, so ensure the name matches the pattern now.
            if (!DB_NAME_PATTERN.asMatchPredicate().test(dbName)) {
                throw new RuntimeException(LogUtil.message("dbName '{}' does not match pattern {}",
                        dbName, DB_NAME_PATTERN));
            }

            // Loop in case of name clash
        } while (DB_NAMES_IN_USE.contains(dbName));

        DB_NAMES_IN_USE.add(dbName);
        return dbName;
    }
Gets an embedded DB datasource for use in tests that don't use guice injection
stroom-test-common/src/main/java/stroom/test/common/util/db/DbTestUtil.java