1 15 package org.apache.tapestry.junit.spec; 16 17 import org.apache.tapestry.junit.TapestryTestCase; 18 import org.apache.tapestry.spec.IAssetSpecification; 19 import org.apache.tapestry.spec.IBeanSpecification; 20 import org.apache.tapestry.spec.IComponentSpecification; 21 import org.apache.tapestry.spec.IContainedComponent; 22 23 29 30 public class TestComponentSpecification extends TapestryTestCase 31 { 32 33 public void testBeanProperty() throws Exception 34 { 35 IComponentSpecification s = parseComponent("BeanProperty.jwc"); 36 IBeanSpecification fred = s.getBeanSpecification("fred"); 37 38 checkList("propertyNames", new String [] 39 { "bruce", "nicole", "zeta" }, fred.getPropertyNames()); 40 41 checkProperty(fred, "bruce", "wayne"); 42 checkProperty(fred, "nicole", "kidman"); 43 checkProperty(fred, "zeta", "jones"); 44 45 } 46 47 public void testComponentProperty() throws Exception 48 { 49 IComponentSpecification s = parseComponent("ComponentProperty.jwc"); 50 IContainedComponent c = s.getComponent("barney"); 51 52 checkList("propertyNames", new String [] 53 { "apple", "chocolate", "frozen" }, c.getPropertyNames()); 54 55 checkProperty(c, "apple", "pie"); 56 checkProperty(c, "chocolate", "cake"); 57 checkProperty(c, "frozen", "yogurt"); 58 59 } 60 61 public void testAssetProperty() throws Exception 62 { 63 IComponentSpecification s = parseComponent("AssetProperty.jwc"); 64 65 checkAsset(s, "private", "hugh", "grant"); 66 checkAsset(s, "external", "joan", "rivers"); 67 checkAsset(s, "context", "john", "cusak"); 68 } 69 70 private void checkAsset(IComponentSpecification s, String assetName, String propertyName, 71 String expectedValue) 72 { 73 IAssetSpecification a = s.getAsset(assetName); 74 75 assertEquals("Property " + propertyName + ".", expectedValue, a.getProperty(propertyName)); 76 } 77 } 78 | Popular Tags |