### Question:
MetadataClient implements AutoCloseable { public DatabaseValue getBasicDatabaseInfo(String databaseName) { DatabaseValue databaseValue = null; String sql = String.format("select DB_ID, `DESC`, NAME, DB_TYPE from DBS where name ='%s'", databaseName); LOGGER.debug("getBasicDatabaseInfo sql is {}", sql); try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { if (resultSet != null && resultSet.next()) { databaseValue = new DatabaseValue(); databaseValue.setDbId(resultSet.getLong("DB_ID")); databaseValue.setName(resultSet.getString("NAME")); databaseValue.setDbType(resultSet.getString("DB_TYPE")); databaseValue.setDesc(resultSet.getString("DESC")); } } return databaseValue; } catch (SQLException ex) { throw new RuntimeException(ex); } } MetadataClient(); DatabaseValue getBasicDatabaseInfoById(Long dbId); List<DatabaseValue> getDataBaseList(); DatabaseValue getBasicDatabaseInfo(String databaseName); Long insertBasicDatabaseInfo(DatabaseValue value); void insertDatabaseSchema(List<DatabaseParamValue> values); List<DatabaseParamValue> getDatabaseSchema(Long databaseId); Long insertTableSchema(TableValue value); List<TableValue> getTableSchema(String tableName); List<TableValue> getTableSchemaByTbl(String tableName); void insertFieldsSchema(List<ColumnValue> columns); void deleteFieldsSchema(Long tbId); List<ColumnValue> getFieldsSchema(Long tableId); void setAutoCommit(boolean flag); void commit(); void rollback(); void close(); String getLastInsertSql();  }### Answer:
@Test public void testQueryBasicDatabaseInfo() { DatabaseValue value = client.getBasicDatabaseInfo("student-profile"); Assert.assertEquals("es", value.getDbType()); Assert.assertEquals("student-profile", value.getName()); }
@Test public void testAccessEmbeddedDatabaseByMultipleClient() { try (MetadataClient otherClient = new MetadataClient()) { DatabaseValue first = otherClient.getBasicDatabaseInfo("student-profile"); DatabaseValue second = client.getBasicDatabaseInfo("student-profile"); Assert.assertNotNull(first); Assert.assertNotNull(second); Assert.assertEquals(first, second); } catch (SQLException ex) { Assert.assertTrue(false); } }
@Test public void testAccessEmbeddedDatabaseConcurrently() throws InterruptedException { BlockingQueue<DatabaseValue> queue = new ArrayBlockingQueue<>(10); for (int i = 0; i < 10; i++) { Thread thread = new Thread(() -> { try (MetadataClient client = new MetadataClient()) { DatabaseValue value = client.getBasicDatabaseInfo("student-profile"); queue.offer(value); } catch (SQLException ex) { ex.printStackTrace(); } }); thread.start(); thread.join(); } DatabaseValue value = client.getBasicDatabaseInfo("student-profile"); DatabaseValue[] values = new DatabaseValue[10]; Arrays.fill(values, value); Assert.assertArrayEquals(values, queue.toArray()); }