1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.junit.http;
12
13 import java.util.Enumeration;
14 import java.util.HashMap;
15 import java.util.Iterator;
16 import java.util.Map;
17
18 import javax.servlet.ServletConfig;
19 import javax.servlet.ServletContext;
20
21
22
23
24 public class MockServletConfig implements ServletConfig {
25 private final Map<String, String> parameters = new HashMap<>();
26
27
28
29
30
31
32
33 public void setInitParameter(String name, String value) {
34 parameters.put(name, value);
35 }
36
37
38 @Override
39 public String getInitParameter(String name) {
40 return parameters.get(name);
41 }
42
43
44 @Override
45 public Enumeration<String> getInitParameterNames() {
46 final Iterator<String> i = parameters.keySet().iterator();
47 return new Enumeration<>() {
48
49 @Override
50 public boolean hasMoreElements() {
51 return i.hasNext();
52 }
53
54 @Override
55 public String nextElement() {
56 return i.next();
57 }
58 };
59 }
60
61
62 @Override
63 public String getServletName() {
64 return "MOCK_SERVLET";
65 }
66
67
68 @Override
69 public ServletContext getServletContext() {
70 return null;
71 }
72 }