1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.portletbridge.portlet;
17  
18  import junit.framework.TestCase;
19  
20  /***
21   * @author JMcCrindle
22   */
23  public class DefaultPortletBridgeServiceTest extends TestCase {
24  
25      /*
26       * @see TestCase#setUp()
27       */
28      protected void setUp() throws Exception {
29          super.setUp();
30      }
31  
32      /*
33       * @see TestCase#tearDown()
34       */
35      protected void tearDown() throws Exception {
36          super.tearDown();
37      }
38  
39      /***
40       * Constructor for DefaultPortletBridgeServiceTest.
41       * @param name
42       */
43      public DefaultPortletBridgeServiceTest(String name) {
44          super(name);
45      }
46  
47      public void testGetIdFromRequestUri() {
48          DefaultPortletBridgeService service = new DefaultPortletBridgeService();
49          String idFromRequestUri = service.getIdFromRequestUri("/portletbridge-portlet", "/portletbridge-portlet/pbhs/23/awards.shtml");
50          assertEquals("23", idFromRequestUri);
51          idFromRequestUri = service.getIdFromRequestUri("/portletbridge-portlet", "/portletbridge-portlet/pbhs/23/test/");
52          assertEquals("23", idFromRequestUri);
53          idFromRequestUri = service.getIdFromRequestUri("/portletbridge-portlet", "/portletbridge-portlet/pbhs/23//");
54          assertEquals("23", idFromRequestUri);
55          idFromRequestUri = service.getIdFromRequestUri("/portletbridge-portlet", "/portletbridge-portlet/pbhs/23/");
56          assertEquals("23", idFromRequestUri);
57          idFromRequestUri = service.getIdFromRequestUri("/portletbridge-portlet", "/portletbridge-portlet/pbhs/");
58          idFromRequestUri = service.getIdFromRequestUri("", "/pbhs/23/");
59          assertEquals("23", idFromRequestUri);
60      }
61  
62  }