Message response method and device, electronic equipment and computer program product
By receiving and analyzing request messages, calculating similarity, and filtering target elements to form response messages, the problem of low accuracy and poor flexibility in matching complex structured messages in existing technologies is solved, achieving more efficient software testing results.
Patent Information
- Application Number
- CN202511070975.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-31
- Publication Date
- 2025-11-18
AI Technical Summary
Existing technologies suffer from low matching accuracy and poor flexibility when processing complex structured messages, especially in high-concurrency, high-throughput real-time transaction systems where they cannot achieve accurate and efficient matching.
By receiving request messages sent by the system under test, extracting M message elements, calculating the similarity with N candidate elements, constructing a similarity matrix, filtering out M target elements, forming a response message, and sending it.
It improves the accuracy and flexibility of matching complex structured messages, enhances the effectiveness and robustness of software testing, and enables a more comprehensive evaluation of the functionality and robustness of the system under test.
Smart Images

Figure CN120973671A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of software testing, in particular to a response method and device of a message, an electronic device and a computer program product. BACKGROUND
[0002] In the modern software development and testing environment, system integration testing is particularly important, aiming to ensure that different systems can communicate correctly and effectively, and application programs often need to interact with external services by sending and receiving complex JSON Array format messages. However, when the software testing team uses a simulator to replace those external systems in order to test more efficiently, the traditional matching method often faces challenges, especially when dealing with unordered or partially missing JSONArray messages.
[0003] Firstly, when dealing with JSONArray messages, one solution is to pre-sort the JSON elements in the message based on a common node value for the purpose of matching. When one or more elements are missing in the JSONArray sent by the system under test, since the sorting depends on the integrity of the elements, the corresponding relationship after sorting will be broken, resulting in elements that can be matched originally being unable to be correctly matched due to position disorder (i.e. position offset effect). In this case, the matching strategy after sorting will significantly reduce the accuracy and efficiency of the test, and even produce misleading results.
[0004] Another solution is to traverse each element in the JSONArray sent by the system under test one by one, trying to find a completely consistent corresponding item in the use case library of the simulator. Once found, it is marked as matched to prevent repeated matching of the same element. Although this method performs well when the elements are completely consistent and there is no missing, in actual application, due to the diversity of business requirements, there are often partial inconsistencies or missing of elements. At this time, the traversal elimination method cannot effectively adapt to such changes because it depends on completely matched elements, limiting its application range and flexibility, especially in the case of similar but not completely identical elements, meaningful matching results cannot be obtained. And with the increasing complexity of financial software systems, the message structure not only contains single type elements, but also may involve multi-level nested structures, including nested JSON objects and JSONArray, the existing test framework still has great limitations when dealing with complex JSONArray messages, especially in high concurrency and high throughput real-time trading systems, it cannot achieve accurate and efficient matching of elements.
[0005] In view of the technical problems of low matching accuracy and poor flexibility in matching response messages of complex structured messages in the related art, no effective solution has been proposed so far. SUMMARY
[0006] The main purpose of the present application is to provide a response method and device for a message, an electronic device and a computer program product, so as to solve the technical problems of low matching accuracy and poor flexibility in matching a response message for a complex structured message in the related art.
[0007] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a response method for a message is provided. The method comprises: receiving a request message sent by a system under test, and extracting M message elements from the request message, wherein the request message refers to a message generated after the system under test analyzes a test case selected by a user, and M is a positive integer; calculating the similarity of the M message elements and N candidate elements respectively to obtain M*N similarity data, and determining M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; and constructing a response message based on the M target elements, and sending the response message to the system under test.
[0008] Optionally, determining the M target elements from the candidate elements associated with the M*N similarity data comprises: constructing a similarity matrix based on the M*N similarity data, wherein the element in the i-th row and the j-th column of the similarity matrix refers to the similarity data of the i-th message element and the j-th candidate element, i is less than or equal to M, j is less than or equal to N, and i and j are positive integers; selecting the maximum similarity data from each group of similarity data to obtain M maximum similarity data, and constructing an expected array based on the M maximum similarity data, wherein each group of similarity data includes N similarity data calculated by one message element and N candidate elements; obtaining a preset array, and judging whether the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the expected array and the similarity data of the j-th element of the preset array, wherein after sorting the M message elements, if the target element of the first message element in the M message elements is determined, the preset array is an empty array, and if the target elements of M-1 message elements in the M message elements are determined, the preset array changes based on the similarity data; in the case that the similarity data of the element in the i-th row and the j-th column is equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, obtaining the M candidate elements associated with the M maximum similarity data from the expected array, and determining the M candidate elements as the M target elements; in the case that the similarity data of the element in the i-th row and the j-th column is not equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, stopping the step of determining the M target elements from the candidate elements associated with the M*N similarity data.
[0009] Optionally, the similarity of the M message elements and the N candidate elements is calculated respectively to obtain M*N similarity data, including: for the ith message element and the jth candidate element, extracting a message node from the ith message element to obtain P1 message nodes, and obtaining node data corresponding to each message node to obtain P2 node data, wherein the node type of each message node at least includes a nested type and a standard node type, at least one message node exists in the message node of the nested type, P1 is less than or equal to P2, P1 and P2 are positive integers; extracting node data of a message node in the jth candidate element to obtain a group of candidate node data, calculating the similarity data of each node data and each candidate node data in the group of candidate node data to obtain P2 groups of similarity data; calculating the sum of the similarity data in the P2 groups of similarity data to obtain the similarity data of the ith message element and the jth candidate element.
[0010] Optionally, M candidate elements associated with the M maximum similarity data in the expected array are obtained, and the M candidate elements are determined as the M target elements, including: for a message element, obtaining a candidate element corresponding to the maximum similarity data associated with the message element from the expected array to obtain an initial element, and judging whether the initial element has been matched with a message element; in the case that the initial element has not been matched with a message element, determining the initial element as a target element associated with the message element; and in the case that the initial element has been matched with a message element, screening a target element of the message element from the N-1 candidate elements through a degraded matching algorithm.
[0011] Optionally, the target element of the message element is filtered from the N-1 candidate elements by a degraded matching algorithm, including: judging whether there is a to-be-matched element in the N-1 candidate elements, wherein the similarity data of the to-be-matched element and the message element is the same as the similarity data of the initial element and the message element; if the to-be-matched element exists in the N-1 candidate elements, the to-be-matched element is determined as the target element, if the to-be-matched element does not exist in the N-1 candidate elements, T message elements in the M message elements are cached to an augmented path, and the initial element is cached to the augmented path, wherein the T message elements refer to the message elements having the same similarity data with the same candidate element, and T is a positive integer; a benchmark value is determined based on the algebra sum of the similarity matrix, the expected array and the preset array, and the similarity data of the T message elements in the expected array and the preset array are adjusted based on the benchmark value to obtain an adjusted expected array and an adjusted preset array; in a case where the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, the target element is filtered from the adjusted expected array; in a case where the similarity data of the element in the i-th row and the j-th column of the similarity matrix is not equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, the step of filtering the target element of the message element from the N-1 candidate elements by the degraded matching algorithm is stopped.
[0012] Optionally, the M message elements are extracted from the request message, including: parsing the request message to obtain Y message information in a preset format, wherein the preset format at least includes an array type data exchange format and an object type data exchange format, Y is less than or equal to M, and Y is a positive integer; and performing element extraction on the Y message information in the preset format to obtain the M message elements.
[0013] Optionally, the N candidate elements are obtained by: obtaining a use case number associated with the request message, wherein the use case number refers to a number corresponding to a test use case selected by a user; obtaining a use case library, filtering K message information from the use case library based on the use case number, and extracting N candidate elements from the K message information, wherein the use case library includes message information in a plurality of use cases and a use case number associated with each use case, K is less than or equal to N, and K is a positive integer.
[0014] To achieve the above object, according to another aspect of the present application, a response device of a message is provided. The device comprises: a receiving unit configured to receive a request message sent by a system under test, and extract M message elements from the request message, wherein the request message is a message generated by the system under test after analyzing a test case selected by a user, and M is a positive integer; a calculating unit configured to calculate similarities between the M message elements and N candidate elements respectively, obtain M*N similarity data, and determine M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; and a constituting unit configured to constitute a response message based on the M target elements, and send the response message to the system under test.
[0015] According to another aspect of the embodiments of the present application, a computer readable storage medium is also provided, which comprises a stored executable program, wherein the executable program, when executed, controls a device where the computer readable storage medium is located to perform any of the above message response methods.
[0016] According to another aspect of the embodiments of the present application, an electronic device is also provided, which comprises one or more processors and a memory, the memory storing an executable program, and the processor configured to execute the program, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any of the above message response methods.
[0017] According to another aspect of the embodiments of the present application, a computer program product is also provided, which comprises a computer program, wherein the computer program, when executed by a processor, implements any of the above message response methods.
[0018] In the embodiments of the present application, the response of the message is adopted, the request message sent by the system under test is received, and M message elements are extracted from the request message, wherein the request message is a message generated by the system under test after analyzing a test case selected by a user, and M is a positive integer; similarities between the M message elements and N candidate elements are calculated respectively, M*N similarity data are obtained, and M target elements are determined from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; a response message is constituted based on the M target elements, and the response message is sent to the system under test, thereby solving the technical problems of low matching accuracy and poor flexibility in matching the response message of the complex structured message in the related art, determining the target elements according to the similarities between the message elements and the candidate elements by receiving the request message sent by the system under test and extracting the message elements from the request message, constituting the response message based on the target elements, sending the response message to the system under test, and further achieving the technical effects of improving the matching accuracy and flexibility of the complex structured message processing. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which form a part of this application, are included to provide a further understanding of the application and are incorporated in and constitute a part of this application. The embodiments of the application illustrated in the drawings are provided to explain the present application and are not meant to limit the present application. In the drawings:
[0020] Figure 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a response method of a message;
[0021] Figure 2 is a flow chart of a response method of a message according to an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of an optional response method of a message according to an embodiment of the present application Figure 1 ;
[0023] Figure 4 is a schematic diagram of an optional response method of a message according to an embodiment of the present application Figure 2 ;
[0024] Figure 5 is a schematic diagram of a response device of a message according to an embodiment of the present application;
[0025] Figure 6 is a structure block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work should belong to the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0028] It should be noted that the related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present application are information and data authorized by the user or authorized by all parties. For example, the system and related users or institutions have an interface, which provides the user with the corresponding operation entry for the user to choose to agree or refuse the automatic decision result. Before obtaining the related information, the interface needs to send a request to the aforementioned user or institution, and after receiving the consent information fed back by the aforementioned user or institution, the related information is obtained; if the user chooses to refuse, the expert decision process is entered. The user can decode the purpose of data use in real time through authorization, and has the right to withdraw authorization or delete data at any time, and after withdrawing authorization, the system will terminate the related data processing within 24 hours.
[0029] It should be noted that the information collected in the present application is information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data comply with relevant laws, regulations and standards in the relevant region, necessary security measures are taken, do not violate public order and good custom, and provide corresponding operation entry for the user to choose to authorize use or refuse to use.
[0030] Embodiment 1
[0031] According to the embodiments of the present application, a method for responding to a message is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] The method provided by the embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing the method for responding to a message is shown in FIG. 1. Figure 1 As shown in FIG. 1, the computer terminal 10 (or mobile device) can include one or more (central processing unit) CPUs 101, memories 102, storage devices 103, communication interfaces 104, input devices 105, output devices 106, and the like. Figure 1The processor 102 (which can include, but is not limited to, a microcontroller unit (MCU) or a field-programmable gate array (FPGA) or the like), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the bus), a network interface, a keyboard, a cursor control device, a power supply, and / or a camera can be included. Those skilled in the art can understand that Figure 1 The structure shown is only schematic and does not limit the structure of the electronic device described above. For example, the computer terminal 10 can further include more or fewer components than those shown in the figure, or have a different configuration from that shown in the figure. Figure 1 Figure 1 The structure shown is only schematic and does not limit the structure of the electronic device described above. For example, the computer terminal 10 can further include more or fewer components than those shown in the figure, or have a different configuration from that shown in the figure.
[0033] It should be noted that the one or more processors 102 and / or other data processing circuits described above can be referred to herein generally as "data processing circuits". The data processing circuits can be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuits can be a single independent processing module, or any one of the other elements incorporated into the computer terminal 10 (or mobile device) in whole or in part. As referred to in the embodiments of the present application, the data processing circuits serve as a processor to control, for example, the selection of the variable resistance terminal path connected to the interface.
[0034] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage means corresponding to the response method of the message in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, i.e. implements the response method of the message described above. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 can further include a memory remotely located with respect to the processor 102, which can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0035] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the computer terminal 10. In an example, the transmission device 106 includes a network interface controller (NIC) and a network interface that can connect to other network devices through a base station to communicate with the Internet. In an example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet wirelessly.
[0036] The display can be a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or a mobile device).
[0037] In the above operating environment, the application provides a response method of a message as shown in Figure 2 Figure 2 is a flowchart of the response method of the message according to an embodiment of the application, as shown in Figure 2
[0038] In step S201, a request message sent by a system under test is received, and M message elements are extracted from the request message, wherein the request message is a message generated by the system under test after analyzing a test case selected by a user, and M is a positive integer.
[0039] Specifically, the request message is a communication data packet sent by the system under test to a simulator in response to a specific test case triggered by a user in a software testing process, and the message follows a JSON Array format and can include multiple JSON elements. Each element can be a simple key-value pair or a complex nested structure. For example, when a user selects a test case and starts execution, a request reaches the system under test, which analyzes and processes the request and generates a request message for obtaining response data in a real scenario. The request message is a key data carrier in the testing process and includes instructions and data to be processed by the system, i.e., all information required for testing, from simple data points to complex business process instructions. The system under test refers to a software system or module being tested, and the function, performance, or stability of the system is the main target of the test, which can be a core component responsible for processing a certain business logic.
[0040] In the field of software testing, a simulator is a testing tool used to imitate or replace the behavior of an actual system. After the measured system sends a request message, the simulator can receive and analyze the content of the request message to obtain multiple independent message elements. The most similar response message is found in the use case library to return to the measured system, thereby helping to create a controlled testing environment, allowing testers to test the reaction of the measured system under various preset conditions. By converting complex request messages into a series of more easily processed elements, similarity calculation and optimal matching algorithms can be applied to each element rather than the entire message, thereby improving processing efficiency and accuracy. The use case library is a collection of pre-defined test cases and corresponding data, which contains a variety of possible message samples for matching and responding to the request messages sent by the measured system.
[0041] It should be noted that each message element can be a JSON object or a nested JSONArray. In the process of processing the request message, the simulator first needs to identify and separate these message elements to further perform similarity calculation and matching operations.
[0042] After extracting the message elements, the simulator performs similarity calculation and optimal matching procedures to determine the most suitable response message in the use case library and finally returns it to the measured system, thereby helping to verify whether the functions and behaviors of the measured system under various preset conditions meet expectations. Through fine element matching, not only the functionality of the system can be tested, but also its ability to handle complex and non-standard messages can be evaluated, enhancing the overall effectiveness of the test.
[0043] Step S202, respectively calculating the similarity of M message elements and N candidate elements, obtaining M*N similarity data, and determining M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer.
[0044] Specifically, after extracting multiple message elements from the request message, multiple candidate elements can be extracted from the use case library first, then similarity calculation is performed between the message elements and each candidate element to evaluate the closeness between the two data elements in structure, content and semantics, and after obtaining multiple independent similarity data, the target elements that can be matched with each message element are selected from the above-mentioned multiple candidate elements based on the similarity data.
[0045] Step S203, constructing a response message based on the M target elements, and sending the response message to the measured system.
[0046] Specifically, after the corresponding target element is screened out, a response message can be constructed in the same JSONArray format as the request message. Then the response message is sent to the system under test through a set communication mechanism, thereby providing intuitive feedback of the system functionality and interactivity to the tester.
[0047] The method for constructing a response message provided by the embodiments of the present application comprises the following steps: receiving a request message sent by a system under test; extracting M message elements from the request message, wherein the request message is a message generated by the system under test after analyzing a test case selected by a user, and M is a positive integer; calculating the similarity of the M message elements and N candidate elements respectively to obtain M*N similarity data, wherein N is greater than M and N is a positive integer; determining M target elements from the candidate elements associated with the M*N similarity data; and constructing a response message based on the M target elements and sending the response message to the system under test. The method solves the technical problem of low matching accuracy and poor flexibility in matching a response message to a complex structured message in the related art. The method extracts message elements from a request message sent by a system under test, determines target elements according to the similarity of the message elements and candidate elements, constructs a response message based on the target elements, and sends the response message to the system under test, thereby achieving the technical effect of improving the matching accuracy and flexibility of complex structured message processing.
[0048] Optionally, in the response method of the message provided in the embodiments of the present application, determining the M target elements from the M*N similarity data associated candidate elements comprises: constructing a similarity matrix based on the M*N similarity data, wherein the i-th row and j-th column element in the similarity matrix refers to the similarity data of the i-th message element and the j-th candidate element, i is less than or equal to M, j is less than or equal to N, and i and j are positive integers; selecting the maximum similarity data from each group of similarity data of the M*N similarity data respectively to obtain M maximum similarity data, and constructing an expected array from the M maximum similarity data, wherein each group of similarity data includes N similarity data calculated from one message element and N candidate elements; obtaining a preset array, and judging whether the similarity data of the i-th row and j-th column element in the similarity matrix is equal to the sum of the similarity data of the i-th element of the expected array and the similarity data of the j-th element of the preset array, wherein, after sorting the M message elements, if the target element of the first message element in the M message elements is determined, the preset array is an empty array, and if the target elements of M-1 message elements in the M message elements are determined, the preset array changes based on the similarity data; in the case that the similarity data of the i-th row and j-th column element is equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, obtaining the M candidate elements associated with the M maximum similarity data from the expected array, and determining the M candidate elements as the M target elements; in the case that the similarity data of the i-th row and j-th column element is not equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, stopping the step of determining the M target elements from the M*N similarity data associated candidate elements.
[0049] Specifically, in the step of screening the target elements, first, an M*N similarity matrix can be constructed based on the M*N similarity data between the M message elements and the N candidate elements, wherein each element similarArray[i][j] in the matrix similarArray represents the similarity value between the i-th message element in the request message and the j-th candidate element in the use case library, and the matrix can clearly show the similarity relationship between all elements, thereby providing necessary data structure for subsequent steps. Then, the similarity matrix is traversed, and the maximum similarity data is selected for each row in the matrix, thereby obtaining an array with a length of M, which contains the similarity values of the M message elements respectively with the most similar one of the N candidate elements, that is, obtaining the expected array expectArray, and each element expectArray[i] of the expected array corresponds to the best matching expected similarity value of the i-th message element.
[0050] Further, when the target element corresponding to the first message element is selected, after the preset array actualArray with the value of 0 is obtained, the similarity data of the element similarArray[i][j] in the i-th row and the j-th column in the similarity matrix is compared with the sum of the i-th element expectArray[i] in the expected array and the j-th element actualArray[j] in the preset array, that is, expectArray[i]+actualArray[j]. If similarArray[i][j] = expectArray[i]+actualArray[j], it indicates that the current matching is the best choice based on the previous maximum similarity data, the j-th candidate element related to the i-th maximum similarity data is obtained from the expected array, and the j-th candidate element is determined as the target element of the i-th message element.
[0051] On the contrary, if similarArray[i][j] and expectArray[i]+actualArray[j] are inconsistent, it means that the current matching result does not conform to the preset or expected matching scheme, which may be because the matching between the message element and the candidate element has an abnormal situation, such as element missing or inconsistent structure, and at this time, the subsequent steps need to be stopped to avoid producing an incorrect matching result and affecting the accuracy and effectiveness of the test.
[0052] The embodiment filters M target elements most matched with M message elements in the request message from N candidate elements, which not only improves the efficiency and accuracy of matching, but also enhances the flexibility and robustness of software testing, ensures that the test environment can truly simulate various business scenarios, and thus more comprehensively evaluates the functionality and robustness of the system under test.
[0053] Optionally, in the response method of the message provided in the embodiment of the application, the similarity of the M message elements and the N candidate elements is calculated respectively to obtain M*N similarity data, which includes: for the i-th message element and the j-th candidate element, message nodes are extracted from the i-th message element to obtain P1 message nodes, and node data corresponding to each message node is obtained to obtain P2 node data, wherein the node type of each message node at least includes: a nested type and a standard node type, at least one message node exists in the message node of the nested type, P1 is less than or equal to P2, and P1 and P2 are positive integers; node data of message nodes in the j-th candidate element is extracted to obtain a group of candidate node data, similarity data of each node data and each candidate node data in the group of candidate node data is calculated to obtain P2 groups of similarity data; and the sum of the similarity data in the P2 groups of similarity data is calculated to obtain the similarity data of the i-th message element and the j-th candidate element.
[0054] Specifically, when calculating the similarity data, the i-th message element in the request message needs to be analyzed first to extract the message nodes therein, obtaining a plurality of message nodes. It should be noted that a message element can contain a plurality of message nodes, which can be divided into two categories according to their structures: nested message nodes, which means that the node contains other nodes inside, such as nested JSON objects or JSONArray; and standard node types, which are single nodes without nesting, such as key-value pairs. Then the node data of each message node is obtained, obtaining a plurality of corresponding node data. At the same time, the node data of the message nodes in the j-th candidate element is also extracted to form a set of candidate node data.
[0055] Further, the similarity data of each node data and each candidate node data in the candidate element can be calculated by a string similarity algorithm (such as edit distance, cosine similarity, etc.), to quantify the similarity degree of the two node data in structure, content or semantics, and further obtain a plurality of sets of similarity data, wherein if the element is a standard json format, the similarity is directly calculated and summed according to the similarity algorithm; if the element is still nested with JSONArray format message, recursion is performed, returning to the beginning of this step, and the similarity after optimal matching of the JSONArray element is calculated. Finally, all the similarity data is summed up to obtain the similarity data of the i-th message element and the j-th candidate element, which can reflect the similarity between the two elements.
[0056] The embodiment can more accurately identify the similarity between elements by decomposing complex message elements into smaller units and further calculating the similarity data of each node data and each candidate node data in a set of candidate node data. Even in the case of incomplete matching between elements, the overall similarity can be evaluated based on the similarity of the node data, effectively dealing with complex and variable element structures, significantly improving the matching efficiency and accuracy of the simulator in software testing, and enhancing the robustness and effectiveness of the test process.
[0057] Optionally, in the response method of the message provided in the embodiment of the application, the M candidate elements associated with the M maximum similarity data are obtained from the expected array, and the M candidate elements are determined as M target elements, comprising: for a message element, obtaining the candidate element corresponding to the maximum similarity data associated with the message element from the expected array to obtain an initial element, and judging whether the initial element has been matched with a message element; in the case that the initial element has not been matched with a message element, determining the initial element as the target element associated with the message element; and in the case that the initial element has been matched with a message element, screening the target element of the message element from the N-1 candidate elements through a degraded matching algorithm.
[0058] Specifically, when screening the candidate elements, first, according to expectArray[i]+actualArray[j]=similarArray[i][j], the candidate element corresponding to the maximum similarity data of the packet element is found from the expected array expectArray, and the initial element is obtained. In the multi-element matching scenario, the candidate elements in the use case library may be used multiple times, at which time it is necessary to judge whether the initial element has been matched with another packet element, so as to ensure the independence and accuracy of the matching, and the repeated matching situation needs to be avoided.
[0059] If the initial element is not occupied, that is, it is not matched with any packet element, at this time it can be directly determined as the target element associated with the current packet element, avoiding the matching conflict and ensuring that each packet element can find the most similar candidate element that is not used as the matching object. On the contrary, if the initial element has been matched with a packet element, at this time it is necessary to continue to find the element with higher matching degree with the current packet element from the remaining N-1 candidate elements through the degraded matching algorithm, that is, to consider the suboptimal selection, and to screen the most suitable target element of the packet element from the remaining candidate elements by adjusting the similarity threshold or the matching strategy.
[0060] The embodiment can ensure that each packet element is matched with the most similar candidate element as much as possible, can maximize the quality of the matching, can ensure that all packet elements can find the matching object closest in structure and content, can avoid the situation that the same candidate element is repeatedly matched by multiple packet elements, can guarantee the independence of the matching and the reasonable use of the use case library resources, and can increase the flexibility of the matching process by enabling the degraded matching algorithm, so that the scheme can cope with more complex and variable actual scenarios, not only improves the accuracy and speed of the matching, but also enhances the adaptability and robustness of the software testing environment.
[0061] Optionally, in the response method of the message provided in the embodiments of the present application, the step of screening the target element of the message element from the N-1 candidate elements through the degraded matching algorithm comprises: judging whether there is a to-be-matched element in the N-1 candidate elements, wherein the similarity data of the to-be-matched element and the message element is the same as the similarity data of the initial element and the message element; if the to-be-matched element exists in the N-1 candidate elements, the to-be-matched element is determined as the target element; if the to-be-matched element does not exist in the N-1 candidate elements, T message elements in the M message elements are cached to an augmented path, and the initial element is cached to the augmented path, wherein the T message elements refer to the message elements having the same similarity data with the same candidate element, and T is a positive integer; a benchmark value is determined based on the algebraic sum of the similarity matrix, the expected array and the preset array, and the similarity data of the T message elements in the expected array and the preset array are adjusted based on the benchmark value, to obtain an adjusted expected array and an adjusted preset array; if the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, the target element is screened from the adjusted expected array; if the similarity data of the element in the i-th row and the j-th column of the similarity matrix is not equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, the step of screening the target element of the message element from the N-1 candidate elements through the degraded matching algorithm is stopped.
[0062] Specifically, when the initial element is occupied, in order to screen the target element from the remaining candidate elements, first, it can be checked whether there is a to-be-matched element having the same similarity data as the initial element in the remaining candidate elements, wherein the to-be-matched element refers to a candidate element having the optimal matching similarity with the current message element but not yet matched in the similarity matrix. If the to-be-matched element is found, the to-be-matched element can be directly determined as the target element.
[0063] Conversely, if there is no matching element in the candidate elements with the same similarity data, at this time, the message element in the message element, which has the highest similarity data with the same candidate element, that is, the message element with the same candidate element has the equivalent matching degree, is cached to the augmented path, which lays the foundation for subsequent matching. For the candidate elements that have not been matched, the benchmark value is determined by the algebraic sum of the similarity data in the similarity matrix, the expected array and the preset array corresponding to the elements that are being matched and have been matched, that is, the value is calculated in turn through expectArray[i]+actualArray[j]-similarArray[i][j], and the value with the smallest value is determined as the benchmark value, wherein the benchmark value can be used to quantify the amplitude of the matching adjustment, and ensure that the adjusted expected array and preset array can still reflect the matching degree between the message element and the candidate element. Then, based on the benchmark value, the expected array and the preset array are adjusted respectively to obtain the adjusted expected array and the adjusted preset array, that is, the expectArray[i] corresponding to the elements in the augmented path is subtracted by the benchmark value, and the actualArray[j] corresponding to the elements in the augmented path is added by the benchmark value, in this way, the value of similarArray[i][j] of the modified element is unchanged.
[0064] Further, the similarity matrix corresponding to the message elements in the augmented path, the adjusted expected array and the adjusted preset array are analyzed, if the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, at this time, the target element can be screened out from the adjusted expected array, which ensures that even in the case of degraded matching, the target element that meets the matching condition can be found.
[0065] For example, the message elements in the JsonArray message sent by the system under test are [A, B, C], and the candidate elements of the JsonArray message obtained from the use case library are [D, E, F], wherein A, B, C, D, E, F are all standard json formats. Assuming that the similarity of A and D is 8, the similarity of A and E is 12, the similarity of A and F is 15, the similarity of B and D is 10, the similarity of B and E is 13, the similarity of B and F is 12, the similarity of C and D is 6, the similarity of C and E is 14, and the similarity of C and F is 8, at this time the similarity matrix similarArray can be represented as: [[8, 12, 15], [10, 13, 12], [6, 14, 8]], that is, the maximum similarity of A and D, E, F is A and F, and the similarity is 15, and so on. The expected array expectArray can be represented as [15, 13, 14], and the preset array actualArray has all initial values of 0 (that is, [0, 0, 0]).
[0066] In the cycle of traversing each message element, each message element finds the element with the highest matching degree from the candidate elements obtained from the use case library according to expectArray[i]+actualArray[j]=similarArray[i][j], that is, A finds F, and B and C find E. After finding, it is necessary to judge whether the element has been matched by other message elements. Since A finds F first, and B finds E, it indicates that the element matching is successful, that is, A and F match successfully, and B and E match successfully. When C matches, it is found that E most similar to C is occupied by B, and no candidate element with the same similarity data as E can be found in D and F. At this time, B and E need to be cancelled, and a flag is set, that is, the message elements involved are put into the augmented path, that is, B and C are put into the augmented path. Since F has been matched by A, E is in contention with B and C, and for elements other than the elements being matched and the elements that have been matched, that is, D, at this time, the value can be calculated according to expectArray[i]+actualArray[j]-similarArray[i][j] in turn, and the minimum value obtained according to the formula, that is, the minimum change, is determined as the flag value, that is, expectArray[B]+actualArray[D]-similarArray[B][D] is the minimum value obtained by calculation, and the flag value is 3 at this time. Then, the expected array expectArray[i] corresponding to the elements B and C in the augmented path is subtracted by the flag value, that is, since the message elements B and C are in the second and third positions in the array constructed by the message elements, i represents 2 and 3 at this time, and the expected array expectArray becomes [15, 10, 11] at this time. The actualArray[j] corresponding to the candidate element E contended by the message elements in the augmented path is added to the flag value, and actualArray becomes [0, 3, 0] at this time, that is, since the candidate element E is in the second position in the array constructed by the candidate elements, j represents 2 at this time. In this way, the value of similarArray[i][j] remains unchanged. When B and C continue to match, B and D match, and C and E match.
[0067] The above-described degraded matching algorithm is used for element screening in this embodiment, so that when optimal matching is not feasible, the target elements matched with the message elements can still be intelligently and efficiently screened out. Not only is the deadlock or circular matching in the matching process avoided, but also the adaptability and robustness of the system in the face of complex matching scenarios are enhanced, so as to improve the overall matching quality and test efficiency.
[0068] Optionally, in the response method of the message provided in the embodiment of the application, the M message elements are extracted from the request message, including: parsing the request message to obtain Y message information in a preset format, wherein the preset format at least includes an array type data exchange format and an object type data exchange format, Y is less than or equal to M, and Y is a positive integer; and performing element extraction on the Y message information in the preset format to obtain the M message elements.
[0069] Specifically, in order to realize accurate matching and response, when obtaining message elements, since the request message from the system under test is in the JSONArray format, it contains multiple JSON objects. At this time, the request message needs to be parsed, that is, its structure and content are split and understood, so as to obtain multiple message information in a preset format. The preset format refers to the format of the elements in the message, which can include an array type (JSONArray) and an object type (JSON Object). The array type is used to store multiple similar data items, and the object type is used to encapsulate key-value pairs to express more complex data structures.
[0070] Further, since the request message can contain a multi-level nested structure, the message information in the above-mentioned preset format needs to be element-extracted, so as to extract multiple message elements. Each message element can be a single JSON object, or a smaller data unit such as a specific key-value pair, a numerical field or a string field.
[0071] Through the parsing and element extraction of the request message, the embodiment can ensure the standardization of the data format and the fine division of the elements when processing complex JSONArray format data, and provides high-quality input for subsequent multi-dimensional similarity calculation and optimal matching algorithm. This not only improves the matching efficiency, but also ensures the accuracy of the matching, effectively reduces the matching error rate, and improves the accuracy and reliability of the software testing.
[0072] Optionally, in the response method of the message provided in the embodiment of the application, the N candidate elements are obtained by: obtaining a use case number associated with the request message, wherein the use case number refers to the number corresponding to the test use case selected by the user; obtaining a use case library, and filtering K message information from the use case library based on the use case number, and extracting N candidate elements from the K message information, wherein the use case library includes message information in multiple use cases and a use case number associated with each use case, K is less than or equal to N, and K is a positive integer.
[0073] Specifically, when the candidate elements are acquired, since the user starts the test process and selects a specific test case, the test case number corresponding to the test case can be acquired at this time, the scope of the test case is clear, and the subsequent matching process is laid a foundation. Then, based on the acquired test case number, a plurality of message information related to the number is screened from the test case library, wherein the message information represents various request and response messages that the system under test may encounter in a specific test scenario, and then a plurality of candidate elements corresponding to the message information can be extracted.
[0074] The embodiment accurately positions the test case and screens the candidate elements, reduces invalid matching attempts, improves test efficiency, and greatly improves the accuracy and reliability of software testing.
[0075] The embodiment of the application also provides a response method of a message, Figure 3 is a schematic diagram of an optional response method of a message provided by the embodiment of the application Figure 1 , Figure 4 is a schematic diagram of an optional response method of a message provided by the embodiment of the application Figure 2 as shown in Figure 3 , Figure 4 It should be noted that the method involves the following components: a system under test, which refers to a system to be verified in software testing, that is, a system developed by a project to implement main business, mainly receives test case requests and processes business; a simulator, which is used to receive requests sent by the system under test, analyze and match the requests, and return corresponding response information in the test case library; and a test case library, which is a data set to be selected by the simulator. The method comprises the following steps.
[0076] When the user selects a test case and starts execution, after the request reaches the system under test and the system under test analyzes and processes the request, the system under test sends a request to the simulator to acquire response data in a real scenario, that is, the system under test sends a JSONArray format message to the simulator.
[0077] After the simulator receives the request message of the system under test, the simulator receives the request of the system under test, and starts matching with the message information in the test case library, that is, the matching operation is realized through the following steps:
[0078] Step 1: After the simulator receives the JSONArray format message sent by the system under test, the message information is analyzed.
[0079] Step 2: The simulator obtains the test case number according to the message information of the system under test, finds the message information in the corresponding test case in the test case library, that is, acquires the JSONArray format message.
[0080] Third step: Calculate the similarity between each element in the message information of the system under test and the message information in the use case library, and record it in a two-dimensional array similarArray, that is, assign a value to each element. During the calculation process, it is necessary to judge whether the element is nested in JSONArray format. If the element is in standard json format, the values of each node are taken out, and the similarity is calculated in turn according to the similarity algorithm and summed up. If the element is still nested in JSONArray format message, recursive processing is performed, returning to the beginning of this step, and the similarity of the optimal matching of the JSONArray element is calculated. At the same time, the maximum similarity between each element in the message information of the system under test and the element in the message information in the use case library is recorded in the two-dimensional array expectArray, and the initial value of the array actualArray is obtained.
[0081] Fourth step: Loop through each element in the message of the system under test and match the elements in the message information in the use case library.
[0082] Fifth step: According to expectArray[i]+actualArray[j]=similarArray[i][j], find the element with the highest matching degree in the message information in the use case library for each element in the message of the system under test.
[0083] Sixth step: After finding it, judge whether the element has been matched by other elements in the message of the system under test. If it has not been matched, the element in the message of the system under test is matched successfully, that is, to the ninth step.
[0084] Seventh step: If it has been matched, the element in the message of the system under test that has matched the element needs to find other matches, that is, the element in the message of the system under test that occupies the element needs to find other optimal matching elements. If it is found, both elements in the message of the system under test are matched successfully, and the next element starts to find a matching element, that is, to the ninth step.
[0085] Eighth step: If it is still not found, a benchmark is set up, and the weight of the non-augmented path element is modified, that is, the elements involved in the fifth step are put into the augmented path, and the elements in the message of the system under test and the elements in the message information in the use case library that are not in the augmented path are calculated in turn according to expectArray[i]+actualArray[j]-similarArray[i][j], and the minimum value with the smallest change is set as the benchmark. Then the expectArray[i] corresponding to the element in the augmented path is reduced by the benchmark value, and the actualArray[j] corresponding to the element in the augmented path is added to the benchmark value. In this way, the value of similarArray[i][j] remains unchanged. Then return to the fifth step and continue matching.
[0086] Step 9: One element in the system-under-test message is matched successfully.
[0087] Step 10: It is judged whether there is an element in the system-under-test message that is not matched, if yes, return to Step 4 to continue matching; if no, all elements are matched successfully.
[0088] After the matched element is found, the simulator can process the matched element to obtain a matched response message, and return the matched response message to the system-under-test.
[0089] The embodiment receives the request message sent by the system-under-test, extracts message elements from the request message, determines target elements according to the similarity of the message elements and candidate elements, forms a response message based on the target elements, and sends the response message to the system-under-test, thereby achieving the technical effects of improving the matching accuracy and flexibility of complex structured message processing.
[0090] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a group of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0091] Embodiment 2
[0092] The embodiment of the present application also provides a response device for a message. It should be noted that the response device for a message of the embodiment of the present application can be used to execute the response method for a message provided by the embodiment of the present application. The response device for a message provided by the embodiment of the present application is introduced as follows.
[0093] According to the embodiment of the present application, a device for implementing the above-mentioned response method for a message is also provided, Figure 5 is a schematic diagram of the response device for a message provided by the embodiment of the present application, as Figure 5 shown, the device comprises a receiving unit 50, a computing unit 51, and a forming unit 52.
[0094] The receiving unit 50 is configured to receive a request message sent by a system-under-test, and extract M message elements from the request message, wherein the request message refers to a message generated after the system-under-test analyzes a test case selected by a user, and M is a positive integer;
[0095] The computing unit 51 is configured to calculate the similarity of the M message elements and N candidate elements respectively, obtain M*N similarity data, and determine M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer.
[0096] A constructing unit 52 is configured to construct a response message based on the M target elements, and send the response message to the system under test.
[0097] The response message device provided by the embodiment of the application receives a request message sent by the system under test through the receiving unit 50, extracts M message elements from the request message, wherein the request message is a message generated by the system under test after analyzing a test case selected by a user, and M is a positive integer; the calculating unit 51 calculates the similarity of the M message elements and N candidate elements respectively, obtains M*N similarity data, and determines M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; and the constructing unit 52 constructs a response message based on the M target elements, and sends the response message to the system under test, thereby solving the technical problem of low matching accuracy and poor flexibility in matching the response message of the complex structured message in the related art, extracting the message elements from the request message sent by the system under test, determining the target elements according to the similarity of the message elements and the candidate elements, constructing the response message based on the target elements, sending the response message to the system under test, and further achieving the technical effect of improving the matching accuracy and flexibility of the complex structured message processing.
[0098] Optionally, in the response device for the message provided in the embodiments of the present application, the computing unit 51 comprises: a constructing module, configured to construct a similarity matrix based on the M*N similarity data, wherein the element in the i-th row and the j-th column of the similarity matrix refers to the similarity data of the i-th message element and the j-th candidate element, i is less than or equal to M, j is less than or equal to N, i and j are positive integers; a first screening module, configured to screen the maximum similarity data from each group of similarity data of the M*N similarity data respectively, to obtain M maximum similarity data, and to construct an expected array based on the M maximum similarity data, wherein each group of similarity data comprises N similarity data calculated by one message element and N candidate elements respectively; a first obtaining module, configured to obtain a preset array, and to determine whether the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the expected array and the similarity data of the j-th element of the preset array, wherein, after the M message elements are sorted, if the target element of the first message element in the M message elements is determined, the preset array is an empty array, and if the target elements of the M-1 message elements in the M message elements are determined, the preset array is based on the change of the similarity data; a second obtaining module, configured to obtain, in the case that the similarity data of the element in the i-th row and the j-th column is equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, the M candidate elements associated with the M maximum similarity data from the expected array, and to determine the M candidate elements as the M target elements; and a first executing module, configured to stop executing the step of determining the M target elements from the candidate elements associated with the M*N similarity data in the case that the similarity data of the element in the i-th row and the j-th column is not equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element.
[0099] Optionally, in the response device for the message provided in the embodiments of the present application, the computing unit 51 comprises: a first extracting module, configured to extract a message node from the i-th message element for the i-th message element and the j-th candidate element, to obtain P1 message nodes, and to obtain node data corresponding to each message node to obtain P2 node data, wherein the node type of each message node at least comprises a nested type and a standard node type, at least one message node exists in the message node of the nested type, P1 is less than or equal to P2, and P1 and P2 are positive integers; a second extracting module, configured to extract node data of the message node in the j-th candidate element to obtain a group of candidate node data, to calculate the similarity data of each node data and each candidate node data in the group of candidate node data to obtain P2 groups of similarity data; and a computing module, configured to calculate the sum of the similarity data in the P2 groups of similarity data to obtain the similarity data of the i-th message element and the j-th candidate element.
[0100] Optionally, in the response apparatus for the message provided by the embodiment of the present application, the computing unit 51 comprises: a third obtaining module, configured to, for a message element, obtain candidate elements corresponding to the maximum similarity data associated with the message element from the expected array, to obtain an initial element, and judge whether the initial element has been matched with a message element; a first determining module, configured to, in the case that the initial element has not been matched with a message element, determine the initial element as a target element associated with the message element; and a second screening module, configured to, in the case that the initial element has been matched with a message element, screen the target element of the message element from the N-1 candidate elements through the degraded matching algorithm.
[0101] Optionally, in the response apparatus for the message provided by the embodiment of the present application, the computing unit 51 comprises: a judging module, configured to judge whether there is a to-be-matched element in the N-1 candidate elements, wherein the similarity data of the to-be-matched element and the message element is the same as the similarity data of the initial element and the message element; a second determining module, configured to, in the case that there is the to-be-matched element in the N-1 candidate elements, determine the to-be-matched element as the target element, and in the case that there is no to-be-matched element in the N-1 candidate elements, cache T message elements in the M message elements to an augmented path and cache the initial element to the augmented path, wherein the T message elements refer to message elements having the same similarity data with the same candidate element, and T is a positive integer; a third determining module, configured to determine a benchmark value based on the algebraic sum of the similarity matrix, the expected array and the preset array, and adjust the similarity data of the T message elements in the expected array and the preset array based on the benchmark value, to obtain an adjusted expected array and an adjusted preset array; a third screening module, configured to, in the case that the similarity data of the i-th row and j-th column element in the similarity matrix is equal to the sum of the similarity data of the i-th element in the adjusted expected array and the similarity data of the j-th element in the adjusted preset array, screen the target element from the adjusted expected array; and a second executing module, configured to, in the case that the similarity data of the i-th row and j-th column element in the similarity matrix is not equal to the sum of the similarity data of the i-th element in the adjusted expected array and the similarity data of the j-th element in the adjusted preset array, stop executing the step of screening the target element of the message element from the N-1 candidate elements through the degraded matching algorithm.
[0102] Optionally, in the response apparatus for the message provided by the embodiment of the present application, the receiving unit 50 comprises: an analyzing module, configured to analyze the request message to obtain Y message information in a preset format, wherein the preset format at least comprises an array type data exchange format and an object type data exchange format, Y is less than or equal to M, and Y is a positive integer; and a third extracting module, configured to perform element extraction on the Y message information in the preset format to obtain the M message elements.
[0103] Optionally, in the response apparatus for the message provided in the embodiment of the present application, the receiving unit 50 comprises: a fourth obtaining module, configured to obtain a use case number associated with the request message, wherein the use case number refers to a number corresponding to the test use case selected by the user; and a fifth obtaining module, configured to obtain a use case library, filter K pieces of message information from the use case library based on the use case number, and extract N candidate elements from the K pieces of message information, wherein the use case library comprises message information in a plurality of use cases and a use case number associated with each use case, K is less than or equal to N, and K is a positive integer.
[0104] It should be noted that the receiving unit 50, the computing unit 51, and the constituting unit 52 correspond to steps S201 to S203 in Embodiment 1, and have the same instances and application scenarios as those implemented by the corresponding steps, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware components or software components stored in a memory (for example, the memory 104) and processed by one or more processors (for example, the processors 102a, 102b, …, 102n), and the above units can also be a part of the apparatus and can run in the computer terminal 10 provided in Embodiment 1.
[0105] Embodiment 3
[0106] The embodiments of the present application can provide a computer terminal, which can be any one of the computer terminal devices in the computer terminal group. Optionally, in the embodiments, the computer terminal can also be replaced by a mobile terminal or an electronic device or the like.
[0107] Optionally, in the embodiments, the computer terminal can be located in at least one of the network devices in the computer network.
[0108] In the embodiments, the computer terminal can execute the program codes of the following steps in the response method for the message: receiving a request message sent by a system under test, extracting M message elements from the request message, wherein the request message refers to a message generated after the system under test analyzes a test use case selected by a user, and M is a positive integer; calculating the similarity of the M message elements and N candidate elements respectively to obtain M*N similarity data, and determining M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; constituting a response message based on the M target elements, and sending the response message to the system under test.
[0109] Optionally, the computer terminal can execute program codes of the following steps in the response method of the message: constructing a similarity matrix based on the M*N similarity data, wherein the element in the i-th row and the j-th column of the similarity matrix refers to the similarity data of the i-th message element and the j-th candidate element, i is less than or equal to M, j is less than or equal to N, i and j are positive integers; selecting the maximum similarity data from each group of similarity data of the M*N similarity data respectively to obtain M maximum similarity data, and constructing an expected array based on the M maximum similarity data, wherein each group of similarity data includes N similarity data calculated by one message element and N candidate elements; obtaining a preset array, and judging whether the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the expected array and the similarity data of the j-th element of the preset array, wherein, after sorting the M message elements, if the target element of the first message element in the M message elements is determined, the preset array is an empty array, and if the target elements of the M-1 message elements in the M message elements are determined, the preset array is based on the similarity data change; in the case that the similarity data of the element in the i-th row and the j-th column is equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, obtaining the M candidate elements associated with the M maximum similarity data from the expected array, and determining the M candidate elements as the M target elements; in the case that the similarity data of the element in the i-th row and the j-th column is not equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, stopping the step of determining the M target elements from the candidate elements associated with the M*N similarity data.
[0110] Optionally, the computer terminal can execute program codes of the following steps in the response method of the message: for the i-th message element and the j-th candidate element, extracting message nodes from the i-th message element to obtain P1 message nodes, and obtaining node data corresponding to each message node to obtain P2 node data, wherein the node type of each message node at least includes a nested type and a standard node type, there is at least one message node in the message node of the nested type, P1 is less than or equal to P2, and P1 and P2 are positive integers; extracting node data of message nodes in the j-th candidate element to obtain a group of candidate node data, calculating similarity data of each node data and each candidate node data in the group of candidate node data to obtain P2 groups of similarity data; calculating the sum of the similarity data in the P2 groups of similarity data to obtain the similarity data of the i-th message element and the j-th candidate element.
[0111] Optionally, the computer terminal can execute program codes of the following steps in the response method of the message: for a message element, obtaining a candidate element corresponding to the maximum similarity data of the message element from the expected array, obtaining an initial element, and judging whether the initial element has been matched with a message element; in the case that the initial element has not been matched with a message element, determining the initial element as a target element of the message element; in the case that the initial element has been matched with a message element, screening the target element of the message element from N-1 candidate elements through a degraded matching algorithm.
[0112] Optionally, the computer terminal can execute program codes of the following steps in the response method of the message: judging whether there is a to-be-matched element in the N-1 candidate elements, wherein the similarity data of the to-be-matched element and the message element is the same as the similarity data of the initial element and the message element; in the case that there is a to-be-matched element in the N-1 candidate elements, determining the to-be-matched element as the target element, and in the case that there is no to-be-matched element in the N-1 candidate elements, buffering T message elements in the M message elements to an augmented path and buffering the initial element to the augmented path, wherein the T message elements refer to message elements having the same similarity data with the same candidate element, and T is a positive integer; determining a benchmark value based on the algebraic sum of the similarity matrix, the expected array and the preset array, and adjusting the similarity data of the T message elements in the expected array and the preset array based on the benchmark value, to obtain an adjusted expected array and an adjusted preset array; in the case that the similarity data of the element in the i-th row and the j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, screening the target element from the adjusted expected array; in the case that the similarity data of the element in the i-th row and the j-th column of the similarity matrix is not equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, stopping the step of screening the target element of the message element from the N-1 candidate elements through the degraded matching algorithm.
[0113] Optionally, the computer terminal can execute program codes of the following steps in the response method of the message: parsing the request message to obtain Y preset format message information, wherein the preset format at least includes an array type data exchange format and an object type data exchange format, Y is less than or equal to M, and Y is a positive integer; and performing element extraction on the Y preset format message information to obtain M message elements.
[0114] Optionally, the computer terminal described above can execute the program code for the following steps in the message response method: obtaining the test case number associated with the request message, wherein the test case number refers to the number corresponding to the test case selected by the user; obtaining the test case library, filtering K message information from the test case library based on the test case number, and extracting N candidate elements from the K message information, wherein the test case library includes message information from multiple test cases and the test case number associated with each test case, K is less than or equal to N, and K is a positive integer.
[0115] Optionally, Figure 6 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 6 As shown, the electronic device may include: one or more ( Figure 6 (Only one is shown) processor 602, memory 604, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0116] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the message response method and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the aforementioned message response method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0117] The processor can invoke the information and application program stored in the memory through the transmission device to execute the steps described above in the response method for the aforementioned message.
[0118] The embodiment of the application provides a scheme for responding to a message. A request message sent by a system under test is received, M message elements are extracted from the request message, wherein the request message is a message generated after the system under test analyzes a test case selected by a user, and M is a positive integer; similarity of the M message elements and N candidate elements is calculated respectively, M*N similarity data are obtained, and M target elements are determined from the candidate elements associated with the M*N similarity data, wherein N is greater than M, and N is a positive integer; and a response message is formed based on the M target elements, and the response message is sent to the system under test, thereby solving the technical problems of low matching accuracy and poor flexibility in matching a response message of a complex structured message in the related art, extracting a message element from a request message sent by a system under test, determining a target element according to similarity of the message element and a candidate element, forming a response message based on the target element, and sending the response message to the system under test, and thus the technical effects of improving matching accuracy and flexibility of complex structured message processing are achieved.
[0119] Those skilled in the art can understand that Figure 6 The structure shown is only schematic, and the electronic device can also be a smart phone, a tablet computer, a palm computer, a mobile Internet device (MID), a PAD, or the like. Figure 6 This does not limit the structure of the electronic device. For example, the electronic device can include more or fewer components (such as a network interface, a display device, or the like) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 6
[0120] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a program instructing the related hardware of the terminal device, and the program can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0121] Embodiment 4
[0122] The embodiment of the application further provides a storage medium. Optionally, in the embodiment, the storage medium can be used to save the program code executed by the message responding method provided in the embodiment 1.
[0123] Optionally, in the embodiment, the storage medium can be located in any one of computer terminals in a computer terminal group in a computer network, or in any one of mobile terminals in a mobile terminal group.
[0124] Optionally, in the embodiment, the storage medium is configured to store program code for performing the following steps: receiving a request message sent by the system under test, extracting M message elements from the request message, wherein the request message is a message generated by the system under test after parsing a test case selected by a user, M is a positive integer; calculating the similarity of the M message elements and N candidate elements respectively to obtain M*N similarity data, and determining M target elements from the candidate elements associated with the M*N similarity data, wherein N is greater than M and N is a positive integer; constructing a response message based on the M target elements, and sending the response message to the system under test.
[0125] The application further provides a computer program product adapted to perform the steps of the response method of the message when executed on a data processing device.
[0126] The above-mentioned sequence numbers of the embodiments of the application are only for description and do not represent the advantages or disadvantages of the embodiments.
[0127] In the above-mentioned embodiments of the application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0128] In the several embodiments provided by the present application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the unit embodiment described above is only schematic. For example, the division of the units is only a logical function division. There can be another division for actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, access layers, or intermediate units, and can be electrical, or other forms.
[0129] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they can be located in one place, or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0130] In addition, each functional unit in each embodiment of the application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The above integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0131] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0132] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.
Claims
1. A message response method, characterized in that, include: The system receives a request message from the system under test and extracts M message elements from it. The request message refers to the message generated by the system under test after parsing the test cases selected by the user. M is a positive integer; Calculate the similarity between the M message elements and the N candidate elements respectively to obtain M*N similarity data, and determine M target elements from the candidate elements associated with the M*N similarity data, where N is greater than M and N is a positive integer; A response message is constructed based on the M target elements and sent to the system under test.
2. The method according to claim 1, characterized in that, Determining M target elements from the M*N candidate elements associated with similarity data includes: A similarity matrix is constructed based on the M*N similarity data, where the element in the i-th row and j-th column of the similarity matrix refers to the similarity data between the i-th message element and the j-th candidate element, i is less than or equal to M, j is less than or equal to N, and i and j are positive integers; From each group of similarity data in the M*N similarity data, the data with the largest similarity value is selected to obtain M maximum similarity data. An expected array is constructed from the M maximum similarity data, wherein each group of similarity data includes N similarity data calculated between a message element and the N candidate elements. Obtain a preset array, and determine whether the similarity data of the element in the i-th row and j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the expected array and the similarity data of the j-th element of the preset array. Wherein, after sorting the M message elements, if the target element of the first message element among the M message elements is determined, the preset array is an empty array; if the target element of M-1 message elements among the M message elements is determined, the preset array changes based on the similarity data. If the similarity data of the element in the i-th row and j-th column is equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, then obtain the M candidate elements associated with the M maximum similarity data from the expected array, and determine the M candidate elements as the M target elements. If the similarity data of the element in the i-th row and j-th column is not equal to the sum of the similarity data of the i-th element and the similarity data of the j-th element, then stop executing the step of determining M target elements from the candidate elements associated with the M*N similarity data.
3. The method according to claim 2, characterized in that, Calculate the similarity between the M message elements and the N candidate elements respectively, to obtain M*N similarity data, including: For the i-th message element and the j-th candidate element, extract message nodes from the i-th message element to obtain P1 message nodes, and obtain the node data corresponding to each message node to obtain P2 node data. The node type of each message node includes at least: nested type and standard node type. There is at least one message node in the nested type message node. P1 is less than or equal to P2, and P1 and P2 are positive integers. Extract the node data of the message node in the j-th candidate element to obtain a set of candidate node data. Calculate the similarity data between each node data and each candidate node data in the set of candidate node data to obtain P2 sets of similarity data. Calculate the sum of the similarity data in the P2 group of similarity data to obtain the similarity data between the i-th message element and the j-th candidate element.
4. The method according to claim 2, characterized in that, Obtaining M candidate elements associated with the M most similar data from the expected array, and determining the M candidate elements as the M target elements includes: For a message element, obtain the candidate element corresponding to the maximum similarity data associated with the message element from the expected array to obtain the initial element, and determine whether the initial element has matched a message element; If the initial element does not match a message element, the initial element is determined as the target element associated with the message element; If the initial element has already matched a message element, the target element of the message element is obtained from N-1 candidate elements through a downgraded matching algorithm.
5. The method according to claim 4, characterized in that, The target elements of the message element obtained by filtering from N-1 candidate elements using a degradation matching algorithm include: Determine whether there is a matching element among the N-1 candidate elements, wherein the similarity data between the matching element and the message element is the same as the similarity data between the initial element and the message element; If the element to be matched exists among the N-1 candidate elements, the element to be matched is determined as the target element. If the element to be matched does not exist among the N-1 candidate elements, T message elements from the M message elements are cached in the augmenting path, and the initial element is cached in the augmenting path. Here, the T message elements refer to message elements that have the same similarity data as the same candidate element, and T is a positive integer. Based on the algebraic sum of the similarity matrix, the expected array, and the preset array, a benchmark value is determined. Based on the benchmark value, the similarity data of the T message elements in the expected array and the preset array are adjusted respectively to obtain the adjusted expected array and the adjusted preset array. If the similarity data of the element in the i-th row and j-th column of the similarity matrix is equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, the target element is selected from the adjusted expected array. If the similarity data of the element in the i-th row and j-th column of the similarity matrix is not equal to the sum of the similarity data of the i-th element of the adjusted expected array and the similarity data of the j-th element of the adjusted preset array, then the step of filtering the target element of the message element from N-1 candidate elements using the downgraded matching algorithm is stopped.
6. The method according to claim 1, characterized in that, Extracting M message elements from the request message includes: The request message is parsed to obtain Y message information in preset formats, wherein the preset formats include at least array-type data exchange formats and object-type data exchange formats, Y is less than or equal to M, and Y is a positive integer; The Y preset format message information elements are extracted to obtain the M message elements.
7. The method according to claim 1, characterized in that, The N candidate elements are obtained in the following way: Obtain the test case number associated with the request message, wherein the test case number refers to the number corresponding to the test case selected by the user; Obtain a use case library, filter K message information from the use case library based on the use case number, and extract N candidate elements from the K message information. The use case library includes message information from multiple use cases and the use case number associated with each use case, where K is less than or equal to N and K is a positive integer.
8. A message response device, characterized in that, include: The receiving unit is used to receive the request message sent by the system under test, and extract M message elements from the request message, wherein the request message refers to the message generated by the system under test after parsing the test case selected by the user, and M is a positive integer; The calculation unit is used to calculate the similarity between the M message elements and the N candidate elements respectively, to obtain M*N similarity data, and to determine M target elements from the candidate elements associated with the M*N similarity data, where N is greater than M and N is a positive integer; The constituting unit is used to constitut a response message based on the M target elements and send the response message to the system under test.
9. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, executes the message response method according to any one of claims 1 to 7.
10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the message response method according to any one of claims 1 to 7.