idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
27,900 | public String getMessageId ( ) { Object messageId = getHeader ( JmsMessageHeaders . MESSAGE_ID ) ; if ( messageId != null ) { return messageId . toString ( ) ; } return null ; } | Gets the JMS messageId header . | 51 | 9 |
27,901 | public String getCorrelationId ( ) { Object correlationId = getHeader ( JmsMessageHeaders . CORRELATION_ID ) ; if ( correlationId != null ) { return correlationId . toString ( ) ; } return null ; } | Gets the JMS correlationId header . | 51 | 9 |
27,902 | public Destination getReplyTo ( ) { Object replyTo = getHeader ( JmsMessageHeaders . REPLY_TO ) ; if ( replyTo != null ) { return ( Destination ) replyTo ; } return null ; } | Gets the JMS reply to header . | 47 | 9 |
27,903 | public String getRedelivered ( ) { Object redelivered = getHeader ( JmsMessageHeaders . REDELIVERED ) ; if ( redelivered != null ) { return redelivered . toString ( ) ; } return null ; } | Gets the JMS redelivered header . | 53 | 10 |
27,904 | public String getType ( ) { Object type = getHeader ( JmsMessageHeaders . TYPE ) ; if ( type != null ) { return type . toString ( ) ; } return null ; } | Gets the JMS type header . | 42 | 8 |
27,905 | private void performSchemaValidation ( Message receivedMessage , JsonMessageValidationContext validationContext ) { log . debug ( "Starting Json schema validation ..." ) ; ProcessingReport report = jsonSchemaValidation . validate ( receivedMessage , schemaRepositories , validationContext , applicationContext ) ; if ( ! report . isSuccess ( ) ) { log . error ( "Failed to validate Json schema for message:\n" + receivedMessage . getPayload ( String . class ) ) ; throw new ValidationException ( constructErrorMessage ( report ) ) ; } log . info ( "Json schema validation successful: All values OK" ) ; } | Performs the schema validation for the given message under consideration of the given validation context | 136 | 16 |
27,906 | private String constructErrorMessage ( ProcessingReport report ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( "Json validation failed: " ) ; report . forEach ( processingMessage -> stringBuilder . append ( processingMessage . getMessage ( ) ) ) ; return stringBuilder . toString ( ) ; } | Constructs the error message of a failed validation based on the processing report passed from com . github . fge . jsonschema . core . report | 69 | 31 |
27,907 | public static boolean isSpringInternalHeader ( String headerName ) { // "springintegration_" makes Citrus work with Spring Integration 1.x release if ( headerName . startsWith ( "springintegration_" ) ) { return true ; } else if ( headerName . equals ( MessageHeaders . ID ) ) { return true ; } else if ( headerName . equals ( MessageHeaders . TIMESTAMP ) ) { return true ; } else if ( headerName . equals ( MessageHeaders . REPLY_CHANNEL ) ) { return true ; } else if ( headerName . equals ( MessageHeaders . ERROR_CHANNEL ) ) { return true ; } else if ( headerName . equals ( MessageHeaders . CONTENT_TYPE ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . PRIORITY ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . CORRELATION_ID ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . ROUTING_SLIP ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . DUPLICATE_MESSAGE ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . SEQUENCE_NUMBER ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . SEQUENCE_SIZE ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . SEQUENCE_DETAILS ) ) { return true ; } else if ( headerName . equals ( IntegrationMessageHeaderAccessor . EXPIRATION_DATE ) ) { return true ; } else if ( headerName . startsWith ( "jms_" ) ) { return true ; } return false ; } | Check if given header name belongs to Spring Integration internal headers . | 405 | 12 |
27,908 | public static SoapAttachment parseAttachment ( Element attachmentElement ) { SoapAttachment soapAttachment = new SoapAttachment ( ) ; if ( attachmentElement . hasAttribute ( "content-id" ) ) { soapAttachment . setContentId ( attachmentElement . getAttribute ( "content-id" ) ) ; } if ( attachmentElement . hasAttribute ( "content-type" ) ) { soapAttachment . setContentType ( attachmentElement . getAttribute ( "content-type" ) ) ; } if ( attachmentElement . hasAttribute ( "charset-name" ) ) { soapAttachment . setCharsetName ( attachmentElement . getAttribute ( "charset-name" ) ) ; } if ( attachmentElement . hasAttribute ( "mtom-inline" ) ) { soapAttachment . setMtomInline ( Boolean . parseBoolean ( attachmentElement . getAttribute ( "mtom-inline" ) ) ) ; } if ( attachmentElement . hasAttribute ( "encoding-type" ) ) { soapAttachment . setEncodingType ( attachmentElement . getAttribute ( "encoding-type" ) ) ; } Element attachmentDataElement = DomUtils . getChildElementByTagName ( attachmentElement , "data" ) ; if ( attachmentDataElement != null ) { soapAttachment . setContent ( DomUtils . getTextValue ( attachmentDataElement ) ) ; } Element attachmentResourceElement = DomUtils . getChildElementByTagName ( attachmentElement , "resource" ) ; if ( attachmentResourceElement != null ) { soapAttachment . setContentResourcePath ( attachmentResourceElement . getAttribute ( "file" ) ) ; } return soapAttachment ; } | Parse the attachment element with all children and attributes . | 363 | 11 |
27,909 | public ObjectName createObjectName ( ) { try { if ( StringUtils . hasText ( objectName ) ) { return new ObjectName ( objectDomain + ":" + objectName ) ; } if ( type != null ) { if ( StringUtils . hasText ( objectDomain ) ) { return new ObjectName ( objectDomain , "type" , type . getSimpleName ( ) ) ; } return new ObjectName ( type . getPackage ( ) . getName ( ) , "type" , type . getSimpleName ( ) ) ; } return new ObjectName ( objectDomain , "name" , name ) ; } catch ( NullPointerException | MalformedObjectNameException e ) { throw new CitrusRuntimeException ( "Failed to create proper object name for managed bean" , e ) ; } } | Constructs proper object name either from given domain and name property or by evaluating the mbean type class information . | 171 | 22 |
27,910 | public MBeanInfo createMBeanInfo ( ) { if ( type != null ) { return new MBeanInfo ( type . getName ( ) , description , getAttributeInfo ( ) , getConstructorInfo ( ) , getOperationInfo ( ) , getNotificationInfo ( ) ) ; } else { return new MBeanInfo ( name , description , getAttributeInfo ( ) , getConstructorInfo ( ) , getOperationInfo ( ) , getNotificationInfo ( ) ) ; } } | Create managed bean info with all constructors operations notifications and attributes . | 106 | 13 |
27,911 | private MBeanOperationInfo [ ] getOperationInfo ( ) { final List < MBeanOperationInfo > infoList = new ArrayList <> ( ) ; if ( type != null ) { ReflectionUtils . doWithMethods ( type , new ReflectionUtils . MethodCallback ( ) { @ Override public void doWith ( Method method ) throws IllegalArgumentException , IllegalAccessException { infoList . add ( new MBeanOperationInfo ( OPERATION_DESCRIPTION , method ) ) ; } } , new ReflectionUtils . MethodFilter ( ) { @ Override public boolean matches ( Method method ) { return method . getDeclaringClass ( ) . equals ( type ) && ! method . getName ( ) . startsWith ( "set" ) && ! method . getName ( ) . startsWith ( "get" ) && ! method . getName ( ) . startsWith ( "is" ) && ! method . getName ( ) . startsWith ( "$jacoco" ) ; // Fix for code coverage } } ) ; } else { for ( ManagedBeanInvocation . Operation operation : operations ) { List < MBeanParameterInfo > parameterInfo = new ArrayList <> ( ) ; int i = 1 ; for ( OperationParam parameter : operation . getParameter ( ) . getParameter ( ) ) { parameterInfo . add ( new MBeanParameterInfo ( "p" + i ++ , parameter . getType ( ) , "Parameter #" + i ) ) ; } infoList . add ( new MBeanOperationInfo ( operation . getName ( ) , OPERATION_DESCRIPTION , parameterInfo . toArray ( new MBeanParameterInfo [ operation . getParameter ( ) . getParameter ( ) . size ( ) ] ) , operation . getReturnType ( ) , MBeanOperationInfo . UNKNOWN ) ) ; } } return infoList . toArray ( new MBeanOperationInfo [ infoList . size ( ) ] ) ; } | Create this managed bean operations info . | 418 | 7 |
27,912 | private MBeanConstructorInfo [ ] getConstructorInfo ( ) { final List < MBeanConstructorInfo > infoList = new ArrayList <> ( ) ; if ( type != null ) { for ( Constructor constructor : type . getConstructors ( ) ) { infoList . add ( new MBeanConstructorInfo ( constructor . toGenericString ( ) , constructor ) ) ; } } return infoList . toArray ( new MBeanConstructorInfo [ infoList . size ( ) ] ) ; } | Create this managed bean constructor info . | 111 | 7 |
27,913 | private MBeanAttributeInfo [ ] getAttributeInfo ( ) { final List < MBeanAttributeInfo > infoList = new ArrayList <> ( ) ; if ( type != null ) { final List < String > attributes = new ArrayList <> ( ) ; if ( type . isInterface ( ) ) { ReflectionUtils . doWithMethods ( type , new ReflectionUtils . MethodCallback ( ) { @ Override public void doWith ( Method method ) throws IllegalArgumentException , IllegalAccessException { String attributeName ; if ( method . getName ( ) . startsWith ( "get" ) ) { attributeName = method . getName ( ) . substring ( 3 ) ; } else if ( method . getName ( ) . startsWith ( "is" ) ) { attributeName = method . getName ( ) . substring ( 2 ) ; } else { attributeName = method . getName ( ) ; } if ( ! attributes . contains ( attributeName ) ) { infoList . add ( new MBeanAttributeInfo ( attributeName , method . getReturnType ( ) . getName ( ) , ATTRIBUTE_DESCRIPTION , true , true , method . getName ( ) . startsWith ( "is" ) ) ) ; attributes . add ( attributeName ) ; } } } , new ReflectionUtils . MethodFilter ( ) { @ Override public boolean matches ( Method method ) { return method . getDeclaringClass ( ) . equals ( type ) && ( method . getName ( ) . startsWith ( "get" ) || method . getName ( ) . startsWith ( "is" ) ) ; } } ) ; } else { ReflectionUtils . doWithFields ( type , new ReflectionUtils . FieldCallback ( ) { @ Override public void doWith ( Field field ) throws IllegalArgumentException , IllegalAccessException { infoList . add ( new MBeanAttributeInfo ( field . getName ( ) , field . getType ( ) . getName ( ) , ATTRIBUTE_DESCRIPTION , true , true , field . getType ( ) . equals ( Boolean . class ) ) ) ; } } , new ReflectionUtils . FieldFilter ( ) { @ Override public boolean matches ( Field field ) { return ! Modifier . isStatic ( field . getModifiers ( ) ) && ! Modifier . isFinal ( field . getModifiers ( ) ) ; } } ) ; } } else { int i = 1 ; for ( ManagedBeanInvocation . Attribute attribute : attributes ) { infoList . add ( new MBeanAttributeInfo ( attribute . getName ( ) , attribute . getType ( ) , ATTRIBUTE_DESCRIPTION , true , true , attribute . getType ( ) . equals ( Boolean . class . getName ( ) ) ) ) ; } } return infoList . toArray ( new MBeanAttributeInfo [ infoList . size ( ) ] ) ; } | Create this managed bean attributes info . | 629 | 7 |
27,914 | public void finish ( ) throws IOException { if ( printWriter != null ) { printWriter . close ( ) ; } if ( outputStream != null ) { outputStream . close ( ) ; } } | Finish response stream by closing . | 42 | 6 |
27,915 | public void postRegisterUrlHandlers ( Map < String , Object > wsHandlers ) { registerHandlers ( wsHandlers ) ; for ( Object handler : wsHandlers . values ( ) ) { if ( handler instanceof Lifecycle ) { ( ( Lifecycle ) handler ) . start ( ) ; } } } | Workaround for registering the WebSocket request handlers after the spring context has been initialised . | 69 | 18 |
27,916 | public AbstractMessageContentBuilder constructMessageBuilder ( Element messageElement ) { AbstractMessageContentBuilder messageBuilder = null ; if ( messageElement != null ) { messageBuilder = parsePayloadTemplateBuilder ( messageElement ) ; if ( messageBuilder == null ) { messageBuilder = parseScriptBuilder ( messageElement ) ; } } if ( messageBuilder == null ) { messageBuilder = new PayloadTemplateMessageBuilder ( ) ; } if ( messageElement != null && messageElement . hasAttribute ( "name" ) ) { messageBuilder . setMessageName ( messageElement . getAttribute ( "name" ) ) ; } return messageBuilder ; } | Static parse method taking care of basic message element parsing . | 130 | 11 |
27,917 | private PayloadTemplateMessageBuilder parsePayloadTemplateBuilder ( Element messageElement ) { PayloadTemplateMessageBuilder messageBuilder ; messageBuilder = parsePayloadElement ( messageElement ) ; Element xmlDataElement = DomUtils . getChildElementByTagName ( messageElement , "data" ) ; if ( xmlDataElement != null ) { messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . setPayloadData ( DomUtils . getTextValue ( xmlDataElement ) . trim ( ) ) ; } Element xmlResourceElement = DomUtils . getChildElementByTagName ( messageElement , "resource" ) ; if ( xmlResourceElement != null ) { messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . setPayloadResourcePath ( xmlResourceElement . getAttribute ( "file" ) ) ; if ( xmlResourceElement . hasAttribute ( "charset" ) ) { messageBuilder . setPayloadResourceCharset ( xmlResourceElement . getAttribute ( "charset" ) ) ; } } if ( messageBuilder != null ) { Map < String , String > overwriteXpath = new HashMap <> ( ) ; Map < String , String > overwriteJsonPath = new HashMap <> ( ) ; List < ? > messageValueElements = DomUtils . getChildElementsByTagName ( messageElement , "element" ) ; for ( Iterator < ? > iter = messageValueElements . iterator ( ) ; iter . hasNext ( ) ; ) { Element messageValue = ( Element ) iter . next ( ) ; String pathExpression = messageValue . getAttribute ( "path" ) ; if ( JsonPathMessageValidationContext . isJsonPathExpression ( pathExpression ) ) { overwriteJsonPath . put ( pathExpression , messageValue . getAttribute ( "value" ) ) ; } else { overwriteXpath . put ( pathExpression , messageValue . getAttribute ( "value" ) ) ; } } if ( ! overwriteXpath . isEmpty ( ) ) { XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor ( overwriteXpath ) ; messageBuilder . add ( interceptor ) ; } if ( ! overwriteJsonPath . isEmpty ( ) ) { JsonPathMessageConstructionInterceptor interceptor = new JsonPathMessageConstructionInterceptor ( overwriteJsonPath ) ; messageBuilder . add ( interceptor ) ; } } return messageBuilder ; } | Parses message payload template information given in message element . | 524 | 12 |
27,918 | protected void parseHeaderElements ( Element actionElement , AbstractMessageContentBuilder messageBuilder , List < ValidationContext > validationContexts ) { Element headerElement = DomUtils . getChildElementByTagName ( actionElement , "header" ) ; Map < String , Object > messageHeaders = new LinkedHashMap <> ( ) ; if ( headerElement != null ) { List < ? > elements = DomUtils . getChildElementsByTagName ( headerElement , "element" ) ; for ( Iterator < ? > iter = elements . iterator ( ) ; iter . hasNext ( ) ; ) { Element headerValue = ( Element ) iter . next ( ) ; String name = headerValue . getAttribute ( "name" ) ; String value = headerValue . getAttribute ( "value" ) ; String type = headerValue . getAttribute ( "type" ) ; if ( StringUtils . hasText ( type ) ) { value = MessageHeaderType . createTypedValue ( type , value ) ; } messageHeaders . put ( name , value ) ; } List < Element > headerDataElements = DomUtils . getChildElementsByTagName ( headerElement , "data" ) ; for ( Element headerDataElement : headerDataElements ) { messageBuilder . getHeaderData ( ) . add ( DomUtils . getTextValue ( headerDataElement ) . trim ( ) ) ; } List < Element > headerResourceElements = DomUtils . getChildElementsByTagName ( headerElement , "resource" ) ; for ( Element headerResourceElement : headerResourceElements ) { String charset = headerResourceElement . getAttribute ( "charset" ) ; messageBuilder . getHeaderResources ( ) . add ( headerResourceElement . getAttribute ( "file" ) + ( StringUtils . hasText ( charset ) ? FileUtils . FILE_PATH_CHARSET_PARAMETER + charset : "" ) ) ; } // parse fragment with xs-any element List < Element > headerFragmentElements = DomUtils . getChildElementsByTagName ( headerElement , "fragment" ) ; for ( Element headerFragmentElement : headerFragmentElements ) { List < Element > fragment = DomUtils . getChildElements ( headerFragmentElement ) ; if ( ! CollectionUtils . isEmpty ( fragment ) ) { messageBuilder . getHeaderData ( ) . add ( PayloadElementParser . parseMessagePayload ( fragment . get ( 0 ) ) ) ; } } messageBuilder . setMessageHeaders ( messageHeaders ) ; if ( headerElement . hasAttribute ( "ignore-case" ) ) { boolean ignoreCase = Boolean . valueOf ( headerElement . getAttribute ( "ignore-case" ) ) ; validationContexts . stream ( ) . filter ( context -> context instanceof HeaderValidationContext ) . map ( context -> ( HeaderValidationContext ) context ) . forEach ( context -> context . setHeaderNameIgnoreCase ( ignoreCase ) ) ; } } } | Parse message header elements in action and add headers to message content builder . | 650 | 15 |
27,919 | protected void parseExtractHeaderElements ( Element element , List < VariableExtractor > variableExtractors ) { Element extractElement = DomUtils . getChildElementByTagName ( element , "extract" ) ; Map < String , String > extractHeaderValues = new HashMap <> ( ) ; if ( extractElement != null ) { List < ? > headerValueElements = DomUtils . getChildElementsByTagName ( extractElement , "header" ) ; for ( Iterator < ? > iter = headerValueElements . iterator ( ) ; iter . hasNext ( ) ; ) { Element headerValue = ( Element ) iter . next ( ) ; extractHeaderValues . put ( headerValue . getAttribute ( "name" ) , headerValue . getAttribute ( "variable" ) ) ; } MessageHeaderVariableExtractor headerVariableExtractor = new MessageHeaderVariableExtractor ( ) ; headerVariableExtractor . setHeaderMappings ( extractHeaderValues ) ; if ( ! CollectionUtils . isEmpty ( extractHeaderValues ) ) { variableExtractors . add ( headerVariableExtractor ) ; } } } | Parses header extract information . | 238 | 7 |
27,920 | public String build ( ) { StringBuilder scriptBuilder = new StringBuilder ( ) ; StringBuilder scriptBody = new StringBuilder ( ) ; String importStmt = "import " ; try { if ( scriptCode . contains ( importStmt ) ) { BufferedReader reader = new BufferedReader ( new StringReader ( scriptCode ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . trim ( ) . startsWith ( importStmt ) ) { scriptBuilder . append ( line ) ; scriptBuilder . append ( "\n" ) ; } else { scriptBody . append ( ( scriptBody . length ( ) == 0 ? "" : "\n" ) ) ; scriptBody . append ( line ) ; } } } else { scriptBody . append ( scriptCode ) ; } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to construct script from template" , e ) ; } scriptBuilder . append ( scriptHead ) ; scriptBuilder . append ( scriptBody . toString ( ) ) ; scriptBuilder . append ( scriptTail ) ; return scriptBuilder . toString ( ) ; } | Builds the final script . | 246 | 6 |
27,921 | public static TemplateBasedScriptBuilder fromTemplateResource ( Resource scriptTemplateResource ) { try { return new TemplateBasedScriptBuilder ( FileUtils . readToString ( scriptTemplateResource . getInputStream ( ) ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Error loading script template from file resource" , e ) ; } } | Static construction method returning a fully qualified instance of this builder . | 75 | 12 |
27,922 | private ResponseEntity < ? > handleRequestInternal ( HttpMethod method , HttpEntity < ? > requestEntity ) { HttpMessage request = endpointConfiguration . getMessageConverter ( ) . convertInbound ( requestEntity , endpointConfiguration , null ) ; HttpServletRequest servletRequest = ( ( ServletRequestAttributes ) RequestContextHolder . getRequestAttributes ( ) ) . getRequest ( ) ; UrlPathHelper pathHelper = new UrlPathHelper ( ) ; Enumeration allHeaders = servletRequest . getHeaderNames ( ) ; for ( String headerName : CollectionUtils . toArray ( allHeaders , new String [ ] { } ) ) { if ( request . getHeader ( headerName ) == null ) { String headerValue = servletRequest . getHeader ( headerName ) ; request . header ( headerName , headerValue != null ? headerValue : "" ) ; } } if ( endpointConfiguration . isHandleCookies ( ) ) { request . setCookies ( servletRequest . getCookies ( ) ) ; } if ( endpointConfiguration . isHandleAttributeHeaders ( ) ) { Enumeration < String > attributeNames = servletRequest . getAttributeNames ( ) ; while ( attributeNames . hasMoreElements ( ) ) { String attributeName = attributeNames . nextElement ( ) ; Object attribute = servletRequest . getAttribute ( attributeName ) ; request . setHeader ( attributeName , attribute ) ; } } request . path ( pathHelper . getRequestUri ( servletRequest ) ) . uri ( pathHelper . getRequestUri ( servletRequest ) ) . contextPath ( pathHelper . getContextPath ( servletRequest ) ) . queryParams ( Optional . ofNullable ( pathHelper . getOriginatingQueryString ( servletRequest ) ) . map ( queryString -> queryString . replaceAll ( "&" , "," ) ) . orElse ( "" ) ) . version ( servletRequest . getProtocol ( ) ) . method ( method ) ; Message response = endpointAdapter . handleMessage ( request ) ; ResponseEntity < ? > responseEntity ; if ( response == null ) { responseEntity = new ResponseEntity <> ( HttpStatus . valueOf ( endpointConfiguration . getDefaultStatusCode ( ) ) ) ; } else { HttpMessage httpResponse ; if ( response instanceof HttpMessage ) { httpResponse = ( HttpMessage ) response ; } else { httpResponse = new HttpMessage ( response ) ; } if ( httpResponse . getStatusCode ( ) == null ) { httpResponse . status ( HttpStatus . valueOf ( endpointConfiguration . getDefaultStatusCode ( ) ) ) ; } responseEntity = ( ResponseEntity < ? > ) endpointConfiguration . getMessageConverter ( ) . convertOutbound ( httpResponse , endpointConfiguration , null ) ; if ( endpointConfiguration . isHandleCookies ( ) && httpResponse . getCookies ( ) != null ) { HttpServletResponse servletResponse = ( ( ServletRequestAttributes ) RequestContextHolder . getRequestAttributes ( ) ) . getResponse ( ) ; for ( Cookie cookie : httpResponse . getCookies ( ) ) { servletResponse . addCookie ( cookie ) ; } } } responseCache . add ( responseEntity ) ; return responseEntity ; } | Handles requests with endpoint adapter implementation . Previously sets Http request method as header parameter . | 703 | 18 |
27,923 | @ Override public Message buildMessageContent ( final TestContext context , final String messageType , final MessageDirection direction ) { final Object payload = buildMessagePayload ( context , messageType ) ; try { Message message = new DefaultMessage ( payload , buildMessageHeaders ( context , messageType ) ) ; message . setName ( messageName ) ; if ( payload != null ) { for ( final MessageConstructionInterceptor interceptor : context . getGlobalMessageConstructionInterceptors ( ) . getMessageConstructionInterceptors ( ) ) { if ( direction . equals ( MessageDirection . UNBOUND ) || interceptor . getDirection ( ) . equals ( MessageDirection . UNBOUND ) || direction . equals ( interceptor . getDirection ( ) ) ) { message = interceptor . interceptMessageConstruction ( message , messageType , context ) ; } } if ( dataDictionary != null ) { message = dataDictionary . interceptMessageConstruction ( message , messageType , context ) ; } for ( final MessageConstructionInterceptor interceptor : messageInterceptors ) { if ( direction . equals ( MessageDirection . UNBOUND ) || interceptor . getDirection ( ) . equals ( MessageDirection . UNBOUND ) || direction . equals ( interceptor . getDirection ( ) ) ) { message = interceptor . interceptMessageConstruction ( message , messageType , context ) ; } } } message . getHeaderData ( ) . addAll ( buildMessageHeaderData ( context ) ) ; return message ; } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { throw new CitrusRuntimeException ( "Failed to build message content" , e ) ; } } | Constructs the control message with headers and payload coming from subclass implementation . | 359 | 14 |
27,924 | public Map < String , Object > buildMessageHeaders ( final TestContext context , final String messageType ) { try { final Map < String , Object > headers = context . resolveDynamicValuesInMap ( messageHeaders ) ; headers . put ( MessageHeaders . MESSAGE_TYPE , messageType ) ; for ( final Map . Entry < String , Object > entry : headers . entrySet ( ) ) { final String value = entry . getValue ( ) . toString ( ) ; if ( MessageHeaderType . isTyped ( value ) ) { final MessageHeaderType type = MessageHeaderType . fromTypedValue ( value ) ; final Constructor < ? > constr = type . getHeaderClass ( ) . getConstructor ( String . class ) ; entry . setValue ( constr . newInstance ( MessageHeaderType . removeTypeDefinition ( value ) ) ) ; } } MessageHeaderUtils . checkHeaderTypes ( headers ) ; return headers ; } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { throw new CitrusRuntimeException ( "Failed to build message content" , e ) ; } } | Build message headers . | 243 | 4 |
27,925 | public List < String > buildMessageHeaderData ( final TestContext context ) { final List < String > headerDataList = new ArrayList <> ( ) ; for ( final String headerResourcePath : headerResources ) { try { headerDataList . add ( context . replaceDynamicContentInString ( FileUtils . readToString ( FileUtils . getFileResource ( headerResourcePath , context ) , FileUtils . getCharset ( headerResourcePath ) ) ) ) ; } catch ( final IOException e ) { throw new CitrusRuntimeException ( "Failed to read message header data resource" , e ) ; } } for ( final String data : headerData ) { headerDataList . add ( context . replaceDynamicContentInString ( data . trim ( ) ) ) ; } return headerDataList ; } | Build message header data . | 172 | 5 |
27,926 | public SoapServerFaultResponseActionBuilder attachment ( String contentId , String contentType , String content ) { SoapAttachment attachment = new SoapAttachment ( ) ; attachment . setContentId ( contentId ) ; attachment . setContentType ( contentType ) ; attachment . setContent ( content ) ; getAction ( ) . getAttachments ( ) . add ( attachment ) ; return this ; } | Sets the attachment with string content . | 85 | 8 |
27,927 | public SoapServerFaultResponseActionBuilder charset ( String charsetName ) { if ( ! getAction ( ) . getAttachments ( ) . isEmpty ( ) ) { getAction ( ) . getAttachments ( ) . get ( getAction ( ) . getAttachments ( ) . size ( ) - 1 ) . setCharsetName ( charsetName ) ; } return this ; } | Sets the charset name for this send action builder s attachment . | 85 | 14 |
27,928 | public SoapServerFaultResponseActionBuilder faultDetailResource ( Resource resource , Charset charset ) { try { getAction ( ) . getFaultDetails ( ) . add ( FileUtils . readToString ( resource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read fault detail resource" , e ) ; } return this ; } | Adds a fault detail from file resource . | 88 | 8 |
27,929 | public static CitrusConfiguration from ( Properties extensionProperties ) { CitrusConfiguration configuration = new CitrusConfiguration ( extensionProperties ) ; configuration . setCitrusVersion ( getProperty ( extensionProperties , "citrusVersion" ) ) ; if ( extensionProperties . containsKey ( "autoPackage" ) ) { configuration . setAutoPackage ( Boolean . valueOf ( getProperty ( extensionProperties , "autoPackage" ) ) ) ; } if ( extensionProperties . containsKey ( "suiteName" ) ) { configuration . setSuiteName ( getProperty ( extensionProperties , "suiteName" ) ) ; } if ( extensionProperties . containsKey ( "configurationClass" ) ) { String configurationClass = getProperty ( extensionProperties , "configurationClass" ) ; try { Class < ? > configType = Class . forName ( configurationClass ) ; if ( CitrusSpringConfig . class . isAssignableFrom ( configType ) ) { configuration . setConfigurationClass ( ( Class < ? extends CitrusSpringConfig > ) configType ) ; } else { log . warn ( String . format ( "Found invalid Citrus configuration class: %s, must be a subclass of %s" , configurationClass , CitrusSpringConfig . class ) ) ; } } catch ( ClassNotFoundException e ) { log . warn ( String . format ( "Unable to access Citrus configuration class: %s" , configurationClass ) , e ) ; } } log . debug ( String . format ( "Using Citrus configuration:%n%s" , configuration . toString ( ) ) ) ; return configuration ; } | Constructs Citrus configuration instance from given property set . | 346 | 11 |
27,930 | private static String getProperty ( Properties extensionProperties , String propertyName ) { if ( extensionProperties . containsKey ( propertyName ) ) { Object value = extensionProperties . get ( propertyName ) ; if ( value != null ) { return value . toString ( ) ; } } return null ; } | Try to read property from property set . When not set or null value return null else return String representation of value object . | 64 | 24 |
27,931 | private static Properties readPropertiesFromDescriptor ( ArquillianDescriptor descriptor ) { for ( ExtensionDef extension : descriptor . getExtensions ( ) ) { if ( CitrusExtensionConstants . CITRUS_EXTENSION_QUALIFIER . equals ( extension . getExtensionName ( ) ) ) { Properties properties = new Properties ( ) ; properties . putAll ( extension . getExtensionProperties ( ) ) ; return properties ; } } return new Properties ( ) ; } | Find Citrus extension configuration in descriptor and read properties . | 107 | 11 |
27,932 | protected Resource loadSchemaResources ( ) { PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver ( ) ; for ( String location : schemas ) { try { Resource [ ] findings = resourcePatternResolver . getResources ( location ) ; for ( Resource finding : findings ) { if ( finding . getFilename ( ) . endsWith ( ".xsd" ) || finding . getFilename ( ) . endsWith ( ".wsdl" ) ) { schemaResources . add ( finding ) ; } } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read schema resources for location: " + location , e ) ; } } return schemaResources . get ( 0 ) ; } | Loads all schema resource files from schema locations . | 156 | 10 |
27,933 | public boolean isLast ( ) { Object isLast = getHeader ( WebSocketMessageHeaders . WEB_SOCKET_IS_LAST ) ; if ( isLast != null ) { if ( isLast instanceof String ) { return Boolean . valueOf ( isLast . toString ( ) ) ; } else { return ( Boolean ) isLast ; } } return true ; } | Gets the isLast flag from message headers . | 81 | 10 |
27,934 | private OperationResult getOperationResult ( ) { if ( operationResult == null ) { this . operationResult = ( OperationResult ) marshaller . unmarshal ( new StringSource ( getPayload ( String . class ) ) ) ; } return operationResult ; } | Gets the operation result if any or tries to unmarshal String payload representation to an operation result model . | 55 | 22 |
27,935 | private Operation getOperation ( ) { if ( operation == null ) { this . operation = ( Operation ) marshaller . unmarshal ( new StringSource ( getPayload ( String . class ) ) ) ; } return operation ; } | Gets the operation if any or tries to unmarshal String payload representation to an operation model . | 49 | 20 |
27,936 | String getPayloadAsString ( Message < ? > message ) { if ( message . getPayload ( ) instanceof com . consol . citrus . message . Message ) { return ( ( com . consol . citrus . message . Message ) message . getPayload ( ) ) . getPayload ( String . class ) ; } else { return message . getPayload ( ) . toString ( ) ; } } | Reads message payload as String either from message object directly or from nested Citrus message representation . | 88 | 19 |
27,937 | protected boolean evaluate ( String value ) { if ( ValidationMatcherUtils . isValidationMatcherExpression ( matchingValue ) ) { try { ValidationMatcherUtils . resolveValidationMatcher ( selectKey , value , matchingValue , context ) ; return true ; } catch ( ValidationException e ) { return false ; } } else { return value . equals ( matchingValue ) ; } } | Evaluates given value to match this selectors matching condition . Automatically supports validation matcher expressions . | 86 | 21 |
27,938 | protected FtpMessage createDir ( CommandType ftpCommand ) { try { sftp . mkdir ( ftpCommand . getArguments ( ) ) ; return FtpMessage . result ( FTPReply . PATHNAME_CREATED , "Pathname created" , true ) ; } catch ( SftpException e ) { throw new CitrusRuntimeException ( "Failed to execute ftp command" , e ) ; } } | Execute mkDir command and create new directory . | 93 | 10 |
27,939 | public LSParser createLSParser ( ) { LSParser parser = domImpl . createLSParser ( DOMImplementationLS . MODE_SYNCHRONOUS , null ) ; configureParser ( parser ) ; return parser ; } | Creates basic LSParser instance and sets common properties and configuration parameters . | 51 | 15 |
27,940 | protected void configureParser ( LSParser parser ) { for ( Map . Entry < String , Object > setting : parseSettings . entrySet ( ) ) { setParserConfigParameter ( parser , setting . getKey ( ) , setting . getValue ( ) ) ; } } | Set parser configuration based on this configurers settings . | 56 | 10 |
27,941 | protected void configureSerializer ( LSSerializer serializer ) { for ( Map . Entry < String , Object > setting : serializeSettings . entrySet ( ) ) { setSerializerConfigParameter ( serializer , setting . getKey ( ) , setting . getValue ( ) ) ; } } | Set serializer configuration based on this configurers settings . | 62 | 11 |
27,942 | private void setDefaultParseSettings ( ) { if ( ! parseSettings . containsKey ( CDATA_SECTIONS ) ) { parseSettings . put ( CDATA_SECTIONS , true ) ; } if ( ! parseSettings . containsKey ( SPLIT_CDATA_SECTIONS ) ) { parseSettings . put ( SPLIT_CDATA_SECTIONS , false ) ; } if ( ! parseSettings . containsKey ( VALIDATE_IF_SCHEMA ) ) { parseSettings . put ( VALIDATE_IF_SCHEMA , true ) ; } if ( ! parseSettings . containsKey ( RESOURCE_RESOLVER ) ) { parseSettings . put ( RESOURCE_RESOLVER , createLSResourceResolver ( ) ) ; } if ( ! parseSettings . containsKey ( ELEMENT_CONTENT_WHITESPACE ) ) { parseSettings . put ( ELEMENT_CONTENT_WHITESPACE , false ) ; } } | Sets the default parse settings . | 209 | 7 |
27,943 | private void setDefaultSerializeSettings ( ) { if ( ! serializeSettings . containsKey ( ELEMENT_CONTENT_WHITESPACE ) ) { serializeSettings . put ( ELEMENT_CONTENT_WHITESPACE , true ) ; } if ( ! serializeSettings . containsKey ( SPLIT_CDATA_SECTIONS ) ) { serializeSettings . put ( SPLIT_CDATA_SECTIONS , false ) ; } if ( ! serializeSettings . containsKey ( FORMAT_PRETTY_PRINT ) ) { serializeSettings . put ( FORMAT_PRETTY_PRINT , true ) ; } if ( ! serializeSettings . containsKey ( XML_DECLARATION ) ) { serializeSettings . put ( XML_DECLARATION , true ) ; } } | Sets the default serialize settings . | 177 | 8 |
27,944 | public void addPart ( AttachmentPart part ) { if ( attachments == null ) { attachments = new BodyPart . Attachments ( ) ; } this . attachments . add ( part ) ; } | Adds new attachment part . | 41 | 5 |
27,945 | public static String getBinding ( String resourcePath ) { if ( resourcePath . contains ( "/" ) ) { return resourcePath . substring ( resourcePath . indexOf ( ' ' ) + 1 ) ; } return null ; } | Extract service binding information from endpoint resource path . This is usualle the path after the port specification . | 49 | 21 |
27,946 | public static String getHost ( String resourcePath ) { String hostSpec ; if ( resourcePath . contains ( ":" ) ) { hostSpec = resourcePath . split ( ":" ) [ 0 ] ; } else { hostSpec = resourcePath ; } if ( hostSpec . contains ( "/" ) ) { hostSpec = hostSpec . substring ( 0 , hostSpec . indexOf ( ' ' ) ) ; } return hostSpec ; } | Extract host name from resource path . | 92 | 8 |
27,947 | public static SoapAttachment from ( Attachment attachment ) { SoapAttachment soapAttachment = new SoapAttachment ( ) ; String contentId = attachment . getContentId ( ) ; if ( contentId . startsWith ( "<" ) && contentId . endsWith ( ">" ) ) { contentId = contentId . substring ( 1 , contentId . length ( ) - 1 ) ; } soapAttachment . setContentId ( contentId ) ; soapAttachment . setContentType ( attachment . getContentType ( ) ) ; if ( attachment . getContentType ( ) . startsWith ( "text" ) ) { try { soapAttachment . setContent ( FileUtils . readToString ( attachment . getInputStream ( ) ) . trim ( ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read SOAP attachment content" , e ) ; } } else { // Binary content soapAttachment . setDataHandler ( attachment . getDataHandler ( ) ) ; } soapAttachment . setCharsetName ( Citrus . CITRUS_FILE_ENCODING ) ; return soapAttachment ; } | Static construction method from Spring mime attachment . | 250 | 9 |
27,948 | public String getContent ( ) { if ( content != null ) { return context != null ? context . replaceDynamicContentInString ( content ) : content ; } else if ( StringUtils . hasText ( getContentResourcePath ( ) ) && getContentType ( ) . startsWith ( "text" ) ) { try { String fileContent = FileUtils . readToString ( new PathMatchingResourcePatternResolver ( ) . getResource ( getContentResourcePath ( ) ) . getInputStream ( ) , Charset . forName ( charsetName ) ) ; return context != null ? context . replaceDynamicContentInString ( fileContent ) : fileContent ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read SOAP attachment file resource" , e ) ; } } else { try { byte [ ] binaryData = FileCopyUtils . copyToByteArray ( getDataHandler ( ) . getInputStream ( ) ) ; if ( encodingType . equals ( SoapAttachment . ENCODING_BASE64_BINARY ) ) { return Base64 . encodeBase64String ( binaryData ) ; } else if ( encodingType . equals ( SoapAttachment . ENCODING_HEX_BINARY ) ) { return Hex . encodeHexString ( binaryData ) . toUpperCase ( ) ; } else { throw new CitrusRuntimeException ( String . format ( "Unsupported encoding type '%s' for SOAP attachment - choose one of %s or %s" , encodingType , SoapAttachment . ENCODING_BASE64_BINARY , SoapAttachment . ENCODING_HEX_BINARY ) ) ; } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read SOAP attachment data input stream" , e ) ; } } } | Get the content body . | 406 | 5 |
27,949 | public String getContentResourcePath ( ) { if ( contentResourcePath != null && context != null ) { return context . replaceDynamicContentInString ( contentResourcePath ) ; } else { return contentResourcePath ; } } | Get the content file resource path . | 46 | 7 |
27,950 | public void extractVariables ( Message message , TestContext context ) { if ( CollectionUtils . isEmpty ( headerMappings ) ) { return ; } for ( Entry < String , String > entry : headerMappings . entrySet ( ) ) { String headerElementName = entry . getKey ( ) ; String targetVariableName = entry . getValue ( ) ; if ( message . getHeader ( headerElementName ) == null ) { throw new UnknownElementException ( "Could not find header element " + headerElementName + " in received header" ) ; } context . setVariable ( targetVariableName , message . getHeader ( headerElementName ) . toString ( ) ) ; } } | Reads header information and saves new test variables . | 144 | 10 |
27,951 | public < T extends KubernetesCommand > T command ( T command ) { action . setCommand ( command ) ; return command ; } | Use a kubernetes command . | 29 | 8 |
27,952 | private Message receive ( TestContext context ) { Endpoint messageEndpoint = getOrCreateEndpoint ( context ) ; return receiveTimeout > 0 ? messageEndpoint . createConsumer ( ) . receive ( context , receiveTimeout ) : messageEndpoint . createConsumer ( ) . receive ( context , messageEndpoint . getEndpointConfiguration ( ) . getTimeout ( ) ) ; } | Receives the message with respective message receiver implementation . | 78 | 11 |
27,953 | private Message receiveSelected ( TestContext context , String selectorString ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Setting message selector: '" + selectorString + "'" ) ; } Endpoint messageEndpoint = getOrCreateEndpoint ( context ) ; Consumer consumer = messageEndpoint . createConsumer ( ) ; if ( consumer instanceof SelectiveConsumer ) { if ( receiveTimeout > 0 ) { return ( ( SelectiveConsumer ) messageEndpoint . createConsumer ( ) ) . receive ( context . replaceDynamicContentInString ( selectorString ) , context , receiveTimeout ) ; } else { return ( ( SelectiveConsumer ) messageEndpoint . createConsumer ( ) ) . receive ( context . replaceDynamicContentInString ( selectorString ) , context , messageEndpoint . getEndpointConfiguration ( ) . getTimeout ( ) ) ; } } else { log . warn ( String . format ( "Unable to receive selective with consumer implementation: '%s'" , consumer . getClass ( ) ) ) ; return receive ( context ) ; } } | Receives the message with the respective message receiver implementation also using a message selector . | 225 | 17 |
27,954 | protected Message createControlMessage ( TestContext context , String messageType ) { if ( dataDictionary != null ) { messageBuilder . setDataDictionary ( dataDictionary ) ; } return messageBuilder . buildMessageContent ( context , messageType , MessageDirection . INBOUND ) ; } | Create control message that is expected . | 61 | 7 |
27,955 | public ReceiveMessageAction setValidators ( List < MessageValidator < ? extends ValidationContext > > validators ) { this . validators . clear ( ) ; this . validators . addAll ( validators ) ; return this ; } | Set list of message validators . | 51 | 7 |
27,956 | private DockerCommand createCommand ( Class < ? extends DockerCommand > commandType ) { try { return commandType . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new BeanCreationException ( "Failed to create Docker command of type: " + commandType , e ) ; } } | Creates new Docker command instance of given type . | 68 | 10 |
27,957 | private void fillParams ( final Map < String , String [ ] > params , final String queryString , Charset charset ) { if ( StringUtils . hasText ( queryString ) ) { final StringTokenizer tokenizer = new StringTokenizer ( queryString , "&" ) ; while ( tokenizer . hasMoreTokens ( ) ) { final String [ ] nameValuePair = tokenizer . nextToken ( ) . split ( "=" ) ; try { params . put ( URLDecoder . decode ( nameValuePair [ 0 ] , charset . name ( ) ) , new String [ ] { URLDecoder . decode ( nameValuePair [ 1 ] , charset . name ( ) ) } ) ; } catch ( final UnsupportedEncodingException e ) { throw new CitrusRuntimeException ( String . format ( "Failed to decode query param value '%s=%s'" , nameValuePair [ 0 ] , nameValuePair [ 1 ] ) , e ) ; } } } } | Adds parameter name value paris extracted from given query string . | 218 | 12 |
27,958 | protected void addDependencies ( Archive < ? > archive ) { String version = getConfiguration ( ) . getCitrusVersion ( ) ; CitrusArchiveBuilder archiveBuilder ; if ( version != null ) { archiveBuilder = CitrusArchiveBuilder . version ( version ) ; } else { archiveBuilder = CitrusArchiveBuilder . latestVersion ( ) ; } if ( archive instanceof EnterpriseArchive ) { EnterpriseArchive ear = ( EnterpriseArchive ) archive ; ear . addAsModules ( archiveBuilder . all ( ) . build ( ) ) ; } else if ( archive instanceof WebArchive ) { WebArchive war = ( WebArchive ) archive ; war . addAsLibraries ( archiveBuilder . all ( ) . build ( ) ) ; } } | Adds Citrus archive dependencies and all transitive dependencies to archive . | 163 | 13 |
27,959 | private void initMessage ( HttpMessage message ) { StaticMessageContentBuilder staticMessageContentBuilder = StaticMessageContentBuilder . withMessage ( message ) ; staticMessageContentBuilder . setMessageHeaders ( message . getHeaders ( ) ) ; getAction ( ) . setMessageBuilder ( new HttpMessageContentBuilder ( message , staticMessageContentBuilder ) ) ; } | Initialize message builder . | 76 | 5 |
27,960 | public ExecutePLSQLBuilder sqlResource ( Resource sqlResource , Charset charset ) { try { action . setScript ( FileUtils . readToString ( sqlResource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read sql resource" , e ) ; } return this ; } | Setter for external file resource containing the SQL statements to execute . | 75 | 13 |
27,961 | public List < MessageConstructionInterceptor > getMessageConstructionInterceptors ( ) { return messageConstructionInterceptors . stream ( ) . filter ( interceptor -> ! ( interceptor instanceof DataDictionary ) || ( ( DataDictionary ) interceptor ) . isGlobalScope ( ) ) . collect ( Collectors . toList ( ) ) ; } | Gets the messageConstructionInterceptors . | 73 | 9 |
27,962 | public WaitActionConditionBuilder execution ( ) { ActionCondition condition = new ActionCondition ( ) ; container . setCondition ( condition ) ; containers . push ( container ) ; return new WaitActionConditionBuilder ( container , condition , this ) ; } | The test action condition to wait for during execution . | 49 | 10 |
27,963 | public Wait buildAndRun ( ) { if ( designer != null ) { designer . action ( this ) ; } else if ( runner != null ) { runner . run ( super . build ( ) ) ; } return super . build ( ) ; } | Finishes action build process . | 51 | 6 |
27,964 | protected void validate ( WebElement element , SeleniumBrowser browser , TestContext context ) { validateElementProperty ( "tag-name" , tagName , element . getTagName ( ) , context ) ; validateElementProperty ( "text" , text , element . getText ( ) , context ) ; Assert . isTrue ( displayed == element . isDisplayed ( ) , String . format ( "Selenium web element validation failed, " + "property 'displayed' expected '%s', but was '%s'" , displayed , element . isDisplayed ( ) ) ) ; Assert . isTrue ( enabled == element . isEnabled ( ) , String . format ( "Selenium web element validation failed, " + "property 'enabled' expected '%s', but was '%s'" , enabled , element . isEnabled ( ) ) ) ; for ( Map . Entry < String , String > attributeEntry : attributes . entrySet ( ) ) { validateElementProperty ( String . format ( "attribute '%s'" , attributeEntry . getKey ( ) ) , attributeEntry . getValue ( ) , element . getAttribute ( attributeEntry . getKey ( ) ) , context ) ; } for ( Map . Entry < String , String > styleEntry : styles . entrySet ( ) ) { validateElementProperty ( String . format ( "css style '%s'" , styleEntry . getKey ( ) ) , styleEntry . getValue ( ) , element . getCssValue ( styleEntry . getKey ( ) ) , context ) ; } } | Validates found web element with expected content . | 323 | 9 |
27,965 | private void validateElementProperty ( String propertyName , String controlValue , String resultValue , TestContext context ) { if ( StringUtils . hasText ( controlValue ) ) { String control = context . replaceDynamicContentInString ( controlValue ) ; if ( ValidationMatcherUtils . isValidationMatcherExpression ( control ) ) { ValidationMatcherUtils . resolveValidationMatcher ( "payload" , resultValue , control , context ) ; } else { Assert . isTrue ( control . equals ( resultValue ) , String . format ( "Selenium web element validation failed, %s expected '%s', but was '%s'" , propertyName , control , resultValue ) ) ; } } } | Validates web element property value with validation matcher support . | 155 | 12 |
27,966 | protected void execute ( WebElement element , SeleniumBrowser browser , TestContext context ) { if ( StringUtils . hasText ( element . getTagName ( ) ) ) { context . setVariable ( element . getTagName ( ) , element ) ; } } | Subclasses may override this method in order to add element actions . | 55 | 13 |
27,967 | protected By createBy ( TestContext context ) { if ( by != null ) { return by ; } switch ( property ) { case "id" : return By . id ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "class-name" : return By . className ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "link-text" : return By . linkText ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "css-selector" : return By . cssSelector ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "name" : return By . name ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "tag-name" : return By . tagName ( context . replaceDynamicContentInString ( propertyValue ) ) ; case "xpath" : return By . xpath ( context . replaceDynamicContentInString ( propertyValue ) ) ; } throw new CitrusRuntimeException ( "Unknown selector type: " + property ) ; } | Create by selector from type information . | 223 | 7 |
27,968 | private boolean checkCondition ( TestContext context ) { if ( conditionExpression != null ) { return conditionExpression . evaluate ( context ) ; } // replace dynamic content with each iteration String conditionString = context . replaceDynamicContentInString ( condition ) ; if ( ValidationMatcherUtils . isValidationMatcherExpression ( conditionString ) ) { try { ValidationMatcherUtils . resolveValidationMatcher ( "iteratingCondition" , "" , conditionString , context ) ; return true ; } catch ( AssertionError e ) { return false ; } } return BooleanExpressionParser . evaluate ( conditionString ) ; } | Evaluates condition expression and returns boolean representation . | 134 | 10 |
27,969 | public void beforeDeploy ( @ Observes ( precedence = CitrusExtensionConstants . INSTANCE_PRECEDENCE ) BeforeDeploy event ) { try { if ( ! event . getDeployment ( ) . testable ( ) ) { log . info ( "Producing Citrus framework instance" ) ; citrusInstance . set ( Citrus . newInstance ( configurationInstance . get ( ) . getConfigurationClass ( ) ) ) ; } } catch ( Exception e ) { log . error ( CitrusExtensionConstants . CITRUS_EXTENSION_ERROR , e ) ; throw e ; } } | Before deploy executed before deployment on client . | 128 | 8 |
27,970 | public static List < String > createStatementsFromFileResource ( Resource sqlResource , LastScriptLineDecorator lineDecorator ) { BufferedReader reader = null ; StringBuffer buffer ; List < String > stmts = new ArrayList <> ( ) ; try { if ( log . isDebugEnabled ( ) ) { log . debug ( "Create statements from SQL file: " + sqlResource . getFile ( ) . getAbsolutePath ( ) ) ; } reader = new BufferedReader ( new InputStreamReader ( sqlResource . getInputStream ( ) ) ) ; buffer = new StringBuffer ( ) ; String line ; while ( reader . ready ( ) ) { line = reader . readLine ( ) ; if ( line != null && ! line . trim ( ) . startsWith ( SQL_COMMENT ) && line . trim ( ) . length ( ) > 0 ) { if ( line . trim ( ) . endsWith ( getStatementEndingCharacter ( lineDecorator ) ) ) { if ( lineDecorator != null ) { buffer . append ( lineDecorator . decorate ( line ) ) ; } else { buffer . append ( line ) ; } String stmt = buffer . toString ( ) . trim ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Found statement: " + stmt ) ; } stmts . add ( stmt ) ; buffer . setLength ( 0 ) ; buffer = new StringBuffer ( ) ; } else { buffer . append ( line ) ; //more lines to come for this statement add line break buffer . append ( "\n" ) ; } } } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Resource could not be found - filename: " + sqlResource , e ) ; } finally { if ( reader != null ) { try { reader . close ( ) ; } catch ( IOException e ) { log . warn ( "Warning: Error while closing reader instance" , e ) ; } } } return stmts ; } | Reads SQL statements from external file resource . File resource can hold several multi - line statements and comments . | 432 | 21 |
27,971 | public Object buildMessagePayload ( TestContext context , String messageType ) { this . getMessageInterceptors ( ) . add ( gzipMessageConstructionInterceptor ) ; this . getMessageInterceptors ( ) . add ( binaryMessageConstructionInterceptor ) ; return getPayloadContent ( context , messageType ) ; } | Build the control message from payload file resource or String data . | 68 | 12 |
27,972 | private void purgeEndpoint ( Endpoint endpoint , TestContext context ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Try to purge message endpoint " + endpoint . getName ( ) ) ; } int messagesPurged = 0 ; Consumer messageConsumer = endpoint . createConsumer ( ) ; Message message ; do { try { String selector = MessageSelectorBuilder . build ( messageSelector , messageSelectorMap , context ) ; if ( StringUtils . hasText ( selector ) && messageConsumer instanceof SelectiveConsumer ) { message = ( receiveTimeout >= 0 ) ? ( ( SelectiveConsumer ) messageConsumer ) . receive ( selector , context , receiveTimeout ) : ( ( SelectiveConsumer ) messageConsumer ) . receive ( selector , context ) ; } else { message = ( receiveTimeout >= 0 ) ? messageConsumer . receive ( context , receiveTimeout ) : messageConsumer . receive ( context ) ; } } catch ( ActionTimeoutException e ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Stop purging due to timeout - " + e . getMessage ( ) ) ; } break ; } if ( message != null ) { log . debug ( "Removed message from endpoint " + endpoint . getName ( ) ) ; messagesPurged ++ ; try { Thread . sleep ( sleepTime ) ; } catch ( InterruptedException e ) { log . warn ( "Interrupted during wait" , e ) ; } } } while ( message != null ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Purged " + messagesPurged + " messages from endpoint" ) ; } } | Purges all messages from a message endpoint . Prerequisite is that endpoint operates on a destination that queues messages . | 346 | 22 |
27,973 | protected Endpoint resolveEndpointName ( String endpointName ) { try { return beanFactory . getBean ( endpointName , Endpoint . class ) ; } catch ( BeansException e ) { throw new CitrusRuntimeException ( String . format ( "Unable to resolve endpoint for name '%s'" , endpointName ) , e ) ; } } | Resolve the endpoint by name . | 73 | 7 |
27,974 | public SftpClientBuilder sessionConfigs ( Map < String , String > sessionConfigs ) { endpoint . getEndpointConfiguration ( ) . setSessionConfigs ( sessionConfigs ) ; return this ; } | Sets the sessionConfigs property . | 44 | 8 |
27,975 | public void saveReplyMessageChannel ( Message receivedMessage , TestContext context ) { MessageChannel replyChannel = null ; if ( receivedMessage . getHeader ( org . springframework . messaging . MessageHeaders . REPLY_CHANNEL ) instanceof MessageChannel ) { replyChannel = ( MessageChannel ) receivedMessage . getHeader ( org . springframework . messaging . MessageHeaders . REPLY_CHANNEL ) ; } else if ( StringUtils . hasText ( ( String ) receivedMessage . getHeader ( org . springframework . messaging . MessageHeaders . REPLY_CHANNEL ) ) ) { replyChannel = resolveChannelName ( receivedMessage . getHeader ( org . springframework . messaging . MessageHeaders . REPLY_CHANNEL ) . toString ( ) , context ) ; } if ( replyChannel != null ) { String correlationKeyName = endpointConfiguration . getCorrelator ( ) . getCorrelationKeyName ( getName ( ) ) ; String correlationKey = endpointConfiguration . getCorrelator ( ) . getCorrelationKey ( receivedMessage ) ; correlationManager . saveCorrelationKey ( correlationKeyName , correlationKey , context ) ; correlationManager . store ( correlationKey , replyChannel ) ; } else { log . warn ( "Unable to retrieve reply message channel for message \n" + receivedMessage + "\n - no reply channel found in message headers!" ) ; } } | Store reply message channel . | 296 | 5 |
27,976 | public static boolean isElementIgnored ( final Node received , Set < String > ignoreExpressions , NamespaceContext namespaceContext ) { if ( CollectionUtils . isEmpty ( ignoreExpressions ) ) { return false ; } /** This is the faster version, but then the ignoreValue name must be * the full path name like: Numbers.NumberItem.AreaCode */ if ( ignoreExpressions . contains ( XMLUtils . getNodesPathName ( received ) ) ) { return true ; } /** This is the slower version, but here the ignoreValues can be * the short path name like only: AreaCode * * If there are more nodes with the same short name, * the first one will match, eg. if there are: * Numbers1.NumberItem.AreaCode * Numbers2.NumberItem.AreaCode * And ignoreValues contains just: AreaCode * the only first Node: Numbers1.NumberItem.AreaCode will be ignored. */ for ( String expression : ignoreExpressions ) { if ( received == XMLUtils . findNodeByName ( received . getOwnerDocument ( ) , expression ) ) { return true ; } } /** This is the XPath version using XPath expressions in * ignoreValues to identify nodes to be ignored */ for ( String expression : ignoreExpressions ) { if ( XPathUtils . isXPathExpression ( expression ) ) { NodeList foundNodes = XPathUtils . evaluateAsNodeList ( received . getOwnerDocument ( ) , expression , namespaceContext ) ; if ( foundNodes != null ) { for ( int i = 0 ; i < foundNodes . getLength ( ) ; i ++ ) { if ( foundNodes . item ( i ) != null && foundNodes . item ( i ) . isSameNode ( received ) ) { return true ; } } } } } return false ; } | Checks whether the node is ignored by node path expression or xpath expression . | 391 | 16 |
27,977 | public static boolean isAttributeIgnored ( Node receivedElement , Node receivedAttribute , Node sourceAttribute , Set < String > ignoreMessageElements , NamespaceContext namespaceContext ) { if ( isAttributeIgnored ( receivedElement , receivedAttribute , ignoreMessageElements , namespaceContext ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Attribute '" + receivedAttribute . getLocalName ( ) + "' is on ignore list - skipped value validation" ) ; } return true ; } else if ( ( StringUtils . hasText ( sourceAttribute . getNodeValue ( ) ) && sourceAttribute . getNodeValue ( ) . trim ( ) . equals ( Citrus . IGNORE_PLACEHOLDER ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Attribute: '" + receivedAttribute . getLocalName ( ) + "' is ignored by placeholder '" + Citrus . IGNORE_PLACEHOLDER + "'" ) ; } return true ; } return false ; } | Checks whether the current attribute is ignored either by global ignore placeholder in source attribute value or by xpath ignore expressions . | 219 | 24 |
27,978 | private static boolean isAttributeIgnored ( Node receivedElement , Node receivedAttribute , Set < String > ignoreMessageElements , NamespaceContext namespaceContext ) { if ( CollectionUtils . isEmpty ( ignoreMessageElements ) ) { return false ; } /** This is the faster version, but then the ignoreValue name must be * the full path name like: Numbers.NumberItem.AreaCode */ if ( ignoreMessageElements . contains ( XMLUtils . getNodesPathName ( receivedElement ) + "." + receivedAttribute . getNodeName ( ) ) ) { return true ; } /** This is the slower version, but here the ignoreValues can be * the short path name like only: AreaCode * * If there are more nodes with the same short name, * the first one will match, eg. if there are: * Numbers1.NumberItem.AreaCode * Numbers2.NumberItem.AreaCode * And ignoreValues contains just: AreaCode * the only first Node: Numbers1.NumberItem.AreaCode will be ignored. */ for ( String expression : ignoreMessageElements ) { Node foundAttributeNode = XMLUtils . findNodeByName ( receivedElement . getOwnerDocument ( ) , expression ) ; if ( foundAttributeNode != null && receivedAttribute . isSameNode ( foundAttributeNode ) ) { return true ; } } /** This is the XPath version using XPath expressions in * ignoreValues to identify nodes to be ignored */ for ( String expression : ignoreMessageElements ) { if ( XPathUtils . isXPathExpression ( expression ) ) { Node foundAttributeNode = XPathUtils . evaluateAsNode ( receivedElement . getOwnerDocument ( ) , expression , namespaceContext ) ; if ( foundAttributeNode != null && foundAttributeNode . isSameNode ( receivedAttribute ) ) { return true ; } } } return false ; } | Checks whether the current attribute is ignored . | 392 | 9 |
27,979 | public PurgeJmsQueuesBuilder withApplicationContext ( ApplicationContext applicationContext ) { if ( applicationContext . containsBean ( "connectionFactory" ) ) { connectionFactory ( applicationContext . getBean ( "connectionFactory" , ConnectionFactory . class ) ) ; } return this ; } | Sets the Spring bean factory for using endpoint names . | 61 | 11 |
27,980 | public String getServerUrl ( ) { if ( StringUtils . hasText ( this . serverUrl ) ) { return serverUrl ; } else { return "service:jmx:" + protocol + ":///jndi/" + protocol + "://" + host + ":" + port + ( binding != null ? "/" + binding : "" ) ; } } | Gets the value of the serverUrl property . | 77 | 10 |
27,981 | public SoapClientResponseActionBuilder receive ( ) { SoapClientResponseActionBuilder soapClientResponseActionBuilder ; if ( soapClient != null ) { soapClientResponseActionBuilder = new SoapClientResponseActionBuilder ( action , soapClient ) ; } else { soapClientResponseActionBuilder = new SoapClientResponseActionBuilder ( action , soapClientUri ) ; } soapClientResponseActionBuilder . withApplicationContext ( applicationContext ) ; return soapClientResponseActionBuilder ; } | Generic response builder for expecting response messages on client . | 99 | 10 |
27,982 | public ConditionalBuilder when ( Object value , Matcher expression ) { action . setConditionExpression ( new HamcrestConditionExpression ( expression , value ) ) ; return this ; } | Condition which allows execution if evaluates to true . | 39 | 9 |
27,983 | public SoapFault locale ( String locale ) { LocaleEditor localeEditor = new LocaleEditor ( ) ; localeEditor . setAsText ( locale ) ; this . locale = ( Locale ) localeEditor . getValue ( ) ; return this ; } | Sets the locale used in SOAP fault . | 54 | 10 |
27,984 | public static SoapFault from ( org . springframework . ws . soap . SoapFault fault ) { QNameEditor qNameEditor = new QNameEditor ( ) ; qNameEditor . setValue ( fault . getFaultCode ( ) ) ; SoapFault soapFault = new SoapFault ( ) . faultCode ( qNameEditor . getAsText ( ) ) . faultActor ( fault . getFaultActorOrRole ( ) ) . faultString ( fault . getFaultStringOrReason ( ) ) ; if ( fault . getFaultDetail ( ) != null ) { Iterator < SoapFaultDetailElement > details = fault . getFaultDetail ( ) . getDetailEntries ( ) ; while ( details . hasNext ( ) ) { SoapFaultDetailElement soapFaultDetailElement = details . next ( ) ; soapFault . addFaultDetail ( extractFaultDetail ( soapFaultDetailElement ) ) ; } } return soapFault ; } | Builder method from Spring WS SOAP fault object . | 225 | 10 |
27,985 | private static String extractFaultDetail ( SoapFaultDetailElement detail ) { StringResult detailResult = new StringResult ( ) ; try { TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . transform ( detail . getSource ( ) , detailResult ) ; } catch ( TransformerException e ) { throw new CitrusRuntimeException ( e ) ; } return detailResult . toString ( ) ; } | Extracts fault detail string from soap fault detail instance . Transforms detail source into string and takes care . | 130 | 22 |
27,986 | public void extractVariables ( Message message , TestContext context ) { if ( CollectionUtils . isEmpty ( xPathExpressions ) ) { return ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Reading XML elements with XPath" ) ; } NamespaceContext nsContext = context . getNamespaceContextBuilder ( ) . buildContext ( message , namespaces ) ; for ( Entry < String , String > entry : xPathExpressions . entrySet ( ) ) { String pathExpression = context . replaceDynamicContentInString ( entry . getKey ( ) ) ; String variableName = entry . getValue ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Evaluating XPath expression: " + pathExpression ) ; } Document doc = XMLUtils . parseMessagePayload ( message . getPayload ( String . class ) ) ; if ( XPathUtils . isXPathExpression ( pathExpression ) ) { XPathExpressionResult resultType = XPathExpressionResult . fromString ( pathExpression , XPathExpressionResult . STRING ) ; pathExpression = XPathExpressionResult . cutOffPrefix ( pathExpression ) ; Object value = XPathUtils . evaluate ( doc , pathExpression , nsContext , resultType ) ; if ( value == null ) { throw new CitrusRuntimeException ( "Not able to find value for expression: " + pathExpression ) ; } if ( value instanceof List ) { value = StringUtils . arrayToCommaDelimitedString ( ( ( List ) value ) . toArray ( new String [ ( ( List ) value ) . size ( ) ] ) ) ; } context . setVariable ( variableName , value ) ; } else { Node node = XMLUtils . findNodeByName ( doc , pathExpression ) ; if ( node == null ) { throw new UnknownElementException ( "No element found for expression" + pathExpression ) ; } if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { if ( node . getFirstChild ( ) != null ) { context . setVariable ( xPathExpressions . get ( pathExpression ) , node . getFirstChild ( ) . getNodeValue ( ) ) ; } else { context . setVariable ( xPathExpressions . get ( pathExpression ) , "" ) ; } } else { context . setVariable ( xPathExpressions . get ( pathExpression ) , node . getNodeValue ( ) ) ; } } } } | Extract variables using Xpath expressions . | 548 | 8 |
27,987 | public String getFailureStackAsString ( ) { StringBuilder builder = new StringBuilder ( ) ; for ( FailureStackElement failureStackElement : getFailureStack ( ) ) { builder . append ( "\n\t" ) ; builder . append ( failureStackElement . getStackMessage ( ) ) ; } return builder . toString ( ) ; } | Get formatted string representation of failure stack information . | 72 | 9 |
27,988 | public Stack < FailureStackElement > getFailureStack ( ) { Stack < FailureStackElement > stack = new Stack < FailureStackElement > ( ) ; for ( FailureStackElement failureStackElement : failureStack ) { stack . push ( failureStackElement ) ; } return stack ; } | Gets the custom failure stack with line number information where the testcase failed . | 58 | 16 |
27,989 | private Condition parseHttpCondition ( Element element ) { HttpCondition condition = new HttpCondition ( ) ; condition . setUrl ( element . getAttribute ( "url" ) ) ; String method = element . getAttribute ( "method" ) ; if ( StringUtils . hasText ( method ) ) { condition . setMethod ( method ) ; } String statusCode = element . getAttribute ( "status" ) ; if ( StringUtils . hasText ( statusCode ) ) { condition . setHttpResponseCode ( statusCode ) ; } String timeout = element . getAttribute ( "timeout" ) ; if ( StringUtils . hasText ( timeout ) ) { condition . setTimeout ( timeout ) ; } return condition ; } | Parse Http request condition . | 152 | 7 |
27,990 | private Condition parseMessageCondition ( Element element ) { MessageCondition condition = new MessageCondition ( ) ; condition . setMessageName ( element . getAttribute ( "name" ) ) ; return condition ; } | Parse message store condition . | 41 | 6 |
27,991 | private BeanDefinition parseActionCondition ( Element element , ParserContext parserContext ) { Map < String , BeanDefinitionParser > actionRegistry = TestActionRegistry . getRegisteredActionParser ( ) ; Element action = DOMUtil . getFirstChildElement ( element ) ; if ( action != null ) { BeanDefinitionParser parser = actionRegistry . get ( action . getTagName ( ) ) ; if ( parser != null ) { return parser . parse ( action , parserContext ) ; } else { return parserContext . getReaderContext ( ) . getNamespaceHandlerResolver ( ) . resolve ( action . getNamespaceURI ( ) ) . parse ( action , parserContext ) ; } } throw new BeanCreationException ( "Invalid wait for action condition - action not set properly" ) ; } | Parse test action condition . | 167 | 6 |
27,992 | private Condition parseFileCondition ( Element element ) { FileCondition condition = new FileCondition ( ) ; condition . setFilePath ( element . getAttribute ( "path" ) ) ; return condition ; } | Parse file existence condition . | 41 | 6 |
27,993 | private void addDispatcherServlet ( ) { ServletHolder servletHolder = new ServletHolder ( new CitrusMessageDispatcherServlet ( this ) ) ; servletHolder . setName ( getServletName ( ) ) ; servletHolder . setInitParameter ( "contextConfigLocation" , contextConfigLocation ) ; servletHandler . addServlet ( servletHolder ) ; ServletMapping servletMapping = new ServletMapping ( ) ; servletMapping . setServletName ( getServletName ( ) ) ; servletMapping . setPathSpec ( servletMappingPath ) ; servletHandler . addServletMapping ( servletMapping ) ; } | Adds Citrus message dispatcher servlet . | 158 | 8 |
27,994 | public Connector [ ] getConnectors ( ) { if ( connectors != null ) { return Arrays . copyOf ( connectors , connectors . length ) ; } else { return new Connector [ ] { } ; } } | Gets the connectors . | 46 | 5 |
27,995 | public String getValidationScript ( TestContext context ) { try { if ( validationScriptResourcePath != null ) { return context . replaceDynamicContentInString ( FileUtils . readToString ( FileUtils . getFileResource ( validationScriptResourcePath , context ) , Charset . forName ( context . replaceDynamicContentInString ( validationScriptResourceCharset ) ) ) ) ; } else if ( validationScript != null ) { return context . replaceDynamicContentInString ( validationScript ) ; } else { return "" ; } } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to load validation script resource" , e ) ; } } | Constructs the actual validation script either from data or external resource . | 143 | 13 |
27,996 | public void setBinaryMediaTypes ( List < MediaType > binaryMediaTypes ) { requestMessageConverters . stream ( ) . filter ( converter -> converter instanceof ByteArrayHttpMessageConverter ) . map ( ByteArrayHttpMessageConverter . class :: cast ) . forEach ( converter -> converter . setSupportedMediaTypes ( binaryMediaTypes ) ) ; responseMessageConverters . stream ( ) . filter ( converter -> converter instanceof ByteArrayHttpMessageConverter ) . map ( ByteArrayHttpMessageConverter . class :: cast ) . forEach ( converter -> converter . setSupportedMediaTypes ( binaryMediaTypes ) ) ; } | Sets the binaryMediaTypes . | 137 | 7 |
27,997 | public void doWithMessage ( WebServiceMessage requestMessage ) throws IOException , TransformerException { endpointConfiguration . getMessageConverter ( ) . convertOutbound ( requestMessage , message , endpointConfiguration , context ) ; } | Callback method called before request message is sent . | 47 | 9 |
27,998 | private void copyCookies ( final Message message ) { if ( message instanceof HttpMessage ) { this . cookies . putAll ( ( ( HttpMessage ) message ) . getCookiesMap ( ) ) ; } } | Sets the cookies extracted from the given message as far as it is a HttpMessage | 47 | 18 |
27,999 | public HttpMessage status ( final HttpStatus statusCode ) { statusCode ( statusCode . value ( ) ) ; reasonPhrase ( statusCode . name ( ) ) ; return this ; } | Sets the Http response status code . | 41 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.