idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
28,200
@ Override protected void validateFaultDetailString ( String receivedDetailString , String controlDetailString , TestContext context , ValidationContext validationContext ) throws ValidationException { XmlMessageValidationContext xmlMessageValidationContext ; if ( validationContext instanceof XmlMessageValidationContext ) { xmlMessageValidationContext = ( XmlMessageValidationContext ) validationContext ; } else { xmlMessageValidationContext = new XmlMessageValidationContext ( ) ; } messageValidator . validateMessage ( new DefaultMessage ( receivedDetailString ) , new DefaultMessage ( controlDetailString ) , context , xmlMessageValidationContext ) ; }
Delegates to XML message validator for validation of fault detail .
139
13
28,201
public void start ( ) { if ( ! isStarted ( ) ) { if ( getEndpointConfiguration ( ) . getWebDriver ( ) != null ) { webDriver = getEndpointConfiguration ( ) . getWebDriver ( ) ; } else if ( StringUtils . hasText ( getEndpointConfiguration ( ) . getRemoteServerUrl ( ) ) ) { webDriver = createRemoteWebDriver ( getEndpointConfiguration ( ) . getBrowserType ( ) , getEndpointConfiguration ( ) . getRemoteServerUrl ( ) ) ; } else { webDriver = createLocalWebDriver ( getEndpointConfiguration ( ) . getBrowserType ( ) ) ; } if ( ! CollectionUtils . isEmpty ( getEndpointConfiguration ( ) . getEventListeners ( ) ) ) { EventFiringWebDriver wrapper = new EventFiringWebDriver ( webDriver ) ; log . info ( "Add event listeners to web driver: " + getEndpointConfiguration ( ) . getEventListeners ( ) . size ( ) ) ; for ( WebDriverEventListener listener : getEndpointConfiguration ( ) . getEventListeners ( ) ) { wrapper . register ( listener ) ; } } } else { log . warn ( "Browser already started" ) ; } }
Starts the browser and create local or remote web driver .
264
12
28,202
public void stop ( ) { if ( isStarted ( ) ) { log . info ( "Stopping browser " + webDriver . getCurrentUrl ( ) ) ; try { log . info ( "Trying to close the browser " + webDriver + " ..." ) ; webDriver . quit ( ) ; } catch ( UnreachableBrowserException e ) { // It happens for Firefox. It's ok: browser is already closed. log . warn ( "Browser is unreachable" , e ) ; } catch ( WebDriverException e ) { log . error ( "Failed to close browser" , e ) ; } webDriver = null ; } else { log . warn ( "Browser already stopped" ) ; } }
Stop the browser when started .
150
6
28,203
public String storeFile ( Resource file ) { try { File newFile = new File ( temporaryStorage . toFile ( ) , file . getFilename ( ) ) ; log . info ( "Store file " + file + " to " + newFile ) ; FileUtils . copyFile ( file . getFile ( ) , newFile ) ; return newFile . getCanonicalPath ( ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to store file: " + file , e ) ; } }
Deploy resource object from resource folder and return path of deployed file
114
12
28,204
public String getStoredFile ( String filename ) { try { File stored = new File ( temporaryStorage . toFile ( ) , filename ) ; if ( ! stored . exists ( ) ) { throw new CitrusRuntimeException ( "Failed to access stored file: " + stored . getCanonicalPath ( ) ) ; } return stored . getCanonicalPath ( ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to retrieve file: " + filename , e ) ; } }
Retrieve resource object
111
4
28,205
private WebDriver createLocalWebDriver ( String browserType ) { switch ( browserType ) { case BrowserType . FIREFOX : FirefoxProfile firefoxProfile = getEndpointConfiguration ( ) . getFirefoxProfile ( ) ; /* set custom download folder */ firefoxProfile . setPreference ( "browser.download.dir" , temporaryStorage . toFile ( ) . getAbsolutePath ( ) ) ; DesiredCapabilities defaults = DesiredCapabilities . firefox ( ) ; defaults . setCapability ( FirefoxDriver . PROFILE , firefoxProfile ) ; return new FirefoxDriver ( defaults ) ; case BrowserType . IE : return new InternetExplorerDriver ( ) ; case BrowserType . EDGE : return new EdgeDriver ( ) ; case BrowserType . SAFARI : return new SafariDriver ( ) ; case BrowserType . CHROME : return new ChromeDriver ( ) ; case BrowserType . GOOGLECHROME : return new ChromeDriver ( ) ; case BrowserType . HTMLUNIT : BrowserVersion browserVersion = null ; if ( getEndpointConfiguration ( ) . getVersion ( ) . equals ( "FIREFOX" ) ) { browserVersion = BrowserVersion . FIREFOX_45 ; } else if ( getEndpointConfiguration ( ) . getVersion ( ) . equals ( "INTERNET_EXPLORER" ) ) { browserVersion = BrowserVersion . INTERNET_EXPLORER ; } else if ( getEndpointConfiguration ( ) . getVersion ( ) . equals ( "EDGE" ) ) { browserVersion = BrowserVersion . EDGE ; } else if ( getEndpointConfiguration ( ) . getVersion ( ) . equals ( "CHROME" ) ) { browserVersion = BrowserVersion . CHROME ; } HtmlUnitDriver htmlUnitDriver ; if ( browserVersion != null ) { htmlUnitDriver = new HtmlUnitDriver ( browserVersion ) ; } else { htmlUnitDriver = new HtmlUnitDriver ( ) ; } htmlUnitDriver . setJavascriptEnabled ( getEndpointConfiguration ( ) . isJavaScript ( ) ) ; return htmlUnitDriver ; default : throw new CitrusRuntimeException ( "Unsupported local browser type: " + browserType ) ; } }
Creates local web driver .
461
6
28,206
private RemoteWebDriver createRemoteWebDriver ( String browserType , String serverAddress ) { try { switch ( browserType ) { case BrowserType . FIREFOX : DesiredCapabilities defaultsFF = DesiredCapabilities . firefox ( ) ; defaultsFF . setCapability ( FirefoxDriver . PROFILE , getEndpointConfiguration ( ) . getFirefoxProfile ( ) ) ; return new RemoteWebDriver ( new URL ( serverAddress ) , defaultsFF ) ; case BrowserType . IE : DesiredCapabilities defaultsIE = DesiredCapabilities . internetExplorer ( ) ; defaultsIE . setCapability ( CapabilityType . ACCEPT_SSL_CERTS , true ) ; return new RemoteWebDriver ( new URL ( serverAddress ) , defaultsIE ) ; case BrowserType . CHROME : DesiredCapabilities defaultsChrome = DesiredCapabilities . chrome ( ) ; defaultsChrome . setCapability ( CapabilityType . ACCEPT_SSL_CERTS , true ) ; return new RemoteWebDriver ( new URL ( serverAddress ) , defaultsChrome ) ; case BrowserType . GOOGLECHROME : DesiredCapabilities defaultsGoogleChrome = DesiredCapabilities . chrome ( ) ; defaultsGoogleChrome . setCapability ( CapabilityType . ACCEPT_SSL_CERTS , true ) ; return new RemoteWebDriver ( new URL ( serverAddress ) , defaultsGoogleChrome ) ; default : throw new CitrusRuntimeException ( "Unsupported remote browser type: " + browserType ) ; } } catch ( MalformedURLException e ) { throw new CitrusRuntimeException ( "Failed to access remote server" , e ) ; } }
Creates remote web driver .
357
6
28,207
private Path createTemporaryStorage ( ) { try { Path tempDir = Files . createTempDirectory ( "selenium" ) ; tempDir . toFile ( ) . deleteOnExit ( ) ; log . info ( "Download storage location is: " + tempDir . toString ( ) ) ; return tempDir ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Could not create temporary storage" , e ) ; } }
Creates temporary storage .
94
5
28,208
protected void sendClientRequest ( HttpMessage request ) { BuilderSupport < HttpActionBuilder > action = builder -> { HttpClientActionBuilder . HttpClientSendActionBuilder sendBuilder = builder . client ( httpClient ) . send ( ) ; HttpClientRequestActionBuilder requestBuilder ; if ( request . getRequestMethod ( ) == null || request . getRequestMethod ( ) . equals ( HttpMethod . POST ) ) { requestBuilder = sendBuilder . post ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . GET ) ) { requestBuilder = sendBuilder . get ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . PUT ) ) { requestBuilder = sendBuilder . put ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . DELETE ) ) { requestBuilder = sendBuilder . delete ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . HEAD ) ) { requestBuilder = sendBuilder . head ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . TRACE ) ) { requestBuilder = sendBuilder . trace ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . PATCH ) ) { requestBuilder = sendBuilder . patch ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . OPTIONS ) ) { requestBuilder = sendBuilder . options ( ) . message ( request ) ; } else { requestBuilder = sendBuilder . post ( ) . message ( request ) ; } if ( StringUtils . hasText ( url ) ) { requestBuilder . uri ( url ) ; } } ; runner . http ( action ) ; }
Sends client request .
423
5
28,209
protected void receiveClientResponse ( HttpMessage response ) { runner . http ( action -> { HttpClientResponseActionBuilder responseBuilder = action . client ( httpClient ) . receive ( ) . response ( response . getStatusCode ( ) ) . message ( response ) ; for ( Map . Entry < String , String > headerEntry : pathValidations . entrySet ( ) ) { responseBuilder . validate ( headerEntry . getKey ( ) , headerEntry . getValue ( ) ) ; } pathValidations . clear ( ) ; } ) ; }
Receives client response .
114
6
28,210
protected void receiveServerRequest ( HttpMessage request ) { BuilderSupport < HttpActionBuilder > action = builder -> { HttpServerActionBuilder . HttpServerReceiveActionBuilder receiveBuilder = builder . server ( httpServer ) . receive ( ) ; HttpServerRequestActionBuilder requestBuilder ; if ( request . getRequestMethod ( ) == null || request . getRequestMethod ( ) . equals ( HttpMethod . POST ) ) { requestBuilder = receiveBuilder . post ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . GET ) ) { requestBuilder = receiveBuilder . get ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . PUT ) ) { requestBuilder = receiveBuilder . put ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . DELETE ) ) { requestBuilder = receiveBuilder . delete ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . HEAD ) ) { requestBuilder = receiveBuilder . head ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . TRACE ) ) { requestBuilder = receiveBuilder . trace ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . PATCH ) ) { requestBuilder = receiveBuilder . patch ( ) . message ( request ) ; } else if ( request . getRequestMethod ( ) . equals ( HttpMethod . OPTIONS ) ) { requestBuilder = receiveBuilder . options ( ) . message ( request ) ; } else { requestBuilder = receiveBuilder . post ( ) . message ( request ) ; } for ( Map . Entry < String , String > headerEntry : pathValidations . entrySet ( ) ) { requestBuilder . validate ( headerEntry . getKey ( ) , headerEntry . getValue ( ) ) ; } pathValidations . clear ( ) ; } ; runner . http ( action ) ; }
Receives server request .
455
6
28,211
Cookie [ ] convertCookies ( HttpEntity < ? > httpEntity ) { final List < Cookie > cookies = new LinkedList <> ( ) ; List < String > inboundCookies = httpEntity . getHeaders ( ) . get ( HttpHeaders . SET_COOKIE ) ; if ( inboundCookies != null ) { for ( String cookieString : inboundCookies ) { Cookie cookie = convertCookieString ( cookieString ) ; cookies . add ( cookie ) ; } } return cookies . toArray ( new Cookie [ 0 ] ) ; }
Converts cookies from a HttpEntity into Cookie objects
123
11
28,212
String getCookieString ( Cookie cookie ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( cookie . getName ( ) ) ; builder . append ( "=" ) ; builder . append ( cookie . getValue ( ) ) ; if ( cookie . getVersion ( ) > 0 ) { builder . append ( ";" + VERSION + "=" ) . append ( cookie . getVersion ( ) ) ; } if ( StringUtils . hasText ( cookie . getPath ( ) ) ) { builder . append ( ";" + PATH + "=" ) . append ( cookie . getPath ( ) ) ; } if ( StringUtils . hasText ( cookie . getDomain ( ) ) ) { builder . append ( ";" + DOMAIN + "=" ) . append ( cookie . getDomain ( ) ) ; } if ( cookie . getMaxAge ( ) > 0 ) { builder . append ( ";" + MAX_AGE + "=" ) . append ( cookie . getMaxAge ( ) ) ; } if ( StringUtils . hasText ( cookie . getComment ( ) ) ) { builder . append ( ";" + COMMENT + "=" ) . append ( cookie . getComment ( ) ) ; } if ( cookie . getSecure ( ) ) { builder . append ( ";" + SECURE ) ; } if ( cookie . isHttpOnly ( ) ) { builder . append ( ";" + HTTP_ONLY ) ; } return builder . toString ( ) ; }
Converts a given cookie into a HTTP conform cookie String
313
11
28,213
private Cookie convertCookieString ( String cookieString ) { Cookie cookie = new Cookie ( getCookieParam ( NAME , cookieString ) , getCookieParam ( VALUE , cookieString ) ) ; if ( cookieString . contains ( COMMENT ) ) { cookie . setComment ( getCookieParam ( COMMENT , cookieString ) ) ; } if ( cookieString . contains ( PATH ) ) { cookie . setPath ( getCookieParam ( PATH , cookieString ) ) ; } if ( cookieString . contains ( DOMAIN ) ) { cookie . setDomain ( getCookieParam ( DOMAIN , cookieString ) ) ; } if ( cookieString . contains ( MAX_AGE ) ) { cookie . setMaxAge ( Integer . valueOf ( getCookieParam ( MAX_AGE , cookieString ) ) ) ; } if ( cookieString . contains ( SECURE ) ) { cookie . setSecure ( Boolean . valueOf ( getCookieParam ( SECURE , cookieString ) ) ) ; } if ( cookieString . contains ( VERSION ) ) { cookie . setVersion ( Integer . valueOf ( getCookieParam ( VERSION , cookieString ) ) ) ; } if ( cookieString . contains ( HTTP_ONLY ) ) { cookie . setHttpOnly ( Boolean . valueOf ( getCookieParam ( HTTP_ONLY , cookieString ) ) ) ; } return cookie ; }
Converts a cookie string from a http header value into a Cookie object
293
14
28,214
private String getCookieParam ( String param , String cookieString ) { if ( param . equals ( NAME ) ) { return cookieString . substring ( 0 , cookieString . indexOf ( ' ' ) ) ; } if ( param . equals ( VALUE ) ) { if ( cookieString . contains ( ";" ) ) { return cookieString . substring ( cookieString . indexOf ( ' ' ) + 1 , cookieString . indexOf ( ' ' ) ) ; } else { return cookieString . substring ( cookieString . indexOf ( ' ' ) + 1 ) ; } } if ( containsFlag ( SECURE , param , cookieString ) || containsFlag ( HTTP_ONLY , param , cookieString ) ) { return String . valueOf ( true ) ; } if ( cookieString . contains ( param + ' ' ) ) { final int endParam = cookieString . indexOf ( ' ' , cookieString . indexOf ( param + ' ' ) ) ; final int beginIndex = cookieString . indexOf ( param + ' ' ) + param . length ( ) + 1 ; if ( endParam > 0 ) { return cookieString . substring ( beginIndex , endParam ) ; } else { return cookieString . substring ( beginIndex ) ; } } throw new CitrusRuntimeException ( String . format ( "Unable to get cookie argument '%s' from cookie String: %s" , param , cookieString ) ) ; }
Extract cookie param from cookie string as it was provided by Set - Cookie header .
305
17
28,215
protected void parseEndpointConfiguration ( BeanDefinitionBuilder endpointConfigurationBuilder , Element element , ParserContext parserContext ) { BeanDefinitionParserUtils . setPropertyValue ( endpointConfigurationBuilder , element . getAttribute ( "timeout" ) , "timeout" ) ; }
Subclasses can override this parsing method in order to provide proper endpoint configuration bean definition properties .
54
18
28,216
public InputActionBuilder answers ( String ... answers ) { if ( answers . length == 0 ) { throw new CitrusRuntimeException ( "Please specify proper answer possibilities for input action" ) ; } StringBuilder validAnswers = new StringBuilder ( ) ; for ( String answer : answers ) { validAnswers . append ( InputAction . ANSWER_SEPARATOR ) ; validAnswers . append ( answer ) ; } action . setValidAnswers ( validAnswers . toString ( ) . substring ( 1 ) ) ; return this ; }
Sets the valid answers .
115
6
28,217
public void beforeSuite ( String suiteName , String ... testGroups ) { testSuiteListener . onStart ( ) ; if ( ! CollectionUtils . isEmpty ( beforeSuite ) ) { for ( SequenceBeforeSuite sequenceBeforeSuite : beforeSuite ) { try { if ( sequenceBeforeSuite . shouldExecute ( suiteName , testGroups ) ) { sequenceBeforeSuite . execute ( createTestContext ( ) ) ; } } catch ( Exception e ) { testSuiteListener . onStartFailure ( e ) ; afterSuite ( suiteName , testGroups ) ; throw new AssertionError ( "Before suite failed with errors" , e ) ; } } testSuiteListener . onStartSuccess ( ) ; } else { testSuiteListener . onStartSuccess ( ) ; } }
Performs before suite test actions .
174
7
28,218
public void afterSuite ( String suiteName , String ... testGroups ) { testSuiteListener . onFinish ( ) ; if ( ! CollectionUtils . isEmpty ( afterSuite ) ) { for ( SequenceAfterSuite sequenceAfterSuite : afterSuite ) { try { if ( sequenceAfterSuite . shouldExecute ( suiteName , testGroups ) ) { sequenceAfterSuite . execute ( createTestContext ( ) ) ; } } catch ( Exception e ) { testSuiteListener . onFinishFailure ( e ) ; throw new AssertionError ( "After suite failed with errors" , e ) ; } } testSuiteListener . onFinishSuccess ( ) ; } else { testSuiteListener . onFinishSuccess ( ) ; } }
Performs after suite test actions .
162
7
28,219
public JmxMessage attribute ( String name , Object value ) { return attribute ( name , value , value . getClass ( ) ) ; }
Sets attribute for write operation .
29
7
28,220
public JmxMessage attribute ( String name , Object value , Class < ? > valueType ) { if ( mbeanInvocation == null ) { throw new CitrusRuntimeException ( "Invalid access to attribute for JMX message" ) ; } ManagedBeanInvocation . Attribute attribute = new ManagedBeanInvocation . Attribute ( ) ; attribute . setName ( name ) ; if ( value != null ) { attribute . setValueObject ( value ) ; attribute . setType ( valueType . getName ( ) ) ; } mbeanInvocation . setAttribute ( attribute ) ; return this ; }
Sets attribute for write operation with custom value type .
128
11
28,221
public JmxMessage operation ( String name ) { if ( mbeanInvocation == null ) { throw new CitrusRuntimeException ( "Invalid access to operation for JMX message" ) ; } ManagedBeanInvocation . Operation operation = new ManagedBeanInvocation . Operation ( ) ; operation . setName ( name ) ; mbeanInvocation . setOperation ( operation ) ; return this ; }
Sets operation for read write access .
85
8
28,222
public JmxMessage parameter ( Object arg , Class < ? > argType ) { if ( mbeanInvocation == null ) { throw new CitrusRuntimeException ( "Invalid access to operation parameter for JMX message" ) ; } if ( mbeanInvocation . getOperation ( ) == null ) { throw new CitrusRuntimeException ( "Invalid access to operation parameter before operation was set for JMX message" ) ; } if ( mbeanInvocation . getOperation ( ) . getParameter ( ) == null ) { mbeanInvocation . getOperation ( ) . setParameter ( new ManagedBeanInvocation . Parameter ( ) ) ; } OperationParam operationParam = new OperationParam ( ) ; operationParam . setValueObject ( arg ) ; operationParam . setType ( argType . getName ( ) ) ; mbeanInvocation . getOperation ( ) . getParameter ( ) . getParameter ( ) . add ( operationParam ) ; return this ; }
Adds operation parameter with custom parameter type .
202
8
28,223
public Message dispatchMessage ( Message request , String mappingKey ) { return mappingStrategy . getEndpointAdapter ( mappingKey ) . handleMessage ( request ) ; }
Consolidate mapping strategy in order to find dispatch incoming request to endpoint adapter according to mapping key that was extracted before from message content .
34
27
28,224
protected void enrichEndpointConfiguration ( EndpointConfiguration endpointConfiguration , Map < String , String > parameters , TestContext context ) { for ( Map . Entry < String , String > parameterEntry : parameters . entrySet ( ) ) { Field field = ReflectionUtils . findField ( endpointConfiguration . getClass ( ) , parameterEntry . getKey ( ) ) ; if ( field == null ) { throw new CitrusRuntimeException ( String . format ( "Unable to find parameter field on endpoint configuration '%s'" , parameterEntry . getKey ( ) ) ) ; } Method setter = ReflectionUtils . findMethod ( endpointConfiguration . getClass ( ) , "set" + parameterEntry . getKey ( ) . substring ( 0 , 1 ) . toUpperCase ( ) + parameterEntry . getKey ( ) . substring ( 1 ) , field . getType ( ) ) ; if ( setter == null ) { throw new CitrusRuntimeException ( String . format ( "Unable to find parameter setter on endpoint configuration '%s'" , "set" + parameterEntry . getKey ( ) . substring ( 0 , 1 ) . toUpperCase ( ) + parameterEntry . getKey ( ) . substring ( 1 ) ) ) ; } if ( parameterEntry . getValue ( ) != null ) { ReflectionUtils . invokeMethod ( setter , endpointConfiguration , TypeConversionUtils . convertStringToType ( parameterEntry . getValue ( ) , field . getType ( ) , context ) ) ; } else { ReflectionUtils . invokeMethod ( setter , endpointConfiguration , field . getType ( ) . cast ( null ) ) ; } } }
Sets properties on endpoint configuration using method reflection .
357
10
28,225
protected Map < String , String > getEndpointConfigurationParameters ( Map < String , String > parameters , Class < ? extends EndpointConfiguration > endpointConfigurationType ) { Map < String , String > params = new HashMap < String , String > ( ) ; for ( Map . Entry < String , String > parameterEntry : parameters . entrySet ( ) ) { Field field = ReflectionUtils . findField ( endpointConfigurationType , parameterEntry . getKey ( ) ) ; if ( field != null ) { params . put ( parameterEntry . getKey ( ) , parameterEntry . getValue ( ) ) ; } } return params ; }
Removes non config parameters from list of endpoint parameters according to given endpoint configuration type . All parameters that do not reside to a endpoint configuration setting are removed so the result is a qualified list of endpoint configuration parameters .
132
42
28,226
protected String getParameterString ( Map < String , String > parameters , Class < ? extends EndpointConfiguration > endpointConfigurationType ) { StringBuilder paramString = new StringBuilder ( ) ; for ( Map . Entry < String , String > parameterEntry : parameters . entrySet ( ) ) { Field field = ReflectionUtils . findField ( endpointConfigurationType , parameterEntry . getKey ( ) ) ; if ( field == null ) { if ( paramString . length ( ) == 0 ) { paramString . append ( "?" ) . append ( parameterEntry . getKey ( ) ) ; if ( parameterEntry . getValue ( ) != null ) { paramString . append ( "=" ) . append ( parameterEntry . getValue ( ) ) ; } } else { paramString . append ( "&" ) . append ( parameterEntry . getKey ( ) ) ; if ( parameterEntry . getValue ( ) != null ) { paramString . append ( "=" ) . append ( parameterEntry . getValue ( ) ) ; } } } } return paramString . toString ( ) ; }
Filters non endpoint configuration parameters from parameter list and puts them together as parameters string . According to given endpoint configuration type only non endpoint configuration settings are added to parameter string .
227
34
28,227
private com . github . dockerjava . api . DockerClient createDockerClient ( ) { return DockerClientImpl . getInstance ( getDockerClientConfig ( ) ) . withDockerCmdExecFactory ( new JerseyDockerCmdExecFactory ( ) ) ; }
Creates new Docker client instance with configuration .
55
9
28,228
public com . github . dockerjava . api . DockerClient getDockerClient ( ) { if ( dockerClient == null ) { dockerClient = createDockerClient ( ) ; } return dockerClient ; }
Constructs or gets the docker client implementation .
43
9
28,229
private void purgeQueue ( String queueName , Session session ) throws JMSException { purgeDestination ( getDestination ( session , queueName ) , session , queueName ) ; }
Purges a queue destination identified by its name .
38
10
28,230
private void purgeQueue ( Queue queue , Session session ) throws JMSException { purgeDestination ( queue , session , queue . getQueueName ( ) ) ; }
Purges a queue destination .
35
6
28,231
private void purgeDestination ( Destination destination , Session session , String destinationName ) throws JMSException { if ( log . isDebugEnabled ( ) ) { log . debug ( "Try to purge destination " + destinationName ) ; } int messagesPurged = 0 ; MessageConsumer messageConsumer = session . createConsumer ( destination ) ; try { javax . jms . Message message ; do { message = ( receiveTimeout >= 0 ) ? messageConsumer . receive ( receiveTimeout ) : messageConsumer . receive ( ) ; if ( message != null ) { log . debug ( "Removed message from destination " + destinationName ) ; 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 destination" ) ; } } finally { JmsUtils . closeMessageConsumer ( messageConsumer ) ; } }
Purge destination by receiving all available messages .
227
9
28,232
private Destination getDestination ( Session session , String queueName ) throws JMSException { return new DynamicDestinationResolver ( ) . resolveDestinationName ( session , queueName , false ) ; }
Resolves destination by given name .
42
7
28,233
protected Connection createConnection ( ) throws JMSException { if ( connectionFactory instanceof QueueConnectionFactory ) { return ( ( QueueConnectionFactory ) connectionFactory ) . createQueueConnection ( ) ; } return connectionFactory . createConnection ( ) ; }
Create queue connection .
52
4
28,234
protected Session createSession ( Connection connection ) throws JMSException { if ( connection instanceof QueueConnection ) { return ( ( QueueConnection ) connection ) . createQueueSession ( false , Session . AUTO_ACKNOWLEDGE ) ; } return connection . createSession ( false , Session . AUTO_ACKNOWLEDGE ) ; }
Create queue session .
71
4
28,235
public SecurityHandler getObject ( ) throws Exception { ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler ( ) ; securityHandler . setAuthenticator ( authenticator ) ; securityHandler . setRealmName ( realm ) ; for ( Entry < String , Constraint > constraint : constraints . entrySet ( ) ) { ConstraintMapping constraintMapping = new ConstraintMapping ( ) ; constraintMapping . setConstraint ( constraint . getValue ( ) ) ; constraintMapping . setPathSpec ( constraint . getKey ( ) ) ; securityHandler . addConstraintMapping ( constraintMapping ) ; } securityHandler . setLoginService ( loginService ) ; return securityHandler ; }
Construct new security handler for basic authentication .
152
8
28,236
public void afterPropertiesSet ( ) throws Exception { if ( loginService == null ) { loginService = new SimpleLoginService ( ) ; ( ( SimpleLoginService ) loginService ) . setName ( realm ) ; } }
Initialize member variables if not set by user in application context .
47
13
28,237
private void writeFtpReply ( FtpSession session , FtpMessage response ) { try { CommandResultType commandResult = response . getPayload ( CommandResultType . class ) ; FtpReply reply = new DefaultFtpReply ( Integer . valueOf ( commandResult . getReplyCode ( ) ) , commandResult . getReplyString ( ) ) ; session . write ( reply ) ; } catch ( FtpException e ) { throw new CitrusRuntimeException ( "Failed to write ftp reply" , e ) ; } }
Construct ftp reply from response message and write reply to given session .
113
14
28,238
public static List < String > getParameterList ( String parameterString ) { List < String > parameterList = new ArrayList <> ( ) ; StringTokenizer tok = new StringTokenizer ( parameterString , "," ) ; while ( tok . hasMoreElements ( ) ) { String param = tok . nextToken ( ) . trim ( ) ; parameterList . add ( cutOffSingleQuotes ( param ) ) ; } List < String > postProcessed = new ArrayList <> ( ) ; for ( int i = 0 ; i < parameterList . size ( ) ; i ++ ) { int next = i + 1 ; String processed = parameterList . get ( i ) ; if ( processed . startsWith ( "'" ) && ! processed . endsWith ( "'" ) ) { while ( next < parameterList . size ( ) ) { if ( parameterString . contains ( processed + ", " + parameterList . get ( next ) ) ) { processed += ", " + parameterList . get ( next ) ; } else if ( parameterString . contains ( processed + "," + parameterList . get ( next ) ) ) { processed += "," + parameterList . get ( next ) ; } else if ( parameterString . contains ( processed + " , " + parameterList . get ( next ) ) ) { processed += " , " + parameterList . get ( next ) ; } else { processed += parameterList . get ( next ) ; } i ++ ; if ( parameterList . get ( next ) . endsWith ( "'" ) ) { break ; } else { next ++ ; } } } postProcessed . add ( cutOffSingleQuotes ( processed ) ) ; } return postProcessed ; }
Convert a parameter string to a list of parameters .
358
11
28,239
protected void executeActions ( TestContext context ) { context . setVariable ( indexName , String . valueOf ( index ) ) ; for ( TestAction action : actions ) { setActiveAction ( action ) ; action . execute ( context ) ; } }
Executes the nested test actions .
53
7
28,240
protected boolean checkCondition ( TestContext context ) { if ( conditionExpression != null ) { return conditionExpression . evaluate ( index , context ) ; } // replace dynamic content with each iteration String conditionString = condition ; if ( conditionString . indexOf ( Citrus . VARIABLE_PREFIX + indexName + Citrus . VARIABLE_SUFFIX ) != - 1 ) { Properties props = new Properties ( ) ; props . put ( indexName , String . valueOf ( index ) ) ; conditionString = new PropertyPlaceholderHelper ( Citrus . VARIABLE_PREFIX , Citrus . VARIABLE_SUFFIX ) . replacePlaceholders ( conditionString , props ) ; } conditionString = context . replaceDynamicContentInString ( conditionString ) ; if ( ValidationMatcherUtils . isValidationMatcherExpression ( conditionString ) ) { try { ValidationMatcherUtils . resolveValidationMatcher ( "iteratingCondition" , String . valueOf ( index ) , conditionString , context ) ; return true ; } catch ( AssertionError e ) { return false ; } } if ( conditionString . indexOf ( indexName ) != - 1 ) { conditionString = conditionString . replaceAll ( indexName , String . valueOf ( index ) ) ; } return BooleanExpressionParser . evaluate ( conditionString ) ; }
Check aborting condition .
295
5
28,241
private ObjectFactory getObjectFactory ( ) throws IllegalAccessException { if ( Env . INSTANCE . get ( ObjectFactory . class . getName ( ) ) . equals ( CitrusObjectFactory . class . getName ( ) ) ) { return CitrusObjectFactory . instance ( ) ; } else if ( Env . INSTANCE . get ( ObjectFactory . class . getName ( ) ) . equals ( CitrusSpringObjectFactory . class . getName ( ) ) ) { return CitrusSpringObjectFactory . instance ( ) ; } return ObjectFactoryLoader . loadObjectFactory ( new ResourceLoaderClassFinder ( resourceLoader , Thread . currentThread ( ) . getContextClassLoader ( ) ) , Env . INSTANCE . get ( ObjectFactory . class . getName ( ) ) ) ; }
Gets the object factory instance that is configured in environment .
167
12
28,242
public static void initializeCitrus ( ApplicationContext applicationContext ) { if ( citrus != null ) { if ( ! citrus . getApplicationContext ( ) . equals ( applicationContext ) ) { log . warn ( "Citrus instance has already been initialized - creating new instance and shutting down current instance" ) ; if ( citrus . getApplicationContext ( ) instanceof ConfigurableApplicationContext ) { ( ( ConfigurableApplicationContext ) citrus . getApplicationContext ( ) ) . stop ( ) ; } } else { return ; } } citrus = Citrus . newInstance ( applicationContext ) ; }
Initializes Citrus instance with given application context .
122
10
28,243
protected void executeStatements ( TestContext context ) { for ( String stmt : statements ) { try { final String toExecute ; if ( stmt . trim ( ) . endsWith ( ";" ) ) { toExecute = context . replaceDynamicContentInString ( stmt . trim ( ) . substring ( 0 , stmt . trim ( ) . length ( ) - 1 ) ) ; } else { toExecute = context . replaceDynamicContentInString ( stmt . trim ( ) ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Executing SQL statement: " + toExecute ) ; } getJdbcTemplate ( ) . execute ( toExecute ) ; log . info ( "SQL statement execution successful" ) ; } catch ( Exception e ) { if ( ignoreErrors ) { log . error ( "Ignoring error while executing SQL statement: " + e . getLocalizedMessage ( ) ) ; continue ; } else { throw new CitrusRuntimeException ( e ) ; } } } }
Run all SQL statements .
222
5
28,244
private void dispatch ( final ProcessingMessage message ) throws ProcessingException { final LogLevel level = message . getLogLevel ( ) ; if ( level . compareTo ( exceptionThreshold ) >= 0 ) throw message . asException ( ) ; if ( level . compareTo ( currentLevel ) > 0 ) currentLevel = level ; if ( level . compareTo ( logLevel ) >= 0 ) log ( message ) ; }
Main dispatch method
85
3
28,245
private void addRequestCachingFilter ( ) { FilterMapping filterMapping = new FilterMapping ( ) ; filterMapping . setFilterName ( "request-caching-filter" ) ; filterMapping . setPathSpec ( "/*" ) ; FilterHolder filterHolder = new FilterHolder ( new RequestCachingServletFilter ( ) ) ; filterHolder . setName ( "request-caching-filter" ) ; servletHandler . addFilter ( filterHolder , filterMapping ) ; }
Adds request caching filter used for not using request data when logging incoming requests
112
14
28,246
private void addGzipFilter ( ) { FilterMapping filterMapping = new FilterMapping ( ) ; filterMapping . setFilterName ( "gzip-filter" ) ; filterMapping . setPathSpec ( "/*" ) ; FilterHolder filterHolder = new FilterHolder ( new GzipServletFilter ( ) ) ; filterHolder . setName ( "gzip-filter" ) ; servletHandler . addFilter ( filterHolder , filterMapping ) ; }
Adds gzip filter for automatic response messages compressing .
106
11
28,247
private boolean containsNode ( NodeList findings , Node node ) { for ( int i = 0 ; i < findings . getLength ( ) ; i ++ ) { if ( findings . item ( i ) . equals ( node ) ) { return true ; } } return false ; }
Checks if given node set contains node .
57
9
28,248
private NamespaceContext buildNamespaceContext ( Node node ) { SimpleNamespaceContext simpleNamespaceContext = new SimpleNamespaceContext ( ) ; Map < String , String > namespaces = XMLUtils . lookupNamespaces ( node . getOwnerDocument ( ) ) ; // add default namespace mappings namespaces . putAll ( namespaceContextBuilder . getNamespaceMappings ( ) ) ; simpleNamespaceContext . setBindings ( namespaces ) ; return simpleNamespaceContext ; }
Builds namespace context with dynamic lookup on received node document and global namespace mappings from namespace context builder .
101
21
28,249
public Delete delete ( String path ) { Delete command = new Delete ( ) ; command . path ( path ) ; command . version ( DEFAULT_VERSION ) ; action . setCommand ( command ) ; return command ; }
Adds a delete command .
45
5
28,250
public GetData get ( String path ) { GetData command = new GetData ( ) ; command . path ( path ) ; action . setCommand ( command ) ; return command ; }
Adds a get - data command .
38
7
28,251
public SetData set ( String path , String data ) { SetData command = new SetData ( ) ; command . path ( path ) ; command . data ( data ) ; command . version ( 0 ) ; action . setCommand ( command ) ; return command ; }
Adds a set - data command .
55
7
28,252
public boolean handleRequest ( MessageContext messageContext ) throws WebServiceClientException { try { logRequest ( "Sending SOAP request" , messageContext , false ) ; } catch ( SoapEnvelopeException e ) { log . warn ( "Unable to write SOAP request to logger" , e ) ; } catch ( TransformerException e ) { log . warn ( "Unable to write SOAP request to logger" , e ) ; } return true ; }
Write SOAP request to logger before sending .
99
9
28,253
public boolean handleResponse ( MessageContext messageContext ) throws WebServiceClientException { try { logResponse ( "Received SOAP response" , messageContext , true ) ; } catch ( SoapEnvelopeException e ) { log . warn ( "Unable to write SOAP response to logger" , e ) ; } catch ( TransformerException e ) { log . warn ( "Unable to write SOAP response to logger" , e ) ; } return true ; }
Write SOAP response to logger .
99
7
28,254
public GroovyActionBuilder script ( Resource scriptResource , Charset charset ) { try { action . setScript ( FileUtils . readToString ( scriptResource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read script resource file" , e ) ; } return this ; }
Sets the Groovy script to execute .
74
9
28,255
public GroovyActionBuilder template ( Resource scriptTemplate , Charset charset ) { try { action . setScriptTemplate ( FileUtils . readToString ( scriptTemplate , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read script template file" , e ) ; } return this ; }
Use a script template resource .
75
6
28,256
private Object getObjectInstanceFromClass ( TestContext context ) throws ClassNotFoundException , SecurityException , NoSuchMethodException , IllegalArgumentException , InstantiationException , IllegalAccessException , InvocationTargetException { if ( ! StringUtils . hasText ( className ) ) { throw new CitrusRuntimeException ( "Neither class name nor object instance reference " + "is set for Java reflection call" ) ; } log . info ( "Instantiating class for name '" + className + "'" ) ; Class < ? > classToRun = Class . forName ( className ) ; Class < ? > [ ] constructorTypes = new Class < ? > [ constructorArgs . size ( ) ] ; Object [ ] constructorObjects = new Object [ constructorArgs . size ( ) ] ; for ( int i = 0 ; i < constructorArgs . size ( ) ; i ++ ) { constructorTypes [ i ] = constructorArgs . get ( i ) . getClass ( ) ; if ( constructorArgs . get ( i ) . getClass ( ) . equals ( String . class ) ) { constructorObjects [ i ] = context . replaceDynamicContentInString ( constructorArgs . get ( i ) . toString ( ) ) ; } else { constructorObjects [ i ] = constructorArgs . get ( i ) ; } } Constructor < ? > constr = classToRun . getConstructor ( constructorTypes ) ; return constr . newInstance ( constructorObjects ) ; }
Instantiate class for name . Constructor arguments are supported if specified .
310
14
28,257
public void onInboundMessage ( Message message , TestContext context ) { if ( message != null ) { for ( MessageListener listener : messageListener ) { listener . onInboundMessage ( message , context ) ; } } }
Delegate to all known message listener instances .
47
9
28,258
private String removeCDataElements ( String value ) { String data = value . trim ( ) ; if ( data . startsWith ( CDATA_SECTION_START ) ) { data = value . substring ( CDATA_SECTION_START . length ( ) ) ; data = data . substring ( 0 , data . length ( ) - CDATA_SECTION_END . length ( ) ) ; } return data ; }
Cut off CDATA elements .
93
6
28,259
public void afterPropertiesSet ( ) throws Exception { // try to find xml message validator in registry for ( MessageValidator < ? extends ValidationContext > messageValidator : messageValidatorRegistry . getMessageValidators ( ) ) { if ( messageValidator instanceof DomXmlMessageValidator && messageValidator . supportsMessageType ( MessageType . XML . name ( ) , new DefaultMessage ( "" ) ) ) { xmlMessageValidator = ( DomXmlMessageValidator ) messageValidator ; } } if ( xmlMessageValidator == null ) { LOG . warn ( "No XML message validator found in Spring bean context - setting default validator" ) ; xmlMessageValidator = new DomXmlMessageValidator ( ) ; xmlMessageValidator . setApplicationContext ( applicationContext ) ; } }
Initialize xml message validator if not injected by Spring bean context .
173
14
28,260
private String appendRequestPath ( String uri , Map < String , Object > headers ) { if ( ! headers . containsKey ( REQUEST_PATH_HEADER_NAME ) ) { return uri ; } String requestUri = uri ; String path = headers . get ( REQUEST_PATH_HEADER_NAME ) . toString ( ) ; while ( requestUri . endsWith ( "/" ) ) { requestUri = requestUri . substring ( 0 , requestUri . length ( ) - 1 ) ; } while ( path . startsWith ( "/" ) && path . length ( ) > 0 ) { path = path . length ( ) == 1 ? "" : path . substring ( 1 ) ; } return requestUri + "/" + path ; }
Appends optional request path to endpoint uri .
166
10
28,261
public void saveReplyDestination ( JmsMessage jmsMessage , TestContext context ) { if ( jmsMessage . getReplyTo ( ) != null ) { String correlationKeyName = endpointConfiguration . getCorrelator ( ) . getCorrelationKeyName ( getName ( ) ) ; String correlationKey = endpointConfiguration . getCorrelator ( ) . getCorrelationKey ( jmsMessage ) ; correlationManager . saveCorrelationKey ( correlationKeyName , correlationKey , context ) ; correlationManager . store ( correlationKey , jmsMessage . getReplyTo ( ) ) ; } else { log . warn ( "Unable to retrieve reply to destination for message \n" + jmsMessage + "\n - no reply to destination found in message headers!" ) ; } }
Store the reply destination either straight forward or with a given message correlation key .
163
15
28,262
protected void validateAttachmentContentData ( String receivedContent , String controlContent , String controlContentId ) { if ( ignoreAllWhitespaces ) { controlContent = StringUtils . trimAllWhitespace ( controlContent ) ; receivedContent = StringUtils . trimAllWhitespace ( receivedContent ) ; } Assert . isTrue ( receivedContent . equals ( controlContent ) , "Values not equal for attachment content '" + controlContentId + "', expected '" + controlContent . trim ( ) + "' but was '" + receivedContent . trim ( ) + "'" ) ; }
Validates content data .
126
5
28,263
public RmiServerBuilder remoteInterfaces ( Class < ? extends Remote > ... remoteInterfaces ) { endpoint . setRemoteInterfaces ( Arrays . asList ( remoteInterfaces ) ) ; return this ; }
Sets the remote interfaces property .
44
7
28,264
private void sendOrPublishMessage ( Message message ) { if ( endpointConfiguration . isPubSubDomain ( ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Publish Vert.x event bus message to address: '" + endpointConfiguration . getAddress ( ) + "'" ) ; } vertx . eventBus ( ) . publish ( endpointConfiguration . getAddress ( ) , message . getPayload ( ) ) ; } else { if ( log . isDebugEnabled ( ) ) { log . debug ( "Sending Vert.x event bus message to address: '" + endpointConfiguration . getAddress ( ) + "'" ) ; } vertx . eventBus ( ) . send ( endpointConfiguration . getAddress ( ) , message . getPayload ( ) ) ; } }
Sends or publishes new outbound message depending on eventbus nature .
170
14
28,265
public Type [ ] getParameterTypes ( ) { Type [ ] types = new Type [ parameterNames . size ( ) ] ; for ( int i = 0 ; i < types . length ; i ++ ) { types [ i ] = String . class ; } return types ; }
Provide parameter types for this step .
57
8
28,266
public Message < ? > receive ( MessageSelector selector ) { Object [ ] array = this . queue . toArray ( ) ; for ( Object o : array ) { Message < ? > message = ( Message < ? > ) o ; if ( selector . accept ( message ) && this . queue . remove ( message ) ) { return message ; } } return null ; }
Supports selective consumption of messages on the channel . The first message to be accepted by given message selector is returned as result .
77
25
28,267
public Message < ? > receive ( MessageSelector selector , long timeout ) { long timeLeft = timeout ; Message < ? > message = receive ( selector ) ; while ( message == null && timeLeft > 0 ) { timeLeft -= pollingInterval ; if ( RETRY_LOG . isDebugEnabled ( ) ) { RETRY_LOG . debug ( "No message received with message selector - retrying in " + ( timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft ) + "ms" ) ; } try { Thread . sleep ( timeLeft > 0 ? pollingInterval : pollingInterval + timeLeft ) ; } catch ( InterruptedException e ) { RETRY_LOG . warn ( "Thread interrupted while waiting for retry" , e ) ; } message = receive ( selector ) ; } return message ; }
Consume messages on the channel via message selector . Timeout forces several retries with polling interval setting .
175
21
28,268
public void setInterceptors ( List < ClientInterceptor > interceptors ) { this . interceptors = interceptors ; getWebServiceTemplate ( ) . setInterceptors ( interceptors . toArray ( new ClientInterceptor [ interceptors . size ( ) ] ) ) ; }
Sets the client interceptors .
59
7
28,269
protected String randomValue ( List < String > values ) { if ( values == null || values . isEmpty ( ) ) { throw new InvalidFunctionUsageException ( "No values to choose from" ) ; } final int idx = random . nextInt ( values . size ( ) ) ; return values . get ( idx ) ; }
Pseudo - randomly choose one of the supplied values and return it .
70
15
28,270
public SeleniumActionBuilder navigate ( String page ) { NavigateAction action = new NavigateAction ( ) ; action . setPage ( page ) ; action ( action ) ; return this ; }
Navigate action .
40
4
28,271
public ElementActionBuilder select ( String option ) { DropDownSelectAction action = new DropDownSelectAction ( ) ; action . setOption ( option ) ; action ( action ) ; return new ElementActionBuilder ( action ) ; }
Dropdown select single option action .
47
7
28,272
public ElementActionBuilder select ( String ... options ) { DropDownSelectAction action = new DropDownSelectAction ( ) ; action . setOptions ( Arrays . asList ( options ) ) ; action ( action ) ; return new ElementActionBuilder ( action ) ; }
Dropdown select multiple options action .
55
7
28,273
public ElementActionBuilder setInput ( String value ) { SetInputAction action = new SetInputAction ( ) ; action . setValue ( value ) ; action ( action ) ; return new ElementActionBuilder ( action ) ; }
Set input action .
46
4
28,274
public ElementActionBuilder checkInput ( boolean checked ) { CheckInputAction action = new CheckInputAction ( ) ; action . setChecked ( checked ) ; action ( action ) ; return new ElementActionBuilder ( action ) ; }
Check input action .
47
4
28,275
public SeleniumActionBuilder screenshot ( String outputDir ) { MakeScreenshotAction action = new MakeScreenshotAction ( ) ; action . setOutputDir ( outputDir ) ; action ( action ) ; return this ; }
Make screenshot with custom output directory .
43
7
28,276
public SeleniumActionBuilder store ( String filePath ) { StoreFileAction action = new StoreFileAction ( ) ; action . setFilePath ( filePath ) ; action ( action ) ; return this ; }
Store file .
43
3
28,277
public SeleniumActionBuilder getStored ( String fileName ) { GetStoredFileAction action = new GetStoredFileAction ( ) ; action . setFileName ( fileName ) ; action ( action ) ; return this ; }
Get stored file .
49
4
28,278
private < T extends SeleniumAction > T action ( T delegate ) { if ( seleniumBrowser != null ) { delegate . setBrowser ( seleniumBrowser ) ; } action . setDelegate ( delegate ) ; return delegate ; }
Prepare selenium action .
50
7
28,279
public Message createMessage ( final String messageName ) { final Message [ ] message = { null } ; for ( final Object messageCreator : messageCreators ) { ReflectionUtils . doWithMethods ( messageCreator . getClass ( ) , new ReflectionUtils . MethodCallback ( ) { @ Override public void doWith ( Method method ) throws IllegalArgumentException , IllegalAccessException { if ( method . getAnnotation ( MessageCreator . class ) . value ( ) . equals ( messageName ) ) { try { message [ 0 ] = ( Message ) method . invoke ( messageCreator ) ; } catch ( InvocationTargetException e ) { throw new CitrusRuntimeException ( "Unsupported message creator method: " + method . getName ( ) , e ) ; } } } } , new ReflectionUtils . MethodFilter ( ) { @ Override public boolean matches ( Method method ) { return method . getAnnotationsByType ( MessageCreator . class ) . length > 0 ; } } ) ; } if ( message [ 0 ] == null ) { throw new CitrusRuntimeException ( "Unable to find message creator for message: " + messageName ) ; } return message [ 0 ] ; }
Create message by delegating message creation to known message creators that are able to create message with given name .
258
21
28,280
public void addType ( String type ) { try { messageCreators . add ( Class . forName ( type ) . newInstance ( ) ) ; } catch ( ClassNotFoundException | IllegalAccessException e ) { throw new CitrusRuntimeException ( "Unable to access message creator type: " + type , e ) ; } catch ( InstantiationException e ) { throw new CitrusRuntimeException ( "Unable to create message creator instance of type: " + type , e ) ; } }
Adds new message creator POJO instance from type .
104
10
28,281
private boolean checkAnswer ( String input ) { StringTokenizer tok = new StringTokenizer ( validAnswers , ANSWER_SEPARATOR ) ; while ( tok . hasMoreTokens ( ) ) { if ( tok . nextElement ( ) . toString ( ) . trim ( ) . equalsIgnoreCase ( input . trim ( ) ) ) { return true ; } } log . info ( "User input is not valid - must be one of " + validAnswers ) ; return false ; }
Validate given input according to valid answer tokens .
108
10
28,282
public T message ( Message controlMessage ) { StaticMessageContentBuilder staticMessageContentBuilder = StaticMessageContentBuilder . withMessage ( controlMessage ) ; staticMessageContentBuilder . setMessageHeaders ( getMessageContentBuilder ( ) . getMessageHeaders ( ) ) ; getAction ( ) . setMessageBuilder ( staticMessageContentBuilder ) ; return self ; }
Expect a control message in this receive action .
74
10
28,283
protected void setPayload ( String payload ) { MessageContentBuilder messageContentBuilder = getMessageContentBuilder ( ) ; if ( messageContentBuilder instanceof PayloadTemplateMessageBuilder ) { ( ( PayloadTemplateMessageBuilder ) messageContentBuilder ) . setPayloadData ( payload ) ; } else if ( messageContentBuilder instanceof StaticMessageContentBuilder ) { ( ( StaticMessageContentBuilder ) messageContentBuilder ) . getMessage ( ) . setPayload ( payload ) ; } else { throw new CitrusRuntimeException ( "Unable to set payload on message builder type: " + messageContentBuilder . getClass ( ) ) ; } }
Sets the payload data on the message builder implementation .
133
11
28,284
public T payload ( Resource payloadResource , Charset charset ) { try { setPayload ( FileUtils . readToString ( payloadResource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read payload resource" , e ) ; } return self ; }
Expect this message payload data in received message .
69
10
28,285
public T payload ( Object payload , Marshaller marshaller ) { StringResult result = new StringResult ( ) ; try { marshaller . marshal ( payload , result ) ; } catch ( XmlMappingException e ) { throw new CitrusRuntimeException ( "Failed to marshal object graph for message payload" , e ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to marshal object graph for message payload" , e ) ; } setPayload ( result . toString ( ) ) ; return self ; }
Expect this message payload as model object which is marshalled to a character sequence using the default object to xml mapper before validation is performed .
120
29
28,286
public T payload ( Object payload , ObjectMapper objectMapper ) { try { setPayload ( objectMapper . writer ( ) . writeValueAsString ( payload ) ) ; } catch ( JsonProcessingException e ) { throw new CitrusRuntimeException ( "Failed to map object graph for message payload" , e ) ; } return self ; }
Expect this message payload as model object which is mapped to a character sequence using the default object to json mapper before validation is performed .
76
28
28,287
public T payloadModel ( Object payload ) { Assert . notNull ( applicationContext , "Citrus application context is not initialized!" ) ; if ( ! CollectionUtils . isEmpty ( applicationContext . getBeansOfType ( Marshaller . class ) ) ) { return payload ( payload , applicationContext . getBean ( Marshaller . class ) ) ; } else if ( ! CollectionUtils . isEmpty ( applicationContext . getBeansOfType ( ObjectMapper . class ) ) ) { return payload ( payload , applicationContext . getBean ( ObjectMapper . class ) ) ; } throw new CitrusRuntimeException ( "Unable to find default object mapper or marshaller in application context" ) ; }
Expect this message payload as model object which is marshalled to a character sequence using the default object to xml mapper that is available in Spring bean application context .
154
33
28,288
public T header ( String name , Object value ) { getMessageContentBuilder ( ) . getMessageHeaders ( ) . put ( name , value ) ; return self ; }
Expect this message header entry in received message .
36
10
28,289
public T headers ( Map < String , Object > headers ) { getMessageContentBuilder ( ) . getMessageHeaders ( ) . putAll ( headers ) ; return self ; }
Expect this message header entries in received message .
37
10
28,290
public T headerFragment ( Object model ) { Assert . notNull ( applicationContext , "Citrus application context is not initialized!" ) ; if ( ! CollectionUtils . isEmpty ( applicationContext . getBeansOfType ( Marshaller . class ) ) ) { return headerFragment ( model , applicationContext . getBean ( Marshaller . class ) ) ; } else if ( ! CollectionUtils . isEmpty ( applicationContext . getBeansOfType ( ObjectMapper . class ) ) ) { return headerFragment ( model , applicationContext . getBean ( ObjectMapper . class ) ) ; } throw new CitrusRuntimeException ( "Unable to find default object mapper or marshaller in application context" ) ; }
Expect this message header data as model object which is marshalled to a character sequence using the default object to xml mapper that is available in Spring bean application context .
159
34
28,291
public T headerFragment ( Object model , String mapperName ) { Assert . notNull ( applicationContext , "Citrus application context is not initialized!" ) ; if ( applicationContext . containsBean ( mapperName ) ) { Object mapper = applicationContext . getBean ( mapperName ) ; if ( Marshaller . class . isAssignableFrom ( mapper . getClass ( ) ) ) { return headerFragment ( model , ( Marshaller ) mapper ) ; } else if ( ObjectMapper . class . isAssignableFrom ( mapper . getClass ( ) ) ) { return headerFragment ( model , ( ObjectMapper ) mapper ) ; } else { throw new CitrusRuntimeException ( String . format ( "Invalid bean type for mapper '%s' expected ObjectMapper or Marshaller but was '%s'" , mapperName , mapper . getClass ( ) ) ) ; } } throw new CitrusRuntimeException ( "Unable to find default object mapper or marshaller in application context" ) ; }
Expect this message header data as model object which is marshalled to a character sequence using the given object to xml mapper that is accessed by its bean name in Spring bean application context .
229
38
28,292
public T headerFragment ( Object model , Marshaller marshaller ) { StringResult result = new StringResult ( ) ; try { marshaller . marshal ( model , result ) ; } catch ( XmlMappingException e ) { throw new CitrusRuntimeException ( "Failed to marshal object graph for message header data" , e ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to marshal object graph for message header data" , e ) ; } return header ( result . toString ( ) ) ; }
Expect this message header data as model object which is marshalled to a character sequence using the default object to xml mapper before validation is performed .
120
30
28,293
public T headerFragment ( Object model , ObjectMapper objectMapper ) { try { return header ( objectMapper . writer ( ) . writeValueAsString ( model ) ) ; } catch ( JsonProcessingException e ) { throw new CitrusRuntimeException ( "Failed to map object graph for message header data" , e ) ; } }
Expect this message header data as model object which is mapped to a character sequence using the default object to json mapper before validation is performed .
75
29
28,294
public T header ( Resource resource , Charset charset ) { try { getMessageContentBuilder ( ) . getHeaderData ( ) . add ( FileUtils . readToString ( resource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read header resource" , e ) ; } return self ; }
Expect this message header data in received message from file resource . Message header data is used in SOAP messages as XML fragment for instance .
78
28
28,295
public T validateScript ( Resource scriptResource , Charset charset ) { try { validateScript ( FileUtils . readToString ( scriptResource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read script resource file" , e ) ; } return self ; }
Reads validation script file resource and sets content as validation script .
70
13
28,296
public T messageType ( String messageType ) { this . messageType = messageType ; getAction ( ) . setMessageType ( messageType ) ; if ( getAction ( ) . getValidationContexts ( ) . isEmpty ( ) ) { getAction ( ) . getValidationContexts ( ) . add ( headerValidationContext ) ; getAction ( ) . getValidationContexts ( ) . add ( xmlMessageValidationContext ) ; getAction ( ) . getValidationContexts ( ) . add ( jsonMessageValidationContext ) ; } return self ; }
Sets a explicit message type for this receive action .
122
11
28,297
public T validateNamespace ( String prefix , String namespaceUri ) { xmlMessageValidationContext . getControlNamespaces ( ) . put ( prefix , namespaceUri ) ; return self ; }
Validates XML namespace with prefix and uri .
41
10
28,298
public T validate ( String path , Object controlValue ) { if ( JsonPathMessageValidationContext . isJsonPathExpression ( path ) ) { getJsonPathValidationContext ( ) . getJsonPathExpressions ( ) . put ( path , controlValue ) ; } else { getXPathValidationContext ( ) . getXpathExpressions ( ) . put ( path , controlValue ) ; } return self ; }
Adds message element validation .
93
5
28,299
public T ignore ( String path ) { if ( messageType . equalsIgnoreCase ( MessageType . XML . name ( ) ) || messageType . equalsIgnoreCase ( MessageType . XHTML . name ( ) ) ) { xmlMessageValidationContext . getIgnoreExpressions ( ) . add ( path ) ; } else if ( messageType . equalsIgnoreCase ( MessageType . JSON . name ( ) ) ) { jsonMessageValidationContext . getIgnoreExpressions ( ) . add ( path ) ; } return self ; }
Adds ignore path expression for message element .
114
8