[jboss-dev-forums] [Design of JBossXB] - Re: Recent tests

alex.loubyansky@jboss.com do-not-reply at jboss.com
Tue Dec 5 06:01:38 EST 2006


I've been looking into the AnyComplexTypeUnitTestCase. One issue related to the test was fixed in JBossXB. The other one is the way the binding is configured in the test itself.
Specifically, it's the use of type.setStartElementCreatesObject(false). It's always true for the complex types or types that are supposed to have child values.
Following that, in the testcase it should be true (i.e. not set to false). I'll add a javadoc description to clarify that.
This is the diff with an example of a correct binding to make the test pass:
$ svn diff test/
  | Index: test/java/org/jboss/test/xml/AnyComplexTypeUnitTestCase.java
  | ===================================================================
  | --- test/java/org/jboss/test/xml/AnyComplexTypeUnitTestCase.java        (revision 2184)
  | +++ test/java/org/jboss/test/xml/AnyComplexTypeUnitTestCase.java        (working copy)
  | @@ -34,6 +34,7 @@
  |  import org.jboss.xb.binding.metadata.ValueMetaData;
  |  import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
  |  import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
  | +import org.jboss.xb.binding.sunday.unmarshalling.DefaultHandlers;
  |  import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
  |  import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
  |  import org.jboss.xb.binding.sunday.unmarshalling.ParticleHandler;
  | @@ -155,15 +156,24 @@
  | 
  |        DOMUnresolvedHandler unresolved = new DOMUnresolvedHandler();
  |        TypeBinding type = schema.getType(new QName(NS, "any-complexType"));
  | -      type.setStartElementCreatesObject(false);
  | +      //type.setStartElementCreatesObject(false);
  | +      type.setHandler(new DOMUnresolvedHandler()
  | +      {
  | +         public void setParent(Object parent, Object o, QName qName, ParticleBinding particle,
  | +               ParticleBinding parentParticle)
  | +         {
  | +            DefaultHandlers.ELEMENT_HANDLER.setParent(parent, o, qName, particle, parentParticle);
  | +         }
  | +      }
  | +      );
  |        WildcardBinding wild = type.getWildcard();
  |        assertNotNull(wild);
  |        wild.setUnresolvedElementHandler(unresolved);
  |        wild.setUnresolvedCharactersHandler(unresolved);
  | 
  | -      DOMInterceptor interceptor = new DOMInterceptor();
  | -      element = schema.getElement(new QName(NS, "element"));
  | -      element.pushInterceptor(interceptor);
  | +      //DOMInterceptor interceptor = new DOMInterceptor();
  | +      //element = schema.getElement(new QName(NS, "element"));
  | +      //element.pushInterceptor(interceptor);
  | 
  |        Top top = (Top) unmarshal("AnyComplexTypeFromMultipleWildCardAndElement.xml", schema, Top.class);
  |        Element dom = top.element;
  | 

The snapshot in the repository hasn't been updated yet.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991235#3991235

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991235



More information about the jboss-dev-forums mailing list