use of io.crate.testing.UseRandomizedSchema in project crate by crate.
the class SQLIntegrationTestCase method RandomizedSchema.
/**
* If the Test class or method contains a @UseRandomizedSchema annotation then,
* based on the schema argument, a random (unquoted) schema name is returned. The schema name consists
* of a 1-20 character long ASCII string.
* For more details on the schema parameter see {@link UseRandomizedSchema}
* <p>
* Method annotations have higher priority than class annotations.
*/
private String RandomizedSchema() {
UseRandomizedSchema annotation = getTestAnnotation(UseRandomizedSchema.class);
if (annotation == null || annotation.random() == false) {
return Schemas.DOC_SCHEMA_NAME;
}
Random random = RandomizedContext.current().getRandom();
while (true) {
String schemaName = RandomStrings.randomAsciiLettersOfLengthBetween(random, 1, 20).toLowerCase();
if (!Schemas.READ_ONLY_SYSTEM_SCHEMAS.contains(schemaName) && !Identifiers.isKeyWord(schemaName) && !containsExtendedAsciiChars(schemaName)) {
return schemaName;
}
}
}
Aggregations