01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.driver.services.portal;
18:
19: import junit.framework.TestCase;
20:
21: /**
22: *
23: * @version 1.0
24: * @since Dec 1, 2005
25: */
26: public class PortletWindowConfigTest extends TestCase {
27:
28: public void testCreatePortletId() {
29: assertEquals("context.PortletName!", PortletWindowConfig
30: .createPortletId("context", "PortletName", ""));
31: assertEquals("c.PortletName!1234567", PortletWindowConfig
32: .createPortletId("c", "PortletName", "1234567"));
33: assertEquals("context.P!", PortletWindowConfig.createPortletId(
34: "context", "P", ""));
35: assertEquals("c.P!", PortletWindowConfig.createPortletId("c",
36: "P", ""));
37: }
38:
39: public void testParsePortletName() {
40: assertEquals("PortletName", PortletWindowConfig
41: .parsePortletName("context.PortletName!1234567"));
42: assertEquals("PortletName", PortletWindowConfig
43: .parsePortletName("c.PortletName!1234567"));
44: assertEquals("P", PortletWindowConfig
45: .parsePortletName("context.P!"));
46: assertEquals("P", PortletWindowConfig
47: .parsePortletName("c.P!ABC"));
48: assertEquals("PortletName", PortletWindowConfig
49: .parsePortletName("context.PortletName"));
50: }
51:
52: public void testParseContextPath() {
53: assertEquals("context", PortletWindowConfig
54: .parseContextPath("context.PortletName!aasdf"));
55: assertEquals("c", PortletWindowConfig
56: .parseContextPath("c.PortletName!1234"));
57: assertEquals("context", PortletWindowConfig
58: .parseContextPath("context.P"));
59: assertEquals("c", PortletWindowConfig.parseContextPath("c.P"));
60: }
61:
62: public void testParseMetaInfo() {
63: assertEquals("A", PortletWindowConfig.parseMetaInfo("c.p!A"));
64: assertEquals("", PortletWindowConfig.parseMetaInfo("c.p"));
65: }
66:
67: public void testParseInvalidId() {
68: testParseInvalid(".NoContext");
69: testParseInvalid("Use/Slash");
70: testParseInvalid("NoPortlet.");
71: }
72:
73: private void testParseInvalid(String id) {
74: try {
75: PortletWindowConfig.parseContextPath(id);
76: fail("Exception should have been thrown.");
77: } catch (IllegalArgumentException iae) {
78:
79: }
80: }
81:
82: }
|