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

Examples of org.eclipse.wst.wsi.internal.core.analyzer.AssertionFailException


      while (accessor != null)
      {
        // If there is no the corresponding wsdl:part element
        // for an accessor, the assertion failed
        if (!i.hasNext())
          throw new AssertionFailException(
            "The part accessor element '" + accessor.getLocalName()
            + "' does not have the corresponding wsdl:part element.");

        // If local name of accessor does not equal to the name of the
        // corresponding wsdl:part element, the assertion failed
        String partName = (String) i.next();
        if (!accessor.getLocalName().equals(partName))
          throw new AssertionFailException(
            "The accessor local name is " + accessor.getLocalName()
            + ", the corresponding part element name is " + partName);

        // Getting the next accessor
        accessor = XMLUtils.getNextSibling(accessor);
View Full Code Here


      Map httpHeaderMap = HTTPUtils.getHttpHeaderTokens(httpHeader, ":");
      String contentType = (String) httpHeaderMap.get("Content-Type".toUpperCase());

      if (contentType == null)
      {
        throw new AssertionFailException(
          "The Content-Type header is not present.");
      }

      contentType = contentType.trim();
      String charset = contentType.substring(
        contentType.indexOf(";") + 1, contentType.length());
      charset = charset.trim();
      if (!charset.startsWith("charset"))
      {
        throw new AssertionFailException(
          "Missing or bad \"charset\" attribute in the Content-Type header: "
          + charset);
      }

      String charsetValue = charset.substring(
        charset.indexOf("=") + 1, charset.length());
      if (charsetValue.startsWith("\""))
      {
        charsetValue = charsetValue.substring(1, charsetValue.length() - 1);
      }

      if (!charsetValue.equalsIgnoreCase("utf-8")
          && !charsetValue.equalsIgnoreCase("utf-16"))
      {
        throw new AssertionFailException("The value of the \"charset\" "
          + "attribute of the Content-Type header is " + contentType);
      }
      // Parse log message
      //gets first string
      int idx = entryContext.getMessageEntry().getMessage().indexOf("<?xml");
      if (idx == -1)
      {
        throw new AssertionPassException();
      }

      int idx2 = entryContext.getMessageEntry().getMessage().indexOf("?>");
      if (idx2 == -1)
      {
        throw new AssertionPassException();
      }

      String xmlDeclaration = entryContext.getMessageEntry().getMessage()
        .substring(idx, idx2 + "?>".length());

      idx = xmlDeclaration.indexOf("encoding");
      if (idx == -1)
      {
        if (charsetValue.equalsIgnoreCase("utf-8"))
        {
            throw new AssertionPassException();
        }
        else
        {
          throw new AssertionFailException("There is no XML declaration and the"
            + " charset value in the Content-Type header is not UTF-8."
            + "\nCharset value in the Content-Type header: " + charsetValue);
        }
      }

      int idxQ = xmlDeclaration.indexOf('\'', idx);
      int idxQQ = xmlDeclaration.indexOf('\"', idx);
      int idxQuote = -1;
      char qouteCh = '\0';
      if (idxQ == -1)
      {
        idxQuote = idxQQ;
        qouteCh = '\"';
      }
      else
      {
        if (idxQQ == -1)
        {
          idxQuote = idxQ;
          qouteCh = '\'';
        }
        else
        {
          if (idxQQ < idxQ)
          {
            idxQuote = idxQQ;
            qouteCh = '\"';
          }
          else
          {
            idxQuote = idxQ;
            qouteCh = '\'';
          }
        }
      }

      if (idxQuote == -1 || qouteCh == '\0')
      {
        throw new AssertionPassException();
      }

      int idxLQoute = xmlDeclaration.indexOf(qouteCh, idxQuote + 1);

      if (idxLQoute == -1)
      {
        throw new AssertionPassException();
      }

      String xmlEncoding =
        xmlDeclaration.substring(idxQuote + 1, idxLQoute);
      if (charsetValue.equalsIgnoreCase(xmlEncoding))
      {
        // If there is a BOM, then check that it is the same as the xmlEncoding
        int bom = 0;
        if ((bom = entryContext.getMessageEntry().getBOM()) != 0)
        {
          if ((bom == WSIConstants.BOM_UTF8
            && !xmlEncoding.equalsIgnoreCase("utf-8"))
            || ((bom == WSIConstants.BOM_UTF16
              && !xmlEncoding.equalsIgnoreCase("utf-16")))
            || ((bom == WSIConstants.BOM_UTF16_BIG_ENDIAN
              && !xmlEncoding.equalsIgnoreCase("utf-16"))))
          {
            throw new AssertionFailException(
              "The BOM and XML declaration do not match.");
          }
        }

        throw new AssertionPassException();
      }
      else
      {
        throw new AssertionFailException("There is an XML declaration, but its "
          + "encoding value does not match the charset value.\n"
          + "Charset value in the Content-Type header: " + charsetValue
          + "\nEncoding in the XML declaration: " + xmlEncoding);
      }
    }
View Full Code Here

                    XMLUtils.SOAP_ELEM_FAULT_DETAIL)))
              {
                // PB: This is checked in 1316 now
                //|| (child.getNamespaceURI() != null)) {
                // Assertion failed
                throw new AssertionFailException(
                  entryContext.getMessageEntry().getMessage());
              }
            }
          }
        }
View Full Code Here

            .equals(String.valueOf(HttpURLConnection.HTTP_INTERNAL_ERROR)))
          {
            //if (!responseCode.equalsIgnoreCase("OK") ||
            //  (!statusCode.equalsIgnoreCase("ServerError"))) {          
            // Assertion failed
            throw new AssertionFailException(httpHeader);
          }
        }
        catch (AssertionFailException e)
        {
          result = AssertionResult.RESULT_FAILED;
View Full Code Here

      // If the envelope contains the xmlns:xml namespace declaration,
      // the assertion failed
      String incorrectElementName = getIncorrectElementName(elem);
      if (incorrectElementName != null)
      {
        throw new AssertionFailException("The name of an element containing "
          + "such namespace declaration is \"" + incorrectElementName + "\".");
      }
    }
    catch (AssertionNotApplicableException anae)
    {
View Full Code Here

        // If there is xsi:nil attribute and its value is "1" or "true"
        // the assertion failed
        if (attr != null
          && (attr.getValue().equals("1") || attr.getValue().equals("true")))
        {
          throw new AssertionFailException("The accessor name is "
            + accessor.getNodeName());
        }
        // Getting the next accessor
        accessor = XMLUtils.getNextSibling(accessor);
      }
View Full Code Here

                        WSIConstants.NS_URI_SOAP,
                        "encodingStyle")
                      != null)
                    {
                      // Assertion failed (ADD highlight the child here ?)
                      throw new AssertionFailException(
                        entryContext.getMessageEntry().getMessage());
                    }
                  }
                }
              }
View Full Code Here

          // If there is a soap:header in the non-root mime:part,
          // the assertion failed
          if (containsInvalidMimePart(inputMultiparts))
          {
            throw new AssertionFailException("The invalid mime:part element "
              + "is in the wsdl:input of the \"" + bindingOperation.getName()
              + "\" binding operation.");
          }
        }

        // If the wsdl:output contains mime:multipartRelated elements
        if (!outputMultiparts.isEmpty())
        {
          multipartsFound = true;

          // If there is a soap:header in the non-root mime:part,
          // the assertion failed
          if (containsInvalidMimePart(outputMultiparts))
          {
            throw new AssertionFailException("The invalid mime:part element "
                + "is in the wsdl:output of the \"" + bindingOperation.getName()
                + "\" binding operation.");
          }
        }
      }
View Full Code Here

         (!contentType.equalsIgnoreCase(WSIConstants.CONTENT_TYPE_MULTIPART) &&
         !contentType.equalsIgnoreCase(WSIConstants.CONTENT_TYPE_TEXT_XML)) ||
         ((contentType.equalsIgnoreCase(WSIConstants.CONTENT_TYPE_MULTIPART) &&
             !isMultiPart)))
      {
        throw new AssertionFailException("The content-type header field  " +
            "value \"" + contentType + "\" is incorrect");
      }
    }
    catch (AssertionNotApplicableException e)
    {
View Full Code Here

      boolean isSchemaValid;
     
      try {
          isSchemaValid = this.validator.messageIsDocLitSchemaValid(entryContext);        
        } catch (Exception e) {
           throw new AssertionFailException();
        }
      // </experiment>
     

      //isSchemaValid = true; // for now, getting this far does it

      if (isSchemaValid)
      {
        throw new AssertionPassException();
      }
      else
      {
        throw new AssertionFailException();
      }

    }
    catch (AssertionPassException e)
    {
View Full Code Here

TOP

Related Classes of org.eclipse.wst.wsi.internal.core.analyzer.AssertionFailException

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.