From 2453cdb1f57a9fe7d5743b69848630be80d702c4 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sat, 21 Mar 2020 09:26:29 -0600 Subject: [PATCH 01/18] Switchs StrutsException by TypeConversionException in DateConverter, DateConverterTest added for unit testing --- .../xwork2/conversion/impl/DateConverter.java | 5 +- .../conversion/impl/DateConverterTest.java | 90 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index 96392058b..04c5c392f 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -18,6 +18,7 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; import org.apache.struts2.StrutsException; import java.lang.reflect.Constructor; @@ -90,11 +91,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 StrutsException("Couldn't create class " + toType + " using default (long) constructor", e); + throw new TypeConversionException("Couldn't create class " + toType + " using default (long) constructor", e); } } } catch (ParseException e) { - throw new StrutsException("Could not parse date", e); + throw new TypeConversionException("Could not parse date", e); } } else if (Date.class.isAssignableFrom(value.getClass())) { result = (Date) value; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java new file mode 100644 index 000000000..b69461591 --- /dev/null +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -0,0 +1,90 @@ +package com.opensymphony.xwork2.conversion.impl; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.StrutsInternalTestCase; + +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +public class DateConverterTest extends StrutsInternalTestCase { + + private final static String TIME_00_59_10 = "00:59:10"; + private final static String TIMESTAMP_STR = "2020-03-20 00:59:10"; + private final static String DATE_STR = "2020-03-20"; + private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00 CST 2020"; + private final static String INVALID_DATE = "99/99/2010"; + private final static String MESSAGE_PARSE_ERROR = "Could not parse date"; + private final static String MESSAGE_DEFAULT_CONSTRUCTOR_ERROR = "Couldn't create class null using default (long) constructor"; + + public void testSqlTimeType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, TIME_00_59_10, Time.class); + assertEquals(Time.valueOf(TIME_00_59_10), value); + + } + + public void testSqlTimestampType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, TIMESTAMP_STR, Timestamp.class); + assertEquals(Timestamp.valueOf(TIMESTAMP_STR), value); + + } + + public void testDateType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, DATE_STR, Date.class); + assertEquals(DATE_CONVERTED, ((Date)value).toString()); + + } + + public void testTypeConversionExceptionWhenParseError(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + try{ + Object value = converter.convertValue(context, null, null, null, INVALID_DATE, Date.class); + fail("TypeConversionException expected - Conversion error occurred"); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertEquals(MESSAGE_PARSE_ERROR, ex.getMessage()); + } + + } + + public void testTypeConversionExceptionWhenUsingLongConstructor(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + try{ + Object value = converter.convertValue(context, null, null, null, "01-10-10", null); + fail("TypeConversionException expected - Error using default (long) constructor"); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertEquals(MESSAGE_DEFAULT_CONSTRUCTOR_ERROR, ex.getMessage()); + } + + } + +} From ec157c038a1c75390315f3b26df67e7339220167 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 22 Mar 2020 15:32:01 -0600 Subject: [PATCH 02/18] Removes unnecessary import StrutsException --- .../com/opensymphony/xwork2/conversion/impl/DateConverter.java | 1 - .../opensymphony/xwork2/conversion/impl/DateConverterTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index 04c5c392f..b1583ee20 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -19,7 +19,6 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.conversion.TypeConversionException; -import org.apache.struts2.StrutsException; import java.lang.reflect.Constructor; import java.lang.reflect.Member; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index b69461591..9246cc8e5 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -2,7 +2,6 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.conversion.TypeConversionException; -import org.apache.commons.lang3.StringUtils; import org.apache.struts2.StrutsInternalTestCase; import java.sql.Time; From 686e069d6d72c234d003866360cebca21e79b819 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 22 Mar 2020 15:37:58 -0600 Subject: [PATCH 03/18] Switches StrutsException by TypeConversionException in NumberConverter; The respective unit tests are added to the NumberConverterTest --- .../conversion/impl/NumberConverter.java | 18 +- .../conversion/impl/NumberConverterTest.java | 164 +++++++++++++++++- 2 files changed, 170 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java index 92c5e7d2f..d4514e1ec 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java @@ -18,9 +18,9 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; 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 StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePos.getIndex()); } else { if (!isInRange(number, stringValue, toType)) - throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); } if (!isInRange(number, stringValue, Double.class)) { - throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); } if (!isInRange(number, stringValue, Float.class)) { - throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); } if (number != null) { diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java index 698afd8d8..21dd1b01a 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java @@ -21,15 +21,25 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.SimpleFooAction; import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.conversion.TypeConversionException; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.HashMap; import java.util.Locale; import java.util.Map; public class NumberConverterTest extends XWorkTestCase { + + private final static String FLOAT_OUT_OF_RANGE = "3.5028235E38"; + private final static String DOUBLE_OUT_OF_RANGE = "1.7976931348623157E309"; + private final static String INTEGER_OUT_OF_RANGE = "2147483648"; + private final static String MSG_OUT_OF_RANGE_CASTING = "Overflow or underflow casting"; + private final static String MSG_OUT_OF_RANGE_CONVERTING = "Overflow or underflow converting"; + private final static String MSG_UNPARSEABLE_NUMBER = "Unparseable number"; + private final static String MSG_TEST_FAILS_OUT_OF_RANGE = "TypeConversionException expected when OUT OF RANGE"; + private final static String MSG_TEST_FAILS_UNPARSEABLE_NUMBER = "TypeConversionException expected when UNPARSEABLE NUMBER"; + private final static Locale LOCALE_MEXICO = new Locale("es_MX", "MX"); public void testStringToNumberConversionPL() throws Exception { // given @@ -169,6 +179,154 @@ public class NumberConverterTest extends XWorkTestCase { // then assertEquals(1234.4F, value); } - - + + public void testExceptionWhenPrimitiveIsOutOfRange(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, INTEGER_OUT_OF_RANGE, int.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); + } + + } + + public void testExceptionWhenANotPrimitiveIsUnparsable(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1.2"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenANotPrimitiveIsOutOfRange(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "129"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); + } + + } + + public void testExceptionWhenUnparseableInConvertToBigDecimal(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, BigDecimal.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenUnparseableInConvertToDouble(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Double.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenOutOfRangeInConvertToDouble(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, DOUBLE_OUT_OF_RANGE, Double.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); + } + + } + + public void testExceptionWhenOutOfRangeInConvertToFloat(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, FLOAT_OUT_OF_RANGE, Float.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); + } + + } + + public void testExceptionWhenUnparseableInConvertToFloat(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Float.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + } From cd9cc534426ecd2b45ac11c54f14c17a343b49a0 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 29 Mar 2020 14:27:01 -0600 Subject: [PATCH 04/18] Switches StrutsException by TypeConversionException in XWorkBasicConverter; necessary Tests added to XWorkBasicConverterTest --- .../conversion/impl/XWorkBasicConverter.java | 16 ++-- .../impl/XWorkBasicConverterTest.java | 89 +++++++++++++++++++ 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java index 23129a64c..5d4de6c2f 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java @@ -18,11 +18,11 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; 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 StrutsException("Cannot create type " + toType + " from value " + value); + throw new TypeConversionException("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 StrutsException(e.getLocalizedMessage(), e); + throw new TypeConversionException(e.getLocalizedMessage(), e); } } return clazz; @@ -179,7 +179,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter { private Object doConvertToCollection(Map context, Object o, Member member, String prop, Object value, Class toType) { TypeConverter converter = container.getInstance(CollectionConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object o, Member member, String prop, Object value, Class toType) { TypeConverter converter = container.getInstance(ArrayConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value, Class toType) { TypeConverter converter = container.getInstance(DateConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value, Class toType) { TypeConverter converter = container.getInstance(NumberConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value) { TypeConverter converter = container.getInstance(StringConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ StrutsConstants.STRUTS_CONVERTER_STRING); } return converter.convertValue(context, null, null, null, value, null); } diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java index e171261c2..6b7269c28 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java @@ -20,8 +20,12 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.conversion.TypeConversionException; +import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.test.annotations.Person; import org.apache.struts2.StrutsException; +import org.mockito.Mock; +import org.mockito.Mockito; import java.math.BigDecimal; import java.math.BigInteger; @@ -37,6 +41,9 @@ import java.util.*; public class XWorkBasicConverterTest extends XWorkTestCase { private XWorkBasicConverter basicConverter; + private Container mockedContainer; + private final static String MSG_EXCEPTION_EXPECTED = "TypeConversionException expected"; + private final static String MSG_TYPE_CONVERTER_EXCEPTION = "TypeConverter with name"; // TODO: test for every possible conversion // take into account of empty string @@ -294,11 +301,93 @@ public class XWorkBasicConverterTest extends XWorkTestCase { Class toType = String.class; basicConverter.convertValue(context, value, null, s, value, toType); } + + public void testExceptionWhenCantCreateTypeFromValue() { + try{ + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, 4, Date.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith("Cannot create type")); + } + + } + + public void testExceptionInDoConvertToClass() { + try{ + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", Class.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + } + } + + public void testExceptionInDoConvertToCollection() { + try{ + Mockito.when(mockedContainer.getInstanceNames(CollectionConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", ArrayList.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToArray() { + try{ + int[] arrayInt = new int[1]; + Mockito.when(mockedContainer.getInstanceNames(ArrayConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", arrayInt.getClass()); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToDate() { + try{ + Mockito.when(mockedContainer.getInstanceNames(DateConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", Date.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToNumber() { + try{ + Mockito.when(mockedContainer.getInstanceNames(NumberConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", int.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToString() { + try{ + Mockito.when(mockedContainer.getInstanceNames(StringConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, 1, String.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } @Override protected void setUp() throws Exception { super.setUp(); basicConverter = container.getInstance(XWorkBasicConverter.class); + mockedContainer = Mockito.mock(Container.class); } @Override From 03a609cf6721ee3fbb595e2558475b33dea5b6ea Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sat, 21 Mar 2020 09:26:29 -0600 Subject: [PATCH 05/18] Switchs StrutsException by TypeConversionException in DateConverter, DateConverterTest added for unit testing --- .../xwork2/conversion/impl/DateConverter.java | 5 +- .../conversion/impl/DateConverterTest.java | 90 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index 96392058b..04c5c392f 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -18,6 +18,7 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; import org.apache.struts2.StrutsException; import java.lang.reflect.Constructor; @@ -90,11 +91,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 StrutsException("Couldn't create class " + toType + " using default (long) constructor", e); + throw new TypeConversionException("Couldn't create class " + toType + " using default (long) constructor", e); } } } catch (ParseException e) { - throw new StrutsException("Could not parse date", e); + throw new TypeConversionException("Could not parse date", e); } } else if (Date.class.isAssignableFrom(value.getClass())) { result = (Date) value; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java new file mode 100644 index 000000000..b69461591 --- /dev/null +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -0,0 +1,90 @@ +package com.opensymphony.xwork2.conversion.impl; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.StrutsInternalTestCase; + +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +public class DateConverterTest extends StrutsInternalTestCase { + + private final static String TIME_00_59_10 = "00:59:10"; + private final static String TIMESTAMP_STR = "2020-03-20 00:59:10"; + private final static String DATE_STR = "2020-03-20"; + private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00 CST 2020"; + private final static String INVALID_DATE = "99/99/2010"; + private final static String MESSAGE_PARSE_ERROR = "Could not parse date"; + private final static String MESSAGE_DEFAULT_CONSTRUCTOR_ERROR = "Couldn't create class null using default (long) constructor"; + + public void testSqlTimeType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, TIME_00_59_10, Time.class); + assertEquals(Time.valueOf(TIME_00_59_10), value); + + } + + public void testSqlTimestampType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, TIMESTAMP_STR, Timestamp.class); + assertEquals(Timestamp.valueOf(TIMESTAMP_STR), value); + + } + + public void testDateType(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + Object value = converter.convertValue(context, null, null, null, DATE_STR, Date.class); + assertEquals(DATE_CONVERTED, ((Date)value).toString()); + + } + + public void testTypeConversionExceptionWhenParseError(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + try{ + Object value = converter.convertValue(context, null, null, null, INVALID_DATE, Date.class); + fail("TypeConversionException expected - Conversion error occurred"); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertEquals(MESSAGE_PARSE_ERROR, ex.getMessage()); + } + + } + + public void testTypeConversionExceptionWhenUsingLongConstructor(){ + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + try{ + Object value = converter.convertValue(context, null, null, null, "01-10-10", null); + fail("TypeConversionException expected - Error using default (long) constructor"); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertEquals(MESSAGE_DEFAULT_CONSTRUCTOR_ERROR, ex.getMessage()); + } + + } + +} From a11291dc58a185f5ee13e9b796aa8a2a441571ea Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 22 Mar 2020 15:32:01 -0600 Subject: [PATCH 06/18] Removes unnecessary import StrutsException --- .../com/opensymphony/xwork2/conversion/impl/DateConverter.java | 1 - .../opensymphony/xwork2/conversion/impl/DateConverterTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index 04c5c392f..b1583ee20 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -19,7 +19,6 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.conversion.TypeConversionException; -import org.apache.struts2.StrutsException; import java.lang.reflect.Constructor; import java.lang.reflect.Member; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index b69461591..9246cc8e5 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -2,7 +2,6 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.conversion.TypeConversionException; -import org.apache.commons.lang3.StringUtils; import org.apache.struts2.StrutsInternalTestCase; import java.sql.Time; From b6586c7e38b8147987043b06151e8cdf300bc4bc Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 22 Mar 2020 15:37:58 -0600 Subject: [PATCH 07/18] Switches StrutsException by TypeConversionException in NumberConverter; The respective unit tests are added to the NumberConverterTest --- .../conversion/impl/NumberConverter.java | 18 +- .../conversion/impl/NumberConverterTest.java | 164 +++++++++++++++++- 2 files changed, 170 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java index 92c5e7d2f..d4514e1ec 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java @@ -18,9 +18,9 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; 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 StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePos.getIndex()); } else { if (!isInRange(number, stringValue, toType)) - throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); } if (!isInRange(number, stringValue, Double.class)) { - throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("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 StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); + throw new TypeConversionException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex()); } if (!isInRange(number, stringValue, Float.class)) { - throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); + throw new TypeConversionException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName()); } if (number != null) { diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java index 698afd8d8..21dd1b01a 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java @@ -21,15 +21,25 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.SimpleFooAction; import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.conversion.TypeConversionException; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.HashMap; import java.util.Locale; import java.util.Map; public class NumberConverterTest extends XWorkTestCase { + + private final static String FLOAT_OUT_OF_RANGE = "3.5028235E38"; + private final static String DOUBLE_OUT_OF_RANGE = "1.7976931348623157E309"; + private final static String INTEGER_OUT_OF_RANGE = "2147483648"; + private final static String MSG_OUT_OF_RANGE_CASTING = "Overflow or underflow casting"; + private final static String MSG_OUT_OF_RANGE_CONVERTING = "Overflow or underflow converting"; + private final static String MSG_UNPARSEABLE_NUMBER = "Unparseable number"; + private final static String MSG_TEST_FAILS_OUT_OF_RANGE = "TypeConversionException expected when OUT OF RANGE"; + private final static String MSG_TEST_FAILS_UNPARSEABLE_NUMBER = "TypeConversionException expected when UNPARSEABLE NUMBER"; + private final static Locale LOCALE_MEXICO = new Locale("es_MX", "MX"); public void testStringToNumberConversionPL() throws Exception { // given @@ -169,6 +179,154 @@ public class NumberConverterTest extends XWorkTestCase { // then assertEquals(1234.4F, value); } - - + + public void testExceptionWhenPrimitiveIsOutOfRange(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, INTEGER_OUT_OF_RANGE, int.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); + } + + } + + public void testExceptionWhenANotPrimitiveIsUnparsable(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1.2"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenANotPrimitiveIsOutOfRange(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "129"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); + } + + } + + public void testExceptionWhenUnparseableInConvertToBigDecimal(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, BigDecimal.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenUnparseableInConvertToDouble(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Double.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + + public void testExceptionWhenOutOfRangeInConvertToDouble(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, DOUBLE_OUT_OF_RANGE, Double.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); + } + + } + + public void testExceptionWhenOutOfRangeInConvertToFloat(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, FLOAT_OUT_OF_RANGE, Float.class); + fail(MSG_TEST_FAILS_OUT_OF_RANGE); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); + } + + } + + public void testExceptionWhenUnparseableInConvertToFloat(){ + // given + NumberConverter converter = new NumberConverter(); + Map context = new HashMap<>(); + String strValue = "1-23"; + context.put(ActionContext.LOCALE, LOCALE_MEXICO); + + // when + try{ + Object value = converter.convertValue(context, null, null, null, strValue, Float.class); + fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); + }catch(Exception ex){ + // then + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); + } + + } + } From a9802a61c7834d947a8623b76b4b31cafad512f9 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 29 Mar 2020 14:27:01 -0600 Subject: [PATCH 08/18] Switches StrutsException by TypeConversionException in XWorkBasicConverter; necessary Tests added to XWorkBasicConverterTest --- .../conversion/impl/XWorkBasicConverter.java | 16 ++-- .../impl/XWorkBasicConverterTest.java | 89 +++++++++++++++++++ 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java index 23129a64c..5d4de6c2f 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java @@ -18,11 +18,11 @@ */ package com.opensymphony.xwork2.conversion.impl; +import com.opensymphony.xwork2.conversion.TypeConversionException; 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 StrutsException("Cannot create type " + toType + " from value " + value); + throw new TypeConversionException("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 StrutsException(e.getLocalizedMessage(), e); + throw new TypeConversionException(e.getLocalizedMessage(), e); } } return clazz; @@ -179,7 +179,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter { private Object doConvertToCollection(Map context, Object o, Member member, String prop, Object value, Class toType) { TypeConverter converter = container.getInstance(CollectionConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object o, Member member, String prop, Object value, Class toType) { TypeConverter converter = container.getInstance(ArrayConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value, Class toType) { TypeConverter converter = container.getInstance(DateConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value, Class toType) { TypeConverter converter = container.getInstance(NumberConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ 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 context, Object value) { TypeConverter converter = container.getInstance(StringConverter.class); if (converter == null) { - throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING); + throw new TypeConversionException("TypeConverter with name [#0] must be registered first! Converter: "+ StrutsConstants.STRUTS_CONVERTER_STRING); } return converter.convertValue(context, null, null, null, value, null); } diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java index e171261c2..6b7269c28 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java @@ -20,8 +20,12 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.conversion.TypeConversionException; +import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.test.annotations.Person; import org.apache.struts2.StrutsException; +import org.mockito.Mock; +import org.mockito.Mockito; import java.math.BigDecimal; import java.math.BigInteger; @@ -37,6 +41,9 @@ import java.util.*; public class XWorkBasicConverterTest extends XWorkTestCase { private XWorkBasicConverter basicConverter; + private Container mockedContainer; + private final static String MSG_EXCEPTION_EXPECTED = "TypeConversionException expected"; + private final static String MSG_TYPE_CONVERTER_EXCEPTION = "TypeConverter with name"; // TODO: test for every possible conversion // take into account of empty string @@ -294,11 +301,93 @@ public class XWorkBasicConverterTest extends XWorkTestCase { Class toType = String.class; basicConverter.convertValue(context, value, null, s, value, toType); } + + public void testExceptionWhenCantCreateTypeFromValue() { + try{ + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, 4, Date.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith("Cannot create type")); + } + + } + + public void testExceptionInDoConvertToClass() { + try{ + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", Class.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + } + } + + public void testExceptionInDoConvertToCollection() { + try{ + Mockito.when(mockedContainer.getInstanceNames(CollectionConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", ArrayList.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToArray() { + try{ + int[] arrayInt = new int[1]; + Mockito.when(mockedContainer.getInstanceNames(ArrayConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", arrayInt.getClass()); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToDate() { + try{ + Mockito.when(mockedContainer.getInstanceNames(DateConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", Date.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToNumber() { + try{ + Mockito.when(mockedContainer.getInstanceNames(NumberConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "Foo", int.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } + + public void testExceptionInDoConvertToString() { + try{ + Mockito.when(mockedContainer.getInstanceNames(StringConverter.class)).thenReturn(null); + basicConverter.setContainer(mockedContainer); + Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, 1, String.class); + fail(MSG_EXCEPTION_EXPECTED); + }catch(Exception ex){ + assertEquals(TypeConversionException.class, ex.getClass()); + assertTrue(ex.getMessage().startsWith(MSG_TYPE_CONVERTER_EXCEPTION)); + } + } @Override protected void setUp() throws Exception { super.setUp(); basicConverter = container.getInstance(XWorkBasicConverter.class); + mockedContainer = Mockito.mock(Container.class); } @Override From 1ef2985ea712fe584de5dc5a1338ba12ea277878 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 29 Mar 2020 18:31:49 -0600 Subject: [PATCH 09/18] Corrects formatting defects --- .../conversion/impl/DateConverterTest.java | 49 +++++++--------- .../conversion/impl/NumberConverterTest.java | 58 ++++++++----------- .../impl/XWorkBasicConverterTest.java | 4 +- 3 files changed, 48 insertions(+), 63 deletions(-) diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index 9246cc8e5..3cbe0240c 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -21,7 +21,7 @@ public class DateConverterTest extends StrutsInternalTestCase { private final static String MESSAGE_PARSE_ERROR = "Could not parse date"; private final static String MESSAGE_DEFAULT_CONSTRUCTOR_ERROR = "Couldn't create class null using default (long) constructor"; - public void testSqlTimeType(){ + public void testSqlTimeType() { DateConverter converter = new DateConverter(); Map context = new HashMap<>(); @@ -29,10 +29,9 @@ public class DateConverterTest extends StrutsInternalTestCase { Object value = converter.convertValue(context, null, null, null, TIME_00_59_10, Time.class); assertEquals(Time.valueOf(TIME_00_59_10), value); - } - public void testSqlTimestampType(){ + public void testSqlTimestampType() { DateConverter converter = new DateConverter(); Map context = new HashMap<>(); @@ -40,50 +39,46 @@ public class DateConverterTest extends StrutsInternalTestCase { Object value = converter.convertValue(context, null, null, null, TIMESTAMP_STR, Timestamp.class); assertEquals(Timestamp.valueOf(TIMESTAMP_STR), value); - } - public void testDateType(){ + public void testDateType() { DateConverter converter = new DateConverter(); Map context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); Object value = converter.convertValue(context, null, null, null, DATE_STR, Date.class); - assertEquals(DATE_CONVERTED, ((Date)value).toString()); - + assertEquals(DATE_CONVERTED, ((Date) value).toString()); } - - public void testTypeConversionExceptionWhenParseError(){ - DateConverter converter = new DateConverter(); - Map context = new HashMap<>(); - context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); - - try{ - Object value = converter.convertValue(context, null, null, null, INVALID_DATE, Date.class); - fail("TypeConversionException expected - Conversion error occurred"); - }catch(Exception ex){ - assertEquals(TypeConversionException.class, ex.getClass()); - assertEquals(MESSAGE_PARSE_ERROR, ex.getMessage()); - } - - } - - public void testTypeConversionExceptionWhenUsingLongConstructor(){ + public void testTypeConversionExceptionWhenParseError() { DateConverter converter = new DateConverter(); Map context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); - try{ + try { + Object value = converter.convertValue(context, null, null, null, INVALID_DATE, Date.class); + fail("TypeConversionException expected - Conversion error occurred"); + } catch (Exception ex) { + assertEquals(TypeConversionException.class, ex.getClass()); + assertEquals(MESSAGE_PARSE_ERROR, ex.getMessage()); + } + } + + public void testTypeConversionExceptionWhenUsingLongConstructor() { + DateConverter converter = new DateConverter(); + + Map context = new HashMap<>(); + context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + + try { Object value = converter.convertValue(context, null, null, null, "01-10-10", null); fail("TypeConversionException expected - Error using default (long) constructor"); - }catch(Exception ex){ + } catch (Exception ex) { assertEquals(TypeConversionException.class, ex.getClass()); assertEquals(MESSAGE_DEFAULT_CONSTRUCTOR_ERROR, ex.getMessage()); } - } } diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java index 21dd1b01a..8b995dc09 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java @@ -180,25 +180,24 @@ public class NumberConverterTest extends XWorkTestCase { assertEquals(1234.4F, value); } - public void testExceptionWhenPrimitiveIsOutOfRange(){ + public void testExceptionWhenPrimitiveIsOutOfRange() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, INTEGER_OUT_OF_RANGE, int.class); fail(MSG_TEST_FAILS_OUT_OF_RANGE); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); } - } - public void testExceptionWhenANotPrimitiveIsUnparsable(){ + public void testExceptionWhenANotPrimitiveIsUnparsable() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); @@ -206,18 +205,17 @@ public class NumberConverterTest extends XWorkTestCase { context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); } - } - public void testExceptionWhenANotPrimitiveIsOutOfRange(){ + public void testExceptionWhenANotPrimitiveIsOutOfRange() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); @@ -225,18 +223,17 @@ public class NumberConverterTest extends XWorkTestCase { context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, strValue, Byte.class); fail(MSG_TEST_FAILS_OUT_OF_RANGE); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CASTING)); } - } - public void testExceptionWhenUnparseableInConvertToBigDecimal(){ + public void testExceptionWhenUnparseableInConvertToBigDecimal() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); @@ -244,18 +241,17 @@ public class NumberConverterTest extends XWorkTestCase { context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, strValue, BigDecimal.class); fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); } - } - public void testExceptionWhenUnparseableInConvertToDouble(){ + public void testExceptionWhenUnparseableInConvertToDouble() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); @@ -263,54 +259,51 @@ public class NumberConverterTest extends XWorkTestCase { context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, strValue, Double.class); fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); } - } - public void testExceptionWhenOutOfRangeInConvertToDouble(){ + public void testExceptionWhenOutOfRangeInConvertToDouble() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, DOUBLE_OUT_OF_RANGE, Double.class); fail(MSG_TEST_FAILS_OUT_OF_RANGE); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); } - } - public void testExceptionWhenOutOfRangeInConvertToFloat(){ + public void testExceptionWhenOutOfRangeInConvertToFloat() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); context.put(ActionContext.LOCALE, LOCALE_MEXICO); - + // when - try{ + try { Object value = converter.convertValue(context, null, null, null, FLOAT_OUT_OF_RANGE, Float.class); fail(MSG_TEST_FAILS_OUT_OF_RANGE); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_OUT_OF_RANGE_CONVERTING)); } - } - public void testExceptionWhenUnparseableInConvertToFloat(){ + public void testExceptionWhenUnparseableInConvertToFloat() { // given NumberConverter converter = new NumberConverter(); Map context = new HashMap<>(); @@ -318,15 +311,14 @@ public class NumberConverterTest extends XWorkTestCase { context.put(ActionContext.LOCALE, LOCALE_MEXICO); // when - try{ + try { Object value = converter.convertValue(context, null, null, null, strValue, Float.class); fail(MSG_TEST_FAILS_UNPARSEABLE_NUMBER); - }catch(Exception ex){ + } catch (Exception ex) { // then assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith(MSG_UNPARSEABLE_NUMBER)); } - } } diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java index 6b7269c28..8a6d9cfe2 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java @@ -310,7 +310,6 @@ public class XWorkBasicConverterTest extends XWorkTestCase { assertEquals(TypeConversionException.class, ex.getClass()); assertTrue(ex.getMessage().startsWith("Cannot create type")); } - } public void testExceptionInDoConvertToClass() { @@ -395,6 +394,5 @@ public class XWorkBasicConverterTest extends XWorkTestCase { super.tearDown(); ActionContext.setContext(null); } - - + } From 5239aa4b1326f3abe90db35ec2fd439c2b73fcd0 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 29 Mar 2020 21:54:18 -0600 Subject: [PATCH 10/18] License info added --- .../conversion/impl/DateConverterTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index 3cbe0240c..b0eb05f1f 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -1,3 +1,21 @@ +/* + * 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.conversion.impl; import com.opensymphony.xwork2.ActionContext; From 2c2b1af39271c5f49271aaa996fa8231597a11aa Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sun, 29 Mar 2020 23:04:43 -0600 Subject: [PATCH 11/18] Modifies the expected result in DateConverter validation, ignores the TimeZone --- .../xwork2/conversion/impl/DateConverterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index b0eb05f1f..605f7048e 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -34,7 +34,7 @@ public class DateConverterTest extends StrutsInternalTestCase { private final static String TIME_00_59_10 = "00:59:10"; private final static String TIMESTAMP_STR = "2020-03-20 00:59:10"; private final static String DATE_STR = "2020-03-20"; - private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00 CST 2020"; + private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00"; private final static String INVALID_DATE = "99/99/2010"; private final static String MESSAGE_PARSE_ERROR = "Could not parse date"; private final static String MESSAGE_DEFAULT_CONSTRUCTOR_ERROR = "Couldn't create class null using default (long) constructor"; @@ -66,7 +66,7 @@ public class DateConverterTest extends StrutsInternalTestCase { context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); Object value = converter.convertValue(context, null, null, null, DATE_STR, Date.class); - assertEquals(DATE_CONVERTED, ((Date) value).toString()); + assertTrue(((Date) value).toString().startsWith(DATE_CONVERTED)); } public void testTypeConversionExceptionWhenParseError() { From 3e0473a97e7f4327ae636146f8291c961490f362 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Tue, 31 Mar 2020 18:30:09 -0600 Subject: [PATCH 12/18] Adequates the strings for date formatting due to erros with JDK8 --- .../xwork2/conversion/impl/DateConverterTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index 605f7048e..6d8b88b72 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -24,6 +24,8 @@ import org.apache.struts2.StrutsInternalTestCase; import java.sql.Time; import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; import java.util.Date; import java.util.HashMap; import java.util.Locale; @@ -31,8 +33,8 @@ import java.util.Map; public class DateConverterTest extends StrutsInternalTestCase { - private final static String TIME_00_59_10 = "00:59:10"; - private final static String TIMESTAMP_STR = "2020-03-20 00:59:10"; + private final static String TIME_01_59_10 = "01:59:10 AM"; + private final static String TIMESTAMP_STR = "03/03/2020 00:00:00.000"; private final static String DATE_STR = "2020-03-20"; private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00"; private final static String INVALID_DATE = "99/99/2010"; @@ -45,8 +47,8 @@ public class DateConverterTest extends StrutsInternalTestCase { Map context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); - Object value = converter.convertValue(context, null, null, null, TIME_00_59_10, Time.class); - assertEquals(Time.valueOf(TIME_00_59_10), value); + Object value = converter.convertValue(context, null, null, null, TIME_01_59_10, Time.class); + assertEquals("01:59:10", value.toString()); } public void testSqlTimestampType() { @@ -56,7 +58,7 @@ public class DateConverterTest extends StrutsInternalTestCase { context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); Object value = converter.convertValue(context, null, null, null, TIMESTAMP_STR, Timestamp.class); - assertEquals(Timestamp.valueOf(TIMESTAMP_STR), value); + assertEquals("2020-03-03 00:00:00.0", value.toString()); } public void testDateType() { @@ -91,7 +93,7 @@ public class DateConverterTest extends StrutsInternalTestCase { context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); try { - Object value = converter.convertValue(context, null, null, null, "01-10-10", null); + Object value = converter.convertValue(context, null, null, null, "03/31/20", null); fail("TypeConversionException expected - Error using default (long) constructor"); } catch (Exception ex) { assertEquals(TypeConversionException.class, ex.getClass()); From 9e1a55458d4a61c9b0cf8178271c6e1b366414e0 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Wed, 1 Apr 2020 03:58:41 -0600 Subject: [PATCH 13/18] Fixes error with Formatting Date when Java is 9 or greater due to the JEP 252 --- .../conversion/impl/DateConverterTest.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index 6d8b88b72..676d29c17 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -25,7 +25,6 @@ import org.apache.struts2.StrutsInternalTestCase; import java.sql.Time; import java.sql.Timestamp; import java.text.DateFormat; -import java.text.ParseException; import java.util.Date; import java.util.HashMap; import java.util.Locale; @@ -33,8 +32,11 @@ import java.util.Map; public class DateConverterTest extends StrutsInternalTestCase { + private String INPUT_TIME_STAMP_STR; + private String INPUT_WHEN_LONG_CONSTRUCTOR_STR; + private Locale mxLocale = new Locale("es_MX", "MX"); + private final static String RES_TIME_STAMP_STR = "2020-03-20 00:00:00.0"; private final static String TIME_01_59_10 = "01:59:10 AM"; - private final static String TIMESTAMP_STR = "03/03/2020 00:00:00.000"; private final static String DATE_STR = "2020-03-20"; private final static String DATE_CONVERTED = "Fri Mar 20 00:00:00"; private final static String INVALID_DATE = "99/99/2010"; @@ -53,12 +55,11 @@ public class DateConverterTest extends StrutsInternalTestCase { public void testSqlTimestampType() { DateConverter converter = new DateConverter(); - Map context = new HashMap<>(); - context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); + context.put(ActionContext.LOCALE, mxLocale); - Object value = converter.convertValue(context, null, null, null, TIMESTAMP_STR, Timestamp.class); - assertEquals("2020-03-03 00:00:00.0", value.toString()); + Object value = converter.convertValue(context, null, null, null, INPUT_TIME_STAMP_STR, Timestamp.class); + assertEquals(RES_TIME_STAMP_STR, value.toString()); } public void testDateType() { @@ -93,7 +94,7 @@ public class DateConverterTest extends StrutsInternalTestCase { context.put(ActionContext.LOCALE, new Locale("es_MX", "MX")); try { - Object value = converter.convertValue(context, null, null, null, "03/31/20", null); + Object value = converter.convertValue(context, null, null, null, INPUT_WHEN_LONG_CONSTRUCTOR_STR, null); fail("TypeConversionException expected - Error using default (long) constructor"); } catch (Exception ex) { assertEquals(TypeConversionException.class, ex.getClass()); @@ -101,4 +102,17 @@ public class DateConverterTest extends StrutsInternalTestCase { } } + @Override + protected void setUp() { + //Due to JEP 252: Use CLDR Locale Data by Default + DateFormat dFormat = DateFormat.getDateInstance(DateFormat.SHORT, mxLocale); + if(dFormat.format(new Date()).contains("-")){ // Format when Java 9 or greater + INPUT_TIME_STAMP_STR = "2020-03-20 00:00:00.000"; + INPUT_WHEN_LONG_CONSTRUCTOR_STR = "2020-03-20"; + }else{ // Format when Java 8 or lower + INPUT_TIME_STAMP_STR = "03/20/2020 00:00:00.000"; + INPUT_WHEN_LONG_CONSTRUCTOR_STR = "03/31/20"; + } + } + } From 269af57ea026a91970cdd98eb5e25ca8020887a6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 11 Apr 2020 18:25:13 +0200 Subject: [PATCH 14/18] Adds nicer email messages --- Jenkinsfile | 63 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5bff27ecb..ac7516de8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -170,14 +170,21 @@ pipeline { failure { script { emailext( - subject: "[BUILD-FAILURE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", - body: """ - BUILD-FAILURE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': - - Check console output at ${env.BUILD_URL} - """.stripMargin(), to: "dev@struts.apache.org", - recipientProviders: [[$class: 'DevelopersRecipientProvider']] + recipientProviders: [[$class: 'DevelopersRecipientProvider']], + from: "Mr. Jenkins ", + subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} failed", + body: """ +There is a build failure in ${env.JOB_NAME}. + +Build: ${env.BUILD_URL} +Logs: ${env.BUILD_URL}console +Changes: ${env.BUILD_URL}changes + +-- +Mr. Jenkins +Director of Continuous Integration +""" ) } } @@ -186,14 +193,21 @@ pipeline { unstable { script { emailext( - subject: "[BUILD-UNSTABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", - body: """ - BUILD-UNSTABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': - - Check console output at ${env.BUILD_URL} - """.stripMargin(), to: "dev@struts.apache.org", - recipientProviders: [[$class: 'DevelopersRecipientProvider']] + recipientProviders: [[$class: 'DevelopersRecipientProvider']], + from: "Mr. Jenkins ", + subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} unstable", + body: """ +Some tests have failed in ${env.JOB_NAME}. + +Build: ${env.BUILD_URL} +Logs: ${env.BUILD_URL}console +Changes: ${env.BUILD_URL}changes + +-- +Mr. Jenkins +Director of Continuous Integration +""" ) } } @@ -202,14 +216,21 @@ pipeline { fixed { script { emailext( - subject: "[BUILD-STABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", - body: """ - BUILD-STABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': - - Is back to normal. - """.stripMargin(), to: "dev@struts.apache.org", - recipientProviders: [[$class: 'DevelopersRecipientProvider']] + recipientProviders: [[$class: 'DevelopersRecipientProvider']], + from: 'Mr. Jenkins ', + subject: "Jenkins job ${env.JOB_NAME}#${env.BUILD_NUMBER} back to normal", + body: """ +The build for ${env.JOB_NAME} completed successfully and is back to normal. + +Build: ${env.BUILD_URL} +Logs: ${env.BUILD_URL}console +Changes: ${env.BUILD_URL}changes + +-- +Mr. Jenkins +Director of Continuous Integration +""" ) } } From bf267ade1115e062b61a52add737556bc32a4a21 Mon Sep 17 00:00:00 2001 From: santosr09 Date: Sat, 11 Apr 2020 14:01:29 -0500 Subject: [PATCH 15/18] Moves TypeConversionException into org.apache.struts2.conversion --- .../com/opensymphony/xwork2/conversion/impl/DateConverter.java | 2 +- .../opensymphony/xwork2/conversion/impl/NumberConverter.java | 2 +- .../xwork2/conversion/impl/XWorkBasicConverter.java | 2 +- .../apache/struts2}/conversion/TypeConversionException.java | 2 +- .../opensymphony/xwork2/conversion/impl/DateConverterTest.java | 2 +- .../xwork2/conversion/impl/NumberConverterTest.java | 2 +- .../xwork2/conversion/impl/XWorkBasicConverterTest.java | 3 +-- 7 files changed, 7 insertions(+), 8 deletions(-) rename core/src/main/java/{com/opensymphony/xwork2 => org/apache/struts2}/conversion/TypeConversionException.java (97%) diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index b1583ee20..749b08bb6 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -18,7 +18,7 @@ */ package com.opensymphony.xwork2.conversion.impl; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import java.lang.reflect.Constructor; import java.lang.reflect.Member; diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java index d4514e1ec..3f4756629 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java @@ -18,7 +18,7 @@ */ package com.opensymphony.xwork2.conversion.impl; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java index 5d4de6c2f..d415a8d1a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java @@ -18,7 +18,7 @@ */ package com.opensymphony.xwork2.conversion.impl; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import com.opensymphony.xwork2.conversion.TypeConverter; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.inject.Inject; diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java b/core/src/main/java/org/apache/struts2/conversion/TypeConversionException.java similarity index 97% rename from core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java rename to core/src/main/java/org/apache/struts2/conversion/TypeConversionException.java index 73db26498..0d324bcad 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java +++ b/core/src/main/java/org/apache/struts2/conversion/TypeConversionException.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.opensymphony.xwork2.conversion; +package org.apache.struts2.conversion; import org.apache.struts2.StrutsException; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java index 676d29c17..157e6d815 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/DateConverterTest.java @@ -19,7 +19,7 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import org.apache.struts2.StrutsInternalTestCase; import java.sql.Time; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java index 8b995dc09..049e740e4 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java @@ -21,7 +21,7 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.SimpleFooAction; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import org.apache.commons.lang3.StringUtils; import java.math.BigDecimal; diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java index 8a6d9cfe2..33fea8377 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java @@ -20,11 +20,10 @@ package com.opensymphony.xwork2.conversion.impl; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.XWorkTestCase; -import com.opensymphony.xwork2.conversion.TypeConversionException; +import org.apache.struts2.conversion.TypeConversionException; import com.opensymphony.xwork2.inject.Container; import com.opensymphony.xwork2.test.annotations.Person; import org.apache.struts2.StrutsException; -import org.mockito.Mock; import org.mockito.Mockito; import java.math.BigDecimal; From 9d0a6a80adf433c80ba1289a81277beb75f0cf77 Mon Sep 17 00:00:00 2001 From: JCgH4164838Gh792C124B5 <43964333+JCgH4164838Gh792C124B5@users.noreply.github.com> Date: Sat, 18 Apr 2020 18:40:21 -0400 Subject: [PATCH 16/18] Proposed WW-5068 change. ------ Proposed list of library version updates: --- cdi-api 1.0-SP4 -> 1.2 weld-core 1.0.1-SP4 -> 2.2.16.SP1 weld-se 1.0.1-Final -> weld-se-core 2.2.16.SP1 htmlunit 2.27.0 and 2.37.0 -> 2.39.0 slf4j-api 1.7.29 -> 1.7.30 slf4j-simple 1.7.29 -> 1.7.30 log4j2 2.12.1 - > 2.13.1 jackson 2.10.1 -> 2.10.3 ognl 3.2.12 -> 3.2.14 asm 7.2 -> 7.3.1 spring 4.3.25.RELEASE -> 4.3.26.RELEASE fluido-skin 1.8 -> 1.9 freemarker 2.3.28 -> 2.3.30 org.apache.felix.main 4.6.1 -> 6.0.3 velocity 2.1 -> 2.2 junit 4.12 -> 4.13 easymock 3.5.1 -> 4.2 javax.el 3.0.1-b10 -> 3.0.1-b11 jstl 1.1.2 -> 1.2 tomcat-jasper 8.5.37 -> 8.5.53 tomcat-api 8.5.37 -> 8.5.53 tomcat-juli 8.5.37 -> 8.5.53 commons-lang3 3.9 -> 3.10 assertj-core 2.9.1 -> 3.15.0 mockito-core 2.23.0 -> 3.3.3 (required exclusion for objenesis) testng 5.14.10 -> 7.1.0 juneau-marshall 7.2.2 -> 8.1.3 validation-api 1.1.0.Final -> 2.0.1.Final hibernate-validator 5.4.3.Final -> 6.1.2.Final jaxb-impl 2.3.1 -> 2.3.2 --- Proposed list of Maven plugin version updates: --- maven-project-info-reports-plugin 2.7 -> 3.0.0 updateimpact-maven-plugin 1.0.10 -> 1.0.12 maven-surefire-plugin 2.22.2 -> 3.0.0-M4 jacoco-maven-plugin 0.8.4 - > 0.8.5 maven-war-plugin 3.2.2 -> 3.2.3 maven-bundle-plugin 3.5.0 -> 4.2.1 maven-dependency-plugin 3.1.1 -> 3.1.2 dependency-check-maven 5.2.4 -> 5.3.2 maven-enforcer-plugin 3.0.0-M2 -> 3.0.0-M3 maven-failsafe-plugin 2.22.2 -> 3.0.0-M4 maven-site-plugin 3.8.2 -> 3.9.0 doxia-core 1.9 -> 1.9.1 doxia-module-markdown 1.9 -> 1.9.1 --- --- apps/rest-showcase/pom.xml | 2 +- apps/showcase/pom.xml | 6 +-- plugins/bean-validation/pom.xml | 6 +-- plugins/cdi/pom.xml | 2 +- pom.xml | 80 ++++++++++++++++++--------------- 5 files changed, 52 insertions(+), 44 deletions(-) diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 2bf65a13a..9aff868e1 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -80,7 +80,7 @@ net.sourceforge.htmlunit htmlunit - 2.27 + 2.39.0 test diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 6360c0ae4..78564ac36 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -144,7 +144,7 @@ net.sourceforge.htmlunit htmlunit - 2.37.0 + 2.39.0 test @@ -152,7 +152,7 @@ org.hibernate hibernate-validator - 5.4.3.Final + 6.1.2.Final - 7.2 - 2.10.1 - 2.12.1 - 3.2.12 - 1.7.29 - 4.3.25.RELEASE + 7.3.1 + 2.10.3 + 2.13.1 + 3.2.14 + 1.7.30 + 4.3.26.RELEASE 3.0.8 1.0.7 - 1.8 + 1.9 https://builds.apache.org/analysis/ - 2.22.2 + 3.0.0-M4 @@ -223,7 +223,7 @@ org.jacoco jacoco-maven-plugin - 0.8.4 + 0.8.5 prepare-agent @@ -287,17 +287,17 @@ org.apache.maven.plugins maven-war-plugin - 3.2.2 + 3.2.3 org.apache.felix maven-bundle-plugin - 3.5.0 + 4.2.1 org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + 3.1.2 org.apache.maven.plugins @@ -353,7 +353,7 @@ org.owasp dependency-check-maven - 5.2.4 + 5.3.2 src/etc/project-suppression.xml @@ -366,7 +366,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.0.0-M2 + 3.0.0-M3 enforce @@ -425,7 +425,7 @@ org.apache.maven.plugins maven-site-plugin - 3.8.2 + 3.9.0 false @@ -433,12 +433,12 @@ org.apache.maven.doxia doxia-core - 1.9 + 1.9.1 org.apache.maven.doxia doxia-module-markdown - 1.9 + 1.9.1 @@ -678,13 +678,13 @@ org.freemarker freemarker - 2.3.28 + 2.3.30 org.apache.felix org.apache.felix.main - 4.6.1 + 6.0.3 org.apache.felix @@ -713,7 +713,7 @@ org.apache.velocity velocity-engine-core - 2.1 + 2.2 @@ -746,13 +746,13 @@ junit junit - 4.12 + 4.13 org.easymock easymock - 3.5.1 + 4.2 test @@ -766,7 +766,7 @@ org.glassfish javax.el - 3.0.1-b10 + 3.0.1-b11 @@ -779,21 +779,21 @@ javax.servlet jstl - 1.1.2 + 1.2 test org.apache.tomcat tomcat-jasper - 8.5.37 + 8.5.53 provided org.apache.tomcat tomcat-api - 8.5.37 + 8.5.53 provided @@ -870,7 +870,7 @@ org.apache.tomcat tomcat-juli - 8.5.37 + 8.5.53 @@ -903,7 +903,7 @@ org.apache.commons commons-lang3 - 3.9 + 3.10 org.apache.commons @@ -1025,14 +1025,22 @@ org.assertj assertj-core - 2.9.1 + 3.15.0 test org.mockito mockito-core - 2.23.0 + 3.3.3 + + + + org.objenesis + objenesis + + test @@ -1063,7 +1071,7 @@ org.testng testng - 5.14.10 + 7.1.0 compile true @@ -1131,26 +1139,26 @@ org.apache.juneau juneau-marshall - 7.2.2 + 8.1.3 javax.enterprise cdi-api - 1.0-SP4 + 1.2 org.jboss.weld weld-core - 1.0.1-SP4 + 2.2.16.SP1 - org.jboss.weld + org.jboss.weld.se weld-se - 1.0.1-Final + 2.2.16.SP1 From 963fd90d1e70a51ac2d88f66bfb5f19c54836dd9 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 19 Apr 2020 10:53:53 +0200 Subject: [PATCH 17/18] Adds required distributionManagement section to allow publish the site --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 793487034..237985e09 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,14 @@ + + + struts-stage + Apache Struts + file://${project.build.directory}/staging/ + + + bom core From 230a300685d6d0b82b68818e743ebf506b3225aa Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Mon, 20 Apr 2020 07:20:22 +0200 Subject: [PATCH 18/18] Fixes url used to generate the website --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 237985e09..a551c0d4d 100644 --- a/pom.xml +++ b/pom.xml @@ -74,9 +74,9 @@ - struts-stage + struts-site Apache Struts - file://${project.build.directory}/staging/ + https://struts.apache.org/maven/