public static void tearDown(ConfigurationManager configurationManager) throws Exception { // clear out configuration if (configurationManager != null) { configurationManager.destroyConfiguration(); } ActionContext.setContext(null); } }
public String execute() throws Exception { ActionContext nestedContext = ActionContext.getContext(); ActionContext.setContext(invocation.getInvocationContext()); String retCode = null; String profileKey = "execute: "; try { UtilTimerStack.push(profileKey); retCode = invocation.invoke(); } finally { if (cleanupContext) { ActionContext.setContext(nestedContext); } UtilTimerStack.pop(profileKey); } return retCode; }
ActionContext.setContext(context);
@After public void tearDown() throws Exception { if (configurationManager != null) { configurationManager.destroyConfiguration(); configurationManager = null; } ActionContext.setContext(null); this.configurationManager = null; this.configuration = null; this.container = null; this.actionProxyFactory = null; Dispatcher.setInstance(null); session = null; httpSession = null; }
ActionContext.setContext(new ActionContext(vs.getContext()));
protected void initActionContext(ActionContext actionContext) { actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build()); initSession(actionContext); // set the action context to the one used by the proxy ActionContext.setContext(actionContext); }
@Test public void testActionInvocationWhenExceptionThrownDuringRequestCalculation() throws Exception { // Mocking the ActionContext to throw exception. Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { throw new Exception("FATAL!"); } }).when(actionContext).getName(); ActionContext.setContext(actionContext); interceptor.intercept(actionInvocation); } }
protected ActionContext setContext(Container cont) { ActionContext context = ActionContext.getContext(); if (context == null) { ValueStack vs = cont.getInstance(ValueStackFactory.class).createValueStack(); context = new ActionContext(vs.getContext()); ActionContext.setContext(context); } return context; }
protected void initActionContext(ActionContext actionContext) { actionContext.setParameters(HttpParameters.create(request.getParameterMap()).build()); initSession(actionContext); applyAdditionalParams(actionContext); // set the action context to the one used by the proxy ActionContext.setContext(actionContext); }
public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext, ValueStack vs) { this.beanClass = beanClass; this.includeDefaultContext = includeDefaultContext; validationSupport = new ValidationAwareSupport(); validationContext = new DelegatingValidatorContext(validationSupport); if (vs == null) { // create a standalone value stack ConfigurationManager confManager = new ConfigurationManager(); Configuration conf = confManager.getConfiguration(); vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); if (log.isDebugEnabled()) { log.info("create a standalone value stack " + vs); } } else { if (log.isDebugEnabled()) { log.debug("use given value stack " + vs); } } context = new ActionContext(vs.getContext()); ActionContext.setContext(context); // init validator validator = context.getContainer().getInstance(ActionValidatorManager.class, "no-annotations"); // init context setContextName(contextName); }
public static ConfigurationManager setUp() throws Exception { ConfigurationManager configurationManager = new ConfigurationManager(); configurationManager.addContainerProvider(new XWorkConfigurationProvider()); Configuration config = configurationManager.getConfiguration(); Container container = config.getContainer(); // Reset the value stack ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack(); stack.getContext().put(ActionContext.CONTAINER, container); ActionContext.setContext(new ActionContext(stack.getContext())); // clear out localization LocalizedTextUtil.reset(); //ObjectFactory.setObjectFactory(container.getInstance(ObjectFactory.class)); return configurationManager; }
@Before public void testInitialize() { RequestTelemetryContext requestTelemetryContext = new RequestTelemetryContext(DateTimeUtils.getDateTimeNow().getTime()); ThreadContext.setRequestTelemetryContext(requestTelemetryContext); RequestTelemetry requestTelemetry = ThreadContext.getRequestTelemetryContext().getHttpRequestTelemetry(); requestTelemetry.setHttpMethod(HTTP_METHOD); // Setting mock for action context actionContext = mock(ActionContext.class); when(actionContext.getName()).thenReturn(ACTION_NAME); ActionContext.setContext(actionContext); }
/** * Executes an action with extra context information * * @param namespace The namespace * @param name The action name * @param method The method name * @param extraContext A map of extra context information * @throws Exception If anything goes wrong */ public void executeAction(String namespace, String name, String method, Map<String, Object> extraContext) throws XWorkException { Configuration config = configurationManager.getConfiguration(); try { ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy( namespace, name, method, extraContext, true, false); proxy.execute(); } catch (Exception e) { throw new XWorkException(e); } finally { ActionContext.setContext(null); } } }
protected Dispatcher initDispatcher(Map<String, String> params) { Dispatcher du = new Dispatcher(servletContext, params); du.init(); Dispatcher.setInstance(du); ValueStack stack = ((ValueStackFactory) du.getContainer().getInstance(ValueStackFactory.class)).createValueStack(); stack.getContext().put("com.opensymphony.xwork2.ActionContext.container", du.getContainer()); ActionContext.setContext(new ActionContext(stack.getContext())); configurationManager = du.getConfigurationManager(); configuration = configurationManager.getConfiguration(); container = configuration.getContainer(); return du; }
ActionContext.setContext(context);
invocationContext.setParameters(HttpParameters.create(request.getParameterMap()).build()); ActionContext.setContext(invocationContext); ActionContext.setContext(invocationContext);
ActionContext.setContext(new ActionContext(stack.getContext()));
} finally { if (oldContext == null) { ActionContext.setContext(null);
@SuppressWarnings("unchecked") private ActionProxy getProxy(String uri) { ServletActionContext.setRequest(request); request.setRequestURI(uri); ActionMapping mapping = getActionMapping(request); String namespace = mapping.getNamespace(); String name = mapping.getName(); String method = mapping.getMethod(); ActionProxy proxy = this.actionProxyFactory.createActionProxy(namespace, name, method, new HashMap<String, Object>(), true, false); TestActionProxy testProxy = new TestActionProxy(proxy); testProxy.addExecutionListener(this); this.actionFromProxy = (T) proxy.getAction(); proxy.setExecuteResult(isExecuteResult()); ActionContext invocationContext = proxy.getInvocation().getInvocationContext(); invocationContext.setParameters(new HashMap<String, Object>(request.getParameterMap())); invocationContext.setSession(session); // set the action context to the one used by the proxy ActionContext.setContext(invocationContext); ServletActionContext.setServletContext(servletContext); ServletActionContext.setRequest(request); ServletActionContext.setResponse(response); proxy.getInvocation().addPreResultListener(this); return testProxy; }