mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
WW-3714 Moves all classes from com.opensymphony.xwork2 into org.apache.struts2
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.struts2.interceptor.AbstractInterceptor;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
|
||||
+4
-4
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.inject.Container;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -18,23 +18,19 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.DefaultActionInvocation;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.*;
|
||||
import org.apache.struts2.config.ConfigurationException;
|
||||
import org.apache.struts2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.config.entities.ResultConfig;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.struts2.interceptor.ValidationAware;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.ValidationAware;
|
||||
import org.apache.struts2.result.HttpHeaderResult;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
import org.apache.struts2.rest.handler.HtmlHandler;
|
||||
import org.apache.struts2.result.HttpHeaderResult;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.config.Configuration;
|
||||
import org.apache.struts2.config.ConfigurationManager;
|
||||
import org.apache.struts2.config.entities.PackageConfig;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -36,19 +36,19 @@ import java.util.HashMap;
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
* This Restful action mapper enforces Ruby-On-Rails Rest-style mappings. If the method
|
||||
* is not specified (via '!' or 'method:' prefix), the method is "guessed" at using
|
||||
* This Restful action mapper enforces Ruby-On-Rails Rest-style mappings. If the method
|
||||
* is not specified (via '!' or 'method:' prefix), the method is "guessed" at using
|
||||
* ReST-style conventions that examine the URL and the HTTP method. Special care has
|
||||
* been given to ensure this mapper works correctly with the codebehind plugin so that
|
||||
* XML configuration is unnecessary.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This mapper supports the following parameters:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li><code>struts.mapper.idParameterName</code> - If set, this value will be the name
|
||||
* of the parameter under which the id is stored. The id will then be removed
|
||||
* from the action name. Whether or not the method is specified, the mapper will
|
||||
* from the action name. Whether or not the method is specified, the mapper will
|
||||
* try to truncate the identifier from the url and store it as a parameter.
|
||||
* </li>
|
||||
* <li><code>struts.mapper.indexMethodName</code> - The method name to call for a GET
|
||||
@@ -76,7 +76,7 @@ import java.util.HashMap;
|
||||
* <p>
|
||||
* The following URL's will invoke its methods:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <ul>
|
||||
* <li><code>GET: /movies => method="index"</code></li>
|
||||
* <li><code>GET: /movies/Thrillers => method="show", id="Thrillers"</code></li>
|
||||
* <li><code>GET: /movies/Thrillers;edit => method="edit", id="Thrillers"</code></li>
|
||||
@@ -116,11 +116,11 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
private String postContinueMethodName = "createContinue";
|
||||
private String putContinueMethodName = "updateContinue";
|
||||
private boolean allowDynamicMethodCalls = false;
|
||||
|
||||
|
||||
public RestActionMapper() {
|
||||
this.defaultMethodName = indexMethodName;
|
||||
}
|
||||
|
||||
|
||||
public String getIdParameterName() {
|
||||
return idParameterName;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
public void setAllowDynamicMethodCalls(String allowDynamicMethodCalls) {
|
||||
this.allowDynamicMethodCalls = "true".equalsIgnoreCase(allowDynamicMethodCalls);
|
||||
}
|
||||
|
||||
|
||||
public ActionMapping getMapping(HttpServletRequest request,
|
||||
ConfigurationManager configManager) {
|
||||
ActionMapping mapping = new ActionMapping();
|
||||
@@ -238,14 +238,14 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
|
||||
if (isOptions(request)) {
|
||||
mapping.setMethod(optionsMethodName);
|
||||
|
||||
|
||||
// Handle uris with no id, possibly ending in '/'
|
||||
} else if (lastSlashPos == -1 || lastSlashPos == fullName.length() -1) {
|
||||
|
||||
// Index e.g. foo
|
||||
if (isGet(request)) {
|
||||
mapping.setMethod(indexMethodName);
|
||||
|
||||
|
||||
// Creating a new entry on POST e.g. foo
|
||||
} else if (isPost(request)) {
|
||||
if (isExpectContinue(request)) {
|
||||
@@ -257,12 +257,12 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
|
||||
// Handle uris with an id at the end
|
||||
} else if (id != null) {
|
||||
|
||||
|
||||
// Viewing the form to edit an item e.g. foo/1;edit
|
||||
if (isGet(request) && id.endsWith(";edit")) {
|
||||
id = id.substring(0, id.length() - ";edit".length());
|
||||
mapping.setMethod(editMethodName);
|
||||
|
||||
|
||||
// Viewing the form to create a new item e.g. foo/new
|
||||
} else if (isGet(request) && "new".equals(id)) {
|
||||
mapping.setMethod(newMethodName);
|
||||
@@ -270,12 +270,12 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
// Removing an item e.g. foo/1
|
||||
} else if (isDelete(request)) {
|
||||
mapping.setMethod(deleteMethodName);
|
||||
|
||||
|
||||
// Viewing an item e.g. foo/1
|
||||
} else if (isGet(request)) {
|
||||
mapping.setMethod(getMethodName);
|
||||
|
||||
// Updating an item e.g. foo/1
|
||||
|
||||
// Updating an item e.g. foo/1
|
||||
} else if (isPut(request)) {
|
||||
if (isExpectContinue(request)) {
|
||||
mapping.setMethod(putContinueMethodName);
|
||||
@@ -326,7 +326,7 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the name and namespace from the uri. Uses the configured package
|
||||
* Parses the name and namespace from the uri. Uses the configured package
|
||||
* namespaces to determine the name and id parameter, to be parsed later.
|
||||
*
|
||||
* @param uri
|
||||
@@ -387,10 +387,10 @@ public class RestActionMapper extends DefaultActionMapper {
|
||||
protected boolean isOptions(HttpServletRequest request) {
|
||||
return OPTIONS.equalsIgnoreCase(request.getMethod());
|
||||
}
|
||||
|
||||
|
||||
protected boolean isExpectContinue(HttpServletRequest request) {
|
||||
String expect = request.getHeader("Expect");
|
||||
return (expect != null && expect.toLowerCase().contains("100-continue"));
|
||||
return (expect != null && expect.toLowerCase().contains("100-continue"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.DefaultActionProxyFactory;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ActionProxy;
|
||||
import org.apache.struts2.DefaultActionProxyFactory;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -25,16 +25,16 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ActionSupport;
|
||||
|
||||
/**
|
||||
* Extends {@link ActionSupport} to provides a default implementation of the index method that can be invoked for
|
||||
* unknown actions by the {@link com.opensymphony.xwork2.UnknownHandler}.
|
||||
* unknown actions by the {@link org.apache.struts2.UnknownHandler}.
|
||||
*/
|
||||
public class RestActionSupport extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -889518620073576882L;
|
||||
|
||||
|
||||
private static final String DELETE = "DELETE";
|
||||
private static final String PUT = "PUT";
|
||||
private static final String POST = "POST";
|
||||
@@ -50,16 +50,16 @@ public class RestActionSupport extends ActionSupport {
|
||||
public Object index() throws Exception {
|
||||
return execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inspect the implemented methods to know the allowed http methods.
|
||||
*
|
||||
* @return Include the header "Allow" with the allowed http methods.
|
||||
*
|
||||
* @return Include the header "Allow" with the allowed http methods.
|
||||
*/
|
||||
public HttpHeaders options() {
|
||||
|
||||
|
||||
String methods = OPTIONS;
|
||||
|
||||
|
||||
Method[] meths = this.getClass().getDeclaredMethods();
|
||||
for (Method m : meths) {
|
||||
String methodName = m.getName();
|
||||
@@ -77,22 +77,22 @@ public class RestActionSupport extends ActionSupport {
|
||||
methods += DIVIDER + DELETE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HttpServletRequest request = ServletActionContext.getRequest();
|
||||
HttpServletResponse response = ServletActionContext.getResponse();
|
||||
response.addHeader("Allow", methods);
|
||||
|
||||
|
||||
DefaultHttpHeaders httpHeaders = new DefaultHttpHeaders();
|
||||
httpHeaders.apply(request, response, this);
|
||||
httpHeaders.disableCaching().withStatus(HttpServletResponse.SC_OK);
|
||||
|
||||
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* By default, return continue.
|
||||
* Is possible override the method to return expectation failed.
|
||||
*
|
||||
*
|
||||
* @return continue
|
||||
*/
|
||||
public HttpHeaders createContinue() {
|
||||
@@ -100,11 +100,11 @@ public class RestActionSupport extends ActionSupport {
|
||||
.disableCaching()
|
||||
.withStatus(HttpServletResponse.SC_CONTINUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* By default, return continue.
|
||||
* Is possible override the method to return expectation failed.
|
||||
*
|
||||
*
|
||||
* @return continue
|
||||
*/
|
||||
public HttpHeaders updateContinue() {
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
|
||||
import org.apache.struts2.Action;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.struts2.interceptor.MethodFilterInterceptor;
|
||||
import org.apache.struts2.interceptor.ValidationAware;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.interceptor.ValidationAware;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -38,7 +38,7 @@ import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
* <b>This interceptor does not perform any validation</b>.
|
||||
*
|
||||
* <p>
|
||||
* Copied from the {@link com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support
|
||||
* Copied from the {@link org.apache.struts2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support
|
||||
* for error handling of Restful operations. For example, if an validation error is discovered, a map of errors
|
||||
* is created and processed to be returned, using the appropriate content handler for rendering the body.
|
||||
* </p>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
@@ -21,8 +21,8 @@ package org.apache.struts2.rest.handler;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.juneau.parser.ParseException;
|
||||
import org.apache.juneau.serializer.SerializeException;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import com.thoughtworks.xstream.security.ArrayTypePermission;
|
||||
@@ -28,7 +29,6 @@ import com.thoughtworks.xstream.security.PrimitiveTypePermission;
|
||||
import com.thoughtworks.xstream.security.TypePermission;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.rest.handler.xstream.XStreamAllowedClassNames;
|
||||
import org.apache.struts2.rest.handler.xstream.XStreamAllowedClasses;
|
||||
import org.apache.struts2.rest.handler.xstream.XStreamPermissionProvider;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<struts>
|
||||
|
||||
<bean type="com.opensymphony.xwork2.ActionProxyFactory" name="rest" class="org.apache.struts2.rest.RestActionProxyFactory" />
|
||||
<bean type="org.apache.struts2.ActionProxyFactory" name="rest" class="org.apache.struts2.rest.RestActionProxyFactory" />
|
||||
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="rest" class="org.apache.struts2.rest.RestActionMapper" />
|
||||
|
||||
<bean type="org.apache.struts2.rest.ContentTypeHandlerManager" class="org.apache.struts2.rest.DefaultContentTypeHandlerManager" />
|
||||
|
||||
+6
-6
@@ -20,12 +20,12 @@ package org.apache.struts2.rest;
|
||||
|
||||
import com.mockobjects.dynamic.C;
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.mock.MockActionInvocation;
|
||||
import com.opensymphony.xwork2.mock.MockActionProxy;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.inject.Container;
|
||||
import org.apache.struts2.mock.MockActionInvocation;
|
||||
import org.apache.struts2.mock.MockActionProxy;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
import org.apache.struts2.rest.handler.FormUrlEncodedHandler;
|
||||
|
||||
@@ -20,10 +20,10 @@ package org.apache.struts2.rest;
|
||||
|
||||
import com.mockobjects.dynamic.AnyConstraintMatcher;
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.Action;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
+4
-4
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Scope;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.XWorkTestCase;
|
||||
import org.apache.struts2.inject.Container;
|
||||
import org.apache.struts2.inject.Scope;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.DefaultUnknownHandlerManager;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.mock.MockActionProxy;
|
||||
import com.opensymphony.xwork2.mock.MockInterceptor;
|
||||
import com.opensymphony.xwork2.ognl.DefaultOgnlBeanInfoCacheFactory;
|
||||
import com.opensymphony.xwork2.ognl.DefaultOgnlExpressionCacheFactory;
|
||||
import com.opensymphony.xwork2.ognl.OgnlUtil;
|
||||
import com.opensymphony.xwork2.util.XWorkTestCaseHelper;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.DefaultUnknownHandlerManager;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.ObjectFactory;
|
||||
import org.apache.struts2.config.ConfigurationException;
|
||||
import org.apache.struts2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.config.entities.InterceptorMapping;
|
||||
import org.apache.struts2.config.entities.ResultConfig;
|
||||
import org.apache.struts2.mock.MockActionProxy;
|
||||
import org.apache.struts2.mock.MockInterceptor;
|
||||
import org.apache.struts2.ognl.DefaultOgnlBeanInfoCacheFactory;
|
||||
import org.apache.struts2.ognl.DefaultOgnlExpressionCacheFactory;
|
||||
import org.apache.struts2.ognl.OgnlUtil;
|
||||
import org.apache.struts2.util.XWorkTestCaseHelper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
@@ -45,7 +45,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.opensymphony.xwork2.ognl.OgnlCacheFactory.CacheType.BASIC;
|
||||
import static org.apache.struts2.ognl.OgnlCacheFactory.CacheType.BASIC;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_NOT_MODIFIED;
|
||||
|
||||
public class RestActionInvocationTest extends TestCase {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
*/
|
||||
package org.apache.struts2.rest;
|
||||
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import org.apache.struts2.config.Configuration;
|
||||
import org.apache.struts2.config.ConfigurationManager;
|
||||
import org.apache.struts2.config.entities.PackageConfig;
|
||||
import org.apache.struts2.config.impl.DefaultConfiguration;
|
||||
import org.apache.struts2.inject.Container;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
@@ -181,7 +181,7 @@ public class RestActionMapperTest extends TestCase {
|
||||
req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
|
||||
req.setServletPath("/animals/dog/fido");
|
||||
req.setMethod("GET");
|
||||
|
||||
|
||||
ActionMapping mapping = mapper.getMapping(req, configManager);
|
||||
|
||||
assertEquals("/animals", mapping.getNamespace());
|
||||
@@ -194,10 +194,10 @@ public class RestActionMapperTest extends TestCase {
|
||||
req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
|
||||
req.setServletPath("/animals/dog/fido");
|
||||
req.setMethod("GET");
|
||||
|
||||
|
||||
// allow DMI
|
||||
mapper.setAllowDynamicMethodCalls("true");
|
||||
|
||||
|
||||
ActionMapping mapping = mapper.getMapping(req, configManager);
|
||||
|
||||
assertEquals("/animals", mapping.getNamespace());
|
||||
@@ -205,7 +205,7 @@ public class RestActionMapperTest extends TestCase {
|
||||
assertEquals("fido", ((String[]) mapping.getParams().get("id"))[0]);
|
||||
assertEquals("update", mapping.getMethod());
|
||||
}
|
||||
|
||||
|
||||
public void testMappingWithMethodAndId() throws Exception {
|
||||
req.setRequestURI("/myapp/animals/dog/fido/test/some-id!create;jsessionid=29fefpv23do1g");
|
||||
req.setServletPath("/animals/dog/fido/test/some-id");
|
||||
@@ -243,7 +243,7 @@ public class RestActionMapperTest extends TestCase {
|
||||
assertEquals("custom/menu/Yosemite/Vernal_Fall", mapping.getName());
|
||||
assertEquals("Vernal_Fall_Image", ((String[]) mapping.getParams().get("id"))[0]);
|
||||
assertEquals("iframe", mapping.getMethod());
|
||||
}
|
||||
}
|
||||
|
||||
public void testParseNameAndNamespace() {
|
||||
tryUri("/foo/23", "", "foo/23");
|
||||
@@ -316,7 +316,7 @@ public class RestActionMapperTest extends TestCase {
|
||||
assertEquals("fido", ((String[])mapping.getParams().get("id"))[0]);
|
||||
assertEquals("update", mapping.getMethod());
|
||||
}
|
||||
|
||||
|
||||
private void tryUri(String uri, String expectedNamespace, String expectedName) {
|
||||
ActionMapping mapping = new ActionMapping();
|
||||
mapper.setAllowDynamicMethodCalls(allowDynamicMethodInvocation);
|
||||
|
||||
@@ -20,10 +20,10 @@ package org.apache.struts2.rest;
|
||||
|
||||
import com.mockobjects.dynamic.AnyConstraintMatcher;
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.ActionProxy;
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.mock.MockActionInvocation;
|
||||
import org.apache.struts2.mock.MockActionInvocation;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
+4
-4
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.mock.MockActionInvocation;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.XWorkTestCase;
|
||||
import org.apache.struts2.mock.MockActionInvocation;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
@@ -43,7 +43,7 @@ public class JacksonXmlHandlerTest extends XWorkTestCase {
|
||||
parents = "<parents>" +
|
||||
"<parents>Adam</parents>" +
|
||||
"<parents>Ewa</parents>" +
|
||||
"</parents>";
|
||||
"</parents>";
|
||||
prefix = "<SimpleBean>";
|
||||
suffix = "</SimpleBean>";
|
||||
xml = prefix + name + age + parents + suffix;
|
||||
|
||||
+4
-5
@@ -18,17 +18,16 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.mock.MockActionInvocation;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.XWorkTestCase;
|
||||
import org.apache.struts2.mock.MockActionInvocation;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
*/
|
||||
package org.apache.struts2.rest.handler;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.mock.MockActionInvocation;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.XWorkTestCase;
|
||||
import org.apache.struts2.mock.MockActionInvocation;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.StaxDriver;
|
||||
import com.thoughtworks.xstream.security.ExplicitTypePermission;
|
||||
import com.thoughtworks.xstream.security.TypePermission;
|
||||
import org.apache.struts2.rest.handler.xstream.XStreamAllowedClassNames;
|
||||
import org.apache.struts2.rest.handler.xstream.XStreamAllowedClasses;
|
||||
@@ -39,7 +38,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
Reference in New Issue
Block a user