Search in sources :

Example 1 with Action

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());
}
Also used : SimpleAction(com.opensymphony.xwork2.SimpleAction) ModelDrivenAction(com.opensymphony.xwork2.ModelDrivenAction) Action(com.opensymphony.xwork2.Action) OgnlValueStack(com.opensymphony.xwork2.ognl.OgnlValueStack) ValueStack(com.opensymphony.xwork2.util.ValueStack) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SimpleAction(com.opensymphony.xwork2.SimpleAction) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Action

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));
}
Also used : SimpleAction(com.opensymphony.xwork2.SimpleAction) ModelDrivenAction(com.opensymphony.xwork2.ModelDrivenAction) Action(com.opensymphony.xwork2.Action) OgnlValueStack(com.opensymphony.xwork2.ognl.OgnlValueStack) ValueStack(com.opensymphony.xwork2.util.ValueStack) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) SimpleAction(com.opensymphony.xwork2.SimpleAction) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Action

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();
}
Also used : SimpleAction(com.opensymphony.xwork2.SimpleAction) ModelDrivenAction(com.opensymphony.xwork2.ModelDrivenAction) Action(com.opensymphony.xwork2.Action) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation)

Example 4 with Action

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());
}
Also used : Action(com.opensymphony.xwork2.Action) HttpParameters(org.apache.struts2.dispatcher.HttpParameters) HashMap(java.util.HashMap) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ActionContext(com.opensymphony.xwork2.ActionContext) Mock(com.mockobjects.dynamic.Mock)

Example 5 with Action

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();
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) SimpleFooAction(com.opensymphony.xwork2.SimpleFooAction) SimpleAction(com.opensymphony.xwork2.SimpleAction) Action(com.opensymphony.xwork2.Action) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) SimpleFooAction(com.opensymphony.xwork2.SimpleFooAction) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Aggregations

Action (io.atlasmap.v2.Action)35 Digest (build.bazel.remote.execution.v2.Digest)28 ByteString (com.google.protobuf.ByteString)28 Action (build.bazel.remote.execution.v2.Action)27 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)26 List (java.util.List)22 Action (com.google.privacy.dlp.v2.Action)20 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)19 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)19 DlpJob (com.google.privacy.dlp.v2.DlpJob)19 Action (com.opensymphony.xwork2.Action)19 Subscriber (com.google.cloud.pubsub.v1.Subscriber)18 GetDlpJobRequest (com.google.privacy.dlp.v2.GetDlpJobRequest)18 ProjectSubscriptionName (com.google.pubsub.v1.ProjectSubscriptionName)18 IOException (java.io.IOException)18 Command (build.bazel.remote.execution.v2.Command)17 ActionResult (build.bazel.remote.execution.v2.ActionResult)16 BigQueryTable (com.google.privacy.dlp.v2.BigQueryTable)16 ExecutionException (java.util.concurrent.ExecutionException)16