コード例 #1
0
  @Test(
      dataProvider = "unit-test",
      groups = {"functional"})
  public void semanticErrorTest(final String rootDir, final String adlName) throws Exception {
    initSourcePath(rootDir);
    final ExpectedError expectedError = parserFirstLine(adlName);
    try {
      loader.load(adlName, context);
      if (expectedError != null) fail("Successful loading of erroneous " + adlName + " ADL.");
    } catch (final ADLException e) {
      final Error error = e.getError();
      if (error == null) {
        throw new AssertionFailedError("Loader returned an exception without error.");
      }
      ErrorLocator locator = error.getLocator();
      while (locator instanceof ChainedErrorLocator) {
        locator = ((ChainedErrorLocator) locator).getRootLocator();
      }

      assertNotNull(locator, "Caught ADLException have no locator");
      assertEquals(
          ((Enum<?>) error.getTemplate()).name(),
          expectedError.errorId,
          "Unexpected errorId of caught ADLException");
      assertEquals(
          error.getTemplate().getGroupId(),
          expectedError.groupId,
          "Unexpected groupId of caught ADLException");
      assertEquals(
          locator.getBeginLine(), expectedError.line, "Unexpected line of caught ADLException");
    }
  }
コード例 #2
0
 @Test(
     dataProvider = "unit-test",
     groups = {"functional"})
 public void syntacticErrorTest(final String rootDir, final String adlName) throws Exception {
   initSourcePath(rootDir);
   try {
     loader.load(adlName, context);
   } catch (final ADLException e) {
     final Error error = e.getError();
     assertNotNull(error);
     assertEquals(ADLErrors.PARSE_ERROR, error.getTemplate());
     assertEquals(ADLErrors.GROUP_ID, error.getTemplate().getGroupId());
     return;
   }
   fail("Successful loading of erroneous adl file.");
 }