@Test
  public void testTemplateSetAndTimeSeriesExistenceCheck() throws SQLException {
    try (Connection connection = EnvFactory.getEnv().getConnection();
        Statement statement = connection.createStatement()) {
      // set device template
      statement.execute("SET DEVICE TEMPLATE t1 TO root.sg1.d1");
      // show paths set device template
      String[] expectedResult = new String[] {"root.sg1.d1"};
      Set<String> expectedResultSet = new HashSet<>(Arrays.asList(expectedResult));
      try (ResultSet resultSet = statement.executeQuery("SHOW PATHS SET DEVICE TEMPLATE t1")) {
        String resultRecord;
        while (resultSet.next()) {
          resultRecord = resultSet.getString(1);
          Assert.assertTrue(expectedResultSet.contains(resultRecord));
          expectedResultSet.remove(resultRecord);
        }
      }
      Assert.assertEquals(0, expectedResultSet.size());

      try {
        statement.execute("CREATE TIMESERIES root.sg1.d1.s INT32");
        fail();
      } catch (SQLException e) {
        Assert.assertEquals(
            "516: Cannot create timeseries [root.sg1.d1.s] since device template [t1] already set on path [root.sg1.d1].",
            e.getMessage());
      }

      // unset device template
      statement.execute("UNSET DEVICE TEMPLATE t1 FROM root.sg1.d1");
      try (ResultSet resultSet = statement.executeQuery("SHOW PATHS SET DEVICE TEMPLATE t1")) {
        Assert.assertFalse(resultSet.next());
      }

      statement.execute("CREATE TIMESERIES root.sg1.d1.s INT32");

      try {
        statement.execute("SET DEVICE TEMPLATE t1 TO root.sg1.d1");
      } catch (SQLException e) {
        Assert.assertEquals(
            "516: Cannot set device template [t1] to path [root.sg1.d1] since there's timeseries under path [root.sg1.d1].",
            e.getMessage());
      }

      statement.execute("DELETE TIMESERIES root.sg1.d1.s");

      statement.execute("SET DEVICE TEMPLATE t1 TO root.sg1.d1");
      expectedResult = new String[] {"root.sg1.d1"};
      expectedResultSet = new HashSet<>(Arrays.asList(expectedResult));
      try (ResultSet resultSet = statement.executeQuery("SHOW PATHS SET DEVICE TEMPLATE t1")) {
        String resultRecord;
        while (resultSet.next()) {
          resultRecord = resultSet.getString(1);
          Assert.assertTrue(expectedResultSet.contains(resultRecord));
          expectedResultSet.remove(resultRecord);
        }
      }
      Assert.assertEquals(0, expectedResultSet.size());

      statement.execute("SET DEVICE TEMPLATE t1 TO root.sg1.d2.tmp.m");
      try {
        statement.execute("CREATE TIMESERIES root.sg1.d2 INT32");
      } catch (SQLException e) {
        Assert.assertEquals(
            "516: Cannot create timeseries [root.sg1.d2] since device template [t1] already set on path [root.sg1.d2.tmp.m].",
            e.getMessage());
      }
      try {
        statement.execute("CREATE TIMESERIES root.sg1.d2.s(tmp) INT32");
      } catch (SQLException e) {
        Assert.assertEquals(
            "516: Cannot create timeseries [root.sg1.d2.s] since device template [t1] already set on path [root.sg1.d2.tmp.m].",
            e.getMessage());
      }
      statement.execute("CREATE TIMESERIES root.sg1.d2.s INT32");
    }
  }
Notice that, all test begins with "IoTDB" is integration test. All test which will start the
IoTDB server should be defined as integration test.
integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java