Compares two string with each other in order to validate plain text.

@param receivedMessagePayload
@param controlMessagePayload
19572
private void validateText(String receivedMessagePayload, String controlMessagePayload) {
        if (!StringUtils.hasText(controlMessagePayload)) {
            log.debug("Skip message payload validation as no control message was defined");
            return;
        } else {
            Assert.isTrue(StringUtils.hasText(receivedMessagePayload), "Validation failed - " +
                    "expected message contents, but received empty message!");
        }

        if (!receivedMessagePayload.equals(controlMessagePayload)) {
            if (StringUtils.trimAllWhitespace(receivedMessagePayload).equals(StringUtils.trimAllWhitespace(controlMessagePayload))) {
                throw new ValidationException("Text values not equal (only whitespaces!), expected '" + controlMessagePayload + "' " +
                        "but was '" + receivedMessagePayload + "'");
            } else {
                throw new ValidationException("Text values not equal, expected '" + controlMessagePayload + "' " +
                        "but was '" + receivedMessagePayload + "'");
            }
        }
    }
1252404
public static <T extends CharSequence> T validateLetter(T value, String errorMsg) throws ValidateException {
		if (false == isLetter(value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
1279909
protected void validateEqualField(String field_1, String field_2, String errorKey, String errorMessage) {
		String value_1 = controller.getPara(field_1);
		String value_2 = controller.getPara(field_2);
		if (value_1 == null || value_2 == null || (! value_1.equals(value_2))) {
			addError(errorKey, errorMessage);
		}
	}
404000
protected void compareText(CharacterData control, CharacterData test,
                               DifferenceListener listener)
        throws DifferenceFoundException {
        compareCharacterData(control, test, listener,
                             control instanceof CDATASection ? CDATA_VALUE : TEXT_VALUE);
    }
1111479
protected void validateMessage(Message receivedMessage, TestContext context) throws IOException {
        // extract variables from received message content
        for (VariableExtractor variableExtractor : variableExtractors) {
            variableExtractor.extractVariables(receivedMessage, context);
        }

        if (validationCallback != null) {
            if (StringUtils.hasText(receivedMessage.getName())) {
                context.getMessageStore().storeMessage(receivedMessage.getName(), receivedMessage);
            } else {
                context.getMessageStore().storeMessage(context.getMessageStore().constructMessageName(this, getOrCreateEndpoint(context)), receivedMessage);
            }

            validationCallback.validate(receivedMessage, context);
        } else {
            Message controlMessage = createControlMessage(context, messageType);
            if (StringUtils.hasText(controlMessage.getName())) {
                context.getMessageStore().storeMessage(controlMessage.getName(), receivedMessage);
            } else {
                context.getMessageStore().storeMessage(context.getMessageStore().constructMessageName(this, getOrCreateEndpoint(context)), receivedMessage);
            }

            if (!CollectionUtils.isEmpty(validators)) {
                for (MessageValidator<? extends ValidationContext> messageValidator : validators) {
                    messageValidator.validateMessage(receivedMessage, controlMessage, context, validationContexts);
                }

                if (validators.parallelStream()
                                .map(Object::getClass)
                                .noneMatch(DefaultMessageHeaderValidator.class::isAssignableFrom)) {
                    MessageValidator defaultMessageHeaderValidator = context.getMessageValidatorRegistry().getDefaultMessageHeaderValidator();
                    if (defaultMessageHeaderValidator != null) {
                        defaultMessageHeaderValidator.validateMessage(receivedMessage, controlMessage, context, validationContexts);
                    }
                }
            } else {
                List<MessageValidator<? extends ValidationContext>> validators =
                        context.getMessageValidatorRegistry().findMessageValidators(messageType, receivedMessage);

                if (validators.isEmpty()) {
                    if (controlMessage.getPayload() instanceof String &&
                            StringUtils.hasText(controlMessage.getPayload(String.class))) {
                        throw new CitrusRuntimeException(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts));
                    } else if (validationContexts.stream().anyMatch(item -> JsonPathMessageValidationContext.class.isAssignableFrom(item.getClass())
                            || XpathMessageValidationContext.class.isAssignableFrom(item.getClass())
                            || ScriptValidationContext.class.isAssignableFrom(item.getClass()))) {
                        throw new CitrusRuntimeException(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts));
                    } else {
                        log.warn(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts));
                    }
                }

                for (MessageValidator<? extends ValidationContext> messageValidator : validators) {
                    messageValidator.validateMessage(receivedMessage, controlMessage, context, validationContexts);
                }
            }
        }
    }
65180
public static void check(boolean isValid, String message, Object... args) {
    if (!isValid) {
      String[] argStrings = new String[args.length];
      for (int i = 0; i < args.length; i += 1) {
        argStrings[i] = String.valueOf(args[i]);
      }
      throw new ValidationException(
          String.format(String.valueOf(message), (Object[]) argStrings));
    }
  }
272296
public void sendMessage(View view) {
    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
        .hideSoftInputFromWindow(hostEdit.getWindowToken(), 0);
    sendButton.setEnabled(false);
    resultText.setText("");
    new GrpcTask(this, cache)
        .execute(
            hostEdit.getText().toString(),
            messageEdit.getText().toString(),
            portEdit.getText().toString(),
            getCheckBox.isChecked(),
            noCacheCheckBox.isChecked(),
            onlyIfCachedCheckBox.isChecked());
  }
340192
private static void receiveMessageResultMd5Check(ReceiveMessageResult receiveMessageResult) {
        if (receiveMessageResult.getMessages() != null) {
            for (Message messageReceived : receiveMessageResult.getMessages()) {
                String messageBody = messageReceived.getBody();
                String bodyMd5Returned = messageReceived.getMD5OfBody();
                String clientSideBodyMd5 = calculateMessageBodyMd5(messageBody);
                if (!clientSideBodyMd5.equals(bodyMd5Returned)) {
                    throw new AmazonClientException(String.format(MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_BODY,
                            clientSideBodyMd5, bodyMd5Returned));
                }

                Map<String, MessageAttributeValue> messageAttr = messageReceived.getMessageAttributes();
                if (messageAttr != null && !messageAttr.isEmpty()) {
                    String attrMd5Returned = messageReceived.getMD5OfMessageAttributes();
                    String clientSideAttrMd5 = calculateMessageAttributesMd5(messageAttr);
                    if (!clientSideAttrMd5.equals(attrMd5Returned)) {
                        throw new AmazonClientException(String.format(MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_ATTRIBUTES,
                                clientSideAttrMd5, attrMd5Returned));
                    }
                }
            }
        }
    }
1257688
@Test
    public void managed_send_and_receive_is_working() throws JMSException {
        testSender1.send("MANAGED");

        try {
            managed.await(1, TimeUnit.SECONDS);

            Assertions.assertThat(textManaged).isEqualTo("MANAGED");
        } catch (InterruptedException e) {
            fail("Thread interrupted");
        }
    }
1239228
@Nonnull
  protected static EValidity validateMessage (@Nonnull final String sMsg)
  {
    ValueEnforcer.notNull (sMsg, "Msg");

    return validateMessage (sMsg.toCharArray ());
  }
421357
public T validate(String path, Object controlValue) {
        if (JsonPathMessageValidationContext.isJsonPathExpression(path)) {
            getJsonPathValidationContext().getJsonPathExpressions().put(path, controlValue);
        } else {
            getXPathValidationContext().getXpathExpressions().put(path, controlValue);
        }

        return self;
    }
54835
public boolean evaluateMessage(
    Selector selectorTree,
    Selector discriminatorTree,
    SIBusMessage msg)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "evaluateMessage", new Object[] { selectorTree, msg });

    boolean ret = false;
    Object result = null;
    boolean discriminatorMatches = true; //assume it does match

    // Use the dummy evaluation cache, we don't need one hear as we're not
    // searching the MatchSpace
    EvalCache cache = EvalCache.DUMMY;

    try
    {
      Evaluator evaluator = Matching.getEvaluator();
      //    See if we need to process a discriminator expression first
      if (discriminatorTree != null)
      {
        discriminatorMatches = false; //can no longer assume it does match
        String discriminator = msg.getDiscriminator();

        MatchSpaceKey msk = new DiscriminatorMatchSpaceKey(discriminator);
        // Evaluate message against selector tree
        result = evaluator.eval(discriminatorTree, msk, cache, null, false);
        if (result != null && ((Boolean) result).booleanValue())
        {
          discriminatorMatches = true;
        }
      }

      // Evaluate message against selector tree
      if (selectorTree != null && discriminatorMatches)
      {
        result =
          evaluator.eval(selectorTree, (MatchSpaceKey) msg, cache, null, false);
      }

    }
    catch (BadMessageFormatMatchingException qex)
    {
      FFDCFilter.processException(
        qex,
        "com.ibm.ws.sib.processor.matching.MessageProcessorMatching.evaluateMessage",
        "1:1824:1.117.1.11",
        this);

      SibTr.exception(tc, qex);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");

      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1834:1.117.1.11",
          qex });

      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1844:1.117.1.11",
            qex },
          null),
        qex);
    }

    // The result of expression evaluation can be either a
    // boolean, or not, which is interpreted as false.
    if (result instanceof Boolean)
    {
      // This turns a BooleanValue into a boolean
      // it will return false for unknown which is what we want.
      ret = ((Boolean) result).booleanValue();
    }
    else if (result == null)
    {
      ret = false;
    }
    else
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", "SICoreException");
      // For now, I'll throw a core exception, but in due course this (or something with a
      // better name) will be externalised in the Core API.
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1870:1.117.1.11" });

      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1877:1.117.1.11" },
          null));
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", Boolean.valueOf(ret));
    return ret;
  }
450489
public static Validation<String> contains(String c, String msg) {
        return notEmpty().and(SimpleValidation.from((s) -> s.contains(c), format(msg, c)));
    }
1298073
@Nonnull
  public static EValidity validateMessage (@Nullable final String sMsg)
  {
    final int nLen = StringHelper.getLength (sMsg);
    if (nLen >= 7 && nLen <= 8)
      if (AbstractUPCEAN.validateMessage (sMsg).isValid ())
        return EValidity.VALID;
    return EValidity.INVALID;
  }
671289
public static void validateNotEmptyAndNotEqual(Object t1, Object t2, String errorMsg) throws ValidateException {
		validateNotEmpty(t1, errorMsg);
		validateNotEqual(t1, t2, errorMsg);
	}
1043543
@FFDCIgnore(IOException.class)
    public boolean processWithWholeMessageHandler(DATA_TYPE dt) throws CharacterCodingException {
        if ((appTextMessageHandler != null) && (dt == DATA_TYPE.TEXT)) {

            Class<?> clazz = appTextMessageHandlerClass;

            if (clazz.equals(String.class)) {
                String message = convertMessageToString();

                // call the application's MessageHandler.onMessage(<String> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<String>) appTextMessageHandler).onMessage(message);
                return true;
            }

            else if (clazz.equals(Reader.class)) {
                Reader message = convertMessageToReader();

                // call the application's MessageHandler.onMessage(<Reader> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<Reader>) appTextMessageHandler).onMessage(message);
                return true;
            }
        }

        if ((appBinaryMessageHandler != null) && (dt == DATA_TYPE.BINARY)) {
            Class<?> clazz = appBinaryMessageHandlerClass;

            if (clazz.equals(ByteBuffer.class)) {
                ByteBuffer message = convertMessageToByteBuffer();

                // call the application's MessageHandler.onMessage(<ByteBuffer> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<ByteBuffer>) appBinaryMessageHandler).onMessage(message);
                return true;
            }

            else if (clazz.equals(byte[].class)) {
                byte[] message = convertPayloadToByteArray();

                // call the application's MessageHandler.onMessage(<byte[]> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<byte[]>) appBinaryMessageHandler).onMessage(message);
                return true;
            }

            else if (clazz.equals(InputStream.class)) {
                InputStream message = convertMessageToInputStream();

                // call the application's MessageHandler.onMessage(<InputStream> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<InputStream>) appBinaryMessageHandler).onMessage(message);
                return true;
            }
        }
        if ((appPongMessageHandler != null) && (dt == DATA_TYPE.PONG)) {
            Class<?> clazz = appPongMessageHandlerClass;
            if (clazz.equals(PongMessage.class)) {
                ByteBuffer message = convertMessageToByteBuffer(true);
                PongMessage msg = new PongMessageImpl(message);

                // call the application's MessageHandler.onMessage(<Reader> x) method
                connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                ((MessageHandler.Whole<PongMessage>) appPongMessageHandler).onMessage(msg);
                return true;
            }
        }

        // if the generic type for this MessageHandler.Whole equals one of the configured decoder generic types, then use that decoder
        // clazz: is the generic class that the MessageHandler.Whole specifies
        // then go through the decoders that also have been specified with this same (or assignable) generic class.
        // in other words, let me see if I have any decoders<X> to use with this  MessageHandler<X>.
        if ((appTextMessageHandler != null) && (dt == DATA_TYPE.TEXT)) {

            Class<?> clazz = appTextMessageHandlerClass;
            ArrayList<Decoder> dcList = findDecoderFromAppDecoderType(clazz, dt);

            if (dcList != null && dcList.size() > 0) {
                Decoder firstDecoder = dcList.get(0);
                if (firstDecoder instanceof Decoder.Text) {
                    String message = convertMessageToString();
                    //user might have declared multiple decoders of same type for this endpoint. In this case, check
                    //decoder list and find the first decoder in the list which has implemented willDecode(..) to return
                    //'true'
                    Decoder dc = findWillDecodeDecoder(dcList, message);
                    if (dc != null) {
                        try {
                            dc.init(endpointConfig);
                            Object appObj = ((Decoder.Text) dc).decode(message);
                            connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                            ((MessageHandler.Whole) appTextMessageHandler).onMessage(appObj);
                            return true;
                        } catch (DecodeException e) {
                            connLink.callOnError(e, true);
                            return true;
                        }
                    }
                } else if (firstDecoder instanceof Decoder.TextStream) {
                    Reader message = convertMessageToReader();
                    try {
                        //WebSocket API does not support willDecode() method for Decoder.BinaryStream type. Hence, even if
                        //user has declared multiple same type of decoder, just pick the first one in the list and use it.

                        firstDecoder.init(endpointConfig);
                        Object appObj = ((Decoder.TextStream) firstDecoder).decode(message);
                        connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                        ((MessageHandler.Whole) appTextMessageHandler).onMessage(appObj);
                        return true;
                    } catch (DecodeException e) {
                        connLink.callOnError(e, true);
                        return true;
                    } catch (IOException e) {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "IOException calling onMessage on class " + clazz.getName() + " while decoding Decoder.TextStream type "
                                         + ((Decoder.TextStream) firstDecoder).toString()
                                         + "Exception is: " + e.getMessage());
                        }
                        //Since IOexception has occurred, there is no point in attempting to read message TextStream to convert into
                        //message string to pass as first param to form DecodeException. Hence passing just a error message
                        //"IOException decoding BinaryStream" as first parameter here
                        String msg = Tr.formatMessage(tc,
                                                      "decoder.ioexception",
                                                      appTextMessageHandler.getClass().getName(), firstDecoder.getClass().getName());

                        DecodeException de = new DecodeException(msg, e.getMessage(), e);
                        connLink.callOnError(de, true);
                        return true;
                    }
                }
            }
        }

        if ((appBinaryMessageHandler != null) && (dt == DATA_TYPE.BINARY)) {
            Class<?> clazz = appBinaryMessageHandlerClass;
            ArrayList<Decoder> dcList = findDecoderFromAppDecoderType(clazz, dt);

            if (dcList != null && dcList.size() > 0) {
                Decoder firstDecoder = dcList.get(0);
                if (firstDecoder instanceof Decoder.Binary) {
                    // Decode the given bytes into an object of type T
                    ByteBuffer message = convertMessageToByteBuffer();
                    //user might have declared multiple decoders of same type for this endpoint. In this case, check
                    //decoder list and find the first decoder in the list which has implemented willDecode(..) to return
                    //'true'
                    Decoder dc = findWillDecodeDecoder(dcList, message);
                    if (dc != null) {
                        try {
                            dc.init(endpointConfig);
                            Object appObj = ((Decoder.Binary) dc).decode(message);
                            connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                            ((MessageHandler.Whole) appBinaryMessageHandler).onMessage(appObj);
                            return true;
                        } catch (DecodeException e) {
                            connLink.callOnError(e, true);
                            return true;
                        }
                    } else {
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "willDecode returned false");
                        }
                        return true;
                    }
                } else if (firstDecoder instanceof Decoder.BinaryStream) {
                    InputStream message = convertMessageToInputStream();
                    try {
                        //WebSocket API does not support willDecode() method for Decoder.BinaryStream type. Hence, even if
                        //user has declared multiple same type of decoder, just pick the first one in the list and use it.
                        firstDecoder.init(endpointConfig);
                        Object appObj = ((Decoder.BinaryStream) firstDecoder).decode(message);
                        connLink.setReadLinkStatus(READ_LINK_STATUS.ON_READ_THREAD);
                        ((MessageHandler.Whole) appBinaryMessageHandler).onMessage(appObj);
                        return true;
                    } catch (DecodeException e) {
                        connLink.callOnError(e, true);
                        return true;
                    } catch (IOException e) {
                        // do NOT allow instrumented FFDC to be used here
                        if (tc.isDebugEnabled()) {
                            Tr.debug(tc, "IOException calling onMessage on class " + clazz.getName() + " while decoding Decoder.BinaryStream type "
                                         + ((Decoder.BinaryStream) firstDecoder).toString()
                                         + "Exception is: " + e.getMessage());
                        }
                        //Since IOexception has occurred, there is no point in attempting to read message BinaryStream to convert into
                        //message string to pass as first param to form DecodeException. Hence passing just a error message
                        //"IOException decoding BinaryStream" as first parameter here
                        String msg = Tr.formatMessage(tc,
                                                      "decoder.ioexception",
                                                      appBinaryMessageHandler.getClass().getName(), ((Decoder.BinaryStream) firstDecoder).getClass().getName());
                        DecodeException de = new DecodeException(msg, e.getMessage(), e);
                        connLink.callOnError(de, true);
                        return true;
                    }
                }
            }
        }
        return false;
    }
753196
void recivedMessage(final ByteBuffer message, final SynchronizeFXTomcatConnection sender) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Received a message in thread: id: " + Thread.currentThread().getName() + ", name: "
                    + Thread.currentThread().getName());
        }
        List<Command> commands;
        try {
            commands = serializer.deserialize(message.array());
        } catch (final SynchronizeFXException e) {
            try {
                sender.getWsOutbound().close(0, null);
            } catch (final IOException e1) {
                callback.onClientConnectionError(sender, new SynchronizeFXException(e1));
            }
            callback.onClientConnectionError(sender, e);
            return;
        }
        synchronized (callback) {
            callback.recive(commands, sender);
        }
    }