KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > olap > model > impl > FormatStringParserTest


1 package com.tonbeller.jpivot.olap.model.impl;
2
3 import junit.framework.TestCase;
4
5 import com.tonbeller.jpivot.olap.model.Property;
6
7 public class FormatStringParserTest extends TestCase {
8
9   public void testParse() {
10     FormatStringParser parser = new FormatStringParser();
11     CellImpl cell = new CellImpl();
12     
13     FormatStringParser.Result res = parser.parse(cell, "value");
14     assertEquals("value", res.getFormattedValue());
15     assertEquals(0, res.getProperties().size());
16     
17     res = parser.parse(cell, "|a|b=c");
18     assertEquals("a", res.getFormattedValue());
19     assertEquals(1, res.getProperties().size());
20     Property p = (Property) res.getProperties().get(0);
21     assertEquals("b", p.getName());
22     assertEquals("c", p.getValue());
23     
24     cell.setValue(new Long JavaDoc(3600L * 3 + 60 * 6 + 11));
25     res = parser.parse(cell, "|11171|exit=hhhmmss");
26     assertEquals("3:06:11", res.getFormattedValue());
27     
28     res = parser.parse(cell, "|11171|exit=hhhmmss|a=b");
29     assertEquals("3:06:11", res.getFormattedValue());
30     assertEquals(1, res.getProperties().size());
31   }
32
33 }
34
Popular Tags