/razpub/test_src/com/razie/pub/draw/test/TestContainers.java

http://razpub.googlecode.com/ · Java · 92 lines · 77 code · 11 blank · 4 comment · 0 complexity · 41c81fec2b49b3d41fcb2e169dc92b57 MD5 · raw file

  1. /**
  2. * Razvan's public code.
  3. * Copyright 2008 based on Apache license (share alike) see LICENSE.txt for details.
  4. */
  5. package com.razie.pub.draw.test;
  6. import java.io.IOException;
  7. import junit.framework.TestCase;
  8. import razie.draw.DrawList;
  9. import razie.draw.DrawStream;
  10. import razie.draw.DrawTable;
  11. import razie.draw.SimpleDrawStream;
  12. import razie.draw.Technology;
  13. import com.razie.pub.base.log.Log;
  14. public class TestContainers extends TestCase {
  15. public void setUp() {
  16. }
  17. public void testWriteList() throws IOException {
  18. DrawStream stream = new SimpleDrawStream(Technology.HTML);
  19. DrawList list = new DrawList();
  20. list.write("11");
  21. list.write("22");
  22. list.write("33");
  23. stream.write(list);
  24. String s = stream.toString();
  25. assertTrue(s.contains("33"));
  26. }
  27. public void testWriteTable() throws IOException {
  28. DrawStream stream = new SimpleDrawStream(Technology.HTML);
  29. DrawTable list = new DrawTable(0, 2);
  30. list.write("11");
  31. list.write("22");
  32. list.write("33");
  33. stream.write(list);
  34. String s = stream.toString();
  35. assertTrue(s.contains("33"));
  36. }
  37. public void testStreamList() throws IOException {
  38. DrawStream stream = new SimpleDrawStream(Technology.HTML);
  39. DrawList list = new DrawList();
  40. stream.open(list);
  41. String s = stream.toString();
  42. list.write("11");
  43. list.write("22");
  44. list.write("33");
  45. s = stream.toString();
  46. assertTrue(s.contains("33"));
  47. list.close();
  48. s = stream.toString();
  49. assertTrue(s.contains("33"));
  50. }
  51. public void testStreamTable() throws IOException {
  52. DrawStream stream = new SimpleDrawStream(Technology.HTML);
  53. DrawTable list = new DrawTable(0, 2);
  54. stream.open(list);
  55. String s = stream.toString();
  56. list.write("11");
  57. list.write("22");
  58. list.write("33");
  59. s = stream.toString();
  60. assertFalse(s.contains("33"));
  61. list.close();
  62. s = stream.toString();
  63. assertTrue(s.contains("33"));
  64. }
  65. public void testStreamTableWithExactCols() throws IOException {
  66. DrawStream stream = new SimpleDrawStream(Technology.HTML);
  67. DrawTable list = new DrawTable(0, 2);
  68. stream.open(list);
  69. String s = stream.toString();
  70. list.write("11");
  71. list.write("22");
  72. list.write("33");
  73. list.write("44");
  74. s = stream.toString();
  75. assertFalse(s.contains("33"));
  76. list.close();
  77. s = stream.toString();
  78. assertTrue(s.contains("33"));
  79. }
  80. static final Log logger = Log.factory.create(TestContainers.class.getName());
  81. }