/** 构造数据源,仅构造一次. */
 protected static void buildDataSourceOnce() throws ClassNotFoundException {
   if (dataSource == null) {
     dataSource = new SimpleDriverDataSource();
     dataSource.setDriverClass(
         (Class<? extends Driver>) Class.forName(propertiesLoader.getProperty("jdbc.driver")));
     dataSource.setUrl(propertiesLoader.getProperty("jdbc.url"));
     dataSource.setUsername(propertiesLoader.getProperty("jdbc.username"));
     dataSource.setPassword(propertiesLoader.getProperty("jdbc.password"));
   }
 }
 /** 载入默认数据. */
 protected static void reloadSampleData() throws Exception {
   String dbType = propertiesLoader.getProperty("db.type", "h2");
   DataFixtures.executeScript(
       dataSource,
       "classpath:data/" + dbType + "/cleanup-data.sql",
       "classpath:data/" + dbType + "/import-data.sql");
 }
  @BeforeClass
  public static void initFunctionalTestEnv() throws Exception {

    baseUrl = propertiesLoader.getProperty("baseUrl");

    Boolean isEmbedded =
        new URL(baseUrl).getHost().equals("localhost")
            && propertiesLoader.getBoolean("embeddedForLocal");

    if (isEmbedded) {
      startJettyOnce();
    }

    buildDataSourceOnce();
    reloadSampleData();
  }