KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > TestAbstractComponent


1 // Copyright 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;
16
17 import org.apache.hivemind.test.HiveMindTestCase;
18
19 /**
20  * Tests a few new features of {@link org.apache.tapestry.AbstractComponent} added in release
21  * 4.0.
22  *
23  * @author Howard M. Lewis Ship
24  * @since 4.0
25  */

26 public class TestAbstractComponent extends HiveMindTestCase
27 {
28     private static class ConcreteComponent extends AbstractComponent
29     {
30
31         protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
32         {
33         }
34
35     }
36
37     public void testUnimplementedMethods()
38     {
39         IComponent component = new ConcreteComponent();
40
41         try
42         {
43             component.getMessages();
44             unreachable();
45         }
46         catch (IllegalStateException JavaDoc ex)
47         {
48             assertEquals(
49                     "Method getMessages() is not implemented. An implementation of this method should be provided via runtime class enhancement.",
50                     ex.getMessage());
51         }
52
53         try
54         {
55             component.getSpecification();
56             unreachable();
57         }
58         catch (IllegalStateException JavaDoc ex)
59         {
60             assertEquals(TapestryMessages.providedByEnhancement("getSpecification"), ex
61                     .getMessage());
62         }
63     }
64 }
Popular Tags