View Javadoc

1   /*
2    * $Id: UriParamFilterTestCase.java 22377 2011-07-11 12:41:42Z 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  import static org.junit.Assert.assertEquals;
16  
17  public class UriParamFilterTestCase extends AbstractIBeansTestCase
18  {
19      private UriParamFilter filter = new UriParamFilter();
20  
21      @Test
22      public void testOptionalRemoveOneParam() throws Exception
23      {
24          String test = "http://foo.com?param=null.param";
25          test = filter.filterParamsByValue(test, "null.param");
26          assertEquals("http://foo.com", test);
27      }
28  
29      @Test
30      public void testOptionalRemoveTwoParam() throws Exception
31      {
32          String test = "http://foo.com?param=null.param&param2=foo";
33          test = filter.filterParamsByValue(test, "null.param");
34          assertEquals("http://foo.com?param2=foo", test);
35      }
36  
37      @Test
38      public void testOptionalRemoveThrteeParamsMiddle() throws Exception
39      {
40          String test = "http://foo.com?param0=foo&param1=null.param&param2=bar";
41          test = filter.filterParamsByValue(test, "null.param");
42          assertEquals("http://foo.com?param0=foo&param2=bar", test);
43      }
44  
45      @Test
46      public void testOptionalRemoveThreeParamsEnd() throws Exception
47      {
48          String test = "http://foo.com?param0=foo&param1=bar&param2=null.param";
49          test = filter.filterParamsByValue(test, "null.param");
50          assertEquals("http://foo.com?param0=foo&param1=bar", test);
51      }
52  
53      @Test
54      public void testOptionalRemoveAllButOne() throws Exception
55      {
56          String test = "http://foo.com?param0=foo&param1=null.param&param2=null.param&param3=null.param";
57          test = filter.filterParamsByValue(test, "null.param");
58          assertEquals("http://foo.com?param0=foo", test);
59      }
60  }