/src/test/java/com/googlecode/charts4j/PlotTest.java

http://charts4j.googlecode.com/ · Java · 83 lines · 70 code · 13 blank · 0 comment · 0 complexity · ea69eff8b06cd2e1c0eec787eec09033 MD5 · raw file

  1. package com.googlecode.charts4j;
  2. import static com.googlecode.charts4j.Color.*;
  3. import static com.googlecode.charts4j.UrlUtil.normalize;
  4. import static org.junit.Assert.assertEquals;
  5. import java.util.logging.Logger;
  6. import org.junit.After;
  7. import org.junit.AfterClass;
  8. import org.junit.Before;
  9. import org.junit.BeforeClass;
  10. import org.junit.Test;
  11. public class PlotTest {
  12. @BeforeClass
  13. public static void setUpBeforeClass() throws Exception {
  14. }
  15. @AfterClass
  16. public static void tearDownAfterClass() throws Exception {
  17. }
  18. @Before
  19. public void setUp() throws Exception {
  20. }
  21. @After
  22. public void tearDown() throws Exception {
  23. }
  24. @Test
  25. public void testAddShapeMarkersShapeColorIntIntInt() {
  26. final Line line = TestUtil.getBasicLine();
  27. line.addShapeMarkers(Shape.DIAMOND, BLUE, 12);
  28. final LineChart chart = GCharts.newLineChart(line);
  29. Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString());
  30. String expectedString = "http://chart.apis.google.com/chart?chd=e:AAgA..&chm=d,0000FF,0,-1,12,0&chs=200x125&cht=lc";
  31. assertEquals("Junit error", normalize(expectedString), normalize(chart.toURLString()));
  32. }
  33. @Test
  34. public void testAddTextMarkers() {
  35. final Line line = TestUtil.getBasicLine();
  36. line.addTextMarker("foo", BLACK, 12, 1);
  37. final LineChart chart = GCharts.newLineChart(line);
  38. Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString());
  39. String expectedString = "http://chart.apis.google.com/chart?chd=e:AAgA..&chm=tfoo,000000,0,1,12,0&chs=200x125&cht=lc";
  40. assertEquals("Junit error", normalize(expectedString), normalize(chart.toURLString()));
  41. }
  42. @Test
  43. public void testAddShapeMarkersShapeColorInt() {
  44. final Line line = TestUtil.getBasicLine();
  45. line.addShapeMarkers(Shape.DIAMOND, BLUE, 12);
  46. final LineChart chart = GCharts.newLineChart(line);
  47. Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString());
  48. String expectedString = "http://chart.apis.google.com/chart?chd=e:AAgA..&chm=d,0000FF,0,-1,12,0&chs=200x125&cht=lc";
  49. assertEquals("Junit error", normalize(expectedString), normalize(chart.toURLString()));
  50. }
  51. @Test
  52. public void testAddMarkers() {
  53. final Line line = TestUtil.getBasicLine();
  54. line.addMarker(Markers.newShapeMarker(Shape.X, RED, 12), 0);
  55. line.addMarker(Markers.newTextMarker("foo", BLACK, 12), 1);
  56. final LineChart chart = GCharts.newLineChart(line);
  57. Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString());
  58. String expectedString = "http://chart.apis.google.com/chart?chd=e:AAgA..&chm=x,FF0000,0,0,12,0|tfoo,000000,0,1,12,0&chs=200x125&cht=lc";
  59. assertEquals("Junit error", normalize(expectedString), normalize(chart.toURLString()));
  60. }
  61. @Test
  62. public void testAddFlaggedMarkers() {
  63. final Line line = TestUtil.getBasicLine();
  64. line.addMarker(Markers.newFlaggedTextMarker("foo", BLACK, 12), 1);
  65. final LineChart chart = GCharts.newLineChart(line);
  66. Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString());
  67. String expectedString = "http://chart.apis.google.com/chart?chd=e:AAgA..&chm=ffoo,000000,0,1,12,0&chs=200x125&cht=lc";
  68. assertEquals("Junit error", normalize(expectedString), normalize(chart.toURLString()));
  69. }
  70. }