KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > resolver > AbstractSpecificationResolverTestCase


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.resolver;
16
17 import java.net.URL JavaDoc;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.hivemind.Resource;
21 import org.apache.hivemind.test.HiveMindTestCase;
22 import org.apache.hivemind.util.URLResource;
23 import org.apache.tapestry.IRequestCycle;
24 import org.apache.tapestry.spec.IComponentSpecification;
25 import org.easymock.MockControl;
26
27 /**
28  * Base class for testing specification resolvers.
29  *
30  * @author Howard M. Lewis Ship
31  * @since 4.0
32  */

33 public abstract class AbstractSpecificationResolverTestCase extends HiveMindTestCase
34 {
35
36     protected IComponentSpecification newSpecification()
37     {
38         return (IComponentSpecification) newMock(IComponentSpecification.class);
39     }
40
41     protected IRequestCycle newCycle()
42     {
43         return (IRequestCycle) newMock(IRequestCycle.class);
44     }
45
46     protected URL JavaDoc newURL(String JavaDoc file)
47     {
48         return getClass().getResource(file);
49     }
50
51     protected Resource newResource(URL JavaDoc url)
52     {
53         MockControl control = newControl(Resource.class);
54         Resource resource = (Resource) control.getMock();
55
56         resource.getResourceURL();
57         control.setReturnValue(url);
58
59         return resource;
60     }
61
62     protected Resource newResource(String JavaDoc path)
63     {
64         return new URLResource(newURL(path));
65     }
66
67     protected void train(Log log, MockControl control, String JavaDoc message)
68     {
69         log.isDebugEnabled();
70         control.setReturnValue(true);
71
72         log.debug(message);
73     }
74
75 }
Popular Tags