use of com.opensymphony.xwork2.util.OgnlTextParser in project struts by apache.
the class AbstractTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
scriptingAttrs.put("onclick", "onclick_");
scriptingAttrs.put("ondblclick", "ondblclick_");
scriptingAttrs.put("onmousedown", "onmousedown_");
scriptingAttrs.put("onmouseup", "onmouseup_");
scriptingAttrs.put("onmouseover", "onmouseover_");
scriptingAttrs.put("onmousemove", "onmousemove_");
scriptingAttrs.put("onmouseout", "onmouseout_");
scriptingAttrs.put("onfocus", "onfocus_");
scriptingAttrs.put("onblur", "onblur_");
scriptingAttrs.put("onkeypress", "onkeypress_");
scriptingAttrs.put("onkeydown", "onkeydown_");
scriptingAttrs.put("onkeyup", "onkeyup_");
scriptingAttrs.put("onselect", "onselect_");
scriptingAttrs.put("onchange", "onchange_");
commonAttrs.put("accesskey", "accesskey_");
dynamicAttrs.put("data-remote", "data-remote_");
dynamicAttrs.put("data-label", "data-label_");
theme = new SimpleTheme();
writer = new StringWriter();
map = new HashMap<>();
template = createMock(Template.class);
stack = createNiceMock(ValueStack.class);
setUpStack();
stackContext = new HashMap<>();
context = new TemplateRenderingContext(template, writer, stack, map, null);
stackContext.put(Component.COMPONENT_STACK, new Stack<>());
ActionContext actionContext = ActionContext.of(stackContext).bind();
request = createNiceMock(HttpServletRequest.class);
expect(request.getContextPath()).andReturn("/some/path").anyTimes();
response = createNiceMock(HttpServletResponse.class);
expect(stack.getActionContext()).andReturn(actionContext).anyTimes();
expect(stack.getContext()).andReturn(stackContext).anyTimes();
Container container = createNiceMock(Container.class);
XWorkConverter converter = new ConverterEx();
expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
TextParser parser = new OgnlTextParser();
expect(container.getInstance(TextParser.class)).andReturn(parser).anyTimes();
replay(request);
replay(stack);
replay(container);
actionContext.withContainer(container).withServletRequest(request);
}
use of com.opensymphony.xwork2.util.OgnlTextParser in project struts by apache.
the class NotURLClassLoader method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
result = new EmbeddedJSPResult();
request = EasyMock.createNiceMock(HttpServletRequest.class);
response = new MockHttpServletResponse();
context = new MockServletContext();
config = new MockServletConfig(context);
final Map params = new HashMap();
HttpSession session = EasyMock.createNiceMock(HttpSession.class);
EasyMock.replay(session);
EasyMock.expect(request.getSession()).andReturn(session).anyTimes();
EasyMock.expect(request.getParameterMap()).andReturn(params).anyTimes();
EasyMock.expect(request.getParameter("username")).andAnswer(() -> ActionContext.getContext().getParameters().get("username").getValue());
EasyMock.expect(request.getAttribute("something")).andReturn("somethingelse").anyTimes();
EasyMock.replay(request);
// mock value stack
ValueStack valueStack = EasyMock.createNiceMock(ValueStack.class);
EasyMock.expect(valueStack.getActionContext()).andReturn(ActionContext.getContext()).anyTimes();
EasyMock.replay(valueStack);
// mock converter
XWorkConverter converter = new DummyConverter();
DefaultFileManager fileManager = new DefaultFileManager();
fileManager.setReloadingConfigs(false);
// mock container
Container container = EasyMock.createNiceMock(Container.class);
EasyMock.expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
TextParser parser = new OgnlTextParser();
EasyMock.expect(container.getInstance(TextParser.class)).andReturn(parser).anyTimes();
EasyMock.expect(container.getInstanceNames(FileManager.class)).andReturn(new HashSet<>()).anyTimes();
EasyMock.expect(container.getInstance(FileManager.class)).andReturn(fileManager).anyTimes();
UrlHelper urlHelper = new DefaultUrlHelper();
EasyMock.expect(container.getInstance(UrlHelper.class)).andReturn(urlHelper).anyTimes();
FileManagerFactory fileManagerFactory = new DummyFileManagerFactory();
EasyMock.expect(container.getInstance(FileManagerFactory.class)).andReturn(fileManagerFactory).anyTimes();
EasyMock.replay(container);
ActionContext.of(new HashMap<>()).withParameters(HttpParameters.create(params).build()).withServletRequest(request).withServletResponse(response).withServletContext(context).withContainer(container).withValueStack(valueStack).bind();
}
Aggregations