idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
28,400 | public DataSet createDataSet ( final Message response , final MessageType messageType ) { try { if ( response . getPayload ( ) instanceof DataSet ) { return response . getPayload ( DataSet . class ) ; } else if ( isReadyToMarshal ( response , messageType ) ) { return marshalResponse ( response , messageType ) ; } else { return new DataSet ( ) ; } } catch ( final SQLException e ) { throw new CitrusRuntimeException ( "Failed to read dataSet from response message" , e ) ; } } | Converts Citrus result set representation to db driver model result set . |
28,401 | private DataSet marshalResponse ( final Message response , final MessageType messageType ) throws SQLException { String dataSet = null ; if ( response instanceof JdbcMessage || response . getPayload ( ) instanceof OperationResult ) { dataSet = response . getPayload ( OperationResult . class ) . getDataSet ( ) ; } else { try { JdbcMarshaller jdbcMarshaller = new JdbcMarshaller ( ) ; jdbcMarshaller . setType ( messageType . name ( ) ) ; Object object = jdbcMarshaller . unmarshal ( new StringSource ( response . getPayload ( String . class ) ) ) ; if ( object instanceof OperationResult && StringUtils . hasText ( ( ( OperationResult ) object ) . getDataSet ( ) ) ) { dataSet = ( ( OperationResult ) object ) . getDataSet ( ) ; } } catch ( CitrusRuntimeException e ) { dataSet = response . getPayload ( String . class ) ; } } if ( isJsonResponse ( messageType ) ) { return new JsonDataSetProducer ( Optional . ofNullable ( dataSet ) . orElse ( "[]" ) ) . produce ( ) ; } else if ( isXmlResponse ( messageType ) ) { return new XmlDataSetProducer ( Optional . ofNullable ( dataSet ) . orElse ( "<dataset></dataset>" ) ) . produce ( ) ; } else { throw new CitrusRuntimeException ( "Unable to create dataSet from data type " + messageType . name ( ) ) ; } } | Marshals the given message to the requested MessageType |
28,402 | public boolean canValidate ( Document doc ) { XsdSchema schema = schemaMappingStrategy . getSchema ( schemas , doc ) ; return schema != null ; } | Find the matching schema for document using given schema mapping strategy . |
28,403 | protected void addCitrusSchema ( String schemaName ) throws IOException , SAXException , ParserConfigurationException { Resource resource = new PathMatchingResourcePatternResolver ( ) . getResource ( "classpath:com/consol/citrus/schema/" + schemaName + ".xsd" ) ; if ( resource . exists ( ) ) { addXsdSchema ( resource ) ; } } | Adds Citrus message schema to repository if available on classpath . |
28,404 | private void copyToStream ( String txt , OutputStream stream ) throws IOException { if ( txt != null ) { stream . write ( txt . getBytes ( ) ) ; } } | Copy character sequence to outbput stream . |
28,405 | public void addControl ( Control control ) { if ( controls == null ) { controls = new FormData . Controls ( ) ; } this . controls . add ( control ) ; } | Adds new form control . |
28,406 | public List < SimpleJsonSchema > filter ( List < JsonSchemaRepository > schemaRepositories , JsonMessageValidationContext jsonMessageValidationContext , ApplicationContext applicationContext ) { if ( isSchemaRepositorySpecified ( jsonMessageValidationContext ) ) { return filterByRepositoryName ( schemaRepositories , jsonMessageValidationContext ) ; } else if ( isSchemaSpecified ( jsonMessageValidationContext ) ) { return getSchemaFromContext ( jsonMessageValidationContext , applicationContext ) ; } else { return mergeRepositories ( schemaRepositories ) ; } } | Filters the all schema repositories based on the configuration in the jsonMessageValidationContext and returns a list of relevant schemas for the validation |
28,407 | private List < SimpleJsonSchema > getSchemaFromContext ( JsonMessageValidationContext jsonMessageValidationContext , ApplicationContext applicationContext ) { try { SimpleJsonSchema simpleJsonSchema = applicationContext . getBean ( jsonMessageValidationContext . getSchema ( ) , SimpleJsonSchema . class ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Found specified schema: \"" + jsonMessageValidationContext . getSchema ( ) + "\"." ) ; } return Collections . singletonList ( simpleJsonSchema ) ; } catch ( NoSuchBeanDefinitionException e ) { throw new CitrusRuntimeException ( "Could not find the specified schema: \"" + jsonMessageValidationContext . getSchema ( ) + "\"." , e ) ; } } | Extracts the the schema specified in the jsonMessageValidationContext from the application context |
28,408 | private List < SimpleJsonSchema > filterByRepositoryName ( List < JsonSchemaRepository > schemaRepositories , JsonMessageValidationContext jsonMessageValidationContext ) { for ( JsonSchemaRepository jsonSchemaRepository : schemaRepositories ) { if ( Objects . equals ( jsonSchemaRepository . getName ( ) , jsonMessageValidationContext . getSchemaRepository ( ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Found specified schema-repository: \"" + jsonMessageValidationContext . getSchemaRepository ( ) + "\"." ) ; } return jsonSchemaRepository . getSchemas ( ) ; } } throw new CitrusRuntimeException ( "Could not find the specified schema repository: " + "\"" + jsonMessageValidationContext . getSchemaRepository ( ) + "\"." ) ; } | Filters the schema repositories by the name configured in the jsonMessageValidationContext |
28,409 | private List < SimpleJsonSchema > mergeRepositories ( List < JsonSchemaRepository > schemaRepositories ) { return schemaRepositories . stream ( ) . map ( JsonSchemaRepository :: getSchemas ) . flatMap ( List :: stream ) . collect ( Collectors . toList ( ) ) ; } | Merges the list of given schema repositories to one unified list of json schemas |
28,410 | public static final void injectAll ( final Object target , final Citrus citrusFramework ) { injectAll ( target , citrusFramework , citrusFramework . createTestContext ( ) ) ; } | Creates new Citrus test context and injects all supported components and endpoints to target object using annotations . |
28,411 | public static final void injectAll ( final Object target , final Citrus citrusFramework , final TestContext context ) { injectCitrusFramework ( target , citrusFramework ) ; injectEndpoints ( target , context ) ; } | Injects all supported components and endpoints to target object using annotations . |
28,412 | private Map < String , String > getCustomHeaders ( HttpHeaders httpHeaders , Map < String , Object > mappedHeaders ) { Map < String , String > customHeaders = new HashMap < > ( ) ; for ( Map . Entry < String , List < String > > header : httpHeaders . entrySet ( ) ) { if ( ! mappedHeaders . containsKey ( header . getKey ( ) ) ) { customHeaders . put ( header . getKey ( ) , StringUtils . collectionToCommaDelimitedString ( header . getValue ( ) ) ) ; } } return customHeaders ; } | Message headers consist of standard HTTP message headers and custom headers . This method assumes that all header entries that were not initially mapped by header mapper implementations are custom headers . |
28,413 | private HttpHeaders createHttpHeaders ( HttpMessage httpMessage , HttpEndpointConfiguration endpointConfiguration ) { HttpHeaders httpHeaders = new HttpHeaders ( ) ; endpointConfiguration . getHeaderMapper ( ) . fromHeaders ( new org . springframework . messaging . MessageHeaders ( httpMessage . getHeaders ( ) ) , httpHeaders ) ; Map < String , Object > messageHeaders = httpMessage . getHeaders ( ) ; for ( Map . Entry < String , Object > header : messageHeaders . entrySet ( ) ) { if ( ! header . getKey ( ) . startsWith ( MessageHeaders . PREFIX ) && ! MessageHeaderUtils . isSpringInternalHeader ( header . getKey ( ) ) && ! httpHeaders . containsKey ( header . getKey ( ) ) ) { httpHeaders . add ( header . getKey ( ) , header . getValue ( ) . toString ( ) ) ; } } if ( httpHeaders . getFirst ( HttpMessageHeaders . HTTP_CONTENT_TYPE ) == null ) { httpHeaders . add ( HttpMessageHeaders . HTTP_CONTENT_TYPE , composeContentTypeHeaderValue ( endpointConfiguration ) ) ; } return httpHeaders ; } | Creates HttpHeaders based on the outbound message and the endpoint configurations header mapper . |
28,414 | private HttpEntity < ? > createHttpEntity ( HttpHeaders httpHeaders , Object payload , HttpMethod method ) { if ( httpMethodSupportsBody ( method ) ) { return new HttpEntity < > ( payload , httpHeaders ) ; } else { return new HttpEntity < > ( httpHeaders ) ; } } | Composes a HttpEntity based on the given parameters |
28,415 | private HttpMessage convertOutboundMessage ( Message message ) { HttpMessage httpMessage ; if ( message instanceof HttpMessage ) { httpMessage = ( HttpMessage ) message ; } else { httpMessage = new HttpMessage ( message ) ; } return httpMessage ; } | Converts the outbound Message object into a HttpMessage |
28,416 | private boolean httpMethodSupportsBody ( HttpMethod method ) { return HttpMethod . POST . equals ( method ) || HttpMethod . PUT . equals ( method ) || HttpMethod . DELETE . equals ( method ) || HttpMethod . PATCH . equals ( method ) ; } | Determines whether the given message type supports a message body |
28,417 | private String composeContentTypeHeaderValue ( HttpEndpointConfiguration endpointConfiguration ) { return ( endpointConfiguration . getContentType ( ) . contains ( "charset" ) || ! StringUtils . hasText ( endpointConfiguration . getCharset ( ) ) ) ? endpointConfiguration . getContentType ( ) : endpointConfiguration . getContentType ( ) + ";charset=" + endpointConfiguration . getCharset ( ) ; } | Creates the content type header value enriched with charset information if possible |
28,418 | public static void setPropertyValue ( BeanDefinitionBuilder builder , String propertyValue , String propertyName ) { if ( StringUtils . hasText ( propertyValue ) ) { builder . addPropertyValue ( propertyName , propertyValue ) ; } } | Sets the property value on bean definition in case value is set properly . |
28,419 | public static void setConstructorArgValue ( BeanDefinitionBuilder builder , String propertyValue ) { if ( StringUtils . hasText ( propertyValue ) ) { builder . addConstructorArgValue ( propertyValue ) ; } } | Sets the property value on bean definition as constructor argument in case value is not null . |
28,420 | public static BeanDefinitionHolder registerBean ( String beanId , Class < ? > beanClass , ParserContext parserContext , boolean shouldFireEvents ) { return registerBean ( beanId , BeanDefinitionBuilder . genericBeanDefinition ( beanClass ) . getBeanDefinition ( ) , parserContext , shouldFireEvents ) ; } | Creates new bean definition from bean class and registers new bean in parser registry . Returns bean definition holder . |
28,421 | public static BeanDefinitionHolder registerBean ( String beanId , BeanDefinition beanDefinition , ParserContext parserContext , boolean shouldFireEvents ) { if ( parserContext . getRegistry ( ) . containsBeanDefinition ( beanId ) ) { return new BeanDefinitionHolder ( parserContext . getRegistry ( ) . getBeanDefinition ( beanId ) , beanId ) ; } BeanDefinitionHolder configurationHolder = new BeanDefinitionHolder ( beanDefinition , beanId ) ; BeanDefinitionReaderUtils . registerBeanDefinition ( configurationHolder , parserContext . getRegistry ( ) ) ; if ( shouldFireEvents ) { BeanComponentDefinition componentDefinition = new BeanComponentDefinition ( configurationHolder ) ; parserContext . registerComponent ( componentDefinition ) ; } return configurationHolder ; } | Registers bean definition in parser registry and returns bean definition holder . |
28,422 | private static boolean isDesignerMethod ( Method method ) { Class < ? > [ ] parameterTypes = method . getParameterTypes ( ) ; for ( Class < ? > parameterType : parameterTypes ) { if ( parameterType . isAssignableFrom ( TestDesigner . class ) ) { return true ; } } return false ; } | Searches for method parameter of type test designer . |
28,423 | private static boolean isDesignerClass ( Class < ? > type ) { return Stream . of ( type . getDeclaredFields ( ) ) . anyMatch ( field -> TestDesigner . class . isAssignableFrom ( field . getType ( ) ) ) ; } | Searches for field of type test designer . |
28,424 | private static boolean isRunnerMethod ( Method method ) { Class < ? > [ ] parameterTypes = method . getParameterTypes ( ) ; for ( Class < ? > parameterType : parameterTypes ) { if ( parameterType . isAssignableFrom ( TestRunner . class ) ) { return true ; } } return false ; } | Searches for method parameter of type test runner . |
28,425 | private static boolean isRunnerClass ( Class < ? > type ) { return Stream . of ( type . getDeclaredFields ( ) ) . anyMatch ( field -> TestRunner . class . isAssignableFrom ( field . getType ( ) ) ) ; } | Searches for field of type test runner . |
28,426 | public static String getValueFromScript ( String scriptEngine , String code ) { try { ScriptEngine engine = new ScriptEngineManager ( ) . getEngineByName ( scriptEngine ) ; if ( engine == null ) { throw new CitrusRuntimeException ( "Unable to find script engine with name '" + scriptEngine + "'" ) ; } return engine . eval ( code ) . toString ( ) ; } catch ( ScriptException e ) { throw new CitrusRuntimeException ( "Failed to evaluate " + scriptEngine + " script" , e ) ; } } | Evaluates script code and returns a variable value as result . |
28,427 | public static String cutOffSingleQuotes ( String variable ) { if ( StringUtils . hasText ( variable ) && variable . length ( ) > 1 && variable . charAt ( 0 ) == '\'' && variable . charAt ( variable . length ( ) - 1 ) == '\'' ) { return variable . substring ( 1 , variable . length ( ) - 1 ) ; } return variable ; } | Cut off single quotes prefix and suffix . |
28,428 | public static String cutOffDoubleQuotes ( String variable ) { if ( StringUtils . hasText ( variable ) && variable . length ( ) > 1 && variable . charAt ( 0 ) == '"' && variable . charAt ( variable . length ( ) - 1 ) == '"' ) { return variable . substring ( 1 , variable . length ( ) - 1 ) ; } return variable ; } | Cut off double quotes prefix and suffix . |
28,429 | public static String cutOffVariablesPrefix ( String variable ) { if ( variable . startsWith ( Citrus . VARIABLE_PREFIX ) && variable . endsWith ( Citrus . VARIABLE_SUFFIX ) ) { return variable . substring ( Citrus . VARIABLE_PREFIX . length ( ) , variable . length ( ) - Citrus . VARIABLE_SUFFIX . length ( ) ) ; } return variable ; } | Cut off variables prefix |
28,430 | public static String cutOffVariablesEscaping ( String variable ) { if ( variable . startsWith ( Citrus . VARIABLE_ESCAPE ) && variable . endsWith ( Citrus . VARIABLE_ESCAPE ) ) { return variable . substring ( Citrus . VARIABLE_ESCAPE . length ( ) , variable . length ( ) - Citrus . VARIABLE_ESCAPE . length ( ) ) ; } return variable ; } | Cut off variables escaping |
28,431 | public static boolean isVariableName ( final String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return false ; } if ( expression . startsWith ( Citrus . VARIABLE_PREFIX ) && expression . endsWith ( Citrus . VARIABLE_SUFFIX ) ) { return true ; } return false ; } | Checks whether a given expression is a variable name . |
28,432 | public static String replaceVariablesInString ( final String str , TestContext context , boolean enableQuoting ) { StringBuffer newStr = new StringBuffer ( ) ; boolean isVarComplete ; StringBuffer variableNameBuf = new StringBuffer ( ) ; int startIndex = 0 ; int curIndex ; int searchIndex ; while ( ( searchIndex = str . indexOf ( Citrus . VARIABLE_PREFIX , startIndex ) ) != - 1 ) { int control = 0 ; isVarComplete = false ; curIndex = searchIndex + Citrus . VARIABLE_PREFIX . length ( ) ; while ( curIndex < str . length ( ) && ! isVarComplete ) { if ( str . indexOf ( Citrus . VARIABLE_PREFIX , curIndex ) == curIndex ) { control ++ ; } if ( ( ! Character . isJavaIdentifierPart ( str . charAt ( curIndex ) ) && ( str . charAt ( curIndex ) == Citrus . VARIABLE_SUFFIX . charAt ( 0 ) ) ) || ( curIndex + 1 == str . length ( ) ) ) { if ( control == 0 ) { isVarComplete = true ; } else { control -- ; } } if ( ! isVarComplete ) { variableNameBuf . append ( str . charAt ( curIndex ) ) ; } ++ curIndex ; } final String value = context . getVariable ( variableNameBuf . toString ( ) ) ; if ( value == null ) { throw new NoSuchVariableException ( "Variable: " + variableNameBuf . toString ( ) + " could not be found" ) ; } newStr . append ( str . substring ( startIndex , searchIndex ) ) ; if ( enableQuoting ) { newStr . append ( "'" + value + "'" ) ; } else { newStr . append ( value ) ; } startIndex = curIndex ; variableNameBuf = new StringBuffer ( ) ; isVarComplete = false ; } newStr . append ( str . substring ( startIndex ) ) ; return newStr . toString ( ) ; } | Replace all variable expression in a string with its respective value . Variable values are enclosed with quotes if enabled . |
28,433 | protected Vertx createVertx ( VertxEndpointConfiguration endpointConfiguration ) { final Vertx [ ] vertx = new Vertx [ 1 ] ; final Future loading = new FutureFactoryImpl ( ) . future ( ) ; Handler < AsyncResult < Vertx > > asyncLoadingHandler = new Handler < AsyncResult < Vertx > > ( ) { public void handle ( AsyncResult < Vertx > event ) { vertx [ 0 ] = event . result ( ) ; loading . complete ( ) ; log . info ( "Vert.x instance started" ) ; } } ; if ( endpointConfiguration . getPort ( ) > 0 ) { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Creating new Vert.x instance '%s:%s' ..." , endpointConfiguration . getHost ( ) , endpointConfiguration . getPort ( ) ) ) ; } VertxOptions vertxOptions = new VertxOptions ( ) ; vertxOptions . setClusterPort ( endpointConfiguration . getPort ( ) ) ; vertxOptions . setClusterHost ( endpointConfiguration . getHost ( ) ) ; vertxFactory . clusteredVertx ( vertxOptions , asyncLoadingHandler ) ; } else { if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Creating new Vert.x instance '%s:%s' ..." , endpointConfiguration . getHost ( ) , 0L ) ) ; } VertxOptions vertxOptions = new VertxOptions ( ) ; vertxOptions . setClusterPort ( 0 ) ; vertxOptions . setClusterHost ( endpointConfiguration . getHost ( ) ) ; vertxFactory . clusteredVertx ( vertxOptions , asyncLoadingHandler ) ; } while ( ! loading . isComplete ( ) ) { try { log . debug ( "Waiting for Vert.x instance to startup" ) ; Thread . sleep ( 250L ) ; } catch ( InterruptedException e ) { log . warn ( "Interrupted while waiting for Vert.x instance startup" , e ) ; } } return vertx [ 0 ] ; } | Creates new Vert . x instance with default factory . Subclasses may overwrite this method in order to provide special Vert . x instance . |
28,434 | protected int getDateValueOffset ( String offsetString , char c ) { ArrayList < Character > charList = new ArrayList < Character > ( ) ; int index = offsetString . indexOf ( c ) ; if ( index != - 1 ) { for ( int i = index - 1 ; i >= 0 ; i -- ) { if ( Character . isDigit ( offsetString . charAt ( i ) ) ) { charList . add ( 0 , offsetString . charAt ( i ) ) ; } else { StringBuffer offsetValue = new StringBuffer ( ) ; offsetValue . append ( "0" ) ; for ( int j = 0 ; j < charList . size ( ) ; j ++ ) { offsetValue . append ( charList . get ( j ) ) ; } if ( offsetString . charAt ( i ) == '-' ) { return Integer . valueOf ( "-" + offsetValue . toString ( ) ) ; } else { return Integer . valueOf ( offsetValue . toString ( ) ) ; } } } } return 0 ; } | Parse offset string and add or subtract date offset value . |
28,435 | private String createReportContent ( String suiteName , List < TestResult > results , ReportTemplates templates ) throws IOException { final StringBuilder reportDetails = new StringBuilder ( ) ; for ( TestResult result : results ) { Properties detailProps = new Properties ( ) ; detailProps . put ( "test.class" , result . getClassName ( ) ) ; detailProps . put ( "test.name" , StringEscapeUtils . escapeXml ( result . getTestName ( ) ) ) ; detailProps . put ( "test.duration" , "0.0" ) ; if ( result . isFailed ( ) ) { detailProps . put ( "test.error.cause" , Optional . ofNullable ( result . getCause ( ) ) . map ( Object :: getClass ) . map ( Class :: getName ) . orElse ( result . getFailureType ( ) ) ) ; detailProps . put ( "test.error.msg" , StringEscapeUtils . escapeXml ( result . getErrorMessage ( ) ) ) ; detailProps . put ( "test.error.stackTrace" , Optional . ofNullable ( result . getCause ( ) ) . map ( cause -> { StringWriter writer = new StringWriter ( ) ; cause . printStackTrace ( new PrintWriter ( writer ) ) ; return writer . toString ( ) ; } ) . orElse ( result . getFailureStack ( ) ) ) ; reportDetails . append ( PropertyUtils . replacePropertiesInString ( templates . getFailedTemplate ( ) , detailProps ) ) ; } else { reportDetails . append ( PropertyUtils . replacePropertiesInString ( templates . getSuccessTemplate ( ) , detailProps ) ) ; } } Properties reportProps = new Properties ( ) ; reportProps . put ( "test.suite" , suiteName ) ; reportProps . put ( "test.cnt" , Integer . toString ( results . size ( ) ) ) ; reportProps . put ( "test.skipped.cnt" , Long . toString ( results . stream ( ) . filter ( TestResult :: isSkipped ) . count ( ) ) ) ; reportProps . put ( "test.failed.cnt" , Long . toString ( results . stream ( ) . filter ( TestResult :: isFailed ) . count ( ) ) ) ; reportProps . put ( "test.success.cnt" , Long . toString ( results . stream ( ) . filter ( TestResult :: isSuccess ) . count ( ) ) ) ; reportProps . put ( "test.error.cnt" , "0" ) ; reportProps . put ( "test.duration" , "0.0" ) ; reportProps . put ( "tests" , reportDetails . toString ( ) ) ; return PropertyUtils . replacePropertiesInString ( templates . getReportTemplate ( ) , reportProps ) ; } | Create report file for test class . |
28,436 | private void createReportFile ( String reportFileName , String content , File targetDirectory ) { if ( ! targetDirectory . exists ( ) ) { if ( ! targetDirectory . mkdirs ( ) ) { throw new CitrusRuntimeException ( "Unable to create report output directory: " + getReportDirectory ( ) + ( StringUtils . hasText ( outputDirectory ) ? "/" + outputDirectory : "" ) ) ; } } try ( Writer fileWriter = new FileWriter ( new File ( targetDirectory , reportFileName ) ) ) { fileWriter . append ( content ) ; fileWriter . flush ( ) ; } catch ( IOException e ) { log . error ( "Failed to create test report" , e ) ; } } | Creates the JUnit report file |
28,437 | public ProcessingReport validate ( Message message , List < JsonSchemaRepository > schemaRepositories , JsonMessageValidationContext validationContext , ApplicationContext applicationContext ) { return validate ( message , jsonSchemaFilter . filter ( schemaRepositories , validationContext , applicationContext ) ) ; } | Validates the given message against a list of JsonSchemaRepositories under consideration of the actual context |
28,438 | private GraciousProcessingReport validate ( Message message , List < SimpleJsonSchema > jsonSchemas ) { if ( jsonSchemas . isEmpty ( ) ) { return new GraciousProcessingReport ( true ) ; } else { List < ProcessingReport > processingReports = new LinkedList < > ( ) ; for ( SimpleJsonSchema simpleJsonSchema : jsonSchemas ) { processingReports . add ( validate ( message , simpleJsonSchema ) ) ; } return new GraciousProcessingReport ( processingReports ) ; } } | Validates a message against all schemas contained in the given json schema repository |
28,439 | private ProcessingReport validate ( Message message , SimpleJsonSchema simpleJsonSchema ) { try { JsonNode receivedJson = objectMapper . readTree ( message . getPayload ( String . class ) ) ; return simpleJsonSchema . getSchema ( ) . validate ( receivedJson ) ; } catch ( IOException | ProcessingException e ) { throw new CitrusRuntimeException ( "Failed to validate Json schema" , e ) ; } } | Validates a given message against a given json schema |
28,440 | protected Message invokeEndpointAdapter ( MailMessage mail ) { if ( splitMultipart ) { return split ( mail . getPayload ( MailRequest . class ) . getBody ( ) , mail . getHeaders ( ) ) ; } else { return getEndpointAdapter ( ) . handleMessage ( mail ) ; } } | Invokes the endpoint adapter with constructed mail message and headers . |
28,441 | private Message split ( BodyPart bodyPart , Map < String , Object > messageHeaders ) { MailMessage mailRequest = createMailMessage ( messageHeaders , bodyPart . getContent ( ) , bodyPart . getContentType ( ) ) ; Stack < Message > responseStack = new Stack < > ( ) ; if ( bodyPart instanceof AttachmentPart ) { fillStack ( getEndpointAdapter ( ) . handleMessage ( mailRequest . setHeader ( CitrusMailMessageHeaders . MAIL_CONTENT_TYPE , bodyPart . getContentType ( ) ) . setHeader ( CitrusMailMessageHeaders . MAIL_FILENAME , ( ( AttachmentPart ) bodyPart ) . getFileName ( ) ) ) , responseStack ) ; } else { fillStack ( getEndpointAdapter ( ) . handleMessage ( mailRequest . setHeader ( CitrusMailMessageHeaders . MAIL_CONTENT_TYPE , bodyPart . getContentType ( ) ) ) , responseStack ) ; } if ( bodyPart . hasAttachments ( ) ) { for ( AttachmentPart attachmentPart : bodyPart . getAttachments ( ) . getAttachments ( ) ) { fillStack ( split ( attachmentPart , messageHeaders ) , responseStack ) ; } } return responseStack . isEmpty ( ) ? null : responseStack . pop ( ) ; } | Split mail message into several messages . Each body and each attachment results in separate message invoked on endpoint adapter . Mail message response if any should be sent only once within test case . However latest mail response sent by test case is returned others are ignored . |
28,442 | private void registerJsonSchemaRepository ( Element element , ParserContext parserContext ) { BeanDefinitionBuilder builder = BeanDefinitionBuilder . genericBeanDefinition ( JsonSchemaRepository . class ) ; addLocationsToBuilder ( element , builder ) ; parseSchemasElement ( element , builder , parserContext ) ; parserContext . getRegistry ( ) . registerBeanDefinition ( element . getAttribute ( ID ) , builder . getBeanDefinition ( ) ) ; } | Registers a JsonSchemaRepository definition in the parser context |
28,443 | private void registerXmlSchemaRepository ( Element element , ParserContext parserContext ) { BeanDefinitionBuilder builder = BeanDefinitionBuilder . genericBeanDefinition ( XsdSchemaRepository . class ) ; BeanDefinitionParserUtils . setPropertyReference ( builder , element . getAttribute ( "schema-mapping-strategy" ) , "schemaMappingStrategy" ) ; addLocationsToBuilder ( element , builder ) ; parseSchemasElement ( element , builder , parserContext ) ; parserContext . getRegistry ( ) . registerBeanDefinition ( element . getAttribute ( ID ) , builder . getBeanDefinition ( ) ) ; } | Registers a XsdSchemaRepository definition in the parser context |
28,444 | private boolean isXmlSchemaRepository ( Element element ) { String schemaRepositoryType = element . getAttribute ( "type" ) ; return StringUtils . isEmpty ( schemaRepositoryType ) || "xml" . equals ( schemaRepositoryType ) ; } | Decides whether the given element is a xml schema repository . |
28,445 | private void addLocationsToBuilder ( Element element , BeanDefinitionBuilder builder ) { Element locationsElement = DomUtils . getChildElementByTagName ( element , LOCATIONS ) ; if ( locationsElement != null ) { List < Element > locationElements = DomUtils . getChildElementsByTagName ( locationsElement , LOCATION ) ; List < String > locations = locationElements . stream ( ) . map ( locationElement -> locationElement . getAttribute ( "path" ) ) . collect ( Collectors . toList ( ) ) ; if ( ! locations . isEmpty ( ) ) { builder . addPropertyValue ( LOCATIONS , locations ) ; } } } | Adds the locations contained in the given locations element to the BeanDefinitionBuilder |
28,446 | private void parseSchemasElement ( Element element , BeanDefinitionBuilder builder , ParserContext parserContext ) { Element schemasElement = DomUtils . getChildElementByTagName ( element , SCHEMAS ) ; if ( schemasElement != null ) { List < Element > schemaElements = DomUtils . getChildElements ( schemasElement ) ; ManagedList < RuntimeBeanReference > beanReferences = constructRuntimeBeanReferences ( parserContext , schemaElements ) ; if ( ! beanReferences . isEmpty ( ) ) { builder . addPropertyValue ( SCHEMAS , beanReferences ) ; } } } | Parses the given schema element to RuntimeBeanReference in consideration of the given context and adds them to the builder |
28,447 | private ManagedList < RuntimeBeanReference > constructRuntimeBeanReferences ( ParserContext parserContext , List < Element > schemaElements ) { ManagedList < RuntimeBeanReference > runtimeBeanReferences = new ManagedList < > ( ) ; for ( Element schemaElement : schemaElements ) { if ( schemaElement . hasAttribute ( SCHEMA ) ) { runtimeBeanReferences . add ( new RuntimeBeanReference ( schemaElement . getAttribute ( SCHEMA ) ) ) ; } else { schemaParser . parse ( schemaElement , parserContext ) ; runtimeBeanReferences . add ( new RuntimeBeanReference ( schemaElement . getAttribute ( ID ) ) ) ; } } return runtimeBeanReferences ; } | Construct a List of RuntimeBeanReferences from the given list of schema elements under consideration of the given parser context |
28,448 | private PublicKey readKey ( InputStream is ) { InputStreamReader isr = new InputStreamReader ( is ) ; PEMParser r = new PEMParser ( isr ) ; try { Object o = r . readObject ( ) ; if ( o instanceof PEMKeyPair ) { PEMKeyPair keyPair = ( PEMKeyPair ) o ; if ( keyPair . getPublicKeyInfo ( ) != null && keyPair . getPublicKeyInfo ( ) . getEncoded ( ) . length > 0 ) { return provider . getPublicKey ( keyPair . getPublicKeyInfo ( ) ) ; } } else if ( o instanceof SubjectPublicKeyInfo ) { return provider . getPublicKey ( ( SubjectPublicKeyInfo ) o ) ; } } catch ( IOException e ) { log . warn ( "Failed to get key from PEM file" , e ) ; } finally { IoUtils . closeQuietly ( isr , r ) ; } return null ; } | Read the key with bouncycastle s PEM tools |
28,449 | public boolean sendMessage ( WebSocketMessage < ? > message ) { boolean sentSuccessfully = false ; if ( sessions . isEmpty ( ) ) { LOG . warn ( "No Web Socket session exists - message cannot be sent" ) ; } for ( WebSocketSession session : sessions . values ( ) ) { if ( session != null && session . isOpen ( ) ) { try { session . sendMessage ( message ) ; sentSuccessfully = true ; } catch ( IOException e ) { LOG . error ( String . format ( "(%s) error sending message" , session . getId ( ) ) , e ) ; } } } return sentSuccessfully ; } | Publish message to all sessions known to this handler . |
28,450 | public ValidationMatcherLibrary getLibraryForPrefix ( String validationMatcherPrefix ) { if ( validationMatcherLibraries != null ) { for ( ValidationMatcherLibrary validationMatcherLibrary : validationMatcherLibraries ) { if ( validationMatcherLibrary . getPrefix ( ) . equals ( validationMatcherPrefix ) ) { return validationMatcherLibrary ; } } } throw new NoSuchValidationMatcherLibraryException ( "Can not find validationMatcher library for prefix " + validationMatcherPrefix ) ; } | Get library for validationMatcher prefix . |
28,451 | public S ms ( Long milliseconds ) { builder . milliseconds ( String . valueOf ( milliseconds ) ) ; return self ; } | The total length of milliseconds to wait on the condition to be satisfied |
28,452 | public S interval ( Long interval ) { builder . interval ( String . valueOf ( interval ) ) ; return self ; } | The interval in seconds to use between each test of the condition |
28,453 | public static String makeIECachingSafeUrl ( String url , long unique ) { if ( url . contains ( "timestamp=" ) ) { return url . replaceFirst ( "(.*)(timestamp=)(.*)([&#].*)" , "$1$2" + unique + "$4" ) . replaceFirst ( "(.*)(timestamp=)(.*)$" , "$1$2" + unique ) ; } else { return url . contains ( "?" ) ? url + "×tamp=" + unique : url + "?timestamp=" + unique ; } } | Makes new unique URL to avoid IE caching . |
28,454 | public String getStackMessage ( ) { if ( lineNumberEnd . longValue ( ) > 0 && ! lineNumberStart . equals ( lineNumberEnd ) ) { return "at " + testFilePath + "(" + actionName + ":" + lineNumberStart + "-" + lineNumberEnd + ")" ; } else { return "at " + testFilePath + "(" + actionName + ":" + lineNumberStart + ")" ; } } | Constructs the stack trace message . |
28,455 | protected ResponseItem success ( ) { ResponseItem response = new ResponseItem ( ) ; Field statusField = ReflectionUtils . findField ( ResponseItem . class , "status" ) ; ReflectionUtils . makeAccessible ( statusField ) ; ReflectionUtils . setField ( statusField , response , "success" ) ; return response ; } | Construct default success response for commands without return value . |
28,456 | protected String getParameter ( String parameterName , TestContext context ) { if ( getParameters ( ) . containsKey ( parameterName ) ) { return context . replaceDynamicContentInString ( getParameters ( ) . get ( parameterName ) . toString ( ) ) ; } else { throw new CitrusRuntimeException ( String . format ( "Missing docker command parameter '%s'" , parameterName ) ) ; } } | Gets the docker command parameter . |
28,457 | public KafkaEndpointBuilder producerProperties ( Map < String , Object > producerProperties ) { endpoint . getEndpointConfiguration ( ) . setProducerProperties ( producerProperties ) ; return this ; } | Sets the producer properties . |
28,458 | public KafkaEndpointBuilder consumerProperties ( Map < String , Object > consumerProperties ) { endpoint . getEndpointConfiguration ( ) . setConsumerProperties ( consumerProperties ) ; return this ; } | Sets the consumer properties . |
28,459 | private void validateText ( String receivedMessagePayload , String controlMessagePayload ) { if ( ! StringUtils . hasText ( controlMessagePayload ) ) { log . debug ( "Skip message payload validation as no control message was defined" ) ; return ; } else { Assert . isTrue ( StringUtils . hasText ( receivedMessagePayload ) , "Validation failed - " + "expected message contents, but received empty message!" ) ; } if ( ! receivedMessagePayload . equals ( controlMessagePayload ) ) { if ( StringUtils . trimAllWhitespace ( receivedMessagePayload ) . equals ( StringUtils . trimAllWhitespace ( controlMessagePayload ) ) ) { throw new ValidationException ( "Text values not equal (only whitespaces!), expected '" + controlMessagePayload + "' " + "but was '" + receivedMessagePayload + "'" ) ; } else { throw new ValidationException ( "Text values not equal, expected '" + controlMessagePayload + "' " + "but was '" + receivedMessagePayload + "'" ) ; } } } | Compares two string with each other in order to validate plain text . |
28,460 | private String normalizeWhitespace ( String payload ) { if ( ignoreWhitespace ) { StringBuilder result = new StringBuilder ( ) ; boolean lastWasSpace = true ; for ( int i = 0 ; i < payload . length ( ) ; i ++ ) { char c = payload . charAt ( i ) ; if ( Character . isWhitespace ( c ) ) { if ( ! lastWasSpace ) { result . append ( ' ' ) ; } lastWasSpace = true ; } else { result . append ( c ) ; lastWasSpace = false ; } } return result . toString ( ) . trim ( ) ; } if ( ignoreNewLineType ) { return payload . replaceAll ( "\\r(\\n)?" , "\n" ) ; } return payload ; } | Normalize whitespace characters if appropriate . Based on system property settings this method normalizes new line characters exclusively or filters all whitespaces such as double whitespaces and new lines . |
28,461 | public HttpClientBuilder interceptor ( ClientHttpRequestInterceptor interceptor ) { if ( endpoint . getEndpointConfiguration ( ) . getClientInterceptors ( ) == null ) { endpoint . getEndpointConfiguration ( ) . setClientInterceptors ( new ArrayList < ClientHttpRequestInterceptor > ( ) ) ; } endpoint . getEndpointConfiguration ( ) . getClientInterceptors ( ) . add ( interceptor ) ; return this ; } | Sets a client single interceptor . |
28,462 | private FormData createFormData ( Message message ) { FormData formData = new ObjectFactory ( ) . createFormData ( ) ; formData . setContentType ( getFormContentType ( message ) ) ; formData . setAction ( getFormAction ( message ) ) ; if ( message . getPayload ( ) instanceof MultiValueMap ) { MultiValueMap < String , Object > formValueMap = message . getPayload ( MultiValueMap . class ) ; for ( Map . Entry < String , List < Object > > entry : formValueMap . entrySet ( ) ) { Control control = new ObjectFactory ( ) . createControl ( ) ; control . setName ( entry . getKey ( ) ) ; control . setValue ( StringUtils . arrayToCommaDelimitedString ( entry . getValue ( ) . toArray ( ) ) ) ; formData . addControl ( control ) ; } } else { String rawFormData = message . getPayload ( String . class ) ; if ( StringUtils . hasText ( rawFormData ) ) { StringTokenizer tokenizer = new StringTokenizer ( rawFormData , "&" ) ; while ( tokenizer . hasMoreTokens ( ) ) { Control control = new ObjectFactory ( ) . createControl ( ) ; String [ ] nameValuePair = tokenizer . nextToken ( ) . split ( "=" ) ; if ( autoDecode ) { try { control . setName ( URLDecoder . decode ( nameValuePair [ 0 ] , getEncoding ( ) ) ) ; control . setValue ( URLDecoder . decode ( nameValuePair [ 1 ] , getEncoding ( ) ) ) ; } catch ( UnsupportedEncodingException e ) { throw new CitrusRuntimeException ( String . format ( "Failed to decode form control value '%s=%s'" , nameValuePair [ 0 ] , nameValuePair [ 1 ] ) , e ) ; } } else { control . setName ( nameValuePair [ 0 ] ) ; control . setValue ( nameValuePair [ 1 ] ) ; } formData . addControl ( control ) ; } } } return formData ; } | Create form data model object from url encoded message payload . |
28,463 | private String getFormAction ( Message message ) { return message . getHeader ( HttpMessageHeaders . HTTP_REQUEST_URI ) != null ? message . getHeader ( HttpMessageHeaders . HTTP_REQUEST_URI ) . toString ( ) : null ; } | Reads form action target from message headers . |
28,464 | private String getFormContentType ( Message message ) { return message . getHeader ( HttpMessageHeaders . HTTP_CONTENT_TYPE ) != null ? message . getHeader ( HttpMessageHeaders . HTTP_CONTENT_TYPE ) . toString ( ) : null ; } | Reads form content type from message headers . |
28,465 | protected < T > T convertIfNecessary ( String value , T originalValue ) { if ( originalValue == null ) { return ( T ) value ; } return TypeConversionUtils . convertIfNecessary ( value , ( Class < T > ) originalValue . getClass ( ) ) ; } | Convert to original value type if necessary . |
28,466 | private Map < String , String > convertToMap ( Object expression ) { if ( expression instanceof Map ) { return ( Map < String , String > ) expression ; } return Stream . of ( Optional . ofNullable ( expression ) . map ( Object :: toString ) . orElse ( "" ) . split ( "," ) ) . map ( keyValue -> Optional . ofNullable ( StringUtils . split ( keyValue , "=" ) ) . orElse ( new String [ ] { keyValue , "" } ) ) . collect ( Collectors . toMap ( keyValue -> keyValue [ 0 ] , keyValue -> keyValue [ 1 ] ) ) ; } | Convert query string key - value expression to map . |
28,467 | public String buildMessagePayload ( TestContext context , String messageType ) { try { String messagePayload = "" ; if ( scriptResourcePath != null ) { messagePayload = buildMarkupBuilderScript ( context . replaceDynamicContentInString ( FileUtils . readToString ( FileUtils . getFileResource ( scriptResourcePath , context ) , Charset . forName ( context . resolveDynamicValue ( scriptResourceCharset ) ) ) ) ) ; } else if ( scriptData != null ) { messagePayload = buildMarkupBuilderScript ( context . replaceDynamicContentInString ( scriptData ) ) ; } return messagePayload ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to build control message payload" , e ) ; } } | Build the control message from script code . |
28,468 | private String buildMarkupBuilderScript ( String scriptData ) { try { ClassLoader parent = GroovyScriptMessageBuilder . class . getClassLoader ( ) ; GroovyClassLoader loader = new GroovyClassLoader ( parent ) ; Class < ? > groovyClass = loader . parseClass ( TemplateBasedScriptBuilder . fromTemplateResource ( scriptTemplateResource ) . withCode ( scriptData ) . build ( ) ) ; if ( groovyClass == null ) { throw new CitrusRuntimeException ( "Could not load groovy script!" ) ; } GroovyObject groovyObject = ( GroovyObject ) groovyClass . newInstance ( ) ; return ( String ) groovyObject . invokeMethod ( "run" , new Object [ ] { } ) ; } catch ( CompilationFailedException e ) { throw new CitrusRuntimeException ( e ) ; } catch ( InstantiationException e ) { throw new CitrusRuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new CitrusRuntimeException ( e ) ; } } | Builds an automatic Groovy MarkupBuilder script with given script body . |
28,469 | protected InputStream getTemplateAsStream ( TestContext context ) { Resource resource ; if ( templateResource != null ) { resource = templateResource ; } else { resource = FileUtils . getFileResource ( template , context ) ; } String templateYml ; try { templateYml = context . replaceDynamicContentInString ( FileUtils . readToString ( resource ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read template resource" , e ) ; } return new ByteArrayInputStream ( templateYml . getBytes ( ) ) ; } | Create input stream from template resource and add test variable support . |
28,470 | private void fillColumnValuesMap ( List < Map < String , Object > > results , Map < String , List < String > > columnValuesMap ) { for ( Map < String , Object > row : results ) { for ( Entry < String , Object > column : row . entrySet ( ) ) { String columnValue ; String columnName = column . getKey ( ) ; if ( ! columnValuesMap . containsKey ( columnName ) ) { columnValuesMap . put ( columnName , new ArrayList < String > ( ) ) ; } if ( column . getValue ( ) instanceof byte [ ] ) { columnValue = Base64 . encodeBase64String ( ( byte [ ] ) column . getValue ( ) ) ; } else { columnValue = column . getValue ( ) == null ? null : column . getValue ( ) . toString ( ) ; } columnValuesMap . get ( columnName ) . add ( ( columnValue ) ) ; } } } | Form a Map object which contains all columns of the result as keys and a List of row values as values of the Map |
28,471 | public static String resolveFunction ( String functionString , TestContext context ) { String functionExpression = VariableUtils . cutOffVariablesPrefix ( functionString ) ; if ( ! functionExpression . contains ( "(" ) || ! functionExpression . endsWith ( ")" ) || ! functionExpression . contains ( ":" ) ) { throw new InvalidFunctionUsageException ( "Unable to resolve function: " + functionExpression ) ; } String functionPrefix = functionExpression . substring ( 0 , functionExpression . indexOf ( ':' ) + 1 ) ; String parameterString = functionExpression . substring ( functionExpression . indexOf ( '(' ) + 1 , functionExpression . length ( ) - 1 ) ; String function = functionExpression . substring ( functionPrefix . length ( ) , functionExpression . indexOf ( '(' ) ) ; FunctionLibrary library = context . getFunctionRegistry ( ) . getLibraryForPrefix ( functionPrefix ) ; parameterString = VariableUtils . replaceVariablesInString ( parameterString , context , false ) ; parameterString = replaceFunctionsInString ( parameterString , context ) ; String value = library . getFunction ( function ) . execute ( FunctionParameterHelper . getParameterList ( parameterString ) , context ) ; if ( value == null ) { return "" ; } else { return value ; } } | This method resolves a custom function to its respective result . |
28,472 | public AssertSoapFaultBuilder faultDetailResource ( Resource resource , Charset charset ) { try { action . getFaultDetails ( ) . add ( FileUtils . readToString ( resource , charset ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read fault detail resource" , e ) ; } return this ; } | Expect fault detail from file resource . |
28,473 | public AssertSoapFaultBuilder validator ( String validatorName , ApplicationContext applicationContext ) { action . setValidator ( applicationContext . getBean ( validatorName , SoapFaultValidator . class ) ) ; return this ; } | Set explicit SOAP fault validator implementation by bean name . |
28,474 | public Integer getPartition ( ) { Object partition = getHeader ( KafkaMessageHeaders . PARTITION ) ; if ( partition != null ) { return TypeConversionUtils . convertIfNecessary ( partition , Integer . class ) ; } return null ; } | Gets the Kafka partition header . |
28,475 | public Long getTimestamp ( ) { Object timestamp = getHeader ( KafkaMessageHeaders . TIMESTAMP ) ; if ( timestamp != null ) { return Long . valueOf ( timestamp . toString ( ) ) ; } return null ; } | Gets the Kafka timestamp header . |
28,476 | public Long getOffset ( ) { Object offset = getHeader ( KafkaMessageHeaders . OFFSET ) ; if ( offset != null ) { return TypeConversionUtils . convertIfNecessary ( offset , Long . class ) ; } return 0L ; } | Gets the Kafka offset header . |
28,477 | public Object getMessageKey ( ) { Object key = getHeader ( KafkaMessageHeaders . MESSAGE_KEY ) ; if ( key != null ) { return key ; } return null ; } | Gets the Kafka message key header . |
28,478 | public String getTopic ( ) { Object topic = getHeader ( KafkaMessageHeaders . TOPIC ) ; if ( topic != null ) { return topic . toString ( ) ; } return null ; } | Gets the Kafka topic header . |
28,479 | public Wait action ( TestAction action ) { if ( action instanceof TestActionBuilder ) { getCondition ( ) . setAction ( ( ( TestActionBuilder ) action ) . build ( ) ) ; this . action . setAction ( ( ( TestActionBuilder ) action ) . build ( ) ) ; getBuilder ( ) . actions ( ( ( TestActionBuilder ) action ) . build ( ) ) ; } else { getCondition ( ) . setAction ( action ) ; this . action . setAction ( action ) ; getBuilder ( ) . actions ( action ) ; } return getBuilder ( ) . build ( ) ; } | Sets the test action to execute and wait for . |
28,480 | private String getRequestContent ( HttpRequest request , String body ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( request . getMethod ( ) ) ; builder . append ( " " ) ; builder . append ( request . getURI ( ) ) ; builder . append ( NEWLINE ) ; appendHeaders ( request . getHeaders ( ) , builder ) ; builder . append ( NEWLINE ) ; builder . append ( body ) ; return builder . toString ( ) ; } | Builds request content string from request and body . |
28,481 | private String getResponseContent ( CachingClientHttpResponseWrapper response ) throws IOException { if ( response != null ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "HTTP/1.1 " ) ; builder . append ( response . getStatusCode ( ) ) ; builder . append ( " " ) ; builder . append ( response . getStatusText ( ) ) ; builder . append ( NEWLINE ) ; appendHeaders ( response . getHeaders ( ) , builder ) ; builder . append ( NEWLINE ) ; builder . append ( response . getBodyContent ( ) ) ; return builder . toString ( ) ; } else { return "" ; } } | Builds response content string from response object . |
28,482 | private void appendHeaders ( HttpHeaders headers , StringBuilder builder ) { for ( Entry < String , List < String > > headerEntry : headers . entrySet ( ) ) { builder . append ( headerEntry . getKey ( ) ) ; builder . append ( ":" ) ; builder . append ( StringUtils . arrayToCommaDelimitedString ( headerEntry . getValue ( ) . toArray ( ) ) ) ; builder . append ( NEWLINE ) ; } } | Append Http headers to string builder . |
28,483 | public ContainerStart start ( String containerId ) { ContainerStart command = new ContainerStart ( ) ; command . container ( containerId ) ; action . setCommand ( command ) ; return command ; } | Adds a start command . |
28,484 | public ContainerStop stop ( String containerId ) { ContainerStop command = new ContainerStop ( ) ; command . container ( containerId ) ; action . setCommand ( command ) ; return command ; } | Adds a stop command . |
28,485 | public ContainerWait wait ( String containerId ) { ContainerWait command = new ContainerWait ( ) ; command . container ( containerId ) ; action . setCommand ( command ) ; return command ; } | Adds a wait command . |
28,486 | public T messageType ( String messageType ) { this . messageType = messageType ; getAction ( ) . setMessageType ( messageType ) ; if ( binaryMessageConstructionInterceptor . supportsMessageType ( messageType ) ) { getMessageContentBuilder ( ) . add ( binaryMessageConstructionInterceptor ) ; } if ( gzipMessageConstructionInterceptor . supportsMessageType ( messageType ) ) { getMessageContentBuilder ( ) . add ( gzipMessageConstructionInterceptor ) ; } return self ; } | Sets a explicit message type for this send action . |
28,487 | public T xpath ( String expression , String value ) { if ( xpathMessageConstructionInterceptor == null ) { xpathMessageConstructionInterceptor = new XpathMessageConstructionInterceptor ( ) ; if ( getAction ( ) . getMessageBuilder ( ) != null ) { ( getAction ( ) . getMessageBuilder ( ) ) . add ( xpathMessageConstructionInterceptor ) ; } else { PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . getMessageInterceptors ( ) . add ( xpathMessageConstructionInterceptor ) ; getAction ( ) . setMessageBuilder ( messageBuilder ) ; } } xpathMessageConstructionInterceptor . getXPathExpressions ( ) . put ( expression , value ) ; return self ; } | Adds XPath manipulating expression that evaluates to message payload before sending . |
28,488 | public T jsonPath ( String expression , String value ) { if ( jsonPathMessageConstructionInterceptor == null ) { jsonPathMessageConstructionInterceptor = new JsonPathMessageConstructionInterceptor ( ) ; if ( getAction ( ) . getMessageBuilder ( ) != null ) { ( getAction ( ) . getMessageBuilder ( ) ) . add ( jsonPathMessageConstructionInterceptor ) ; } else { PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder ( ) ; messageBuilder . getMessageInterceptors ( ) . add ( jsonPathMessageConstructionInterceptor ) ; getAction ( ) . setMessageBuilder ( messageBuilder ) ; } } jsonPathMessageConstructionInterceptor . getJsonPathExpressions ( ) . put ( expression , value ) ; return self ; } | Adds JSONPath manipulating expression that evaluates to message payload before sending . |
28,489 | protected void logRequest ( String logMessage , MessageContext messageContext , boolean incoming ) throws TransformerException { if ( messageContext . getRequest ( ) instanceof SoapMessage ) { logSoapMessage ( logMessage , ( SoapMessage ) messageContext . getRequest ( ) , incoming ) ; } else { logWebServiceMessage ( logMessage , messageContext . getRequest ( ) , incoming ) ; } } | Logs request message from message context . SOAP messages get logged with envelope transformation other messages with serialization . |
28,490 | protected void logResponse ( String logMessage , MessageContext messageContext , boolean incoming ) throws TransformerException { if ( messageContext . hasResponse ( ) ) { if ( messageContext . getResponse ( ) instanceof SoapMessage ) { logSoapMessage ( logMessage , ( SoapMessage ) messageContext . getResponse ( ) , incoming ) ; } else { logWebServiceMessage ( logMessage , messageContext . getResponse ( ) , incoming ) ; } } } | Logs response message from message context if any . SOAP messages get logged with envelope transformation other messages with serialization . |
28,491 | protected void logSoapMessage ( String logMessage , SoapMessage soapMessage , boolean incoming ) throws TransformerException { Transformer transformer = createIndentingTransformer ( ) ; StringWriter writer = new StringWriter ( ) ; transformer . transform ( soapMessage . getEnvelope ( ) . getSource ( ) , new StreamResult ( writer ) ) ; logMessage ( logMessage , XMLUtils . prettyPrint ( writer . toString ( ) ) , incoming ) ; } | Log SOAP message with transformer instance . |
28,492 | protected void logMessage ( String logMessage , String message , boolean incoming ) { if ( messageListener != null ) { log . debug ( logMessage ) ; if ( incoming ) { messageListener . onInboundMessage ( new RawMessage ( message ) , null ) ; } else { messageListener . onOutboundMessage ( new RawMessage ( message ) , null ) ; } } else { if ( log . isDebugEnabled ( ) ) { log . debug ( logMessage + ":" + System . getProperty ( "line.separator" ) + message ) ; } } } | Performs the final logger call with dynamic message . |
28,493 | private Transformer createIndentingTransformer ( ) throws TransformerConfigurationException { Transformer transformer = createTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; return transformer ; } | Get transformer implementation with output properties set . |
28,494 | private org . apache . kafka . clients . producer . KafkaProducer < Object , Object > createKafkaProducer ( ) { Map < String , Object > producerProps = new HashMap < > ( ) ; producerProps . put ( ProducerConfig . BOOTSTRAP_SERVERS_CONFIG , endpointConfiguration . getServer ( ) ) ; producerProps . put ( ProducerConfig . REQUEST_TIMEOUT_MS_CONFIG , new Long ( endpointConfiguration . getTimeout ( ) ) . intValue ( ) ) ; producerProps . put ( ProducerConfig . KEY_SERIALIZER_CLASS_CONFIG , endpointConfiguration . getKeySerializer ( ) ) ; producerProps . put ( ProducerConfig . VALUE_SERIALIZER_CLASS_CONFIG , endpointConfiguration . getValueSerializer ( ) ) ; producerProps . put ( ProducerConfig . CLIENT_ID_CONFIG , Optional . ofNullable ( endpointConfiguration . getClientId ( ) ) . orElse ( KafkaMessageHeaders . KAFKA_PREFIX + "producer_" + UUID . randomUUID ( ) . toString ( ) ) ) ; producerProps . putAll ( endpointConfiguration . getProducerProperties ( ) ) ; return new org . apache . kafka . clients . producer . KafkaProducer < > ( producerProps ) ; } | Creates default KafkaTemplate instance from endpoint configuration . |
28,495 | public void setProducer ( org . apache . kafka . clients . producer . KafkaProducer < Object , Object > producer ) { this . producer = producer ; } | Sets the producer . |
28,496 | public void start ( ) { application = new CitrusRemoteApplication ( configuration ) ; port ( configuration . getPort ( ) ) ; application . init ( ) ; if ( ! configuration . isSkipTests ( ) ) { new RunController ( configuration ) . run ( ) ; } if ( configuration . getTimeToLive ( ) == 0 ) { stop ( ) ; } } | Start server instance and listen for incoming requests . |
28,497 | public boolean waitForCompletion ( ) { try { return completed . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { log . warn ( "Failed to wait for server completion" , e ) ; } return false ; } | Waits for completed state of application . |
28,498 | public JmxServerBuilder environmentProperties ( Properties environmentProperties ) { HashMap < String , Object > properties = new HashMap < > ( environmentProperties . size ( ) ) ; for ( Map . Entry < Object , Object > entry : environmentProperties . entrySet ( ) ) { properties . put ( entry . getKey ( ) . toString ( ) , entry . getValue ( ) ) ; } endpoint . getEndpointConfiguration ( ) . setEnvironmentProperties ( properties ) ; return this ; } | Sets the environment properties . |
28,499 | public JmxServerBuilder timeout ( long timeout ) { endpoint . setDefaultTimeout ( timeout ) ; endpoint . getEndpointConfiguration ( ) . setTimeout ( timeout ) ; return this ; } | Sets the default timeout . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.