KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > junit > spec > TestComponentSpecification


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

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 /**
24  * Test cases for page and component specifications.
25  *
26  * @author Howard Lewis Ship
27  * @since 2.2
28  */

29
30 public class TestComponentSpecification extends TapestryTestCase
31 {
32
33     public void testBeanProperty() throws Exception JavaDoc
34     {
35         IComponentSpecification s = parseComponent("BeanProperty.jwc");
36         IBeanSpecification fred = s.getBeanSpecification("fred");
37
38         checkList("propertyNames", new String JavaDoc[]
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 JavaDoc
48     {
49         IComponentSpecification s = parseComponent("ComponentProperty.jwc");
50         IContainedComponent c = s.getComponent("barney");
51
52         checkList("propertyNames", new String JavaDoc[]
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 JavaDoc
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 JavaDoc assetName, String JavaDoc propertyName,
71             String JavaDoc expectedValue)
72     {
73         IAssetSpecification a = s.getAsset(assetName);
74
75         assertEquals("Property " + propertyName + ".", expectedValue, a.getProperty(propertyName));
76     }
77 }
78
Popular Tags