示例#1
0
  /**
   * Test to show that reporting an error about an uninitialized variable when generating templates
   * reports the correct line.
   */
  @Test
  public void testParseTemplate() throws Exception {
    String[] lines = {
      /* 0 */ "template: template",
      /* 1 */ "a: {missingVar}",
      /* 2 */ "a: b",
      /* 3 */ "a: c",
      /* 4 */ "",
      /* 5 */ "template: template2",
    };

    // Test must show "missingVar" missing on line 1.
    // Previous behaviour showed "missingVar" on line 5.

    TemplateFile templateFile = new TemplateFile(resourcePath);
    List<LocalizableMessage> warns = new ArrayList<>();

    try {
      templateFile.parse(lines, warns);
    } catch (InitializationException e) {
      String msg = e.getMessage();
      LocalizableMessage msg_locale = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get("missingVar", 1);
      assertEquals(msg, msg_locale.toString(), msg);
    }
  }
示例#2
0
 /** Test for parsing escaped character in templates. */
 @Test(dataProvider = "validTemplates")
 public void testParsingEscapeCharInTemplate(String testName, String[] lines) throws Exception {
   TemplateFile templateFile = new TemplateFile(resourcePath);
   List<LocalizableMessage> warns = new ArrayList<>();
   templateFile.parse(lines, warns);
   assertTrue(warns.isEmpty(), "Warnings in parsing test template " + testName);
 }