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.rewriter;
17  
18  import junit.framework.TestCase;
19  
20  /***
21   * @author JMcCrindle
22   */
23  public class FullUrlRewriterTest 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 FullUrlRewriterTest.
41       * @param name
42       */
43      public FullUrlRewriterTest(String name) {
44          super(name);
45      }
46  
47      public void testRewriteSlashdot() {
48          FullUrlRewriter urlRewriter = new FullUrlRewriter("http://www.slashdot.org", "/portletbridge/http://www.slashdot.org");
49          assertEquals("/portletbridge/http://www.slashdot.org/images/test.gif", urlRewriter.rewrite("/images/test.gif"));
50          assertEquals("/portletbridge/http://www.slashdot.org/images/images/test.gif", urlRewriter.rewrite("/images/images/test.gif"));
51          assertEquals("images/test.gif", urlRewriter.rewrite("images/test.gif"));
52          assertEquals("/portletbridge/http://images.slashdot.org/topics/topicspace.gif", urlRewriter.rewrite("//images.slashdot.org/topics/topicspace.gif"));
53      }
54  
55      public void testRewriteJakarta() {
56          FullUrlRewriter urlRewriter = new FullUrlRewriter("http://jakarta.apache.org", "/portletbridge/http://jakarta.apache.org");
57          assertEquals("./index.html", urlRewriter.rewrite("./index.html"));
58          assertEquals("/portletbridge/http://jakarta.apache.org/", urlRewriter.rewrite("http://jakarta.apache.org"));
59          assertEquals("/portletbridge/http://slashdot.org/", urlRewriter.rewrite("http://slashdot.org"));
60      }
61  
62  }