1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.facade.runtag.render;
17
18 import java.util.Arrays;
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.Map;
22 import java.util.Map.Entry;
23
24 import junit.framework.TestCase;
25
26 public class CallTemplateTest extends TestCase {
27
28 public void testFixPageCriteria() {
29 x();
30 }
31
32 void x() {
33 String[] pc = { "locale", "p" };
34 Map<String, Object> m = new HashMap<String, Object>();
35
36 m.put("TTYPE", "foo");
37 m.put("ARGS_locale", "en");
38 m.put("ARGS_foo", "foo");
39 m.put("ARGS_TNAME", "foo");
40 for (final Iterator<Entry<String, Object>> i = m.entrySet().iterator(); i.hasNext();) {
41 final Entry<String, ?> e = i.next();
42 final String key = e.getKey();
43
44 if (key.startsWith(CallTemplate.ARGS)) {
45
46 String shortKey = key.substring(CallTemplate.ARGS.length());
47 boolean found = CallTemplate.CALLTEMPLATE_EXCLUDE_VARS.contains(shortKey);
48 System.out.println(key +" " + found);
49 if (!found) {
50 for (final String c : pc) {
51 if (c.equalsIgnoreCase(shortKey)) {
52 found = true;
53 break;
54 }
55 }
56 }
57 if (!found) {
58 System.out.println("Argument '" + key + "' not found as PageCriterium " + ". Arguments are: "
59 + m.keySet().toString() + ". PageCriteria: " + Arrays.asList(pc));
60
61
62
63 i.remove();
64 System.out.println("Argument '" + key + "' is removed from the call as it is not a PageCriterium.");
65 }
66
67 }
68 }
69 }
70
71 }