mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
WW-5003 Drops XWorkException and uses StrutsException instead
This commit is contained in:
@@ -23,6 +23,7 @@ import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -212,7 +213,7 @@ public class ActionChainResult implements Result {
|
||||
|
||||
if (isInChainHistory(finalNamespace, finalActionName, finalMethodName)) {
|
||||
addToHistory(finalNamespace, finalActionName, finalMethodName);
|
||||
throw new XWorkException("Infinite recursion detected: " + ActionChainResult.getChainHistory().toString());
|
||||
throw new StrutsException("Infinite recursion detected: " + ActionChainResult.getChainHistory().toString());
|
||||
}
|
||||
|
||||
if (ActionChainResult.getChainHistory().isEmpty() && invocation != null && invocation.getProxy() != null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.opensymphony.xwork2;
|
||||
import com.opensymphony.xwork2.conversion.impl.ConversionData;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -323,7 +324,7 @@ public class ActionContext implements Serializable {
|
||||
if (cont != null) {
|
||||
return cont.getInstance(type);
|
||||
} else {
|
||||
throw new XWorkException("Cannot find an initialized container for this request.");
|
||||
throw new StrutsException("Cannot find an initialized container for this request.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import ognl.MethodFailedException;
|
||||
import ognl.NoSuchPropertyException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -224,7 +225,7 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
return objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
|
||||
} catch (Exception e) {
|
||||
LOG.error("There was an exception while instantiating the result of type {}", resultConfig.getClassName(), e);
|
||||
throw new XWorkException(e, resultConfig);
|
||||
throw new StrutsException(e, resultConfig);
|
||||
}
|
||||
} else if (resultCode != null && !Action.NONE.equals(resultCode) && unknownHandlerManager.hasUnknownHandlers()) {
|
||||
return unknownHandlerManager.handleUnknownResult(invocationContext, proxy.getActionName(), proxy.getConfig(), resultCode);
|
||||
@@ -297,9 +298,9 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
try {
|
||||
action = objectFactory.buildAction(proxy.getActionName(), proxy.getNamespace(), proxy.getConfig(), contextMap);
|
||||
} catch (InstantiationException e) {
|
||||
throw new XWorkException("Unable to instantiate Action!", e, proxy.getConfig());
|
||||
throw new StrutsException("Unable to instantiate Action!", e, proxy.getConfig());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new XWorkException("Illegal access to constructor, is it public?", e, proxy.getConfig());
|
||||
throw new StrutsException("Illegal access to constructor, is it public?", e, proxy.getConfig());
|
||||
} catch (Exception e) {
|
||||
String gripe;
|
||||
|
||||
@@ -314,7 +315,7 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
}
|
||||
|
||||
gripe += (((" -- " + e.getMessage()) != null) ? e.getMessage() : " [no message in exception]");
|
||||
throw new XWorkException(gripe, e, proxy.getConfig());
|
||||
throw new StrutsException(gripe, e, proxy.getConfig());
|
||||
}
|
||||
|
||||
if (actionEventListener != null) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
/**
|
||||
* Handles cases when the result or action is unknown.
|
||||
@@ -36,9 +37,9 @@ public interface UnknownHandler {
|
||||
* @param namespace The namespace
|
||||
* @param actionName The action name
|
||||
* @return An generated ActionConfig, can return <tt>null</tt>
|
||||
* @throws XWorkException in case of errors
|
||||
* @throws StrutsException in case of errors
|
||||
*/
|
||||
ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException;
|
||||
ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException;
|
||||
|
||||
/**
|
||||
* Handles the case when a result cannot be found for an action and result code.
|
||||
@@ -48,9 +49,9 @@ public interface UnknownHandler {
|
||||
* @param actionConfig The action config
|
||||
* @param resultCode The returned result code
|
||||
* @return A result to be executed, can return <tt>null</tt>
|
||||
* @throws XWorkException in case of errors
|
||||
* @throws StrutsException in case of errors
|
||||
*/
|
||||
Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException;
|
||||
Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException;
|
||||
|
||||
/**
|
||||
* Handles the case when an action method cannot be found. This method is responsible both for finding the method and executing it.
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.util.location.Locatable;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationUtils;
|
||||
|
||||
/**
|
||||
* A generic runtime exception that optionally contains Location information
|
||||
*
|
||||
* @author Jason Carreira
|
||||
*/
|
||||
public class XWorkException extends RuntimeException implements Locatable {
|
||||
|
||||
private Location location;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with no detail message.
|
||||
*/
|
||||
public XWorkException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
*/
|
||||
public XWorkException(String s) {
|
||||
this(s, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* detail message and target.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param target the target of the exception.
|
||||
*/
|
||||
public XWorkException(String s, Object target) {
|
||||
this(s, null, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the root cause
|
||||
*
|
||||
* @param cause The wrapped exception
|
||||
*/
|
||||
public XWorkException(Throwable cause) {
|
||||
this(null, cause, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the root cause and target
|
||||
*
|
||||
* @param cause The wrapped exception
|
||||
* @param target The target of the exception
|
||||
*/
|
||||
public XWorkException(Throwable cause, Object target) {
|
||||
this(null, cause, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* detail message and exception cause.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param cause the wrapped exception
|
||||
*/
|
||||
public XWorkException(String s, Throwable cause) {
|
||||
this(s, cause, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* detail message, cause, and target
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param cause The wrapped exception
|
||||
* @param target The target of the exception
|
||||
*/
|
||||
public XWorkException(String s, Throwable cause, Object target) {
|
||||
super(s, cause);
|
||||
|
||||
this.location = LocationUtils.getLocation(target);
|
||||
if (this.location == Location.UNKNOWN) {
|
||||
this.location = LocationUtils.getLocation(cause);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location of the error, if available
|
||||
*
|
||||
* @return the location, <tt>null</tt> if not available
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a short description of this throwable object, including the
|
||||
* location. If no detailed message is available, it will use the message
|
||||
* of the underlying exception if available.
|
||||
*
|
||||
* @return a string representation of this <code>Throwable</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String msg = getMessage();
|
||||
if (msg == null && getCause() != null) {
|
||||
msg = getCause().getMessage();
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
if (msg != null) {
|
||||
return msg + " - " + location.toString();
|
||||
} else {
|
||||
return location.toString();
|
||||
}
|
||||
} else {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,14 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.config;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
/**
|
||||
* ConfigurationException
|
||||
*
|
||||
* @author Jason Carreira
|
||||
*/
|
||||
public class ConfigurationException extends XWorkException {
|
||||
public class ConfigurationException extends StrutsException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>ConfigurationException</code> with no detail message.
|
||||
@@ -43,12 +42,12 @@ public class ConfigurationException extends XWorkException {
|
||||
public ConfigurationException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>ConfigurationException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param s the detail message.
|
||||
* @param target the target object
|
||||
*/
|
||||
public ConfigurationException(String s, Object target) {
|
||||
@@ -63,10 +62,11 @@ public class ConfigurationException extends XWorkException {
|
||||
public ConfigurationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>ConfigurationException</code> with no detail message.
|
||||
* @param cause the cause of the exception
|
||||
*
|
||||
* @param cause the cause of the exception
|
||||
* @param target the target object
|
||||
*/
|
||||
public ConfigurationException(Throwable cause, Object target) {
|
||||
@@ -77,19 +77,19 @@ public class ConfigurationException extends XWorkException {
|
||||
* Constructs a <code>ConfigurationException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param s the detail message.
|
||||
* @param cause the cause of the exception
|
||||
*/
|
||||
public ConfigurationException(String s, Throwable cause) {
|
||||
super(s, cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>ConfigurationException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param cause the cause of the exception
|
||||
* @param s the detail message.
|
||||
* @param cause the cause of the exception
|
||||
* @param target the target object
|
||||
*/
|
||||
public ConfigurationException(String s, Throwable cause, Object target) {
|
||||
|
||||
+2
-2
@@ -22,7 +22,6 @@ import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.FileManager;
|
||||
import com.opensymphony.xwork2.FileManagerFactory;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
@@ -52,6 +51,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -1080,7 +1080,7 @@ public class XmlConfigurationProvider implements ConfigurationProvider {
|
||||
|
||||
docs.add(DomHelper.parse(in, dtdMappings));
|
||||
loadedFileUrls.add(url.toString());
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
if (includeElement != null) {
|
||||
throw new ConfigurationException("Unable to load " + url, e, includeElement);
|
||||
} else {
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.conversion;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
/**
|
||||
* TypeConversionException should be thrown by any TypeConverters which fail to convert values
|
||||
@@ -27,16 +26,16 @@ import com.opensymphony.xwork2.XWorkException;
|
||||
* @author Jason Carreira
|
||||
* Created Oct 3, 2003 12:18:33 AM
|
||||
*/
|
||||
public class TypeConversionException extends XWorkException {
|
||||
public class TypeConversionException extends StrutsException {
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with no detail message.
|
||||
* Constructs a <code>StrutsException</code> with no detail message.
|
||||
*/
|
||||
public TypeConversionException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* Constructs a <code>StrutsException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
@@ -46,7 +45,7 @@ public class TypeConversionException extends XWorkException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with no detail message.
|
||||
* Constructs a <code>StrutsException</code> with no detail message.
|
||||
* @param cause the cause
|
||||
*/
|
||||
public TypeConversionException(Throwable cause) {
|
||||
@@ -54,7 +53,7 @@ public class TypeConversionException extends XWorkException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>XWorkException</code> with the specified
|
||||
* Constructs a <code>StrutsException</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.conversion.impl;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Member;
|
||||
@@ -90,11 +90,11 @@ public class DateConverter extends DefaultTypeConverter {
|
||||
Constructor constructor = toType.getConstructor(new Class[]{long.class});
|
||||
return constructor.newInstance(new Object[]{Long.valueOf(result.getTime())});
|
||||
} catch (Exception e) {
|
||||
throw new XWorkException("Couldn't create class " + toType + " using default (long) constructor", e);
|
||||
throw new StrutsException("Couldn't create class " + toType + " using default (long) constructor", e);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new XWorkException("Could not parse date", e);
|
||||
throw new StrutsException("Could not parse date", e);
|
||||
}
|
||||
} else if (Date.class.isAssignableFrom(value.getClass())) {
|
||||
result = (Date) value;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.conversion.impl;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.math.BigDecimal;
|
||||
@@ -51,7 +51,7 @@ public class NumberConverter extends DefaultTypeConverter {
|
||||
Object convertedValue = super.convertValue(context, value, toType);
|
||||
|
||||
if (!isInRange((Number) convertedValue, stringValue, toType))
|
||||
throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName());
|
||||
throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName());
|
||||
|
||||
return convertedValue;
|
||||
} else {
|
||||
@@ -67,11 +67,11 @@ public class NumberConverter extends DefaultTypeConverter {
|
||||
Number number = numFormat.parse(stringValue, parsePos);
|
||||
|
||||
if (parsePos.getIndex() != stringValue.length()) {
|
||||
throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position "
|
||||
+ parsePos.getIndex());
|
||||
throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position "
|
||||
+ parsePos.getIndex());
|
||||
} else {
|
||||
if (!isInRange(number, stringValue, toType))
|
||||
throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
|
||||
value = super.convertValue(context, number, toType);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class NumberConverter extends DefaultTypeConverter {
|
||||
Number number = format.parse(stringValue, parsePosition);
|
||||
|
||||
if (parsePosition.getIndex() != stringValue.length()) {
|
||||
throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
}
|
||||
|
||||
return number;
|
||||
@@ -123,11 +123,11 @@ public class NumberConverter extends DefaultTypeConverter {
|
||||
Number number = format.parse(stringValue, parsePosition);
|
||||
|
||||
if (parsePosition.getIndex() != stringValue.length()) {
|
||||
throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
}
|
||||
|
||||
if (!isInRange(number, stringValue, Double.class)) {
|
||||
throw new XWorkException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
}
|
||||
|
||||
if (number != null) {
|
||||
@@ -151,11 +151,11 @@ public class NumberConverter extends DefaultTypeConverter {
|
||||
Number number = format.parse(stringValue, parsePosition);
|
||||
|
||||
if (parsePosition.getIndex() != stringValue.length()) {
|
||||
throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
|
||||
}
|
||||
|
||||
if (!isInRange(number, stringValue, Float.class)) {
|
||||
throw new XWorkException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
|
||||
}
|
||||
|
||||
if (number != null) {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.conversion.impl;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.conversion.TypeConverter;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.util.Calendar;
|
||||
@@ -130,7 +130,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
}
|
||||
|
||||
if (result == null && value != null && !"".equals(value)) {
|
||||
throw new XWorkException("Cannot create type " + toType + " from value " + value);
|
||||
throw new StrutsException("Cannot create type " + toType + " from value " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
try {
|
||||
clazz = Class.forName((String) value);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new XWorkException(e.getLocalizedMessage(), e);
|
||||
throw new StrutsException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
return clazz;
|
||||
@@ -179,7 +179,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
private Object doConvertToCollection(Map<String, Object> context, Object o, Member member, String prop, Object value, Class toType) {
|
||||
TypeConverter converter = container.getInstance(CollectionConverter.class);
|
||||
if (converter == null) {
|
||||
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION);
|
||||
throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION);
|
||||
}
|
||||
return converter.convertValue(context, o, member, prop, value, toType);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
private Object doConvertToArray(Map<String, Object> context, Object o, Member member, String prop, Object value, Class toType) {
|
||||
TypeConverter converter = container.getInstance(ArrayConverter.class);
|
||||
if (converter == null) {
|
||||
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY);
|
||||
throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY);
|
||||
}
|
||||
return converter.convertValue(context, o, member, prop, value, toType);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
private Object doConvertToDate(Map<String, Object> context, Object value, Class toType) {
|
||||
TypeConverter converter = container.getInstance(DateConverter.class);
|
||||
if (converter == null) {
|
||||
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE);
|
||||
throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE);
|
||||
}
|
||||
return converter.convertValue(context, null, null, null, value, toType);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
private Object doConvertToNumber(Map<String, Object> context, Object value, Class toType) {
|
||||
TypeConverter converter = container.getInstance(NumberConverter.class);
|
||||
if (converter == null) {
|
||||
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER);
|
||||
throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER);
|
||||
}
|
||||
return converter.convertValue(context, null, null, null, value, toType);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
|
||||
private Object doConvertToString(Map<String, Object> context, Object value) {
|
||||
TypeConverter converter = container.getInstance(StringConverter.class);
|
||||
if (converter == null) {
|
||||
throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING);
|
||||
throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING);
|
||||
}
|
||||
return converter.convertValue(context, null, null, null, value, null);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ package com.opensymphony.xwork2.conversion.impl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.conversion.TypeConverter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -188,7 +188,7 @@ public class XWorkList extends ArrayList {
|
||||
try {
|
||||
this.add(getObjectFactory().buildBean(clazz, ActionContext.getContext().getContextMap()));
|
||||
} catch (Exception e) {
|
||||
throw new XWorkException(e);
|
||||
throw new StrutsException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -21,9 +21,9 @@ package com.opensymphony.xwork2.interceptor;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
@@ -127,7 +127,7 @@ public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
|
||||
Class cls = method.getReturnType();
|
||||
cName = cls.getName();
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new XWorkException("The " + GET_MODEL + "() is not defined in action " + action.getClass() + "", config);
|
||||
throw new StrutsException("The " + GET_MODEL + "() is not defined in action " + action.getClass() + "", config);
|
||||
}
|
||||
}
|
||||
String modelName = name;
|
||||
|
||||
+2
-2
@@ -19,10 +19,10 @@
|
||||
package com.opensymphony.xwork2.interceptor.annotations;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import org.apache.commons.lang3.reflect.MethodUtils;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -191,7 +191,7 @@ public class AnnotationWorkflowInterceptor extends AbstractInterceptor implement
|
||||
try {
|
||||
MethodUtils.invokeMethod(action, true, m.getName());
|
||||
} catch (Exception e) {
|
||||
throw new XWorkException(e);
|
||||
throw new StrutsException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.opensymphony.xwork2.ognl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
@@ -35,6 +34,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
@@ -196,7 +196,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
String message = ErrorMessageBuilder.create()
|
||||
.errorSettingExpressionWithValue(expr, value)
|
||||
.build();
|
||||
throw new XWorkException(message, re);
|
||||
throw new StrutsException(message, re);
|
||||
} else {
|
||||
LOG.warn("Error setting value [{}] with expression [{}]", value, expr, re);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
}
|
||||
|
||||
if (throwExceptionOnFailure) {
|
||||
throw new XWorkException(msg, e);
|
||||
throw new StrutsException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
logLookupFailure(expr, e);
|
||||
|
||||
if (throwExceptionOnFailure)
|
||||
throw new XWorkException(e);
|
||||
throw new StrutsException(e);
|
||||
|
||||
return findInContext(expr);
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
LOG.warn("Could not find property [{}]!", expr, e);
|
||||
}
|
||||
if (throwExceptionOnFailure) {
|
||||
throw new XWorkException(e);
|
||||
throw new StrutsException(e);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.ognl.accessor;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.ognl.OgnlValueStack;
|
||||
import com.opensymphony.xwork2.util.CompoundRoot;
|
||||
@@ -28,6 +27,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.PropertyDescriptor;
|
||||
@@ -111,7 +111,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
|
||||
final String msg = format("No object in the CompoundRoot has a publicly accessible property named '%s' " +
|
||||
"(no setter could be found).", name);
|
||||
if (reportError) {
|
||||
throw new XWorkException(msg);
|
||||
throw new StrutsException(msg);
|
||||
} else {
|
||||
LOG.warn(msg);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
|
||||
} catch (OgnlException e) {
|
||||
if (e.getReason() != null) {
|
||||
final String msg = "Caught an Ognl exception while getting property " + name;
|
||||
throw new XWorkException(msg, e);
|
||||
throw new StrutsException(msg, e);
|
||||
}
|
||||
} catch (IntrospectionException e) {
|
||||
// this is OK if this happens, we'll just keep trying the next
|
||||
|
||||
+3
-3
@@ -19,7 +19,6 @@
|
||||
package com.opensymphony.xwork2.ognl.accessor;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
@@ -29,6 +28,7 @@ import ognl.ListPropertyAccessor;
|
||||
import ognl.OgnlException;
|
||||
import ognl.PropertyAccessor;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -121,7 +121,7 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor {
|
||||
try {
|
||||
list.add(index, result = objectFactory.buildBean(beanClass, context));
|
||||
} catch (Exception exc) {
|
||||
throw new XWorkException(exc);
|
||||
throw new StrutsException(exc);
|
||||
}
|
||||
return result;
|
||||
} else if (list.get(index) == null) {
|
||||
@@ -129,7 +129,7 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor {
|
||||
try {
|
||||
list.set(index, result = objectFactory.buildBean(beanClass, context));
|
||||
} catch (Exception exc) {
|
||||
throw new XWorkException(exc);
|
||||
throw new StrutsException(exc);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.util;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -178,7 +178,7 @@ public class ClassPathFinder {
|
||||
try {
|
||||
urls = Collections.list(loader.getResources("")).toArray(new URL[0]);
|
||||
} catch (IOException e) {
|
||||
throw new XWorkException("unable to get ClassLoader URLs", e);
|
||||
throw new StrutsException("unable to get ClassLoader URLs", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ package com.opensymphony.xwork2.util;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationAttributes;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -105,7 +105,7 @@ public class DomHelper {
|
||||
try {
|
||||
parser = factory.newSAXParser();
|
||||
} catch (Exception ex) {
|
||||
throw new XWorkException("Unable to create SAX parser", ex);
|
||||
throw new StrutsException("Unable to create SAX parser", ex);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class DomHelper {
|
||||
try {
|
||||
parser.parse(inputSource, new StartHandler(locationHandler, dtdMappings));
|
||||
} catch (Exception ex) {
|
||||
throw new XWorkException(ex);
|
||||
throw new StrutsException(ex);
|
||||
}
|
||||
|
||||
return builder.getDocument();
|
||||
@@ -212,7 +212,7 @@ public class DomHelper {
|
||||
}
|
||||
handler.setResult(this.result);
|
||||
} catch (javax.xml.transform.TransformerException local) {
|
||||
throw new XWorkException("Fatal-Error: Unable to get transformer handler", local);
|
||||
throw new StrutsException("Fatal-Error: Unable to get transformer handler", local);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -21,10 +21,10 @@ package com.opensymphony.xwork2.util.classloader;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.FileManager;
|
||||
import com.opensymphony.xwork2.FileManagerFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@@ -66,10 +66,10 @@ public class ReloadingClassLoader extends ClassLoader {
|
||||
if (root != null) {
|
||||
stores = new ResourceStore[]{new FileResourceStore(new File(root.toURI()))};
|
||||
} else {
|
||||
throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false");
|
||||
throw new StrutsException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false");
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e);
|
||||
throw new StrutsException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e);
|
||||
} catch (RuntimeException e) {
|
||||
// see WW-3121
|
||||
// TODO: Fix this for a reloading mechanism to be marked as stable
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2.util.reflection;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
public class ReflectionException extends XWorkException {
|
||||
public class ReflectionException extends StrutsException {
|
||||
|
||||
public ReflectionException() {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
@@ -20,13 +20,13 @@ package com.opensymphony.xwork2.validator;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.inject.Initializable;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
@@ -75,7 +75,7 @@ public class DefaultValidatorFactory implements ValidatorFactory, Initializable
|
||||
validator = objectFactory.buildValidator(className, cfg.getParams(), ActionContext.getContext().getContextMap());
|
||||
} catch (Exception e) {
|
||||
final String msg = "There was a problem creating a Validator of type " + className + " : caused by " + e.getMessage();
|
||||
throw new XWorkException(msg, e, cfg);
|
||||
throw new StrutsException(msg, e, cfg);
|
||||
}
|
||||
|
||||
// set other configured properties
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
*/
|
||||
package org.apache.struts2;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.util.location.Locatable;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationUtils;
|
||||
|
||||
/**
|
||||
* A generic runtime exception that optionally contains Location information
|
||||
*/
|
||||
public class StrutsException extends XWorkException implements Locatable {
|
||||
|
||||
private static final long serialVersionUID = 888724366243600135L;
|
||||
public class StrutsException extends RuntimeException implements Locatable {
|
||||
|
||||
private Location location;
|
||||
|
||||
/**
|
||||
* Constructs a <code>StrutsException</code> with no detail message.
|
||||
@@ -96,6 +96,45 @@ public class StrutsException extends XWorkException implements Locatable {
|
||||
* @param target The target of the exception
|
||||
*/
|
||||
public StrutsException(String s, Throwable cause, Object target) {
|
||||
super(s, cause, target);
|
||||
super(s, cause);
|
||||
|
||||
this.location = LocationUtils.getLocation(target);
|
||||
if (this.location == Location.UNKNOWN) {
|
||||
this.location = LocationUtils.getLocation(cause);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location of the error, if available
|
||||
*
|
||||
* @return the location, <tt>null</tt> if not available
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of this throwable object, including the
|
||||
* location. If no detailed message is available, it will use the message
|
||||
* of the underlying exception if available.
|
||||
*
|
||||
* @return a string representation of this <code>Throwable</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String msg = getMessage();
|
||||
if (msg == null && getCause() != null) {
|
||||
msg = getCause().getMessage();
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
if (msg != null) {
|
||||
return msg + " - " + location.toString();
|
||||
} else {
|
||||
return location.toString();
|
||||
}
|
||||
} else {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;
|
||||
* failed. By default it just ask its super class (Ognl's DefaultTypeConverter) to do the conversion.
|
||||
* </p>
|
||||
*
|
||||
* <p> To allow the framework to recognize that a conversion error has occurred, throw an XWorkException or
|
||||
* <p> To allow the framework to recognize that a conversion error has occurred, throw an StrutsException or
|
||||
* preferable a TypeConversionException.
|
||||
* </p>
|
||||
* <!-- END SNIPPET: javadoc -->
|
||||
|
||||
@@ -20,12 +20,12 @@ package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import com.opensymphony.xwork2.mock.MockResult;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* @author $Author$
|
||||
* @version $Revision$
|
||||
@@ -51,12 +51,12 @@ public class ActionInvocationTest extends XWorkTestCase {
|
||||
public void testCommandInvocationUnknownHandler() throws Exception {
|
||||
|
||||
UnknownHandler unknownHandler = new UnknownHandler() {
|
||||
public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException {
|
||||
public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException {
|
||||
return new ActionConfig.Builder("test", actionName, ActionSupport.class.getName())
|
||||
.addAllowedMethod("unknownmethod")
|
||||
.build();
|
||||
}
|
||||
public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException {
|
||||
public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException {
|
||||
return new MockResult();
|
||||
}
|
||||
public Object handleUnknownActionMethod(Object action, String methodName) {
|
||||
@@ -84,7 +84,7 @@ public class ActionInvocationTest extends XWorkTestCase {
|
||||
public void testResultReturnInvocationAndWired() throws Exception {
|
||||
ActionProxy baseActionProxy = actionProxyFactory.createActionProxy(
|
||||
"baz", "resultAction", null, null);
|
||||
assertEquals(null, baseActionProxy.execute());
|
||||
assertNull(baseActionProxy.execute());
|
||||
assertTrue(SimpleAction.resultCalled);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -113,7 +114,7 @@ public class ChainResultTest extends XWorkTestCase {
|
||||
try {
|
||||
proxy.execute();
|
||||
fail("did not detected repeated chain to an action");
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ package com.opensymphony.xwork2.config.providers;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.UnknownHandler;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
public class SomeUnknownHandler implements UnknownHandler{
|
||||
private ActionConfig actionConfig;
|
||||
private String actionMethodResult;
|
||||
|
||||
public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException {
|
||||
public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException {
|
||||
return actionConfig;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SomeUnknownHandler implements UnknownHandler{
|
||||
}
|
||||
|
||||
public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig,
|
||||
String resultCode) throws XWorkException {
|
||||
String resultCode) throws StrutsException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -19,9 +19,9 @@
|
||||
package com.opensymphony.xwork2.conversion.impl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.test.annotations.Person;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@@ -45,15 +45,15 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
|
||||
|
||||
public void testDateConversionWithEmptyValue() {
|
||||
Object convertedObject = basicConverter.convertValue(new HashMap<String, Object>(), null, null, null, "", Date.class);
|
||||
// we must not get XWorkException as that will caused a conversion error
|
||||
// we must not get StrutsException as that will caused a conversion error
|
||||
assertNull(convertedObject);
|
||||
}
|
||||
|
||||
public void testDateConversionWithInvalidValue() throws Exception {
|
||||
try {
|
||||
basicConverter.convertValue(new HashMap<String, Object>(), null, null, null, "asdsd", Date.class);
|
||||
fail("XWorkException expected - conversion error occurred");
|
||||
} catch (XWorkException e) {
|
||||
fail("StrutsException expected - conversion error occurred");
|
||||
} catch (StrutsException e) {
|
||||
// we MUST get this exception as this is a conversion error
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
|
||||
|
||||
public void testEmptyArrayConversion() throws Exception {
|
||||
Object convertedObject = basicConverter.convertValue(new HashMap<String, Object>(), null, null, null, new Object[]{}, Object[].class);
|
||||
// we must not get XWorkException as that will caused a conversion error
|
||||
// we must not get StrutsException as that will caused a conversion error
|
||||
assertEquals(Object[].class, convertedObject.getClass());
|
||||
Object[] obj = (Object[]) convertedObject;
|
||||
assertEquals(0, obj.length);
|
||||
@@ -127,7 +127,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
|
||||
|
||||
public void testNullArrayConversion() throws Exception {
|
||||
Object convertedObject = basicConverter.convertValue(new HashMap<String, Object>(), null, null, null, null, Object[].class);
|
||||
// we must not get XWorkException as that will caused a conversion error
|
||||
// we must not get StrutsException as that will caused a conversion error
|
||||
assertNull(convertedObject);
|
||||
}
|
||||
|
||||
|
||||
+29
-28
@@ -24,6 +24,7 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.validator.ValidationException;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -44,9 +45,9 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
this.setUpWithExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new XWorkException("test");
|
||||
Exception exception = new StrutsException("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
String result = interceptor.intercept(invocation);
|
||||
assertNotNull(stack.findValue("exception"));
|
||||
assertEquals(stack.findValue("exception"), exception);
|
||||
@@ -61,7 +62,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new ValidationException("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
String result = interceptor.intercept(invocation);
|
||||
assertNotNull(stack.findValue("exception"));
|
||||
assertEquals(stack.findValue("exception"), exception);
|
||||
@@ -73,19 +74,19 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
String result = interceptor.intercept(invocation);
|
||||
assertEquals(result, Action.SUCCESS);
|
||||
assertNull(stack.findValue("exception"));
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatch() throws Exception {
|
||||
public void testThrownExceptionNoMatch() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.intercept(invocation);
|
||||
@@ -95,13 +96,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLogging() throws Exception {
|
||||
public void testThrownExceptionNoMatchLogging() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -112,13 +113,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategory() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategory() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -130,13 +131,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelFatal() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelFatal() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -149,17 +150,17 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
assertEquals("fatal", interceptor.getLogLevel());
|
||||
assertEquals(true, interceptor.isLogEnabled());
|
||||
assertTrue(interceptor.isLogEnabled());
|
||||
assertEquals("showcase.unhandled", interceptor.getLogCategory());
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelError() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelError() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -172,13 +173,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelWarn() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelWarn() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -191,13 +192,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelInfo() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelInfo() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -210,13 +211,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelDebug() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelDebug() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -229,13 +230,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelTrace() throws Exception {
|
||||
public void testThrownExceptionNoMatchLoggingCategoryLevelTrace() {
|
||||
this.setupWithoutExceptionMappings();
|
||||
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -254,7 +255,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
Mock action = new Mock(Action.class);
|
||||
Exception exception = new Exception("test");
|
||||
mockInvocation.expectAndThrow("invoke", exception);
|
||||
mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
|
||||
mockInvocation.matchAndReturn("getAction", action.proxy());
|
||||
|
||||
try {
|
||||
interceptor.setLogEnabled(true);
|
||||
@@ -270,18 +271,18 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
ActionConfig actionConfig = new ActionConfig.Builder("", "", "").build();
|
||||
Mock actionProxy = new Mock(ActionProxy.class);
|
||||
actionProxy.expectAndReturn("getConfig", actionConfig);
|
||||
mockInvocation.expectAndReturn("getProxy", ((ActionProxy) actionProxy.proxy()));
|
||||
mockInvocation.expectAndReturn("getProxy", actionProxy.proxy());
|
||||
invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
}
|
||||
|
||||
private void setUpWithExceptionMappings() {
|
||||
ActionConfig actionConfig = new ActionConfig.Builder("", "", "")
|
||||
.addExceptionMapping(new ExceptionMappingConfig.Builder("xwork", "com.opensymphony.xwork2.XWorkException", "spooky").build())
|
||||
.addExceptionMapping(new ExceptionMappingConfig.Builder("xwork", "org.apache.struts2.StrutsException", "spooky").build())
|
||||
.addExceptionMapping(new ExceptionMappingConfig.Builder("throwable", "java.lang.Throwable", "throwable").build())
|
||||
.build();
|
||||
Mock actionProxy = new Mock(ActionProxy.class);
|
||||
actionProxy.expectAndReturn("getConfig", actionConfig);
|
||||
mockInvocation.expectAndReturn("getProxy", ((ActionProxy) actionProxy.proxy()));
|
||||
mockInvocation.expectAndReturn("getProxy", actionProxy.proxy());
|
||||
|
||||
invocation = (ActionInvocation) mockInvocation.proxy();
|
||||
}
|
||||
@@ -292,7 +293,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
|
||||
stack = ActionContext.getContext().getValueStack();
|
||||
mockInvocation = new Mock(ActionInvocation.class);
|
||||
mockInvocation.expectAndReturn("getStack", stack);
|
||||
mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap<String, Object>()));
|
||||
mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap<>()));
|
||||
interceptor = new ExceptionMappingInterceptor();
|
||||
interceptor.init();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.opensymphony.xwork2.ognl;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
@@ -33,6 +32,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
|
||||
import java.beans.IntrospectionException;
|
||||
import ognl.*;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DateFormat;
|
||||
@@ -1537,7 +1537,7 @@ public class OgnlUtilTest extends XWorkTestCase {
|
||||
try {
|
||||
this.add(clazz.newInstance());
|
||||
} catch (Exception e) {
|
||||
throw new XWorkException(e);
|
||||
throw new StrutsException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.apache.logging.log4j.core.LogEvent;
|
||||
import org.apache.logging.log4j.core.Logger;
|
||||
import org.apache.logging.log4j.core.appender.AbstractAppender;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.config.DefaultPropertiesProvider;
|
||||
|
||||
|
||||
@@ -774,7 +775,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
||||
try {
|
||||
vs.setValue("count2", "a", true);
|
||||
fail("Expected an exception for mismatched getter and setter");
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
//expected
|
||||
}
|
||||
}
|
||||
@@ -792,7 +793,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
||||
try {
|
||||
vs.setValue("count2", "a", true);
|
||||
fail("Expected an exception for mismatched getter and setter");
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
//expected
|
||||
}
|
||||
}
|
||||
@@ -874,7 +875,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
||||
try {
|
||||
stack.setValue("bean", "foobar", true);
|
||||
fail("Should have thrown a type conversion exception");
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
@@ -1172,7 +1173,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
|
||||
try {
|
||||
stack.setValue("count", "a", true);
|
||||
fail("Should have thrown a type conversion exception");
|
||||
} catch (XWorkException e) {
|
||||
} catch (StrutsException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,6 @@ import com.opensymphony.xwork2.FileManagerFactory;
|
||||
import com.opensymphony.xwork2.SimpleAction;
|
||||
import com.opensymphony.xwork2.StubValueStack;
|
||||
import com.opensymphony.xwork2.TestBean;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.test.DataAware2;
|
||||
@@ -34,6 +33,7 @@ import com.opensymphony.xwork2.test.SimpleAction3;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.fs.DefaultFileManager;
|
||||
import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -111,7 +111,7 @@ public class DefaultActionValidatorManagerTest extends XWorkTestCase {
|
||||
C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("com/opensymphony/xwork2/TestBean-badtest-validation.xml")),
|
||||
new ConfigurationException());
|
||||
List validatorList = actionValidatorManager.getValidators(TestBean.class, "badtest");
|
||||
} catch (XWorkException ex) {
|
||||
} catch (StrutsException ex) {
|
||||
pass = true;
|
||||
}
|
||||
mockValidatorFileParser.verify();
|
||||
|
||||
+5
-5
@@ -20,10 +20,10 @@ package com.opensymphony.xwork2.validator;
|
||||
|
||||
import com.mockobjects.dynamic.C;
|
||||
import com.mockobjects.dynamic.Mock;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.validator.validators.*;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@@ -123,7 +123,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
|
||||
boolean pass = false;
|
||||
try {
|
||||
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName3);
|
||||
} catch (XWorkException ex) {
|
||||
} catch (StrutsException ex) {
|
||||
assertTrue("Wrong line number", 24 == ex.getLocation().getLineNumber());
|
||||
pass = true;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
|
||||
boolean pass = false;
|
||||
try {
|
||||
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName4);
|
||||
} catch (XWorkException ex) {
|
||||
} catch (StrutsException ex) {
|
||||
assertTrue("Wrong line number: " + ex.getLocation(), 34 == ex.getLocation().getLineNumber());
|
||||
pass = true;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
|
||||
boolean pass = false;
|
||||
try {
|
||||
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileNameFail);
|
||||
} catch (XWorkException ex) {
|
||||
} catch (StrutsException ex) {
|
||||
assertTrue("Wrong line number: " + ex.getLocation(), 28 == ex.getLocation().getLineNumber());
|
||||
pass = true;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
|
||||
boolean pass = false;
|
||||
try {
|
||||
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName5);
|
||||
} catch (XWorkException ex) {
|
||||
} catch (StrutsException ex) {
|
||||
assertTrue("Wrong line number", 24 == ex.getLocation().getLineNumber());
|
||||
pass = true;
|
||||
}
|
||||
|
||||
+15
-14
@@ -16,33 +16,34 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
package org.apache.struts2;
|
||||
|
||||
import com.opensymphony.xwork2.XWorkTestCase;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
|
||||
public class XWorkExceptionTest extends XWorkTestCase {
|
||||
public class StrutsExceptionTest extends XWorkTestCase {
|
||||
|
||||
public void testUnknown() throws Exception {
|
||||
XWorkException e = new XWorkException("testXXX", this);
|
||||
public void testUnknown() {
|
||||
StrutsException e = new StrutsException("testXXX", this);
|
||||
assertEquals(Location.UNKNOWN, e.getLocation());
|
||||
}
|
||||
|
||||
public void testThrowable() {
|
||||
XWorkException e = new XWorkException("testThrowable", new IllegalArgumentException("Arg is null"));
|
||||
assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
|
||||
StrutsException e = new StrutsException("testThrowable", new IllegalArgumentException("Arg is null"));
|
||||
assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
|
||||
String s = e.getLocation().toString();
|
||||
assertTrue(s.contains("Method: testThrowable"));
|
||||
}
|
||||
|
||||
public void testCauseAndTarget() {
|
||||
XWorkException e = new XWorkException(new IllegalArgumentException("Arg is null"), this);
|
||||
assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
|
||||
StrutsException e = new StrutsException(new IllegalArgumentException("Arg is null"), this);
|
||||
assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
|
||||
String s = e.getLocation().toString();
|
||||
assertTrue(s.contains("Method: testCauseAndTarget"));
|
||||
}
|
||||
|
||||
public void testDefaultConstructor() {
|
||||
XWorkException e = new XWorkException();
|
||||
StrutsException e = new StrutsException();
|
||||
|
||||
assertNull(e.getCause());
|
||||
assertNull(e.getMessage());
|
||||
@@ -52,7 +53,7 @@ public class XWorkExceptionTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testMessageOnly() {
|
||||
XWorkException e = new XWorkException("Hello World");
|
||||
StrutsException e = new StrutsException("Hello World");
|
||||
|
||||
assertNull(e.getCause());
|
||||
assertEquals("Hello World", e.getMessage());
|
||||
@@ -60,22 +61,22 @@ public class XWorkExceptionTest extends XWorkTestCase {
|
||||
}
|
||||
|
||||
public void testCauseOnly() {
|
||||
XWorkException e = new XWorkException(new IllegalArgumentException("Arg is null"));
|
||||
StrutsException e = new StrutsException(new IllegalArgumentException("Arg is null"));
|
||||
|
||||
assertNotNull(e.getCause());
|
||||
assertNotNull(e.getLocation());
|
||||
assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
|
||||
assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
|
||||
String s = e.getLocation().toString();
|
||||
assertTrue(s.contains("Method: testCauseOnly"));
|
||||
assertTrue(e.toString().contains("Arg is null"));
|
||||
}
|
||||
|
||||
public void testCauseOnlyNoMessage() {
|
||||
XWorkException e = new XWorkException(new IllegalArgumentException());
|
||||
StrutsException e = new StrutsException(new IllegalArgumentException());
|
||||
|
||||
assertNotNull(e.getCause());
|
||||
assertNotNull(e.getLocation());
|
||||
assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
|
||||
assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
|
||||
String s = e.getLocation().toString();
|
||||
assertTrue(s.contains("Method: testCauseOnly"));
|
||||
assertTrue(e.toString().contains("Method: testCauseOnly"));
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
|
||||
<global-exception-mappings>
|
||||
<exception-mapping exception="java.lang.RuntimeException" result="runForDeeHillz"/>
|
||||
<exception-mapping exception="com.opensymphony.xwork2.XworkException" result="xworkNaughty"/>
|
||||
<exception-mapping exception="com.opensymphony.xwork2.StrutsException" result="xworkNaughty"/>
|
||||
</global-exception-mappings>
|
||||
|
||||
<action name="Bar" class="com.opensymphony.xwork2.SimpleAction">
|
||||
|
||||
+6
-5
@@ -30,6 +30,7 @@ import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -72,7 +73,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
private ConventionsService conventionsService;
|
||||
private String nameSeparator;
|
||||
|
||||
protected Set<String> allowedMethods = new HashSet<>();
|
||||
protected Set<String> allowedMethods;
|
||||
|
||||
/**
|
||||
* Constructs the unknown handler.
|
||||
@@ -114,7 +115,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
}
|
||||
|
||||
public ActionConfig handleUnknownAction(String namespace, String actionName)
|
||||
throws XWorkException {
|
||||
throws StrutsException {
|
||||
// Strip the namespace if it is just a slash
|
||||
if (namespace == null || "/".equals(namespace)) {
|
||||
namespace = "";
|
||||
@@ -217,7 +218,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
params.put(resultTypeConfig.getDefaultResultParam(), path);
|
||||
|
||||
PackageConfig pkg = configuration.getPackageConfig(defaultParentPackageName);
|
||||
List<InterceptorMapping> interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.<String, String>emptyMap(), null, objectFactory);
|
||||
List<InterceptorMapping> interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.emptyMap(), null, objectFactory);
|
||||
ResultConfig config = new ResultConfig.Builder(Action.SUCCESS, resultTypeConfig.getClassName()).
|
||||
addParams(params).build();
|
||||
results.put(Action.SUCCESS, config);
|
||||
@@ -265,7 +266,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
}
|
||||
|
||||
public Result handleUnknownResult(ActionContext actionContext, String actionName,
|
||||
ActionConfig actionConfig, String resultCode) throws XWorkException {
|
||||
ActionConfig actionConfig, String resultCode) throws StrutsException {
|
||||
|
||||
PackageConfig pkg = configuration.getPackageConfig(actionConfig.getPackageName());
|
||||
String ns = pkg.getNamespace();
|
||||
@@ -351,7 +352,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
|
||||
try {
|
||||
return objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
|
||||
} catch (Exception e) {
|
||||
throw new XWorkException("Unable to build convention result", e, resultConfig);
|
||||
throw new StrutsException("Unable to build convention result", e, resultConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -21,13 +21,13 @@ package org.apache.struts2.convention;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.FileManager;
|
||||
import com.opensymphony.xwork2.FileManagerFactory;
|
||||
import com.opensymphony.xwork2.XWorkException;
|
||||
import com.opensymphony.xwork2.util.finder.ClassFinder;
|
||||
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
|
||||
import com.opensymphony.xwork2.util.finder.Test;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
@@ -445,10 +445,10 @@ public class DefaultClassFinder implements ClassFinder {
|
||||
classReader.accept(new InfoBuildingVisitor(this), ClassReader.SKIP_DEBUG);
|
||||
}
|
||||
} else {
|
||||
throw new XWorkException("Could not load " + className);
|
||||
throw new StrutsException("Could not load " + className);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new XWorkException("Could not load " + className, e);
|
||||
throw new StrutsException("Could not load " + className, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user