Пример #1
0
  /**
   * @param sspHandler
   * @param el
   * @return
   */
  private TestSolution testLink(SSPHandler sspHandler, Element el) {
    ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
    TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();

    // reset the service for each tested element. We use the collection
    // handled by the service to feed the local collection of remarks
    prs.resetService();

    // check the pertinence of the link
    getDecidableElementsChecker().check(sspHandler, elHandler, tsHandler);

    // get the processRemark for eventually override it with the result
    // returned by the title pertinence checker
    ProcessRemark remark = prs.getRemarkList().iterator().next();

    // we check the pertinence of the title if and only if the result is
    // failed. This checker may eventually change the result from failed
    // to nmi but the inverse is impossible.
    if (tsHandler.getTestSolution().equals(TestSolution.FAILED)) {

      // check the pertinence of the title of the link
      String linkText =
          getDecidableElementsChecker().getTextElementBuilder().buildTextFromElement(el);

      if (testTitleAttributeLink(sspHandler, el, linkText).equals(TestSolution.NEED_MORE_INFO)) {
        // override result (evidence element have already been collected
        remark.setIssue(TestSolution.NEED_MORE_INFO);
        remark.setMessageCode(CHECK_LINK_PERTINENCE_MSG);
        remarks.add(remark);
        return TestSolution.NEED_MORE_INFO;
      }
    }

    remarks.add(remark);

    return tsHandler.getTestSolution();
  }
Пример #2
0
  @Override
  protected void setProcess() {
    // ----------------------------------------------------------------------
    // ---------------------------2Failed-01---------------------------------
    // ----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("AW22.Test.8.9.1-2Failed-01");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    SourceCodeRemark sourceCodeRemark =
        ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(TestSolution.FAILED, sourceCodeRemark.getIssue());
    assertEquals(RemarkMessageStore.LINK_WITHOUT_TARGET_MSG, sourceCodeRemark.getMessageCode());
    assertEquals(HtmlElementStore.A_ELEMENT, sourceCodeRemark.getTarget());
    assertNotNull(sourceCodeRemark.getSnippet());
    assertNull(sourceCodeRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------2Failed-02---------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-2Failed-02");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    sourceCodeRemark =
        ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(TestSolution.FAILED, sourceCodeRemark.getIssue());
    assertEquals(RemarkMessageStore.LINK_WITHOUT_TARGET_MSG, sourceCodeRemark.getMessageCode());
    assertEquals(HtmlElementStore.A_ELEMENT, sourceCodeRemark.getTarget());
    assertNotNull(sourceCodeRemark.getSnippet());
    assertNull(sourceCodeRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------2Failed-03---------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-2Failed-03");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    sourceCodeRemark =
        ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(TestSolution.FAILED, sourceCodeRemark.getIssue());
    assertEquals(
        RemarkMessageStore.FIELDSET_NOT_WITHIN_FORM_MSG, sourceCodeRemark.getMessageCode());
    assertEquals(HtmlElementStore.FIELDSET_ELEMENT, sourceCodeRemark.getTarget());
    assertNotNull(sourceCodeRemark.getSnippet());
    assertNull(sourceCodeRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------2Failed-04---------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-2Failed-04");
    // check number of elements in the page
    assertEquals(13, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    sourceCodeRemark =
        ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(TestSolution.FAILED, sourceCodeRemark.getIssue());
    assertEquals(
        RemarkMessageStore.FIELDSET_NOT_WITHIN_FORM_MSG, sourceCodeRemark.getMessageCode());
    assertEquals(HtmlElementStore.FIELDSET_ELEMENT, sourceCodeRemark.getTarget());
    assertNotNull(sourceCodeRemark.getSnippet());
    assertNull(sourceCodeRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-03---------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-01");
    // check number of elements in the page
    assertEquals(11, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    ProcessRemark processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-02------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-02");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-03------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-03");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-04------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-04");
    // check number of elements in the page
    assertEquals(12, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-05------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-05");
    // check number of elements in the page
    assertEquals(13, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-06------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-06");
    // check number of elements in the page
    assertEquals(13, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ---------------------------3NMI-07------------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("AW22.Test.8.9.1-3NMI-07");
    // check number of elements in the page
    assertEquals(13, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = processResult.getRemarkSet().iterator().next();
    assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
    assertEquals(
        getMessageKey(RemarkMessageStore.NO_PATTERN_DETECTED_MSG), processRemark.getMessageCode());
    assertNull(processRemark.getElementList());
  }
Пример #3
0
  @Override
  protected void setProcess() {
    // ----------------------------------------------------------------------
    // ------------------------------1Passed-01------------------------------
    // ----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("Rgaa22.Test.9.3-1Passed-01");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-02------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-02");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-03------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-03");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-04------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-04");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-05------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-05");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-06------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-06");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-07------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-07");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-08------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-08");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-09------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-09");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-10------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-10");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-11------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-11");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-12------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-12");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-13------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-13");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-14------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-14");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------1Passed-15------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-1Passed-15");
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());

    // ----------------------------------------------------------------------
    // ------------------------------2Failed-01------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-2Failed-01");
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    ProcessRemark processRemark =
        ((ProcessRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.INVALID_DOCTYPE_MSG, processRemark.getMessageCode());
    // check number of evidence elements and their value
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ------------------------------2Failed-02------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-2Failed-02");
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark =
        ((ProcessRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.INVALID_DOCTYPE_MSG, processRemark.getMessageCode());
    // check number of evidence elements and their value
    assertNull(processRemark.getElementList());

    // ----------------------------------------------------------------------
    // ------------------------------4NA-01------------------------------
    // ----------------------------------------------------------------------
    processResult = processPageTest("Rgaa22.Test.9.3-4NA-01");
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check test has no remark
    assertNull(processResult.getRemarkSet());
    // check number of elements in the page (no counter management here,
    // we test the presence of one tag in the page)
    assertEquals(0, processResult.getElementCounter());
  }