Detailed Description
The present application is described in further detail below with reference to the attached figures.
FIG. 1 illustrates a block diagram of a first node service device simulating a server returning customized data according to an aspect of the subject application. The first node service equipment comprises a presetting device 11 and an intercepting device 12.
The preset device 11 configures a corresponding method interceptor based on an application implementation method of the first node service equipment, and presets a virtual object test condition and an expected return value corresponding to the virtual object test condition in the method interceptor; when receiving the first service request, the obtaining device 12 obtains the first service request by using the method interceptor, analyzes the first service request to obtain service-specific parameter information, and determines whether the service-specific parameter information satisfies the virtual object test condition, if so, feeds back the corresponding expected return value, and if not, exits the method interceptor.
Here, the first node service device includes, but is not limited to, a service device or a device formed by integrating the service device and a network device through a network. The service device includes, but is not limited to, any mobile electronic product, such as a smart phone, a PDA, etc., capable of human-computer interaction with a user through a touch panel, and the mobile electronic product may employ any operating system, such as an android operating system, an iOS operating system, etc. The network device includes an electronic device capable of automatically performing numerical calculation and information processing according to preset or stored instructions, and the hardware includes but is not limited to a microprocessor, an Application Specific Integrated Circuit (ASIC), a programmable gate array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like. Including, but not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a VPN network, a wireless Ad Hoc network (Ad Hoc network), etc. Preferably, the first node service device may also be a script program running on a device formed by integrating the service device, or the service device and the network device, or the touch terminal, or the network device and the touch terminal through a network. Of course, those skilled in the art should understand that the first node service device is only an example, and other existing or future first node service devices may be applicable to the present application, and are included in the scope of the present application and are incorporated herein by reference.
The above devices are operated continuously, and herein, those skilled in the art should understand that "continuously" means that the above devices are operated in real time or according to the set or real-time adjusted operating mode requirement.
It should be noted that the first node service device includes one or more first node service devices, and each of the first node service devices is deployed on each node in the distributed application deployment environment, and then the first node service device includes a script or an application program that runs on a device formed by integrating the first node service device with other node service devices or client devices through a network. Preferably, the application program in the first node service device has an independent database and an independent server deployment, and the application programs respectively corresponding to the plurality of first node service devices in the distributed application deployment environment form an original complete application program, that is, the original complete application program is split into the plurality of application programs through application and is respectively deployed in the first node service devices, so that the requirements of different testers on verification tests of different service scenarios of the same complete application program can be met. Furthermore, one skilled in the art should understand that: any node service device of the distributed application deployment environment can be simultaneously a first service node device and a second service node device called by other service node devices.
In the embodiment of the present application, the presetting device 11 in the first node service equipment configures a corresponding method interceptor based on an application implementation method of the first node service equipment, and presets a virtual object test condition and an expected return value corresponding to the virtual object test condition in the method interceptor, so that when service is invoked, a server can be quickly and effectively simulated to return the corresponding expected return value; when receiving a first service request, the intercepting apparatus 12 obtains the first service request by using the method interceptor, analyzes the first service request to obtain service-specific parameter information, and determines whether the service-specific parameter information satisfies the virtual object test condition, if so, feeds back the corresponding expected return value, and if not, exits the method interceptor, thereby effectively saving resources and improving the flexibility of the simulation object test in the service calling process.
Further, the presetting device 11 is used for: based on the execution logic of the application implementation method of the first node service equipment and a virtual object test target, a virtual object test condition and an expected return value corresponding to the virtual object test condition are preset in the method interceptor.
It should be noted that, the application implementation method of the first node service device may include, but is not limited to, a technical framework including an application program, an implementation technical manner of the application program, or a source program of the application program. In the embodiment of the present application, the preset apparatus 11 configures, based on a difference in technical frameworks of the application programs of the first node service device, a corresponding method interceptor to write a corresponding interception logic program and deploy the interception logic program on the first node service device. For example, under an open source framework (spring framework), a Method Interceptor (Method Interceptor) is configured; under a Model View Controller (MVC) based framework (struts2 framework), configuring a Method Filter Interceptor (Method Filter Interreceptor); and configuring a blank Interceptor (Empty Interceptor) under an object relationship mapping framework (Hibernate framework) of the open source code. In a preferred embodiment of the present application, a corresponding Method Interceptor (Method Interceptor) is preferably configured under the open source framework (spring framework). Of course, those skilled in the art should understand that the above-mentioned configuration of the corresponding Method Interceptor (Method Interceptor) under the open source framework (spring framework) is only a preferred embodiment of the present application, and other existing or future technology frameworks capable of configuring the corresponding Method Interceptor based on the application program of the first node service device, as applicable to the present application, should be included in the scope of the present application, and are hereby incorporated by reference.
In the embodiment of the present application, the execution logic of the application implementation method of the first node service device may include, but is not limited to, a part of or all of actual test result information obtained based on the virtual object test target in the process of actually testing the application implementation method. For example, in the execution logic (test of payment return condition of bank payment service) process of the application implementation method of the first node service device, the test is performed based on the virtual object test target (the last 3 bits of the input card number), wherein in the test process, conditions such as payment success or payment failure may occur, the actual test result information is preset according to the last 3 bits of the input bank card number, if the last 3 bits of the input card number are 123, the payment success is returned, and if the last 3 bits of the input card number are 456, the payment failure is returned. Presetting a virtual object test condition (mock condition) in the Method Interceptor (Method Interceptor) as { { 3 bits after the input card number are 123 }; { 3 bits after the input card number are 456} }, if the mock condition is satisfied, and 3 bits after the input card number are 123}, the corresponding expected return value is { payment success } or if the mock condition is satisfied, and 3 bits after the input card number is 456}, the corresponding expected return value is { payment failure }, so that when service calling is performed in the virtual object test process, the server can be quickly and effectively simulated to return the corresponding expected return value.
Further, the presetting device 11 includes: a configuration unit 111 (not shown) for configuring a plurality of the method interceptors at the first node service apparatus based on different virtual object tests; a determining unit 112 (not shown) configured to determine a sequence of the plurality of method interceptors acquiring the first service request.
In an embodiment of the present application, the configuration unit 111 (not shown) configures a plurality of the method interceptors at the first node service device based on different virtual object tests. For example, in the process of the identification card information collection application, corresponding tests can be performed in different virtual object tests (service scenarios) through the identification card information, wherein the virtual object tests can include but are not limited to checking the gender of the owner through the identification card number and checking the province of the owner through the identification card number. When a service scene that the gender of the user is checked through the identity card number exists, if the last but one digit of the identity card number is an odd number, the user is a male, and if the last but one digit of the identity card number is an even number, the user is a female; when the business scene of the province where the householder is located is checked through the identity card number, if the first two digits of the identity card number are 11, the householder is a person in Beijing City, if the first two digits of the identity card number are 31, the householder is a person in Shanghai city, and if the first two digits of the identity card number are 44, the householder is a person in Guangdong province. Based on the virtual object tests of the two situations, configuring two corresponding method interceptors in the first node service equipment, wherein a virtual object test condition (mock condition) preset in the method interceptor 1 is { { the last digit of the identity card number is an odd number }; { the second last digit of the identity card number is an even number } }, if the mock condition is met, the corresponding expected return value is { the householder is male } when the second last digit of the identity card number is an odd number, and if the mock condition is met, the corresponding expected return value is { the householder is female }; the method comprises the following steps that a preset virtual object test condition (mock condition) in the interceptor 2 is { { two first digits of an identity card number are 11 }; { the first two digits of the ID number are 31 }; { 44} for the first two digits of the identity card number, if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 11} is { the householder is a Beijing city person }, if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 31} is { the householder is a Shanghai city person }, and if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 44} is { the householder is a Guangdong province person }.
In the determining unit 112 (not shown), there may be one or more first service requests, and according to the time sequence of the first service requests acquired by the plurality of method interceptors, the method interceptors are determined to determine that the corresponding virtual object test conditions are determined based on the first service requests, so that expected return values in different virtual object test processes can be effectively and quickly returned.
Further, the intercepting device 12 is configured to: and utilizing the method interceptor to extract parameters of the first service request so as to obtain the service designated parameter information.
In an embodiment of the application, the first service request includes one or more pieces of call parameter information and related parameter information thereof, where the service specific parameter information is determined by the method interceptor performing parameter extraction on the one or more pieces of call parameter information and related parameter information thereof in the first service request. For example, in the application of bank transaction, the calling parameter information included in the first service request includes the bank account owner, the bank card number, the mobile phone number bound with the bank card number, the bank card expenditure amount and the bank card income amount, if the related parameter information is name information of the bank account opening owner, specific information of the bank card number, detailed list information of bank card expenditure and detailed list information of bank card income, the service designation parameter information judged in the virtual object test condition (mock condition) preset in the method interceptor is the bank account opening owner, performing parameter extraction on the calling parameter information and the related parameter information thereof in the first service request through the method interceptor, the method comprises the steps of obtaining a bank account opening owner and a corresponding bank account opening owner name, and accordingly determining service designated parameter information as the bank account opening owner and the name information of the bank account opening owner.
FIG. 2 illustrates a service call orchestration diagram between a first node service device and a client device and a second node service device simulating a server returning customized data according to an aspect of the subject application.
When the client device calls the first node service device, the first node service device acquires a first service request from the client device, acquires the first service request by using a method interceptor in the first node service device and performs parameter extraction on the first service request to determine service-specific parameter information; and judging whether the specified service parameter information meets the virtual object test condition (mock condition) in a method interceptor in the first node service equipment, and if so, sending the corresponding expected return value to the client equipment.
For example, when a customer buys a train ticket, a specific bank is selected for payment, an application a in customer equipment is used for testing the condition that the payment returned by the bank is successful, and an application B in first node service equipment is used for testing the condition that the payment returned by the bank is failed, a method interceptor is configured in the first node service equipment, wherein the method interceptor includes a preset virtual object test condition (mock condition) and an expected return value corresponding to the mock condition, that is, when the customer equipment (application a) needs to call the first node service equipment (application B) in the test process of a tester a, the method interceptor simulates test result information which may appear in the first node service equipment (application B): if 3 bits after the preset input card number are 123, returning payment success, if 3 bits after the preset input card number are 456, returning payment failure, presetting the test result information which possibly appears as an expected return value corresponding to the mock condition, and in the test process that the client device (application A) calls the first node service device (application B), if the service specified parameter information meets the mock condition { 3 bits after the input card number are 456}, sending the corresponding expected return value { payment success } to the client device (application A), so that the rapid simulation server returns the expected return value corresponding to the mock condition.
In the embodiment of the present application, in the intercepting apparatus 12, when the service specification parameter information in the first service request does not satisfy the virtual object test condition, the method interceptor is exited.
As shown in fig. 2, wherein the solid line represents: the test procedure of tester a, the dashed line indicates: test procedure of tester B. In the test process of the tester a indicated by the solid line, when the client device (application a) calls the first node service device (application B), if a string of random codes is obtained after the service-specific parameter information extracted from the first service request by the method interceptor is used, when the virtual object test condition (mock condition) is judged by using the string of random codes as the service-specific parameter information, the mock condition preset in the method interceptor in the first node service device cannot be met, and the method interceptor is exited.
Further, the first node service apparatus further includes: and an executing device 13 (not shown) configured to, after exiting the method interceptor, execute an application implementation method of the first node service device based on the first service request and feed back a corresponding execution result.
In the above embodiment of the present application, in a test process, when a client device (application a) calls a first node service device (application B), if service-specific parameter information extracted from a first service request by using a method interceptor is a string of random codes, when the virtual object test condition (mock condition) is determined by using the string of random codes as the service-specific parameter information, the mock condition cannot be satisfied, and then the method interceptor is exited; the application implementation method (the source program of the application B) of the first node service apparatus is continuously executed based on the first service request from the client apparatus (the application a) to determine an execution result of the application implementation method (the source program of the application B), and the execution result is fed back to the client apparatus (the application a).
Further, the executing device 13 (not shown) further includes: a first execution unit (not shown), a second execution unit (not shown), and a third execution unit (not shown), where when the first execution unit executes the application implementation method of the first node service device, and when the application implementation method of the second node service device needs to be called, a second service request is sent to the second node service device; the second execution unit acquires feedback information of the second node service equipment based on the second service request; and the third execution unit continues to execute the application implementation method of the first node service equipment based on the feedback information.
As shown in fig. 2, in a whole application service scenario, when the application implementation method of the first node service device is executed, and when the application implementation method of the second node service device (application C) needs to be invoked, where a dotted line in fig. 2 represents a test process of a tester B, during a test process of the tester B, when the first node service device (application B) needs to invoke the application implementation method of the second node service device (application C), after a second service request is sent to the second node service device (application C), feedback information of the second node service device (application C) based on the second service request is obtained, and the application implementation method (source program of the application B) in the first node service device (application B) is continuously executed based on the feedback information.
In the above embodiment of the present application, in the process of performing the test, when the client device (application a) calls the first node service device (application B), the tester a directly returns the expected return value when the service specification parameter information in the first service request from the client device (application a) satisfies the virtual object test condition (mock condition) of the method interceptor in the first node service device (application B); in the process of testing, when the first node service device (application B) needs to call the second node service device (application C), the tester B sends a second service request to the second node service device (application C), acquires feedback information from the second node service device (application C) based on the second service request, and continues to execute the application implementation method of the first node service device (application B) based on the feedback information, thereby meeting the testing requirements of two testers in different service scenarios in the same set of environmental tests.
Further, the feedback information of the second service request in the executing device 13 (not shown) includes: the second node service device is based on information fed back by its method interceptor or on a result of execution of an application implementation method of the second node service device.
In an embodiment of the present application, the information fed back by the second node service device based on its method interceptor includes: the service designation parameter information in the second service request satisfies an expected return value corresponding to a virtual object test condition (mock condition) in a method interceptor in the second node service device; the result executed by the application implementation method based on the second node service equipment comprises the following steps: and when the service designation parameter information in the second service request does not satisfy a virtual object test condition (mock condition) in a method interceptor in the second node service equipment, after exiting the method interceptor of the second node service equipment, executing an application implementation method of the second node service equipment based on the second service request.
For example, the feedback information of the second service request includes: an expected return value corresponding to when a virtual object test condition (mock condition) of a method interceptor in the second node service device (application C) is satisfied, or a result obtained by executing an application implementation method (source program of application C) of the second node service device based on the second service request.
FIG. 3 illustrates a flow diagram of a method for simulating server return of customized data at a first node server side according to an aspect of the subject application. The method includes step S11 and step S12.
Step S11 is to configure a corresponding method interceptor based on an application implementation method of the first node service device, and preset a virtual object test condition and an expected return value corresponding to the virtual object test condition in the method interceptor; when receiving the first service request, the step S12 uses the method interceptor to obtain the first service request, analyzes the first service request to obtain service-specific parameter information, and determines whether the service-specific parameter information satisfies the virtual object test condition, if so, feeds back the corresponding expected return value, and if not, exits the method interceptor.
It should be noted that the first node service device includes one or more first node service devices, and each of the first node service devices is deployed on each node in the distributed application deployment environment, and then the first node service device includes a script or an application program that runs on a device formed by integrating the first node service device with other node service devices or client devices through a network. Preferably, the application program in the first node service device has an independent database and an independent server deployment, and the application programs respectively corresponding to the plurality of first node service devices in the distributed application deployment environment form an original complete application program, that is, the original complete application program is split into the plurality of application programs through application and is respectively deployed in the first node service devices, so that the requirements of different testers on verification tests of different service scenarios of the same complete application program can be met.
In an embodiment of the present application, in step S11, based on an application implementation method of the first node service device, a corresponding method interceptor is configured, and a virtual object test condition and an expected return value corresponding to the virtual object test condition are preset in the method interceptor, so that when service is invoked, a server can be quickly and effectively simulated to return the corresponding expected return value; when receiving the first service request, the step S12 uses the method interceptor to obtain the first service request, analyzes the first service request to obtain service-specific parameter information, and determines whether the service-specific parameter information satisfies the virtual object test condition, if so, feeds back the corresponding expected return value, and if not, exits the method interceptor, thereby effectively saving resources and improving the flexibility of the simulated object test in the service calling process.
Further, the step S11 includes: configuring a corresponding method interceptor based on an application implementation method of first node service equipment, and presetting a virtual object test condition and an expected return value corresponding to the virtual object test condition in the method interceptor; specifically, the step S11 includes: based on the execution logic of the application implementation method of the first node service equipment and a virtual object test target, a virtual object test condition and an expected return value corresponding to the virtual object test condition are preset in the method interceptor.
It should be noted that, the application implementation method of the first node service device may include, but is not limited to, a technical framework including an application program, an implementation technical manner of the application program, or a source program of the application program. In an embodiment of the application, in the step S11, based on a difference in a technical framework of an application program of the first node service device, a corresponding method interceptor is configured to write a corresponding interception logic program and deploy the interception logic program on the first node service device. For example, under an open source framework (spring framework), a Method Interceptor (Method Interceptor) is configured; under a Model View Controller (MVC) based framework (struts2 framework), configuring a Method Filter Interceptor (Method Filter Interreceptor); and configuring a blank Interceptor (Empty Interceptor) under an object relationship mapping framework (Hibernate framework) of the open source code. In a preferred embodiment of the present application, a corresponding Method Interceptor (Method Interceptor) is preferably configured under the open source framework (spring framework). Of course, those skilled in the art should understand that the above-mentioned configuration of the corresponding Method Interceptor (Method Interceptor) under the open source framework (spring framework) is only a preferred embodiment of the present application, and other existing or future technology frameworks capable of configuring the corresponding Method Interceptor based on the application program of the first node service device, as applicable to the present application, should be included in the scope of the present application, and are hereby incorporated by reference.
In the embodiment of the present application, the execution logic of the application implementation method of the first node service device may include, but is not limited to, a part of or all of actual test result information obtained based on the virtual object test target in the process of actually testing the application implementation method. For example, in the execution logic (test of payment return condition of bank payment service) process of the application implementation method of the first node service device, the test is performed based on the virtual object test target (the last 3 bits of the input card number), wherein in the test process, conditions such as payment success or payment failure may occur, the actual test result information is preset according to the last 3 bits of the input bank card number, if the last 3 bits of the input card number are 123, the payment success is returned, and if the last 3 bits of the input card number are 456, the payment failure is returned. Presetting a virtual object test condition (mock condition) in the Method Interceptor (Method Interceptor) as { { 3 bits after the input card number are 123 }; { 3 bits after the input card number are 456} }, if the mock condition is satisfied, and 3 bits after the input card number are 123}, the corresponding expected return value is { payment success } or if the mock condition is satisfied, and 3 bits after the input card number is 456}, the corresponding expected return value is { payment failure }, so that when service calling is performed in the virtual object test process, the server can be quickly and effectively simulated to return the corresponding expected return value.
Further, the step S11 includes: configuring a corresponding method interceptor based on an application implementation method of first node service equipment, and presetting a virtual object test condition and an expected return value corresponding to the virtual object test condition in the method interceptor; specifically, the step S11 includes a step S111 (not shown) and a step S112 (not shown), wherein the step S111 (not shown) includes: configuring a plurality of the method interceptors at the first node service equipment based on different virtual object tests; the step S112 (not shown) includes: determining the sequence of the plurality of method interceptors for acquiring the first service request.
In an embodiment of the application, the step S111 (not shown) configures a plurality of method interceptors at the first node service device based on different virtual object tests. For example, in the process of the identification card information collection application, corresponding tests can be performed in different virtual object tests (service scenarios) through the identification card information, wherein the virtual object tests can include but are not limited to checking the gender of the owner through the identification card number and checking the province of the owner through the identification card number. When a service scene that the gender of the user is checked through the identity card number exists, if the last but one digit of the identity card number is an odd number, the user is a male, and if the last but one digit of the identity card number is an even number, the user is a female; when the business scene of the province where the householder is located is checked through the identity card number, if the first two digits of the identity card number are 11, the householder is a person in Beijing City, if the first two digits of the identity card number are 31, the householder is a person in Shanghai city, and if the first two digits of the identity card number are 44, the householder is a person in Guangdong province. Based on the virtual object tests of the two situations, configuring two corresponding method interceptors in the first node service equipment, wherein a virtual object test condition (mock condition) preset in the method interceptor 1 is { { the last digit of the identity card number is an odd number }; { the second last digit of the identity card number is an even number } }, if the mock condition is met, the corresponding expected return value is { the householder is male } when the second last digit of the identity card number is an odd number, and if the mock condition is met, the corresponding expected return value is { the householder is female }; the method comprises the following steps that a preset virtual object test condition (mock condition) in the interceptor 2 is { { two first digits of an identity card number are 11 }; { the first two digits of the ID number are 31 }; { 44} for the first two digits of the identity card number, if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 11} is { the householder is a Beijing city person }, if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 31} is { the householder is a Shanghai city person }, and if the mock condition is satisfied, the expected return value corresponding to the first two digits of the identity card number being 44} is { the householder is a Guangdong province person }.
In the step S112 (not shown), there may be one or more first service requests, and according to the time sequence of the first service requests acquired by the plurality of method interceptors, it is determined that the plurality of method interceptors perform the judgment on the corresponding virtual object test condition based on the first service request, so that expected return values in different virtual object test processes can be effectively and quickly returned.
Further, the parsing the first service request to obtain service specification parameter information in the step S12 includes: and utilizing the method interceptor to extract parameters of the first service request so as to obtain the service designated parameter information.
In an embodiment of the application, the first service request includes one or more pieces of call parameter information and related parameter information thereof, where the service specific parameter information is determined by the method interceptor performing parameter extraction on the one or more pieces of call parameter information and related parameter information thereof in the first service request. For example, in the application of bank transaction, the calling parameter information included in the first service request includes the bank account owner, the bank card number, the mobile phone number bound with the bank card number, the bank card expenditure amount and the bank card income amount, if the related parameter information is name information of the bank account opening owner, specific information of the bank card number, detailed list information of bank card expenditure and detailed list information of bank card income, the service designation parameter information judged in the virtual object test condition (mock condition) preset in the method interceptor is the bank account opening owner, performing parameter extraction on the calling parameter information and the related parameter information thereof in the first service request through the method interceptor, the method comprises the steps of obtaining a bank account opening owner and a corresponding bank account opening owner name, and accordingly determining service designated parameter information as the bank account opening owner and the name information of the bank account opening owner.
FIG. 2 illustrates a service call flow diagram between a first node service device and a client device and a second node service device simulating a server returning customized data according to an aspect of the subject application.
When the client device calls the first node service device, the first node service device acquires a first service request from the client device, acquires the first service request by using a method interceptor in the first node service device and performs parameter extraction on the first service request to determine service-specific parameter information; and judging whether the specified service parameter information meets the virtual object test condition (mock condition) in a method interceptor in the first node service equipment, and if so, sending the corresponding expected return value to the client equipment.
For example, when a customer buys a train ticket, a specific bank is selected for payment, an application a in customer equipment is used for testing the condition that the payment returned by the bank is successful, and an application B in first node service equipment is used for testing the condition that the payment returned by the bank is failed, a method interceptor is configured in the first node service equipment, wherein the method interceptor includes a preset virtual object test condition (mock condition) and an expected return value corresponding to the mock condition, that is, when the customer equipment (application a) needs to call the first node service equipment (application B) in the test process of a tester a, the method interceptor simulates test result information which may appear in the first node service equipment (application B): if 3 bits after the preset input card number are 123, returning payment success, if 3 bits after the preset input card number are 456, returning payment failure, presetting the test result information which possibly appears as an expected return value corresponding to the mock condition, and in the test process that the client device (application A) calls the first node service device (application B), if the service specified parameter information meets the mock condition { 3 bits after the input card number are 456}, sending the corresponding expected return value { payment success } to the client device (application A), so that the rapid simulation server returns the expected return value corresponding to the mock condition.
In an embodiment of the application, in the step S12, when the service specification parameter information in the first service request does not satisfy the virtual object test condition, the method interceptor is exited.
As shown in fig. 2, wherein the solid line represents: the test procedure of tester a, the dashed line indicates: test procedure of tester B. In the test process of the tester a indicated by the solid line, when the client device (application a) calls the first node service device (application B), if a string of random codes is obtained after the service-specific parameter information extracted from the first service request by the method interceptor is used, when the virtual object test condition (mock condition) is judged by using the string of random codes as the service-specific parameter information, the mock condition preset in the method interceptor in the first node service device cannot be met, and the method interceptor is exited.
Further, the method further comprises: step S13 (not shown), wherein the step S13 (not shown) includes: and after exiting the method interceptor, executing the application implementation method of the first node service equipment based on the first service request and feeding back a corresponding execution result.
In the above embodiment of the present application, in a test process, when a client device (application a) calls a first node service device (application B), if service-specific parameter information extracted from a first service request by using a method interceptor is a string of random codes, when the virtual object test condition (mock condition) is determined by using the string of random codes as the service-specific parameter information, the mock condition cannot be satisfied, and then the method interceptor is exited; the application implementation method (the source program of the application B) of the first node service apparatus is continuously executed based on the first service request from the client apparatus (the application a) to determine an execution result of the application implementation method (the source program of the application B), and the execution result is fed back to the client apparatus (the application a).
Further, the step S13 (not shown) further includes: when the application implementation method of the first node service equipment is executed and the application implementation method of the second node service equipment needs to be called, a second service request is sent to the second node service equipment; acquiring feedback information of the second node service equipment based on the second service request; and continuing to execute the application implementation method of the first node service equipment based on the feedback information.
As shown in fig. 2, in a whole application service scenario, when the application implementation method of the first node service device is executed, and when the application implementation method of the second node service device (application C) needs to be invoked, where a dotted line in fig. 2 represents a test process of a tester B, during a test process of the tester B, when the first node service device (application B) needs to invoke the application implementation method of the second node service device (application C), after a second service request is sent to the second node service device (application C), feedback information of the second node service device (application C) based on the second service request is obtained, and the application implementation method (source program of the application B) in the first node service device (application B) is continuously executed based on the feedback information.
In the above embodiment of the present application, in the process of performing the test, when the client device (application a) calls the first node service device (application B), the tester a directly returns the expected return value when the service specification parameter information in the first service request from the client device (application a) satisfies the virtual object test condition (mock condition) of the method interceptor in the first node service device (application B); in the process of testing, when the first node service device (application B) needs to call the second node service device (application C), the tester B sends a second service request to the second node service device (application C), acquires feedback information from the second node service device (application C) based on the second service request, and continues to execute the application implementation method of the first node service device (application B) based on the feedback information, thereby meeting the testing requirements of two testers in different service scenarios in the same set of environmental tests.
Further, the feedback information of the second service request in the step S13 (not shown) includes: the second node service device is based on information fed back by its method interceptor or on a result of execution of an application implementation method of the second node service device.
In an embodiment of the present application, the information fed back by the second node service device based on its method interceptor includes: the service designation parameter information in the second service request satisfies an expected return value corresponding to a virtual object test condition (mock condition) in a method interceptor in the second node service device; the result executed by the application implementation method based on the second node service equipment comprises the following steps: and when the service designation parameter information in the second service request does not satisfy a virtual object test condition (mock condition) in a method interceptor in the second node service equipment, after exiting the method interceptor of the second node service equipment, executing an application implementation method of the second node service equipment based on the second service request.
For example, the feedback information of the second service request includes: an expected return value corresponding to when a virtual object test condition (mock condition) of a method interceptor in the second node service device (application C) is satisfied, or a result obtained by executing an application implementation method (source program of application C) of the second node service device based on the second service request.
Fig. 4 is a schematic flow chart illustrating an overall method for simulating a server returning customized data at a first node service device side according to a preferred embodiment of another aspect of the present application. The method comprises steps S101, S102, S103, S104, S105 and S106.
Step S101, configuring corresponding method interceptors, and presetting virtual object test conditions (mock conditions) and corresponding expected return values; the step S102 acquires a first service request; the step S103 performs parameter extraction on the first service request; step S104, judging whether a mock condition is met, if so, executing step S105, and if not, executing step S106; said step S105 sending a corresponding expected return value; said step S106 exits the method interceptor and executes the application implementation method of the first node service device.
In the above preferred embodiment of the present application, in step S101, based on an application implementation method of a first node service device, a corresponding method interceptor is configured, and a virtual object test condition and an expected return value corresponding to the virtual object test condition are preset in the method interceptor; the step S102 acquires a first service request from a client device, where the first service request includes service specification parameter information; the step S103 performs parameter extraction on the first service request by using the method interceptor to obtain the service designation parameter information; the step S104 determines whether the service designation parameter information satisfies the virtual object test condition by using the method interceptor, if so, performs the step S105, and if not, performs the step S106; said step S105 feeds back said expected return value corresponding to said virtual object test condition being satisfied to said client device; if the service designation parameter information does not satisfy the virtual object test condition preset in the method interceptor, the method interceptor is exited in the step S106; and continuing to execute the application implementation method of the first node service equipment based on the first service request, and determining and feeding back an execution result.
Compared with the prior art, according to the method and the device for simulating the server to return the customized data at the first node service device side, the corresponding method interceptor is configured through the application implementation method based on the first node service device, the virtual object test condition and the expected return value corresponding to the virtual object test condition are preset in the method interceptor, so that the virtual object test condition is thresholded on each first service node device in advance before the virtual object test is needed and the expected return value corresponding to the virtual object test condition is met, and the server can be quickly and effectively simulated to return the corresponding expected return value when the service is called; further, when a first service request is received, the method interceptor is used for obtaining the first service request, analyzing the first service request to obtain service designated parameter information, and judging whether the service designated parameter information meets the virtual object test condition, if so, the corresponding expected return value is fed back, and if not, the method interceptor is quitted, thereby effectively saving resources and improving the use flexibility of the simulation object test in the service calling process.
Further, according to the method and the device for the simulation server to return the customized data, after the method interceptor exits, the application implementation method of the first node service device is executed based on the first service request and the corresponding execution result is fed back, so that the use flexibility of the simulation object test in the service calling process is effectively improved.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.