# US 2022/0035731 A1 · Test method based on improved rest protocols and electronic device

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0035731 A1
- Document ID: US20220035731A1
- Status: Published application
- Kind: A1
- Application number: 17/387,958
- Filed: 2021-07-28
- Published: 2022-02-03
- Earliest claimed: 2020-07-29
- Assignees: Hon Hai Precision Industry Co., Ltd.
- Applicants: Hon Hai Precision Industry Co., Ltd.
- Inventors: CHIEN-WU YEN
- Web page: https://patentgrep.com/patent/US20220035731A1

## CPC

- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 11/0772: {Means for error signaling, e.g. using interrupts, exception flags, dedicated error registers}
- G06F 11/3692: {for test results analysis}
- H04L 67/02: based on web technology, e.g. hypertext transfer protocol [HTTP]
- H04L 67/133: Protocols for remote procedure calls [RPC]
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

A test method based on improved REST protocols and an electronic device applying the method are disclosed. In response to a received test task, the method sends a REST control request in JSON format from the client to the server and receives a REST response fed back by the server according to the REST control request. A status code is obtained from the REST response and response mode is determined according to the status code, thereby testing the client and the server based on the improved REST protocol. The REST protocol is easy to upgrade, supports multiple protocols, and reduces the complexity of the system, the data is simple and flexible.

## Claims

### Claim 1

A test method based on improved REST protocols, applied to a client communicating with a server, the method comprising:
sending a REST control request in JSON format to the server, in response to a received test task;
receiving a REST response fed back by the server according to the REST control request;
obtaining status codes from the REST response and determining response modes according to the status codes.

### Claim 2 (depends on 1)

The test method based on improved REST protocols according to claim 1, wherein the REST control request and the REST response are compiled in C language, C++, or Python language.

### Claim 3 (depends on 1)

The test method based on improved REST protocols according to claim 1, wherein determining response modes according to the status codes comprises:
determining a first character of the status codes;
determining a response status corresponding to the first character;
detecting an error type of the test task, when the response status is a client error or a server error;
sending the REST control request in JSON format to the server.

### Claim 4 (depends on 3)

The test method based on improved REST protocols according to claim 3, wherein detecting the error type of the test task comprises:
acquiring a pre-configured HTTP status code list, the HTTP status code list storing a correspondence between codes and error types;
matching the status code with codes in the HTTP status code list;
determining an error type corresponding to the matched code as the error type of the test task.

### Claim 5 (depends on 4)

The test method based on improved REST protocols according to claim 4, further comprising:
obtaining standardized HTTP status codes and corresponding error types;
obtaining customized status codes and specified error types;
configuring the HTTP status code list according to the obtained status codes and corresponding error types.

### Claim 6 (depends on 1)

The test method based on improved REST protocols according to claim 1, further comprising:
stopping the test task, in response to a convergence of the REST response.

### Claim 7

An electronic device comprising a memory and a processor, the memory stores at least one computer-readable instruction, and the processor executes the at least one computer-readable instruction to:
send a REST control request in JSON format to the server, in response to a received test task;
receive a REST response fed back by the server according to the REST control request;
obtain status codes from the REST response and determining response modes according to the status codes.

### Claim 8 (depends on 7)

The electronic device according to claim 7, wherein the REST control request and the REST response are compiled in C language, C++, or Python language.

### Claim 9 (depends on 7)

The electronic device according to claim 7, wherein the processor determines response modes according to the status codes by:
determine a first character of the status codes;
determine a response status corresponding to the first character;
detect an error type of the test task, when the response status is a client error or a server error;
send the REST control request in JSON format to the server.

### Claim 10 (depends on 9)

The electronic device according to claim 9, wherein the processor detects the error type of the test task by:
acquire a pre-configured HTTP status code list, the HTTP status code list storing a correspondence between codes and error types;
match the status code with codes in the HTTP status code list;
determine an error type corresponding to the matched code as the error type of the test task.

### Claim 11 (depends on 10)

The electronic device according to claim 10, wherein the processor is further caused to:
obtain standardized HTTP status codes and corresponding error types;
obtain customized status codes and specified error types;
configure the HTTP status code list according to the obtained status codes and corresponding error types.

### Claim 12 (depends on 7)

The electronic device according to claim 7, wherein the processor is further caused to:
stop the test task, in response to a convergence of the REST response.

### Claim 13 (depends on 7)

The electronic device according to claim 7, wherein the processor is further caused to:
in response to a REST control request in JSON format being sent by the client, obtain a call identifier from the REST control request;
match a server code corresponding to the call identifier, and execute the server code to obtain a status code and result;
take the status code and the result data as a REST response and feedback the REST response to the client.

### Claim 14

A non-transitory storage medium having stored thereon at least one computer-readable instructions that, when the at least one computer-readable instructions are executed by a processor to implement the following steps:
sending a REST control request in JSON format to the server, in response to a received test task;
receiving a REST response fed back by the server according to the REST control request;
obtaining status codes from the REST response and determining response modes according to the status codes.

### Claim 15 (depends on 14)

The non-transitory storage medium according to claim 14, wherein the REST control request and the REST response are compiled in C language, C++, or Python language.

### Claim 16 (depends on 14)

The non-transitory storage medium according to claim 14, wherein determining response modes according to the status codes comprises:
determining a first character of the status codes;
determining a response status corresponding to the first character;
detecting an error type of the test task, when the response status is a client error or a server error;
sending the REST control request in JSON format to the server.

### Claim 17 (depends on 16)

The non-transitory storage medium according to claim 16, wherein detecting the error type of the test task comprises:
acquiring a pre-configured HTTP status code list, the HTTP status code list storing a correspondence between codes and error types;
matching the status code with codes in the HTTP status code list;
determining an error type corresponding to the matched code as the error type of the test task.

### Claim 18 (depends on 17)

The non-transitory storage medium according to claim 17, further comprising:
obtaining standardized HTTP status codes and corresponding error types;
obtaining customized status codes and specified error types;
configuring the HTTP status code list according to the obtained status codes and corresponding error types.

### Claim 19 (depends on 14)

The non-transitory storage medium according to claim 14, further comprising:
stopping the test task, in response to a convergence of the REST response.

### Claim 20 (depends on 14)

The non-transitory storage medium according to claim 14, further comprising:
in response to a REST control request in JSON format being sent by the client, obtain a call identifier from the REST control request;
match a server code corresponding to the call identifier, and execute the server code to obtain a status code and result;
take the status code and the result data as a REST response and feedback the REST response to the client.
