View Javadoc

1   /*
2    * $Id: UriParamFilterTestCase.java 19026 2010-08-16 07:30:47Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.module.ibeans.annotations;
11  
12  import org.ibeans.impl.support.util.UriParamFilter;
13  import org.junit.Test;
14  
15  public class UriParamFilterTestCase extends AbstractIBeansTestCase
16  {
17      private UriParamFilter filter = new UriParamFilter();
18  
19      @Test
20      public void testOptionalRemoveOneParam() throws Exception
21      {
22          String test = "http://foo.com?param=null.param";
23          test = filter.filterParamsByValue(test, "null.param");
24          assertEquals("http://foo.com", test);
25      }
26  
27      @Test
28      public void testOptionalRemoveTwoParam() throws Exception
29      {
30          String test = "http://foo.com?param=null.param&param2=foo";
31          test = filter.filterParamsByValue(test, "null.param");
32          assertEquals("http://foo.com?param2=foo", test);
33      }
34  
35      @Test
36      public void testOptionalRemoveThrteeParamsMiddle() throws Exception
37      {
38          String test = "http://foo.com?param0=foo&param1=null.param&param2=bar";
39          test = filter.filterParamsByValue(test, "null.param");
40          assertEquals("http://foo.com?param0=foo&param2=bar", test);
41      }
42  
43      @Test
44      public void testOptionalRemoveThreeParamsEnd() throws Exception
45      {
46          String test = "http://foo.com?param0=foo&param1=bar&param2=null.param";
47          test = filter.filterParamsByValue(test, "null.param");
48          assertEquals("http://foo.com?param0=foo&param1=bar", test);
49      }
50  
51      @Test
52      public void testOptionalRemoveAllButOne() throws Exception
53      {
54          String test = "http://foo.com?param0=foo&param1=null.param&param2=null.param&param3=null.param";
55          test = filter.filterParamsByValue(test, "null.param");
56          assertEquals("http://foo.com?param0=foo", test);
57      }
58  }