Package org.eclipse.wst.wsi.internal.core.profile

Examples of org.eclipse.wst.wsi.internal.core.profile.TestAssertion


              Iterator iassertionResults = assertionResults.values().iterator();

              while (iassertionResults.hasNext())
              {
                AssertionResult ar = (AssertionResult) iassertionResults.next();
                TestAssertion ta = ar.getAssertion();
                // add in to skip errors for assertions that are reporting incorrect problems.
                // This allows us to not report incorrect errors reported in the tools without disabling them
                //              String assertionId = ta.getId();
                //              boolean ignoreAssertion = false;
                //              for(int i = ignoreAssertions.length-1; i >=0;i--)
                //              {
                //                if(ignoreAssertions[i].equalsIgnoreCase(assertionId))
                //                {
                //                  ignoreAssertion = true;
                //                }
                //              }
                //              if(ignoreAssertion)
                //              {
                //                continue;
                //              }
                if (ar.getResult().equalsIgnoreCase(FAILED) &&
                  wsiPreferences.getComplianceLevel().equals(WSITestToolsProperties.STOP_NON_WSI))
                {
                  if (ta.isEnabled())
                  {
                    List errorMessageList = ar.getFailureDetailList();
                    if (errorMessageList != null)
                    {
                      Iterator errorMessages = errorMessageList.iterator();

                      while (errorMessages.hasNext())
                      {
                        FailureDetailImpl fdi = (FailureDetailImpl) errorMessages.next();
                        int lineNumber = 0;
                        int columnNumber = 0;

                        ElementLocation el = fdi.getElementLocation();

                        if (el != null)
                        {
                          lineNumber = el.getLineNumber();
                          columnNumber = el.getColumnNumber();
                        }

                        assertionerrors.add(
                          new AssertionError(ta.getId(), ta.getFailureMessage(), lineNumber, columnNumber));
                      }
                    }
                    // the errorMessageList is null but there is an error so assign it to line 0 for now
                    else
                    {
                      assertionerrors.add(new AssertionError(ta.getId(), ta.getFailureMessage(), 0, 0));
                    }
                  }
                }
                else if (ar.getResult().equalsIgnoreCase(FAILED) &&
                         wsiPreferences.getComplianceLevel().equals(WSITestToolsProperties.WARN_NON_WSI))
                {
                  if (ta.isEnabled())
                  {
                    List errorMessageList = ar.getFailureDetailList();
                    if (errorMessageList != null)
                    {
                      Iterator errorMessages = errorMessageList.iterator();
                      while (errorMessages.hasNext())
                      {
                        FailureDetailImpl fdi = (FailureDetailImpl) errorMessages.next();
                        int lineNumber = 0;
                        int columnNumber = 0;

                        ElementLocation el = fdi.getElementLocation();

                        if (el != null)
                        {
                          lineNumber = el.getLineNumber();
                          columnNumber = el.getColumnNumber();
                        }
                        assertionwarnings.add(
                          new AssertionError(ta.getId(), ta.getFailureMessage(), lineNumber, columnNumber));
                      }
                    }
                    // the errorMessageList is null but there is an error so assign it to line 0 for now
                    else
                    {
                      assertionwarnings.add(new AssertionError(ta.getId(), ta.getFailureMessage(), 0, 0));
                    }
                  }
                }
              }
            }
View Full Code Here


                AssertionResult ar = (AssertionResult) iassertionResults.next();

                if (ar.getResult().equalsIgnoreCase(FAILED) &&
                  wsiPreferences.getComplianceLevel().equals(WSITestToolsEclipseProperties.STOP_NON_WSI))
                {
                  TestAssertion ta = ar.getAssertion();
                  if (ta.isEnabled())
                  {
                    Iterator errorMessages = ar.getFailureDetailList().iterator();
                    while (errorMessages.hasNext())
                    {
                      FailureDetailImpl fdi = (FailureDetailImpl)errorMessages.next();
                      int lineNumber = 0;
                      int columnNumber = 0;
                   
                      ElementLocation el = fdi.getElementLocation();

                      if (el != null)
                      {
                        lineNumber = el.getLineNumber();
                        columnNumber = el.getColumnNumber();
                      }

                      //TODO: get assertion locations in the log file
                      assertionerrors.add(
                        new AssertionError(
                        ta.getId(),
                        "Message ID " + entry.getReferenceID() + ":" + ta.getFailureMessage(),
                        lineNumber,
                        columnNumber));
                    }
                  }
                }
                else if (ar.getResult().equalsIgnoreCase(FAILED) &&
                         wsiPreferences.getComplianceLevel().equals(WSITestToolsEclipseProperties.WARN_NON_WSI))
                {
                  TestAssertion ta = ar.getAssertion();
                  if (ta.isEnabled())
                  {
                    Iterator errorMessages = ar.getFailureDetailList().iterator();
                    while (errorMessages.hasNext())
                    {
                      FailureDetailImpl fdi = (FailureDetailImpl)errorMessages.next();
                      int lineNumber = 0;
                      int columnNumber = 0;
                   
                      ElementLocation el = fdi.getElementLocation();

                      if (el != null)
                      {
                        lineNumber = el.getLineNumber();
                        columnNumber = el.getColumnNumber();
                      }
                      //TODO: get assertion locations in the log file
                      assertionwarnings.add(
                        new AssertionError(
                        ta.getId(),
                        "Message ID " + entry.getReferenceID() + ":" + ta.getFailureMessage(),
                        lineNumber,
                        columnNumber));
                    }
                  }
                }
View Full Code Here

  /* (non-Javadoc)
   * @see org.wsi.test.profile.ProfileAssertions#getTestAssertion(String)
   */
  public TestAssertion getTestAssertion(String id)
  {
    TestAssertion testAssertion = null;

    // Go through the list of artifacts and find the test assertion
    Iterator iterator = artifactList.values().iterator();
    while ((iterator.hasNext()) && (testAssertion == null))
    {
View Full Code Here

    throws WSIException
  {
    long startTime = 0;

    HashMap processList = new HashMap();
    TestAssertion testAssertion = null;
    AssertionProcess assertionProcess;
    AssertionResult assertionResult;

    TreeMap preReqResults;
    PrereqFailedList prereqFailedList;
    String preReqId;

    Class[] paramTypes = new Class[1];
    // If this is an instance of MessageValidator or EnvelopeValidator
    // then use BaseMessageValidator as a param type of assertions constructor
    paramTypes[0] = this instanceof BaseMessageValidator ?
      BaseMessageValidator.class : this.getClass();

    Object[] params = new Object[1];
    params[0] = this;

    // Get entry from context
    Entry entry = entryContext.getEntry();

    // Add entry to artifact
    this.reportArtifact.addEntry(entry);

    // Add entry to report
    if (this instanceof EnvelopeValidator)
       this.reporter.setCurrentEnvelopeEntry(entry);
  else this.reporter.setCurrentEntry(entry);

    try
    {
      // Go through the list of test assertions for the artifact
      Iterator iterator = profileArtifact.getTestAssertionList().iterator();
      while (iterator.hasNext())
      {
        // Get next test assertion
        testAssertion = (TestAssertion) iterator.next();

        // Reset variables
        assertionResult = null;

        // If the test assertion is enabled, then continue
        //        if ((testAssertion.isEnabled()) &&
        //            testAssertion.getEntryTypeName().equals(targetContext.getEntry().getEntryType().getTypeName())) {
        if (testAssertion.isEnabled()
          && isPrimaryEntryTypeMatch(testAssertion, entryContext))
        {
          try
          {
            // Add 1 to assertion processed count
            assertionCount++;

            // If the assertion process hasn't been created yet, then create it
            if ((assertionProcess =
              (AssertionProcess) processList.get(testAssertion.getId()))
              == null)
            {

              // Create a new assertion process
              Class assertionClass =
                Class.forName(classPrefix + testAssertion.getId());

              assertionProcess =
                (AssertionProcess) assertionClass.getConstructor(
                  paramTypes).newInstance(
                  params);

              // Add it to the list
              processList.put(testAssertion.getId(), assertionProcess);
            }

            // Check whether entry is null
            if (entry.getEntryDetail() == null)
            {
              assertionResult =
                createAssertionResult(
                  testAssertion,
                  AssertionResult.RESULT_MISSING_INPUT,
                  (String) null);
            }

            // Check to see if the test assertion should be run
            //if (isNotApplicable(testAssertion, entryContext)) {
            else if (isNotApplicable(testAssertion))
            {
              assertionResult =
                createAssertionResult(
                  testAssertion,
                  AssertionResult.RESULT_NOT_APPLICABLE,
                  (String) null);
            }
            else
            {
              // Processing all the assertion pre-requisites

              preReqResults = null;
              prereqFailedList = null;
              // Get list of pre-reqs for specified assertion
              Iterator i = testAssertion.getPrereqIdList().iterator();
              while (i.hasNext())
              {
                if (preReqResults == null)
                  preReqResults = new TreeMap();
                // Get next id
                preReqId = (String) i.next();
                // Get the prereq result
                AssertionResult preReqResult = reporter.getAssertionResult(preReqId);

                // Adding a result priority value to preReqResults
                preReqResults.put(
                  resultPriority.get(preReqResult.getResult()),
                  preReqResult.getResult());

                // If the prereq failed, then add it to the list
                if (((Integer)resultPriority.get(preReqResult.getResult())).intValue()
                  > MAX_VALID_PRIORITY)
                {
                  // Adding failed prereq ID to the list
                  if (prereqFailedList == null)
                    prereqFailedList = new PrereqFailedListImpl();
                  prereqFailedList.addTestAssertionID(preReqId);
                }
              }

              if (prereqFailedList != null) {
                // Getting the highest pre-requisites' result
                Integer maxRes = (Integer)preReqResults.lastKey();
                String resString = (String)preReqResults.get(maxRes);
                if (resString.equals(AssertionResult.RESULT_FAILED)
                  ||resString.equals(AssertionResult.RESULT_WARNING)) {
                  resString = AssertionResult.RESULT_PREREQ_FAILED;
                }
                // Create assertion result based on pre-requisites which are not passed
                assertionResult = createAssertionResult(testAssertion, resString, prereqFailedList);
              }

              // Pre-requisites are passed, validate current assertion
              else {

                // Reset test assertion
                assertionProcess.reset();

                //  VERBOSE
                if (verboseOption)
                {
                  System.err.println(
                    "  Processing "
                      + testAssertion.getId()
                      + " for entry reference ID ["
                      + entry.getReferenceID()
                      + "] ...");
                  startTime = System.currentTimeMillis();
                }

                // Validate the target
                assertionResult =
                  assertionProcess.validate(testAssertion, entryContext);

                //  VERBOSE
                if (verboseOption)
                {
                  System.err.println(
                    "    Elapsed time: "
                      + (System.currentTimeMillis() - startTime)
                      + "ms");
                }               
              }
            }

            // Add result to the report
            reporter.addAssertionResult(assertionResult);
          }

          catch (ClassNotFoundException cnfe)
          {
            // DEBUG:
            if (testAssertion != null)
            {
              reporter
                .getReport()
                .getReportContext()
                .getAnalyzer()
                .printMessage(
                "WARNING: "
                  + testAssertion.getId()
                  + " is not supported currently.");
            }
          }
        }
      }
View Full Code Here

  public void setAllMissingInput() throws WSIException
  {
    // If profile artifact is set
    if (profileArtifact != null)
    {
      TestAssertion testAssertion;
 
      // Create entry
      Entry entry = this.reporter.getReport().createEntry();
      entry.setArtifactName(this.reportArtifact.getType().getTypeName());
 
      // Add entry to artifact
      this.reportArtifact.addEntry(entry);
 
      // Add entry to report
      this.reporter.setCurrentEntry(entry);
 
      // Go through the list of test assertions for the artifact
      Iterator iterator = profileArtifact.getTestAssertionList().iterator();
      while (iterator.hasNext())
      {
        // Get next test assertion
        testAssertion = (TestAssertion) iterator.next();
 
        // Add missingInput result
        if (testAssertion.isEnabled())
          addMissingInputResult(testAssertion);
      }
 
      // Indicate that we are done with this assertion target
      this.reporter.endCurrentEntry();
View Full Code Here

   * @param entryType an EntryType object.
   * @throws WSIException if there is any problem while processing.
   */
  protected void setMissingInput(EntryType entryType) throws WSIException
  {
    TestAssertion testAssertion;

    // Create entry
    Entry entry = this.reporter.getReport().createEntry();
    entry.setEntryType(entryType);
    entry.setReferenceID("[" + entryType.getTypeName() + "]");

    // Add entry to artifact
    this.reportArtifact.addEntry(entry);

    // Add entry to report
    this.reporter.setCurrentEntry(entry);

    //try {
    // Go through the list of test assertions for the artifact
    Iterator iterator = profileArtifact.getTestAssertionList().iterator();
    while (iterator.hasNext())
    {
      // Get next test assertion
      testAssertion = (TestAssertion) iterator.next();
      if (testAssertion.isEnabled()
        && isPrimaryEntryTypeMatch(testAssertion, entry))
      {
        addMissingInputResult(testAssertion);
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.wsi.internal.core.profile.TestAssertion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.