01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.services;
16:
17: import org.apache.tapestry.test.TapestryTestCase;
18: import org.testng.annotations.Test;
19:
20: public class AliasContributionTest extends TapestryTestCase {
21: @Test
22: public void default_for_mode() {
23: Runnable r = mockRunnable();
24:
25: replay();
26:
27: AliasContribution contribution = AliasContribution.create(
28: Runnable.class, r);
29:
30: assertSame(contribution.getContributionType(), Runnable.class);
31: assertEquals(contribution.getMode(), "");
32: assertSame(contribution.getObject(), r);
33:
34: verify();
35: }
36:
37: @Test
38: public void specific_mode() {
39: Runnable r = mockRunnable();
40:
41: replay();
42:
43: AliasContribution contribution = new AliasContribution<Runnable>(
44: Runnable.class, "mode", r);
45:
46: assertEquals(contribution.getContributionType(), Runnable.class);
47: assertEquals(contribution.getMode(), "mode");
48: assertSame(contribution.getObject(), r);
49:
50: verify();
51: }
52:
53: @Test
54: public void to_string() {
55: AliasContribution contribution = AliasContribution.create(
56: String.class, "FRED");
57:
58: assertEquals(contribution.toString(),
59: "<AliasContribution: java.lang.String FRED>");
60:
61: contribution = new AliasContribution(String.class, "servlet",
62: "FRED");
63:
64: assertEquals(contribution.toString(),
65: "<AliasContribution: java.lang.String mode:servlet FRED>");
66: }
67: }
|