public void testGroupWithJBossXmlNsProperty() throws Exception
{
SchemaBinding schema = JBossXBBuilder.build(RootWithGroupWithJBossXmlNsPrefixProperty.class, true);
ElementBinding e = schema.getElement(new QName("ns", "root"));
ModelGroupBinding group = (ModelGroupBinding) e.getType().getParticle().getTerm();
Collection<ParticleBinding> particles = group.getParticles();
assertEquals(1, particles.size());
group = (ModelGroupBinding) particles.iterator().next().getTerm();
particles = group.getParticles();
assertEquals(4, particles.size());
Iterator<ParticleBinding> iterator = particles.iterator();
ElementBinding gtcf = null;
ElementBinding gfcf = null;
ElementBinding gtct = null;
ElementBinding gfct = null;
if(group instanceof SequenceBinding)
{
gtcf = (ElementBinding) iterator.next().getTerm();
gfcf = (ElementBinding) iterator.next().getTerm();
gtct = (ElementBinding) iterator.next().getTerm();
gfct = (ElementBinding) iterator.next().getTerm();
}
else
{
assertTrue(group instanceof UnorderedSequenceBinding);
while(iterator.hasNext())
{
ElementBinding el = (ElementBinding) iterator.next().getTerm();
if(el.getQName().getLocalPart().equals("group-true-content-false"))
gtcf = el;
else if(el.getQName().getLocalPart().equals("group-false-content-false"))
gfcf = el;
else if(el.getQName().getLocalPart().equals("group-true-content-true"))
gtct = el;
else if(el.getQName().getLocalPart().equals("group-false-content-true"))
gfct = el;
}
}
assertEquals(new QName("childNs", "group-true-content-false"), gtcf.getQName());
group = (ModelGroupBinding) gtcf.getType().getParticle().getTerm();
particles = group.getParticles();
assertEquals(1, particles.size());
e = (ElementBinding) particles.iterator().next().getTerm();
assertEquals(new QName("ns", "name"), e.getQName());
assertEquals(new QName("ns", "group-false-content-false"), gfcf.getQName());
group = (ModelGroupBinding) gfcf.getType().getParticle().getTerm();
particles = group.getParticles();
assertEquals(1, particles.size());
e = (ElementBinding) particles.iterator().next().getTerm();
assertEquals(new QName("ns", "name"), e.getQName());
assertEquals(new QName("childNs", "group-true-content-true"), gtct.getQName());
group = (ModelGroupBinding) gtct.getType().getParticle().getTerm();
particles = group.getParticles();
assertEquals(1, particles.size());
e = (ElementBinding) particles.iterator().next().getTerm();
assertEquals(new QName("childNs", "name"), e.getQName());
assertEquals(new QName("ns", "group-false-content-true"), gfct.getQName());
group = (ModelGroupBinding) gfct.getType().getParticle().getTerm();
particles = group.getParticles();
assertEquals(1, particles.size());
e = (ElementBinding) particles.iterator().next().getTerm();
assertEquals(new QName("childNs", "name"), e.getQName());
}