Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Category(IntegrationTest.class)
- public class InitialStateIntegrationTest {
- private static Connection connection;
- @BeforeClass
- public static void connectToDatabase() throws Exception {
- connection = getConnection();
- }
- @AfterClass
- public static void closeConnection() throws Exception {
- connection.close();
- }
- @Test
- public void database_should_contain_unihan_codepoints() throws Exception {
- List<Integer> codepoints = asList(connection, "select codepoint from hanzi where codepoint in (25165, 30340, 132878)", Integer.class);
- assertThat(codepoints, contains(asInt("才"), asInt("的"), asInt("𠜎")));
- }
- public static <T> List<T> asList(Connection connection, String sql, Class<T> type) throws Exception {
- List<T> result = new ArrayList<>();
- try (ResultSet resultSet = connection.prepareCall(sql).executeQuery()) {
- while (resultSet.next()) {
- result.add(resultSet.getObject(1, type));
- }
- }
- return result;
- }
- public static Integer asInt(String hanzi) {
- return hanzi.codePointAt(0);
- }
- public static String asString(int codePoint) {
- return String.valueOf(Character.toChars(codePoint));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement