use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class HBaseMetadataTest method testRenameExistingTableNoAutoFlush.
@Test(expected = TableNotFoundException.class)
public void testRenameExistingTableNoAutoFlush() throws Exception {
String originalName = "OriginalName";
String newName = "NewName";
TableSchema origSchema = TABLE_SCHEMA_GEN.next();
// Configure the table to disable auto flush
HTableInterface hTableSpy = PowerMockito.spy(MockHTable.create());
Mockito.when(hTableSpy.isAutoFlush()).thenReturn(false);
hbaseMetadata.createTable(originalName, origSchema);
long origId = hbaseMetadata.getTableId(originalName);
hbaseMetadata.renameExistingTable(originalName, newName);
long newId = hbaseMetadata.getTableId(newName);
assertEquals(origId, newId);
Collection<ColumnSchema> origSchemaColumns = origSchema.getColumns();
TableSchema newSchema = hbaseMetadata.getSchema(newId);
for (ColumnSchema columnSchema : newSchema.getColumns()) {
assertTrue(origSchemaColumns.contains(columnSchema));
}
// Trying to access the id of the old table name will result in an exception
hbaseMetadata.getTableId(originalName);
hTableSpy.close();
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class RowKeyTest method testIndexRowKeyStrings.
@Test
public void testIndexRowKeyStrings() {
String columnName = "c1";
String indexName = "i1";
ColumnSchema columnSchema = ColumnSchema.builder("default", ColumnType.DATETIME).build();
IndexSchema indexSchema = new IndexSchema(indexName, ImmutableList.of(columnName), false);
TableSchema tableSchema = new TableSchema(ImmutableList.of(columnSchema), ImmutableList.of(indexSchema));
Generator<RowKey> rowkeysGen = RowKeyGenerator.getAscIndexRowKeyGenerator(tableSchema);
List<RowKey> rowkeys = Lists.newArrayList(Iterables.toIterable(rowkeysGen));
Collections.sort(rowkeys);
List<byte[]> encodedRowkeys = Lists.newArrayList();
for (RowKey rowkey : rowkeys) {
encodedRowkeys.add(rowkey.encode());
}
Collections.sort(encodedRowkeys, new Bytes.ByteArrayComparator());
for (int i = 0; i < rowkeys.size(); i++) {
RowKey rowKey = rowkeys.get(i);
byte[] encodedRowKey = encodedRowkeys.get(i);
Assert.assertArrayEquals(encodedRowKey, rowKey.encode());
}
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseBinaryEmptyValue.
@Test
public void testParseBinaryEmptyValue() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.BINARY).setMaxLength(32).build();
assertEquals(ByteBuffer.wrap(EMPTY_STRING.getBytes(Charsets.UTF_8)), FieldParser.parse(EMPTY_STRING, schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseStringEmptyValue.
@Test
public void testParseStringEmptyValue() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.STRING).setMaxLength(32).build();
assertEquals(ByteBuffer.wrap(EMPTY_STRING.getBytes(Charsets.UTF_8)), FieldParser.parse(EMPTY_STRING, schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseULongNegativeInput.
@Test(expected = IllegalArgumentException.class)
public void testParseULongNegativeInput() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.ULONG).build();
FieldParser.parse("-123", schema);
}
Aggregations