use of org.h2.util.ColumnNamer in project h2database by h2database.
the class TestColumnNamer method test.
@Override
public void test() {
ColumnNamer columnNamer = new ColumnNamer(null);
columnNamer.getConfiguration().configure("MAX_IDENTIFIER_LENGTH = 30");
columnNamer.getConfiguration().configure("REGULAR_EXPRESSION_MATCH_ALLOWED = '[A-Za-z0-9_]+'");
columnNamer.getConfiguration().configure("REGULAR_EXPRESSION_MATCH_DISALLOWED = '[^A-Za-z0-9_]+'");
columnNamer.getConfiguration().configure("DEFAULT_COLUMN_NAME_PATTERN = 'colName$$'");
columnNamer.getConfiguration().configure("GENERATE_UNIQUE_COLUMN_NAMES = 1");
int index = 0;
for (String id : ids) {
Expression columnExp = ValueExpression.getDefault();
String newColumnName = columnNamer.getColumnName(columnExp, index + 1, id);
assertNotNull(newColumnName);
assertTrue(newColumnName.length() <= 30);
assertTrue(newColumnName.length() >= 1);
assertEquals(newColumnName, expectedColumnName[index]);
index++;
}
}
Aggregations