use of jp.ossc.nimbus.service.http.httpclient.HttpClientFactoryService.HttpClientImpl in project nimbus by nimbus-org.
the class HttpResponseImplTest method testGetHeaderMapNull.
/**
* ヘッダー情報を取得するテスト。
* <p>
* 条件:
* <ul>
* <li>定義ファイルをロードし、HttpClientFactoryServiceインスタンスを生成する</li>
* <li>HttpRequestImpl#createRequest(論理アクション名)を実行し、HttpRequestを生成</li>
* <li>HttpRequestImpl#executeRequest()を実行し、HttpResponseを生成</li>
* <li>レスポンスのヘッダーにContent-Type=text/html;charset=Shift_JISが含まれている</li>
* <li>HttpResponseImpl#getHeader(),getHeaders()を実行</li>
* </ul>
* 確認:
* <ul>
* <li>HttpResponseImpl#getHeader(),getHeaders()が正しい結果が返されることを確認</li>
* </ul>
*/
public void testGetHeaderMapNull() {
try {
if (!ServiceManagerFactory.loadManager("jp/ossc/nimbus/service/http/httpclient/service-clientTest.xml")) {
System.exit(-1);
}
final HttpClientFactory factory = (HttpClientFactory) ServiceManagerFactory.getServiceObject("HttpClientFactory");
HttpClientImpl client = (HttpClientImpl) factory.createHttpClient();
DataSet requestDs = new DataSet("Login");
requestDs.setHeaderSchema("UserInfo", ":name,java.lang.String,,,\n" + ":age,int,,,");
Header userInfo = requestDs.getHeader("UserInfo");
userInfo.setProperty("name", "hoge");
userInfo.setProperty("age", 25);
HttpRequest request = factory.createRequest("login");
request.setObject(requestDs);
HttpResponseImpl res = (HttpResponseImpl) client.executeRequest(request);
assertEquals("text/html;charset=Shift_JIS", res.getHeader("Content-Type"));
assertEquals("text/html;charset=Shift_JIS", res.getHeaders("Content-Type")[0]);
} catch (Exception e) {
e.printStackTrace();
fail("例外発生");
} finally {
ServiceManagerFactory.unloadManager("jp/ossc/nimbus/service/http/httpclient/service-clientTest.xml");
}
}
use of jp.ossc.nimbus.service.http.httpclient.HttpClientFactoryService.HttpClientImpl in project nimbus by nimbus-org.
the class HttpResponseImplTest method testGetHeaderMap.
/**
* ヘッダー情報を取得するテスト。
* <p>
* 条件:
* <ul>
* <li>定義ファイルをロードし、HttpClientFactoryServiceインスタンスを生成する</li>
* <li>HttpRequestImpl#createRequest(論理アクション名)を実行し、HttpRequestを生成</li>
* <li>HttpRequestImpl#executeRequest()を実行し、HttpResponseを生成</li>
* <li>レスポンスのヘッダーにContent-Type=text/html;charset=Shift_JISが含まれている</li>
* <li>HttpResponseImpl#getHeadermap()を実行してmapを生成</li>
* <li>HttpResponseImpl#getHeader(),getHeaders()を実行</li>
* </ul>
* 確認:
* <ul>
* <li>HttpResponseImpl#getHeader(),getHeaders()が正しい結果が返されることを確認</li>
* </ul>
*/
public void testGetHeaderMap() {
try {
if (!ServiceManagerFactory.loadManager("jp/ossc/nimbus/service/http/httpclient/service-clientTest.xml")) {
System.exit(-1);
}
final HttpClientFactory factory = (HttpClientFactory) ServiceManagerFactory.getServiceObject("HttpClientFactory");
HttpClientImpl client = (HttpClientImpl) factory.createHttpClient();
DataSet requestDs = new DataSet("Login");
requestDs.setHeaderSchema("UserInfo", ":name,java.lang.String,,,\n" + ":age,int,,,");
Header userInfo = requestDs.getHeader("UserInfo");
userInfo.setProperty("name", "hoge");
userInfo.setProperty("age", 25);
HttpRequest request = factory.createRequest("login");
request.setObject(requestDs);
HttpResponseImpl res = (HttpResponseImpl) client.executeRequest(request);
res.getHeaderMap();
assertEquals("text/html;charset=Shift_JIS", res.getHeader("Content-Type"));
assertEquals("text/html;charset=Shift_JIS", res.getHeaders("Content-Type")[0]);
} catch (Exception e) {
e.printStackTrace();
fail("例外発生");
} finally {
ServiceManagerFactory.unloadManager("jp/ossc/nimbus/service/http/httpclient/service-clientTest.xml");
}
}
Aggregations