com.sun.jersey.api.client框架測試案例

一個採用junit+jersey框架的測試案例:

import org.junit.Test;

import static org.junit.Assert.assertThat;

import static org.hamcrest.Matchers.equalTo;

import static org.hamcrest.Matchers.notNullValue;

import com.sun.jersey.api.client.Client;

import com.sun.jersey.api.client.ClientResponse;

import com.sun.jersey.api.client.WebResource;

public class testtools{

public void HttpRequest(String uri)

{

Client client =new Client();

WebResource webResource=client.resource(uri);

String s=webResource.get(String,class);

ClientResponse response=webResource.get(ClientResponse.class);

assertThat("",response.getEntity(String.class),notNullValue);

assertThat("",response.getStatus,equalTo(200));


}

@Test

public void test(){

HttpRequest(http://www.baidu.com);

}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章