/**
* Test that the {@link StepList} for the root element is properly formed.
*/
@Test
public void testRootElementSteps() {
NamespaceSupport namespaces = new NamespaceSupport();
try {
XPathUtil.rootElementSteps(null, namespaces);
fail("passed null");
} catch (NullPointerException e) {
}
FeatureType complexType = ComplexTestData
.createExample05NoNamespaceURI(new UniqueNameFeatureTypeFactoryImpl());
Name name = complexType.getName();
AttributeDescriptor descriptor = new AttributeDescriptorImpl(complexType, name, 0,
Integer.MAX_VALUE, true, null);
try {
XPathUtil.rootElementSteps(descriptor, namespaces);
} catch (NullPointerException e) {
fail("failed null");
}
assertEquals(1, XPathUtil.rootElementSteps(descriptor, namespaces).size());
XPathUtil.Step step = XPathUtil.rootElementSteps(descriptor, namespaces).get(0);
QName rootQName = new QName(name.getNamespaceURI(), name.getLocalPart(), "");
assertEquals(rootQName, step.getName());
complexType = ComplexTestData
.createExample01MultiValuedComplexProperty(new UniqueNameFeatureTypeFactoryImpl());
name = complexType.getName();
descriptor = new AttributeDescriptorImpl(complexType, name, 0, Integer.MAX_VALUE, true,
null);
String prefix = "wq";
namespaces.declarePrefix(prefix, name.getNamespaceURI());
try {
XPathUtil.rootElementSteps(descriptor, namespaces);
} catch (NullPointerException e) {
fail("failed null");