import cn. com. maiwe. maxview. utils. UserUtil;
import cn. com. maiwe. maxview. vo. UserLoginVO;
import cn. hutool. core. util. StrUtil;
import cn. hutool. crypto. SecureUtil;
import cn. hutool. crypto. digest. BCrypt;
import com. alibaba. fastjson. JSON;
import lombok. extern. slf4j. Slf4j;
import org. apache. http. NameValuePair;
import org. apache. http. client. entity. UrlEncodedFormEntity;
import org. apache. http. client. methods. CloseableHttpResponse;
import org. apache. http. client. methods. HttpPost;
import org. apache. http. entity. StringEntity;
import org. apache. http. impl. client. CloseableHttpClient;
import org. apache. http. impl. client. HttpClients;
import org. apache. http. message. BasicNameValuePair;
import org. apache. http. util. EntityUtils;
import org. springframework. beans. factory. annotation. Autowired;
import org. springframework. boot. test. context. SpringBootTest;
import org. springframework. web. bind. annotation. RequestParam;
import org. testng. annotations. DataProvider;
import org. testng. annotations. Test;
import java. lang. reflect. Method;
import java. util. ArrayList;
import java. util. List;
import static com. sun. org. apache. xml. internal. serialize. OutputFormat. Defaults. Encoding;
@SpringBootTest
public class MaxviewTest {
CloseableHttpClient httpClient = HttpClients. createDefault ( ) ;
@Test ( dataProvider = "datas" , timeOut = 3000 )
public void a ( String phone) {
String restUrl = "http://127.0.0.1:8001/user/user/login" ;
HttpPost httpPost = new HttpPost ( restUrl) ;
httpPost. setHeader ( "Content-Type" , "application/json" ) ;
try {
httpPost. setEntity ( new StringEntity ( phone, Encoding) ) ;
System. out. println ( "method:" + httpPost. getMethod ( ) ) ;
CloseableHttpResponse httpResponse = httpClient. execute ( httpPost) ;
String result = EntityUtils. toString ( httpResponse. getEntity ( ) ) ;
System. out. println ( "*****返回数据:" + result) ;
} catch ( Exception e) {
e. printStackTrace ( ) ;
}
}
@DataProvider
public Object[ ] [ ] datas ( ) {
Object[ ] [ ] datas = { { "{\"finger\":\"asdasd\",\"password\":\"8VCr9S90PhMfT2S8zA0Gug==\",\"phone\":\"8VCr9S90PhMfT2S8zA0Gug==\"}" }
} ;
return datas;
}
}
<?xml version="1.0" encoding="UTF-8"?>
< configuration debug = " false" >
< appender name = " STDOUT" class = " ch.qos.logback.core.ConsoleAppender" >
< encoder>
< pattern> %-4relative [%thread] %-5level %logger{35} - %msg %n</ pattern>
</ encoder>
</ appender>
< root level = " ERROR" >
< appender-ref ref = " STDOUT" />
</ root>
</ configuration>
< dependency>
< groupId> org.testng</ groupId>
< artifactId> testng</ artifactId>
< version> 6.14.3</ version>
< scope> test</ scope>
</ dependency>