OracleConverterTest.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:blade-jdbc 作者:
@Test
public void testUUIDConverter() throws ConverterException {
    UUID uuid = UUID.randomUUID();
    OracleQuirks orclQuirks = new OracleQuirks();
    Converter<UUID> uuidConverter = new OracleUUIDConverter();

    byte[] rawUuid = (byte[])uuidConverter.toDatabaseParam(uuid);

    UUID reconvertedUuid = uuidConverter.convert(rawUuid);

    assertEquals(uuid, reconvertedUuid);

    // convert bytes to hex and put hyphens into the string to recreate the UUID string representation, just to be
    // sure everything is done correct.
    String hex = new HexBinaryAdapter().marshal(rawUuid);
    String hexUuid = String.format("%s-%s-%s-%s-%s",
            hex.substring(0,8),
            hex.substring(8,12),
            hex.substring(12, 16),
            hex.substring(16, 20),
            hex.substring(20)).toLowerCase();


    assertEquals(uuid.toString(), hexUuid);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号