@@ -49,6 +49,9 @@ public class HtmlRendererTest extends TestCase {
4949 List <TableRow > rows ;
5050
5151 List <String > colIds ;
52+
53+ // Use platform dependent new-line to validate the results.
54+ String nl = System .getProperty ("line.separator" );
5255
5356 @ Override
5457 public void setUp () throws Exception {
@@ -129,18 +132,18 @@ public void tearDown() throws Exception {
129132 public void testEmptyDataTableToHtml () {
130133 DataTable dataTable = new DataTable ();
131134 String expected =
132- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
133- + "<html>\n "
134- + "<head>\n "
135- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
136- + "<title>Google Visualization</title>\n "
137- + "</head>\n "
138- + "<body>\n "
139- + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >\n "
140- + "<tr style=\" font-weight: bold; background-color: #aaa;\" ></tr>\n "
141- + "</table>\n "
142- + "</body>\n "
143- + "</html>\n " ;
135+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
136+ + "<html>" + nl
137+ + "<head>" + nl
138+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
139+ + "<title>Google Visualization</title>" + nl
140+ + "</head>" + nl
141+ + "<body>" + nl
142+ + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >" + nl
143+ + "<tr style=\" font-weight: bold; background-color: #aaa;\" ></tr>" + nl
144+ + "</table>" + nl
145+ + "</body>" + nl
146+ + "</html>" + nl ;
144147
145148 String actual = HtmlRenderer .renderDataTable (dataTable , ULocale .US ).toString ();
146149 assertEquals (expected , actual );
@@ -187,42 +190,42 @@ public void testSimpleDataTableToHtml() throws DataSourceException {
187190 testData .addRows (rows );
188191
189192 String expected =
190- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
191- + "<html>\n "
192- + "<head>\n "
193- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
194- + "<title>Google Visualization</title>\n "
195- + "</head>\n "
196- + "<body>\n "
197- + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >\n "
198- + "<tr style=\" font-weight: bold; background-color: #aaa;\" >\n "
193+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
194+ + "<html>" + nl
195+ + "<head>" + nl
196+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
197+ + "<title>Google Visualization</title>" + nl
198+ + "</head>" + nl
199+ + "<body>" + nl
200+ + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >" + nl
201+ + "<tr style=\" font-weight: bold; background-color: #aaa;\" >" + nl
199202 + "<td>col0</td>"
200203 + "<td>col1</td>"
201- + "<td>col2</td>\n "
202- + "</tr>\n "
203- + "<tr style=\" background-color: #f0f0f0\" >\n "
204+ + "<td>col2</td>" + nl
205+ + "</tr>" + nl
206+ + "<tr style=\" background-color: #f0f0f0\" >" + nl
204207 + "<td>aaa</td>"
205208 + "<td align=\" right\" >222</td>"
206- + "<td align=\" center\" >\u2717 </td>\n "
207- + "</tr>\n "
208- + "<tr style=\" background-color: #ffffff\" >\n "
209+ + "<td align=\" center\" >\u2717 </td>" + nl
210+ + "</tr>" + nl
211+ + "<tr style=\" background-color: #ffffff\" >" + nl
209212 + "<td> </td>"
210213 + "<td> </td>"
211- + "<td align=\" center\" >\u2714 </td>\n "
212- + "</tr>\n "
213- + "<tr style=\" background-color: #f0f0f0\" >\n "
214+ + "<td align=\" center\" >\u2714 </td>" + nl
215+ + "</tr>" + nl
216+ + "<tr style=\" background-color: #f0f0f0\" >" + nl
214217 + "<td>bb@@b</td>"
215218 + "<td align=\" right\" >333</td>"
216- + "<td align=\" center\" >\u2714 </td>\n "
217- + "</tr>\n "
218- + "<tr style=\" background-color: #ffffff\" >\n "
219+ + "<td align=\" center\" >\u2714 </td>" + nl
220+ + "</tr>" + nl
221+ + "<tr style=\" background-color: #ffffff\" >" + nl
219222 + "<td>ddd</td>"
220223 + "<td align=\" right\" >222</td>"
221- + "<td align=\" center\" >\u2717 </td>\n "
222- + "</tr>\n "
223- + "</table>\n "
224- + "</body>\n "
225- + "</html>\n " ;
224+ + "<td align=\" center\" >\u2717 </td>" + nl
225+ + "</tr>" + nl
226+ + "</table>" + nl
227+ + "</body>" + nl
228+ + "</html>" + nl ;
226229
227230 String actual = HtmlRenderer .renderDataTable (testData , ULocale .US ).toString ();
228231
@@ -255,31 +258,35 @@ public void testWarnings() throws DataSourceException {
255258 testData .addWarning (new Warning (ReasonType .NOT_SUPPORTED , "foobar" ));
256259
257260 String expected =
258- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
259- + "<html>\n "
260- + "<head>\n "
261- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
262- + "<title>Google Visualization</title>\n "
263- + "</head>\n "
264- + "<body>\n "
265- + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >\n "
266- + "<tr style=\" font-weight: bold; background-color: #aaa;\" >\n "
261+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
262+ + "<html>" + nl
263+ + "<head>" + nl
264+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
265+ + "<title>Google Visualization</title>" + nl
266+ + "</head>" + nl
267+ + "<body>" + nl
268+ + "<table border=\" 1\" cellpadding=\" 2\" cellspacing=\" 0\" >" + nl
269+ + "<tr style=\" font-weight: bold; background-color: #aaa;\" >" + nl
267270 + "<td>col0</td>"
268- + "<td>col1</td>\n "
269- + "</tr>\n "
270- + "<tr style=\" background-color: #f0f0f0\" >\n "
271+ + "<td>col1</td>" + nl
272+ + "</tr>" + nl
273+ + "<tr style=\" background-color: #f0f0f0\" >" + nl
271274 + "<td>aaa</td>"
272- + "<td align=\" right\" >$222</td>\n "
273- + "</tr>\n "
274- + "<tr style=\" background-color: #ffffff\" >\n "
275+ + "<td align=\" right\" >$222</td>" + nl
276+ + "</tr>" + nl
277+ + "<tr style=\" background-color: #ffffff\" >" + nl
275278 + "<td>bbb</td>"
276- + "<td align=\" right\" >333</td>\n "
277- + "</tr>\n "
278- + "</table>\n "
279- + "<br>\n <br>\n <div>Retrieved data was truncated. Sorry, data truncated</div>\n "
280- + "<br>\n <br>\n <div>Operation not supported. foobar</div>\n "
281- + "</body>\n "
282- + "</html>\n " ;
279+ + "<td align=\" right\" >333</td>" + nl
280+ + "</tr>" + nl
281+ + "</table>" + nl
282+ + "<br>" + nl
283+ + "<br>" + nl
284+ + "<div>Retrieved data was truncated. Sorry, data truncated</div>" + nl
285+ + "<br>" + nl
286+ + "<br>" + nl
287+ + "<div>Operation not supported. foobar</div>" + nl
288+ + "</body>" + nl
289+ + "</html>" + nl ;
283290
284291 String actual = HtmlRenderer .renderDataTable (testData , ULocale .US ).toString ();
285292
@@ -290,75 +297,75 @@ public void testEscaping() {
290297 ResponseStatus responseStatus = new ResponseStatus (
291298 StatusType .ERROR , ReasonType .INVALID_REQUEST , "but why? why? why?" );
292299 assertEquals (
293- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
294- + "<html>\n "
295- + "<head>\n "
296- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
297- + "<title>Google Visualization</title>\n "
298- + "</head>\n "
299- + "<body>\n "
300- + "<h3>Oops, an error occured.</h3>\n "
301- + "<div>Status: error</div>\n "
302- + "<div>Reason: Invalid request</div>\n "
303- + "<div>Description: but why? why? why?</div>\n "
304- + "</body>\n "
305- + "</html>\n " ,
300+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
301+ + "<html>" + nl
302+ + "<head>" + nl
303+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
304+ + "<title>Google Visualization</title>" + nl
305+ + "</head>" + nl
306+ + "<body>" + nl
307+ + "<h3>Oops, an error occured.</h3>" + nl
308+ + "<div>Status: error</div>" + nl
309+ + "<div>Reason: Invalid request</div>" + nl
310+ + "<div>Description: but why? why? why?</div>" + nl
311+ + "</body>" + nl
312+ + "</html>" + nl ,
306313 HtmlRenderer .renderHtmlError (responseStatus ).toString ());
307314
308315 responseStatus = new ResponseStatus (
309316 StatusType .ERROR , ReasonType .NOT_SUPPORTED , "Cannot do dat!" );
310317 assertEquals (
311- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
312- + "<html>\n "
313- + "<head>\n "
314- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
315- + "<title>Google Visualization</title>\n "
316- + "</head>\n "
317- + "<body>\n "
318- + "<h3>Oops, an error occured.</h3>\n "
319- + "<div>Status: error</div>\n "
320- + "<div>Reason: Operation not supported</div>\n "
321- + "<div>Description: Cannot do dat!</div>\n "
322- + "</body>\n "
323- + "</html>\n " ,
318+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
319+ + "<html>" + nl
320+ + "<head>" + nl
321+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
322+ + "<title>Google Visualization</title>" + nl
323+ + "</head>" + nl
324+ + "<body>" + nl
325+ + "<h3>Oops, an error occured.</h3>" + nl
326+ + "<div>Status: error</div>" + nl
327+ + "<div>Reason: Operation not supported</div>" + nl
328+ + "<div>Description: Cannot do dat!</div>" + nl
329+ + "</body>" + nl
330+ + "</html>" + nl ,
324331 HtmlRenderer .renderHtmlError (responseStatus ).toString ());
325332 }
326333
327334 public void testRenderError () {
328335 ResponseStatus responseStatus = new ResponseStatus (
329336 StatusType .ERROR , ReasonType .INVALID_REQUEST , "but why? why?" );
330337 assertEquals (
331- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
332- + "<html>\n "
333- + "<head>\n "
334- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
335- + "<title>Google Visualization</title>\n "
336- + "</head>\n "
337- + "<body>\n "
338- + "<h3>Oops, an error occured.</h3>\n "
339- + "<div>Status: error</div>\n "
340- + "<div>Reason: Invalid request</div>\n "
341- + "<div>Description: but why? why?</div>\n "
342- + "</body>\n "
343- + "</html>\n " ,
338+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
339+ + "<html>" + nl
340+ + "<head>" + nl
341+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
342+ + "<title>Google Visualization</title>" + nl
343+ + "</head>" + nl
344+ + "<body>" + nl
345+ + "<h3>Oops, an error occured.</h3>" + nl
346+ + "<div>Status: error</div>" + nl
347+ + "<div>Reason: Invalid request</div>" + nl
348+ + "<div>Description: but why? why?</div>" + nl
349+ + "</body>" + nl
350+ + "</html>" + nl ,
344351 HtmlRenderer .renderHtmlError (responseStatus ).toString ());
345352
346353 responseStatus = new ResponseStatus (
347354 StatusType .ERROR , ReasonType .NOT_SUPPORTED , "Cannot do dat!" );
348355 assertEquals (
349- "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >\n "
350- + "<html>\n "
351- + "<head>\n "
352- + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >\n "
353- + "<title>Google Visualization</title>\n "
354- + "</head>\n "
355- + "<body>\n "
356- + "<h3>Oops, an error occured.</h3>\n "
357- + "<div>Status: error</div>\n "
358- + "<div>Reason: Operation not supported</div>\n "
359- + "<div>Description: Cannot do dat!</div>\n "
360- + "</body>\n "
361- + "</html>\n " ,
356+ "<!DOCTYPE html PUBLIC \" -//W3C//DTD HTML 4.01//EN\" >" + nl
357+ + "<html>" + nl
358+ + "<head>" + nl
359+ + "<META http-equiv=\" Content-Type\" content=\" text/html; charset=UTF-8\" >" + nl
360+ + "<title>Google Visualization</title>" + nl
361+ + "</head>" + nl
362+ + "<body>" + nl
363+ + "<h3>Oops, an error occured.</h3>" + nl
364+ + "<div>Status: error</div>" + nl
365+ + "<div>Reason: Operation not supported</div>" + nl
366+ + "<div>Description: Cannot do dat!</div>" + nl
367+ + "</body>" + nl
368+ + "</html>" + nl ,
362369 HtmlRenderer .renderHtmlError (responseStatus ).toString ());
363370 }
364371}
0 commit comments