4 Replies Latest reply on Nov 3, 2007 3:44 PM by aloubyansky

    Problem with Collection<Enum>

    starksm64

      The org.jboss.test.metadata.web.WebApp5EverythingUnitTestCase test is failing with:

      org.jboss.xb.binding.JBossXBException: Failed to parse source: file:/C:/home/svn/JBossAS/projects/metadata/trunk/target/eclipse-classes/org/jboss/test/metadata/web/WebApp5Everything_testEverything.xml@53,21
      ...
      Caused by: java.lang.RuntimeException: Invalid value java.util.ArrayList@1531164 for {http://java.sun.com/xml/ns/javaee}dispatcherType valid are [REQUEST, ERROR, FORWARD, INCLUDE]
       at org.jboss.xb.builder.runtime.EnumValueAdapter.cast(EnumValueAdapter.java:111)
       at org.jboss.xb.builder.runtime.BeanHandler.setParent(BeanHandler.java:190)
       at org.jboss.xb.builder.runtime.BuilderParticleHandler.setParent(BuilderParticleHandler.java:69)
       at org.jboss.xb.binding.group.ValueListHandler$FACTORY$1.newInstance(ValueListHandler.java:401)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endRepeatableParticle(SundayContentHandler.java:850)
       at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endElement(SundayContentHandler.java:221)
      


      The property in question is the FilterMappingMetaData.dispatchers property, which is a list of enum types:
      package org.jboss.metadata.web.spec;
      
      
      public class FilterMappingMetaData extends IdMetaDataImpl
      
       @XmlElement(name="dispatcher")
       public void setDispatchers(List<DispatcherType> dispatchers)
       {
       this.dispatchers = dispatchers;
       }
      


      The input is an array of strings for valid enum values. Is the EnumValueAdapter supposed to handle collections or is this supposed to be handled by the binding layer?


        • 1. Re: Problem with Collection<Enum>
          aloubyansky

          It's a bug. It should apply the adapter to each item in the collection.
          But there are cases when it should be applied to a collection. E.g. org.jboss.test.xb.builder.object.element.javatypeadapter.test.JavaTypeAdapterUnitTestCase.
          I am looking into this issue.

          • 2. Re: Problem with Collection<Enum>
            aloubyansky

            It should be fixed now in xb trunk.

            • 3. Re: Problem with Collection of Enum
              starksm64

              Turns out this is not complete yet. The array passed in is an array of string, not the DispatcherType enum. I updated the WebApp5EverythingUnitTestCase so that its failing because of this:

              junit.framework.AssertionFailedError: expected:<FORWARD> but was:<FORWARD>
               at junit.framework.Assert.fail(Assert.java:47)
               at junit.framework.Assert.failNotEquals(Assert.java:282)
               at junit.framework.Assert.assertEquals(Assert.java:64)
               at junit.framework.Assert.assertEquals(Assert.java:71)
               at org.jboss.test.metadata.web.WebApp5EverythingUnitTestCase.assertFilterMappings(WebApp5EverythingUnitTestCase.java:195)
               at org.jboss.test.metadata.web.WebApp5EverythingUnitTestCase.assertEverything(WebApp5EverythingUnitTestCase.java:92)
               at org.jboss.test.metadata.web.WebApp5EverythingUnitTestCase.testEverything(WebApp5EverythingUnitTestCase.java:75)
              



              • 4. Re: Problem with Collection<Enum>
                aloubyansky

                There was a typo. It's fixed now.