PageRenderTime 31ms CodeModel.GetById 6ms app.highlight 19ms RepoModel.GetById 2ms app.codeStats 0ms

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