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.internal.services;
16:
17: import org.testng.Assert;
18: import org.testng.annotations.Test;
19:
20: public class ComponentInvocationTest extends Assert {
21: @Test
22: public void no_context() {
23: ComponentInvocation invocation = new ComponentInvocation(
24: new OpaqueConstantTarget("abc"), new String[0], null);
25: assertEquals(invocation.buildURI(false), "abc");
26: assertEquals(invocation.buildURI(true), "abc");
27: }
28:
29: @Test
30: public void context() {
31: ComponentInvocation invocation = new ComponentInvocation(
32: new OpaqueConstantTarget("abc"), new String[] { "x",
33: "123" }, null);
34: assertEquals(invocation.buildURI(false), "abc/x/123");
35: assertEquals(invocation.buildURI(true), "abc/x/123");
36: }
37:
38: @Test
39: public void parameters() {
40: ComponentInvocation invocation = new ComponentInvocation(
41: new OpaqueConstantTarget("abc"), new String[] { "x",
42: "123" }, null);
43: invocation.addParameter("p1", "foo");
44: invocation.addParameter("p2", "bar");
45: assertEquals(invocation.buildURI(false),
46: "abc/x/123?p1=foo&p2=bar");
47: assertEquals(invocation.buildURI(true), "abc/x/123");
48: }
49: }
|