String xsd = findXML(getRootName() + ".xsd");
SchemaBinding schema = XsdBinder.bind(xsd);
schema.setStrictSchema(true);
schema.setIgnoreUnresolvedFieldOrClass(false);
ElementBinding e = schema.getElement(new QName("file:///tmp/test.xsd", "message"));
assertNotNull(e);
TypeBinding type = e.getType();
ClassMetaData cmd = new ClassMetaData();
cmd.setImpl(Root.class.getName());
type.setClassMetaData(cmd);
TermBinding t = type.getParticle().getTerm();
assertTrue(t instanceof ChoiceBinding);
Collection<ParticleBinding> particles = ((ChoiceBinding)t).getParticles();
assertEquals(2, particles.size());
Iterator<ParticleBinding> i = particles.iterator();
ParticleBinding p = i.next();
assertEquals(1, p.getMinOccurs());
assertEquals(1, p.getMaxOccurs());
assertFalse(p.getMaxOccursUnbounded());
t = p.getTerm();
assertTrue(t instanceof SequenceBinding);
p = i.next();
assertEquals(1, p.getMinOccurs());
assertEquals(1, p.getMaxOccurs());
assertFalse(p.getMaxOccursUnbounded());
assertTrue(p.getTerm().isElement());
assertEquals(new QName("file:///tmp/test.xsd", "bar"), ((ElementBinding)p.getTerm()).getQName());
particles = ((SequenceBinding)t).getParticles();
assertEquals(2, particles.size());
i = particles.iterator();
p = i.next();
assertEquals(1, p.getMinOccurs());
assertEquals(1, p.getMaxOccurs());
assertFalse(p.getMaxOccursUnbounded());
assertTrue(p.getTerm().isElement());
assertEquals(new QName("file:///tmp/test.xsd", "foo"), ((ElementBinding)p.getTerm()).getQName());
p = i.next();
assertEquals(1, p.getMinOccurs());
assertEquals(2, p.getMaxOccurs());
assertFalse(p.getMaxOccursUnbounded());
assertTrue(p.getTerm().isElement());
e = (ElementBinding) p.getTerm();
assertEquals(new QName("file:///tmp/test.xsd", "bar"), e.getQName());
PropertyMetaData pmd = new PropertyMetaData();
pmd.setName("barMaxOccurs2");
e.setPropertyMetaData(pmd);
return schema;
}