This is an automated email from the ASF dual-hosted git repository.

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 88b56cd364 AXIS2-5975 More specific Runtime Exceptions instead of just 
'Input values do not follow defined XSD restrictions'
88b56cd364 is described below

commit 88b56cd36469ea0bddb2ce725ca29ff0f6bb7312
Author: Robert Lazarski <robertlazar...@gmail.com>
AuthorDate: Wed Feb 12 06:37:51 2025 -1000

    AXIS2-5975 More specific Runtime Exceptions instead of just 'Input values 
do not follow defined XSD restrictions'
---
 .../axis2/schema/template/ADBBeanTemplate-bean.xsl | 26 +++++++++++-----------
 .../schema/restriction/SchemaRestrictionTest.java  | 20 ++++++++---------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git 
a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
 
b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
index 2260cc25e7..f60d7c22df 100644
--- 
a/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
+++ 
b/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
@@ -162,12 +162,12 @@
                          protected void validate<xsl:value-of 
select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
                          <xsl:if test="not(@unbound) and @array">
                               if ((param != null) &amp;&amp; (param.length 
&gt; <xsl:value-of select="@maxOccurs"/>)){
-                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions");
+                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions, not unbound and array found XSL 
condition 'param != null' and param.length greater than maxOccurs");
                               }
                          </xsl:if>
                          <xsl:if test="$min!=0 and @array">
                               if ((param != null) &amp;&amp; (param.length 
&lt; <xsl:value-of select="$min"/>)){
-                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions");
+                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions, min!=0 and array found XSL 
condition 'param != null' and param.length less than min");
                               }
                          </xsl:if>
                          }
@@ -334,12 +334,12 @@
                               protected void validate<xsl:value-of 
select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
                              <xsl:if test="not(@unbound)">
                               if ((param != null) &amp;&amp; (param.length 
&gt; <xsl:value-of select="@maxOccurs"/>)){
-                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions");
+                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions, not unbound found XSL condition 
'param != null' and param.length greater than maxOccurs");
                               }
                               </xsl:if>
                               <xsl:if test="$min!=0">
                               if ((param != null) &amp;&amp; (param.length 
&lt; <xsl:value-of select="$min"/>)){
-                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions");
+                                throw new java.lang.RuntimeException("Input 
values do not follow defined XSD restrictions, min!=0 found XSL condition 
'param != null' and param.length less than min");
                               }
                               </xsl:if>
                               }
@@ -463,7 +463,7 @@
 
                                             }
                                             else {
-                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with maxLenFacet and minLenFacet and 
patternFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).matches()'");
                                             }
                                         </xsl:when>
                                         <xsl:when test="(@patternFacet)">
@@ -471,7 +471,7 @@
                                                 this.<xsl:value-of 
select="$varName"/>=param;
                                             }
                                             else {
-                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with patternFacet failed XSL 'if' 
condition 
'org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).matches(patternFacet)'");
                                             }
                                         </xsl:when>
                                         <xsl:when test="(@lenFacet)">
@@ -479,7 +479,7 @@
                                                 this.<xsl:value-of 
select="$varName"/>=param;
                                             }
                                             else {
-                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with lenFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).length()
 == lenFacet)'");
                                             }
                                         </xsl:when>
                                         <xsl:when test="(@maxLenFacet) or 
(@minLenFacet)">
@@ -488,7 +488,7 @@
                                                 this.<xsl:value-of 
select="$varName"/>=param;
                                             }
                                             else {
-                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with maxLenFacet or minLenFacetlen failed 
XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.convertToString(param).length()
 == maxLenFacet)'");
                                             }
                                         </xsl:when>
                                         <xsl:when test="(@totalDigitsFacet)">
@@ -497,7 +497,7 @@
                                                     this.<xsl:value-of 
select="$varName"/>=param;
                                             }
                                             else {
-                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with totalDigitsFacet failed XSL 'if' 
condition 'org.apache.axis2.databinding.utils.ConverterUtil.compare(param, 
totalDigitsDecimal) less than zero'");
                                             }
                                         </xsl:when>
                                         <xsl:when test="@maxExFacet or 
@minExFacet or @maxInFacet or @minInFacet">
@@ -506,7 +506,7 @@
                                                         this.<xsl:value-of 
select="$varName"/>=param;
                                                     }
                                                     else {
-                                                        throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                        throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with maxExFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.compare(param, maxExFacet)' 
less than zero");
                                                     }
                                             </xsl:if>
                                             <xsl:if test="@minExFacet">
@@ -514,7 +514,7 @@
                                                     this.<xsl:value-of 
select="$varName"/>=param;
                                                 }
                                                 else {
-                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with minExFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.compare(param, minExFacet) 
greater than zero'");
                                                 }
                                             </xsl:if>
                                             <xsl:if test="@maxInFacet">
@@ -522,7 +522,7 @@
                                                     this.<xsl:value-of 
select="$varName"/>=param;
                                                 }
                                                 else {
-                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with maxInFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.compare(param, maxInFacet) 
less than or equal zero'");
                                                 }
                                             </xsl:if>
                                             <xsl:if test="@minInFacet">
@@ -530,7 +530,7 @@
                                                     this.<xsl:value-of 
select="$varName"/>=param;
                                                 }
                                                 else {
-                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions");
+                                                    throw new 
java.lang.RuntimeException("Input values do not follow defined XSD 
restrictions, on restrictionBaseType with minInFacet failed XSL 'if' condition 
'org.apache.axis2.databinding.utils.ConverterUtil.compare(param, minInFacet) 
greater than or equal zero'");
                                                 }
                                             </xsl:if>
                                         </xsl:when>
diff --git 
a/modules/adb-tests/src/test/java/org/apache/axis2/schema/restriction/SchemaRestrictionTest.java
 
b/modules/adb-tests/src/test/java/org/apache/axis2/schema/restriction/SchemaRestrictionTest.java
index 97a0383e4b..cd4370d836 100644
--- 
a/modules/adb-tests/src/test/java/org/apache/axis2/schema/restriction/SchemaRestrictionTest.java
+++ 
b/modules/adb-tests/src/test/java/org/apache/axis2/schema/restriction/SchemaRestrictionTest.java
@@ -65,7 +65,7 @@ public class SchemaRestrictionTest extends TestCase {
             LimitedStringE.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -79,7 +79,7 @@ public class SchemaRestrictionTest extends TestCase {
             LimitedString.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -93,7 +93,7 @@ public class SchemaRestrictionTest extends TestCase {
             LimitedString.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -107,7 +107,7 @@ public class SchemaRestrictionTest extends TestCase {
             LimitedString.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -121,7 +121,7 @@ public class SchemaRestrictionTest extends TestCase {
             LimitedString.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -143,7 +143,7 @@ public class SchemaRestrictionTest extends TestCase {
             Rating.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -157,7 +157,7 @@ public class SchemaRestrictionTest extends TestCase {
             Rating.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -171,7 +171,7 @@ public class SchemaRestrictionTest extends TestCase {
             Rating.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -185,7 +185,7 @@ public class SchemaRestrictionTest extends TestCase {
             Rating.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }
@@ -199,7 +199,7 @@ public class SchemaRestrictionTest extends TestCase {
             Rating.Factory.parse(element.getXMLStreamReader());
             fail("This should throw RuntimeException");
         } catch (RuntimeException e) {
-            assertEquals(toString(e), ERROR_MSG, e.getMessage());
+            assertTrue(e.getMessage().contains(ERROR_MSG));
 
         }
     }

Reply via email to