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.url.impl;
18:
19: import junit.framework.TestCase;
20:
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23: import org.apache.pluto.driver.url.PortalURL;
24: import org.apache.pluto.driver.url.PortalURLParser;
25:
26: /**
27: * TestPortalURLParser.java
28: * Unit Test for Defect PLUTO-361
29: */
30: public class TestPortalURLParser extends TestCase {
31: private static final Log LOG = LogFactory
32: .getLog(TestPortalURLParser.class);
33:
34: private PortalURLParser parser;
35: private MockHttpServletRequest request;
36: private Throwable throwable = null;
37:
38: public void test_DefectPLUTO_361() {
39: // This is a well formed request.
40: this .request = new MockHttpServletRequest();
41: this .request.setContextPath("/pluto");
42: this .request
43: .setRequestURI("/pluto/portal//Test%20Page/__ac0x3testsuite0x2TestPortlet1!764587357|0");
44: this .request
45: .setRequestURL("http://localhost:8080/pluto/portal//Test%20Page/__ac0x3testsuite0x2TestPortlet1!764587357|0");
46: this .request
47: .setQueryString("testId=0&org.apache.pluto.testsuite.PARAM_ACTION_KEY=org.apache.pluto.testsuite.ACTION_VALUE");
48: this .request
49: .setPathInfo("/Test Page/__ac0x3testsuite0x2TestPortlet1!764587357|0");
50:
51: try {
52: PortalURL portalURL = this .parser.parse(this .request);
53: } catch (Throwable t) {
54: this .throwable = t;
55: LOG.error("ERROR:", t);
56: }
57: assertNull("No exception should be thrown", this .throwable);
58: this .throwable = null;
59:
60: // Not so well formed request as per defect PLUTO-361
61: this .request = new MockHttpServletRequest();
62: this .request.setContextPath("/pluto");
63: this .request.setRequestURI("/pluto/portal/__");
64: this .request
65: .setRequestURL("http://localhost:8080/pluto/portal/__");
66: this .request.setPathInfo("/__");
67:
68: try {
69: PortalURL portalURL = this .parser.parse(this .request);
70: } catch (Throwable t) {
71: this .throwable = t;
72: LOG.error("ERROR:", t);
73: }
74: assertNull("No exception should be thrown", this .throwable);
75: this .throwable = null;
76: }
77:
78: protected void setUp() throws Exception {
79: this.parser = PortalURLParserImpl.getParser();
80: }
81: }
|