use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseULong.
@Test
public void testParseULong() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.ULONG).build();
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x00L)), FieldParser.parse("0", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x7BL)), FieldParser.parse("123", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0xFFFFFFFFFFFFFFFFL)), FieldParser.parse("18446744073709551615", schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseDateTime.
@Test
public void testParseDateTime() throws Exception {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DATETIME).build();
final String expectedParsedDateTime = "1989-05-13 07:32:15";
final List<String> formats = ImmutableList.of(expectedParsedDateTime, "1989.05.13 07:32:15", "1989/05/13 07:32:15", "19890513 073215");
for (final String format : formats) {
assertEquals(ByteBuffer.wrap(expectedParsedDateTime.getBytes()), FieldParser.parse(format, schema));
}
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseEmptyValueNonNullableSchemaLongType.
/**
* Tests a parse request with an empty value and a non-nullable
* {@link ColumnSchema} with a {@link ColumnType} not equal to
* {@link ColumnType#STRING} or {@link ColumnType#BINARY}
*
* @throws ParseException
*/
@Test(expected = IllegalArgumentException.class)
public void testParseEmptyValueNonNullableSchemaLongType() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.LONG).setIsNullable(false).build();
assertNull(FieldParser.parse(EMPTY_STRING, schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseDoubleZeroValue.
@Test
public void testParseDoubleZeroValue() throws ParseException {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.DOUBLE).build();
// Note: These values are all big endian, as per the JVM
assertEquals(ByteBuffer.wrap(Bytes.toBytes(0x00L)), FieldParser.parse("0.0", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0x40283D70A3D70A3DL)), FieldParser.parse("12.12", schema));
assertEquals(ByteBuffer.wrap(Longs.toByteArray(0xC0283D70A3D70A3DL)), FieldParser.parse("-12.12", schema));
}
use of com.nearinfinity.honeycomb.mysql.schema.ColumnSchema in project honeycomb by altamiracorp.
the class FieldParserTest method testParseTime.
@Test
public void testParseTime() throws Exception {
ColumnSchema schema = ColumnSchema.builder(COLUMN_NAME, ColumnType.TIME).build();
final String expectedParsedTime = "07:32:15";
final List<String> formats = ImmutableList.of(expectedParsedTime, "073215");
for (final String format : formats) {
assertEquals(ByteBuffer.wrap(expectedParsedTime.getBytes()), FieldParser.parse(format, schema));
}
}
Aggregations