PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://charts4j.googlecode.com/
Java | 88 lines | 68 code | 20 blank | 0 comment | 0 complexity | 3354a7b68ce4221e9247ddaf911a078d MD5 | raw file
 1package com.googlecode.charts4j;
 2
 3import static com.googlecode.charts4j.UrlUtil.normalize;
 4import static org.junit.Assert.assertEquals;
 5
 6import java.util.logging.Level;
 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 GChartsTest {
16
17    @BeforeClass
18    public static void setUpBeforeClass() throws Exception {
19        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.ALL);
20    }
21
22    @AfterClass
23    public static void tearDownAfterClass() throws Exception {
24    }
25
26    @Before
27    public void setUp() throws Exception {
28    }
29
30    @After
31    public void tearDown() throws Exception {
32    }
33
34    @Test
35    public void testNewLineChart0() {
36        try {
37            Line[] lines = null;
38            GCharts.newLineChart(lines);
39        } catch (NullPointerException e) {
40            return;
41        }
42    }
43
44    @Test
45    public void testNewLineChart1() {
46        try {
47            Line[] lines = { TestUtil.getBasicLine(), null };
48            GCharts.newLineChart(lines);
49        } catch (NullPointerException e) {
50            return;
51        }
52    }
53
54    @Test
55    public void testPloymorphicPlots() {
56        Plot curve = Plots.newPlot(Data.newData(10, 99, 30));
57        Line line = Plots.newLine(Data.newData(70, 5, 50), Color.RED, "foo");
58
59        LineChart lc = GCharts.newLineChart(curve, line);
60        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(lc.toURLString());
61        String expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:Ga.WTN,szDNgA&chdl=+|foo&chco=000000,FF0000&cht=lc";
62        assertEquals("Junit error", normalize(expectedString), normalize(lc.toURLString()));
63
64
65        RadarChart rc = GCharts.newRadarChart(curve, line);
66        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(rc.toURLString());
67        expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:Ga.WTN,szDNgA&chdl=+|foo&chco=000000,FF0000&cht=r";
68        assertEquals("Junit error", normalize(expectedString), normalize(rc.toURLString()));
69
70
71        BarChart bc = GCharts.newBarChart(curve, line);
72        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(bc.toURLString());
73        expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:Ga.WTN,szDNgA&chdl=+|foo&chco=000000,FF0000&chbh=23,4,8&cht=bvg";
74        assertEquals("Junit error", normalize(expectedString), normalize(bc.toURLString()));
75
76
77        XYLineChart xyc = GCharts.newXYLineChart(curve, line);
78        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(xyc.toURLString());
79        expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:AAgA..,Ga.WTN,AAgA..,szDNgA&chdl=+|foo&chco=000000,FF0000&cht=lxy";
80        assertEquals("Junit error", normalize(expectedString), normalize(xyc.toURLString()));
81
82
83        ScatterPlot sp = GCharts.newScatterPlot(line);
84        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(sp.toURLString());
85        expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:AAgA..,szDNgA&chco=FF0000&chdl=foo&chm=o,FF0000,0,0,10,0&cht=s";
86        assertEquals("Junit error", normalize(expectedString), normalize(sp.toURLString()));
87    }
88}