}
public void testBinding() throws Exception
{
SchemaBinding schema = JBossXBBuilder.build(RootWithTwoPropertyGroups.class);
ElementBinding e = schema.getElement(new QName("main-root"));
assertNotNull(e);
TermBinding t = e.getType().getParticle().getTerm();
assertTrue(t instanceof SequenceBinding || t instanceof UnorderedSequenceBinding);
Collection<ParticleBinding> particles = ((ModelGroupBinding)t).getParticles();
assertEquals(2, particles.size());
Iterator<ParticleBinding> i = particles.iterator();
ParticleBinding group1Particle;
ParticleBinding group2Particle;
if(t instanceof SequenceBinding)
{
group1Particle = i.next();
group2Particle = i.next();
}
else
{
ParticleBinding p = i.next();
if(((ElementBinding)p.getTerm()).getQName().equals(new QName("group1")))
{
group1Particle = p;
group2Particle = i.next();
}
else
{
group2Particle = p;
group1Particle = i.next();
}
}
t = group1Particle.getTerm();
assertTrue(t.isElement());
assertEquals(0, group1Particle.getMinOccurs());
assertEquals(1, group1Particle.getMaxOccurs());
assertFalse(group1Particle.getMaxOccursUnbounded());
ElementBinding e1 = (ElementBinding) t;
assertEquals(new QName("group1"), e1.getQName());
assertPropertiesSequenceBinding((ModelGroupBinding)e1.getType().getParticle().getTerm(), false);
t = group2Particle.getTerm();
assertTrue(t.isElement());
assertEquals(0, group2Particle.getMinOccurs());
assertEquals(1, group2Particle.getMaxOccurs());
assertFalse(group2Particle.getMaxOccursUnbounded());
e1 = (ElementBinding) t;
assertEquals(new QName("group2"), e1.getQName());
assertPropertiesSequenceBinding((ModelGroupBinding)e1.getType().getParticle().getTerm(), false);
}