use of jp.ossc.nimbus.util.converter.DataSetXMLConverter in project nimbus by nimbus-org.
the class HttpResponseImplTest method testSetterGetter.
/**
* HttpResponseImplの各プロパティを設定、取得するテスト。
* <p>
* 条件:
* <ul>
* <li>HttpResponseImplインスタンスを生成する</li>
* <li>各getterメソッドを実行</li>
* </ul>
* 確認:
* <ul>
* <li>正常終了。設定した値が正しく取得できることを確認</li>
* </ul>
*/
public void testSetterGetter() {
HttpResponseImpl res = new HttpResponseImpl();
ServiceName name = new ServiceName("DataSetXMLConverter");
res.setStreamConverterServiceName(name);
DataSetXMLConverter xconv = new DataSetXMLConverter();
res.setStreamConverter(xconv);
res.setStatusCode(200);
res.setStatusMessage("OK");
assertEquals(xconv, res.getStreamConverter());
assertEquals(name, res.getStreamConverterServiceName());
assertEquals(200, res.getStatusCode());
assertEquals("OK", res.getStatusMessage());
}
use of jp.ossc.nimbus.util.converter.DataSetXMLConverter in project nimbus by nimbus-org.
the class StreamExchangeInterceptorServiceTest method testSetterGetter.
/**
* StreamExchangeInterceptorServiceTestの各プロパティを設定、取得するテスト。
* <p>
* 条件:
* <ul>
* <li>StreamExchangeInterceptorServiceTestインスタンスを生成する</li>
* <li>各setterメソッドを実行</li>
* <li>各getterメソッドを実行</li>
* </ul>
* 確認:
* <ul>
* <li>正常終了。設定した値が正しく取得できることを確認</li>
* </ul>
*/
public void testSetterGetter() {
StreamExchangeInterceptorService ic = new StreamExchangeInterceptorService();
DataSetXMLConverter xconv = new DataSetXMLConverter();
ic.setRequestStreamConverter(xconv);
assertEquals(xconv, ic.getRequestStreamConverter());
ic.setResponseStreamConverter(xconv);
assertEquals(xconv, ic.getResponseStreamConverter());
Context context = new ThreadContextService();
ic.setThreadContext(context);
assertEquals(context, ic.getThreadContext());
Journal journal = new ThreadManagedJournalService();
ic.setJournal(journal);
assertEquals(journal, ic.getJournal());
EditorFinder finder = new ObjectMappedEditorFinderService();
ic.setExchangeEditorFinder(finder);
assertEquals(finder, ic.getExchangeEditorFinder());
ic.setExchangeRequestEditorFinder(finder);
assertEquals(finder, ic.getExchangeRequestEditorFinder());
ic.setExchangeResponseEditorFinder(finder);
assertEquals(finder, ic.getExchangeResponseEditorFinder());
ic.setRequestBytesEditorFinder(finder);
assertEquals(finder, ic.getRequestBytesEditorFinder());
ic.setRequestObjectEditorFinder(finder);
assertEquals(finder, ic.getRequestObjectEditorFinder());
ic.setResponseBytesEditorFinder(finder);
assertEquals(finder, ic.getResponseBytesEditorFinder());
ic.setResponseObjectEditorFinder(finder);
assertEquals(finder, ic.getResponseObjectEditorFinder());
ic.setExceptionEditorFinder(finder);
assertEquals(finder, ic.getExceptionEditorFinder());
ServiceName sname = new ServiceName("Service");
ic.setRequestStreamConverterServiceName(sname);
assertEquals(sname, ic.getRequestStreamConverterServiceName());
ic.setResponseStreamConverterServiceName(sname);
assertEquals(sname, ic.getResponseStreamConverterServiceName());
ic.setThreadContextServiceName(sname);
assertEquals(sname, ic.getThreadContextServiceName());
ic.setJournalServiceName(sname);
assertEquals(sname, ic.getJournalServiceName());
ic.setExchangeEditorFinderServiceName(sname);
assertEquals(sname, ic.getExchangeEditorFinderServiceName());
ic.setExchangeRequestEditorFinderServiceName(sname);
assertEquals(sname, ic.getExchangeRequestEditorFinderServiceName());
ic.setExchangeResponseEditorFinderServiceName(sname);
assertEquals(sname, ic.getExchangeResponseEditorFinderServiceName());
ic.setRequestBytesEditorFinderServiceName(sname);
assertEquals(sname, ic.getRequestBytesEditorFinderServiceName());
ic.setRequestObjectEditorFinderServiceName(sname);
assertEquals(sname, ic.getRequestObjectEditorFinderServiceName());
ic.setResponseBytesEditorFinderServiceName(sname);
assertEquals(sname, ic.getResponseBytesEditorFinderServiceName());
ic.setResponseObjectEditorFinderServiceName(sname);
assertEquals(sname, ic.getResponseObjectEditorFinderServiceName());
ic.setExceptionEditorFinderServiceName(sname);
assertEquals(sname, ic.getExceptionEditorFinderServiceName());
ic.setResponseContentType("application/x-www-form-urlencoded");
assertEquals("application/x-www-form-urlencoded", ic.getResponseContentType());
ic.setRequestObjectAttributeName("TEST");
assertEquals("TEST", ic.getRequestObjectAttributeName());
ic.setResponseObjectAttributeName("TEST");
assertEquals("TEST", ic.getResponseObjectAttributeName());
ic.setRequestObjectContextKey("TEST");
assertEquals("TEST", ic.getRequestObjectContextKey());
ic.setResponseObjectContextKey("TEST");
assertEquals("TEST", ic.getResponseObjectContextKey());
ic.setRequestStreamInflate(false);
assertEquals(false, ic.isRequestStreamInflate());
ic.setExchangeJournalKey("TEST");
assertEquals("TEST", ic.getExchangeJournalKey());
ic.setExchangeRequestJournalKey("TEST");
assertEquals("TEST", ic.getExchangeRequestJournalKey());
ic.setExchangeResponseJournalKey("TEST");
assertEquals("TEST", ic.getExchangeResponseJournalKey());
ic.setRequestBytesJournalKey("TEST");
assertEquals("TEST", ic.getRequestBytesJournalKey());
ic.setRequestObjectJournalKey("TEST");
assertEquals("TEST", ic.getRequestObjectJournalKey());
ic.setResponseBytesJournalKey("TEST");
assertEquals("TEST", ic.getResponseBytesJournalKey());
ic.setResponseObjectJournalKey("TEST");
assertEquals("TEST", ic.getResponseObjectJournalKey());
ic.setExceptionJournalKey("TEST");
assertEquals("TEST", ic.getExceptionJournalKey());
}
use of jp.ossc.nimbus.util.converter.DataSetXMLConverter in project nimbus by nimbus-org.
the class HttpResponseImplTest method testSetObject.
/**
* HttpResponseのストリームを設定、取得するテスト。
* <p>
* 条件:
* <ul>
* <li>XMLストリームデータをデータセットに変換して取得する</li>
* <li>次の内容をDataSetXMLConverterで変換する<BR>
* <PRE>
* <?xml version="1.0" encoding="UTF-8"?>
* <dataSet>
* <schema>
* <header name="TestHeader">
* :A,java.util.Date,
* "jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=2;Format="yyyy-MM-DD"}",
* "jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=1;Format="yyyy-MM-DD"}",
* "@value@ != null"
* :B,java.lang.String,,,
* </header>
* </schema>
* <header name="TestHeader"><A>2008-01-28</A><B>TestValue</B></header></dataSet>
* <PRE></li>
* <li>上記のストリームデータとコンバータをプロパティに設定して、<BR>
* HttpResponse#getObjectを実行</li>
* </ul>
* 確認:
* <ul>
* <li>正しい値が返ってくることを確認</li>
* </ul>
*/
public void testSetObject() {
try {
HttpResponseImpl res = new HttpResponseImpl();
// CharacterEncodingを設定しておく
res.headerMap = new HashMap();
String[] vals = new String[] { "application/xml;charset=Shift_JIS" };
res.headerMap.put("Content-Type", vals);
String inxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<dataSet><schema><header name=\"TestHeader\">" + ":A,java.util.Date," + "\"jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=2;Format=\"yyyy-MM-DD\"}\"," + "\"jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=1;Format=\"yyyy-MM-DD\"}\"," + "\"@value@ != null\"\n:B,java.lang.String,,," + "</header></schema><header name=\"TestHeader\">" + "<A>2008-01-28</A><B>TestValue</B></header></dataSet>";
// 入力ストリームとコンバーターをプロパティにセット
InputStream is = new ByteArrayInputStream(inxml.getBytes());
res.setInputStream(is);
DataSetXMLConverter conv = new DataSetXMLConverter(DataSetXMLConverter.XML_TO_DATASET);
res.setStreamConverter(conv);
//
DataSet dataset = (DataSet) res.getObject();
assertEquals("TestHeader", dataset.getHeader("TestHeader").getName());
assertEquals(":A,java.util.Date," + "\"jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=2;Format=\"yyyy-MM-DD\"}\"," + "\"jp.ossc.nimbus.util.converter.DateFormatConverter{ConvertType=1;Format=\"yyyy-MM-DD\"}\"," + "\"@value@ != null\"\n:B,java.lang.String,,,", dataset.getHeader("TestHeader").getSchema());
assertEquals("2008-01-28", dataset.getHeader("TestHeader").getFormatProperty("A"));
assertEquals("TestValue", dataset.getHeader("TestHeader").getProperty("B"));
} catch (PropertySchemaDefineException e) {
e.printStackTrace();
fail("例外発生");
} catch (ConvertException e) {
e.printStackTrace();
fail("例外発生");
}
}
Aggregations