use of build.bazel.remote.execution.v2.Action in project struts by apache.
the class ValidateAction method doTestParameterNameLengthRestriction.
private void doTestParameterNameLengthRestriction(ParametersInterceptor parametersInterceptor, int paramNameMaxLength) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < paramNameMaxLength + 1; i++) {
sb.append("x");
}
Map<String, Object> actual = new LinkedHashMap<>();
parametersInterceptor.setValueStackFactory(createValueStackFactory(actual));
ValueStack stack = createStubValueStack(actual);
Map<String, Object> parameters = new HashMap<>();
parameters.put(sb.toString(), "");
parameters.put("huuhaa", "");
Action action = new SimpleAction();
parametersInterceptor.setParameters(action, stack, HttpParameters.create(parameters).build());
assertEquals(1, actual.size());
}
use of build.bazel.remote.execution.v2.Action in project struts by apache.
the class ValidateAction method testOrdered.
public void testOrdered() throws Exception {
ParametersInterceptor pi = new ParametersInterceptor();
pi.setOrdered(true);
container.inject(pi);
final Map<String, Object> actual = new LinkedHashMap<>();
pi.setValueStackFactory(createValueStackFactory(actual));
ValueStack stack = createStubValueStack(actual);
Map<String, Object> parameters = new HashMap<>();
parameters.put("user.address.city", "London");
parameters.put("user.address['postal']", "QJR387");
parameters.put("user.name", "Superman");
Action action = new SimpleAction();
pi.setParameters(action, stack, HttpParameters.create(parameters).build());
assertEquals(true, pi.isOrdered());
assertEquals(3, actual.size());
assertEquals("London", actual.get("user.address.city"));
assertEquals("QJR387", actual.get("user.address['postal']"));
assertEquals("Superman", actual.get("user.name"));
// should be ordered so user.name should be first
List<Object> values = new ArrayList<Object>(actual.values());
assertEquals("Superman", values.get(0));
assertEquals("London", values.get(1));
assertEquals("QJR387", values.get(2));
}
use of build.bazel.remote.execution.v2.Action in project struts by apache.
the class ValidateAction method testNoParametersAction.
public void testNoParametersAction() throws Exception {
ParametersInterceptor interceptor = new ParametersInterceptor();
interceptor.init();
MockActionInvocation mai = new MockActionInvocation();
Action action = new NoParametersAction();
mai.setAction(action);
interceptor.doIntercept(mai);
interceptor.destroy();
}
use of build.bazel.remote.execution.v2.Action in project struts by apache.
the class AnnotationParameterFilterInterceptorTest method testBlockingByDefault.
/**
* Only "name" should remain in the parameter map. All others
* should be removed
*/
public void testBlockingByDefault() throws Exception {
Map<String, Object> parameterMap = new HashMap<>();
parameterMap.put("job", "Baker");
parameterMap.put("name", "Martin");
ActionContext actionContext = ActionContext.of(new HashMap<>()).bind();
actionContext.setParameters(HttpParameters.create(parameterMap).build());
Action action = new BlockingByDefaultAction();
stack.push(action);
Mock mockInvocation = new Mock(ActionInvocation.class);
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
mockInvocation.matchAndReturn("getAction", action);
mockInvocation.matchAndReturn("getStack", stack);
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
mockInvocation.expectAndReturn("getInvocationContext", actionContext);
ActionInvocation invocation = (ActionInvocation) mockInvocation.proxy();
AnnotationParameterFilterInterceptor interceptor = new AnnotationParameterFilterInterceptor();
interceptor.intercept(invocation);
HttpParameters parameters = invocation.getInvocationContext().getParameters();
assertEquals("Parameter map should contain one entry", 1, parameters.keySet().size());
assertFalse(parameters.get("job").isDefined());
assertTrue(parameters.get("name").isDefined());
}
use of build.bazel.remote.execution.v2.Action in project struts by apache.
the class AliasInterceptorTest method testSetAliasKeys.
public void testSetAliasKeys() throws Exception {
Action action = new SimpleFooAction();
MockActionInvocation mai = new MockActionInvocation();
MockActionProxy map = new MockActionProxy();
ActionConfig cfg = new ActionConfig.Builder("", "", "").addParam("hello", "invalid alias expression").build();
map.setConfig(cfg);
mai.setProxy(map);
mai.setAction(action);
mai.setInvocationContext(ActionContext.getContext());
AliasInterceptor ai = new AliasInterceptor();
ai.init();
ai.setAliasesKey("hello");
ai.intercept(mai);
ai.destroy();
}
Aggregations