Minimal implementation for use in unit tests.
| 70 | * Minimal implementation for use in unit tests. |
| 71 | */ |
| 72 | public class TesterContext implements Context { |
| 73 | |
| 74 | private static final Log log = LogFactory.getLog(TesterContext.class); |
| 75 | |
| 76 | private List<String> securityRoles = new ArrayList<>(); |
| 77 | @Override |
| 78 | public void addSecurityRole(String role) { |
| 79 | securityRoles.add(role); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public boolean findSecurityRole(String role) { |
| 84 | return securityRoles.contains(role); |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public String[] findSecurityRoles() { |
| 89 | return securityRoles.toArray(new String[0]); |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public void removeSecurityRole(String role) { |
| 94 | securityRoles.remove(role); |
| 95 | } |
| 96 | |
| 97 | private List<SecurityConstraint> securityConstraints = new ArrayList<>(); |
| 98 | @Override |
| 99 | public void addConstraint(SecurityConstraint constraint) { |
| 100 | securityConstraints.add(constraint); |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public SecurityConstraint[] findConstraints() { |
| 105 | return securityConstraints.toArray(new SecurityConstraint[0]); |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public void removeConstraint(SecurityConstraint constraint) { |
| 110 | securityConstraints.remove(constraint); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | private String path = ""; |
| 115 | @Override |
| 116 | public String getPath() { |
| 117 | return path; |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public void setPath(String path) { |
| 122 | this.path = path; |
| 123 | } |
| 124 | |
| 125 | |
| 126 | @Override |
| 127 | public Log getLogger() { |
| 128 | return log; |
| 129 | } |