@isTest
|
public class FiledDownloadHttpCallMock implements HttpCalloutMock {
|
|
public HTTPResponse respond(HTTPRequest request) {
|
// 创建一个假的回应
|
System.debug('------------------------------------------------------');
|
HttpResponse response = new HttpResponse();
|
if(request.getEndpoint().contains('greaterthan12')){
|
response.setHeader('Content-Length','18000005');//大于12M
|
} else {
|
response.setHeader('Content-Length','180522');//小于12M
|
}
|
response.setHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
response.setBody('{"access_token":"eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImV4cCI6MTYyNDM1OTkzNH0.IXcAshOMZ08Y_ik7o-Iu4EmUy6o0pI9jz4xcx7orpxn6dTUV7wXVWqmdRl3Ded64Pq7OYKB5Vf_FQFUbgeyYjg","code":"200","msg":"正确返回数据"}');
|
response.setStatus('OK');
|
response.setStatusCode(200);
|
return response;
|
// }
|
}
|
}
|