1
2
3
4
5
6
7
8
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¶m2=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¶m1=null.param¶m2=bar";
41 test = filter.filterParamsByValue(test, "null.param");
42 assertEquals("http://foo.com?param0=foo¶m2=bar", test);
43 }
44
45 @Test
46 public void testOptionalRemoveThreeParamsEnd() throws Exception
47 {
48 String test = "http://foo.com?param0=foo¶m1=bar¶m2=null.param";
49 test = filter.filterParamsByValue(test, "null.param");
50 assertEquals("http://foo.com?param0=foo¶m1=bar", test);
51 }
52
53 @Test
54 public void testOptionalRemoveAllButOne() throws Exception
55 {
56 String test = "http://foo.com?param0=foo¶m1=null.param¶m2=null.param¶m3=null.param";
57 test = filter.filterParamsByValue(test, "null.param");
58 assertEquals("http://foo.com?param0=foo", test);
59 }
60 }