Search in sources :

Example 71 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class FetchMetadataInterceptorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    container.inject(interceptor);
    interceptor.setExemptedPaths("/foo,/bar");
    ServletActionContext.setRequest(request);
    ServletActionContext.setResponse(response);
    ActionContext context = ServletActionContext.getActionContext();
    mai.setInvocationContext(context);
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Example 72 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ServletRedirectResultTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    configurationManager.getConfiguration().addPackageConfig("foo", new PackageConfig.Builder("foo").namespace("/namespace").build());
    view = new ServletRedirectResult();
    container.inject(view);
    responseMock = new Mock(HttpServletResponse.class);
    requestMock = new Mock(HttpServletRequest.class);
    requestMock.matchAndReturn("getContextPath", "/context");
    ResultConfig resultConfig = new ResultConfig.Builder("", "").build();
    Map<String, ResultConfig> results = new HashMap<>();
    results.put("myResult", resultConfig);
    ActionConfig actionConfig = new ActionConfig.Builder("", "", "").addResultConfigs(results).build();
    ActionContext ac = ActionContext.getContext();
    ac.withServletRequest((HttpServletRequest) requestMock.proxy());
    ac.withServletResponse((HttpServletResponse) responseMock.proxy());
    MockActionInvocation ai = new MockActionInvocation();
    ai.setInvocationContext(ac);
    ai.setResultCode("myResult");
    ActionProxy mockActionProxy = createNiceMock(ActionProxy.class);
    ai.setProxy(mockActionProxy);
    expect(mockActionProxy.getConfig()).andReturn(actionConfig).anyTimes();
    replay(mockActionProxy);
    ai.setStack(ActionContext.getContext().getValueStack());
    this.ai = ai;
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) ResultConfig(com.opensymphony.xwork2.config.entities.ResultConfig) ActionProxy(com.opensymphony.xwork2.ActionProxy) HashMap(java.util.HashMap) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig) Mock(com.mockobjects.dynamic.Mock) EasyMock.createMock(org.easymock.EasyMock.createMock) EasyMock.createNiceMock(org.easymock.EasyMock.createNiceMock) HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest)

Example 73 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class PrefixBasedActionProxyFactoryTest method testFallbackToDefault.

public void testFallbackToDefault() throws Exception {
    initFactory("/ns1:prefix1");
    ActionProxy proxy1 = factory.createActionProxy("/ns1", "", "", Collections.emptyMap(), false, true);
    assertTrue(proxy1 instanceof Prefix1ActionProxy);
    ActionProxy proxy2 = factory.createActionProxy("", "Foo", "", Collections.emptyMap(), false, true);
    assertTrue(proxy2 instanceof StrutsActionProxy);
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 74 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class CoepInterceptorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    container.inject(interceptor);
    interceptor.setExemptedPaths("/foo");
    ServletActionContext.setRequest(request);
    ServletActionContext.setResponse(response);
    ActionContext context = ServletActionContext.getActionContext();
    Map<String, Object> session = new HashMap<>();
    context.withSession(session);
    mai.setInvocationContext(context);
}
Also used : HashMap(java.util.HashMap) ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Example 75 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class PropertiesConfigurationProviderTest method testRegister_NoLocale.

public void testRegister_NoLocale() {
    ContainerBuilder builder = new ContainerBuilder();
    builder.constant("foo", "bar");
    PropertiesConfigurationProvider prov = new PropertiesConfigurationProvider();
    prov.register(builder, new LocatableProperties());
    Container container = builder.create(true);
    String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
    assertNull(localeStr);
}
Also used : Container(com.opensymphony.xwork2.inject.Container) ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) LocatableProperties(com.opensymphony.xwork2.util.location.LocatableProperties)

Aggregations

Foo (com.opensymphony.xwork2.util.Foo)53 HashMap (java.util.HashMap)32 ValueStack (com.opensymphony.xwork2.util.ValueStack)23 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)20 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)19 StrutsException (org.apache.struts2.StrutsException)19 OgnlException (ognl.OgnlException)18 IntrospectionException (java.beans.IntrospectionException)17 InappropriateExpressionException (ognl.InappropriateExpressionException)17 MethodFailedException (ognl.MethodFailedException)17 NoSuchPropertyException (ognl.NoSuchPropertyException)17 ActionProxy (com.opensymphony.xwork2.ActionProxy)16 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)9 ActionContext (com.opensymphony.xwork2.ActionContext)8 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)8 Bar (com.opensymphony.xwork2.util.Bar)8 Map (java.util.Map)8 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)7 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)7 StubValueStack (com.opensymphony.xwork2.StubValueStack)6