01: package com.canoo.ant.table;
02:
03: import java.util.List;
04: import java.util.Properties;
05:
06: import com.canoo.ant.filter.AllEqualsFilter;
07: import com.canoo.ant.filter.GroupFilter;
08:
09: public class ExcelTableTest extends BaseTestCase {
10:
11: public ExcelTableTest(String name) {
12: super (name);
13: }
14:
15: public void testFull() throws Exception {
16: assertFile("Test.xls");
17: }
18:
19: public void testDefaults() throws Exception {
20: assertFile("ByDefaults.xls");
21: }
22:
23: public void testMixed() throws Exception {
24: assertFile("Mixed.xls");
25: }
26:
27: private void assertFile(final String file) throws Exception {
28: ExcelPropertyTable table = new ExcelPropertyTable();
29: table.setContainer(getPackageResource(file));
30: table.setTable("roles");
31: table.setFilter(new AllEqualsFilter("role.name"));
32: // find lastname of the first user with role "guest"
33: Properties firstProp = (Properties) table.getPropertiesList(
34: "guest", null).get(0);
35: assertEquals(firstProp.toString(), "Koenig", firstProp
36: .getProperty("user.last"));
37: }
38:
39: // pb with the second expansion on the same table when
40: // having multiple lines to expand
41: public void testDepends() throws Exception {
42: ExcelPropertyTable table = new ExcelPropertyTable();
43: table.setContainer(getPackageResource("Depends.xls"));
44: table.setTable("suite");
45: table.setFilter(new AllEqualsFilter("app"));
46: List propertiesList = table.getPropertiesList("a", null);
47: assertEquals(2, propertiesList.size());
48: Properties firstProp = (Properties) propertiesList.get(0);
49: assertEquals("0 " + firstProp.toString(), "PPP", firstProp
50: .getProperty("partner.name"));
51: Properties secondProp = (Properties) propertiesList.get(1);
52: assertEquals("1 " + secondProp.toString(), "PPP", secondProp
53: .getProperty("partner.name"));
54: }
55:
56: public void testGroup() throws Exception {
57: ExcelPropertyTable table = new ExcelPropertyTable();
58: table.setContainer(getPackageResource("Depends.xls"));
59: table.setTable("suite");
60: table.setFilter(new GroupFilter("app"));
61: List propertiesList = table.getPropertiesList("a", null);
62: assertEquals(3, propertiesList.size());
63: }
64: }
|