@Test
public void testSteps() throws Exception {

    FeatureType complexType = ComplexTestData
            .createExample01MultiValuedComplexProperty(new UniqueNameFeatureTypeFactoryImpl());
    Name name = complexType.getName();
    AttributeDescriptor descriptor = new AttributeDescriptorImpl(complexType, name, 0,
            Integer.MAX_VALUE, true, null);
    NamespaceSupport namespaces = new NamespaceSupport();
    namespaces.declarePrefix("wq", name.getNamespaceURI());
    try {
        XPathUtil.steps(descriptor, null, namespaces);
        fail("passed null");
    } catch (NullPointerException e) {
    }
    List expected;
    String xpath;
    xpath = "/";
    assertEquals(1, XPathUtil.steps(descriptor, xpath, namespaces).size());
    XPathUtil.Step step = (XPathUtil.Step) XPathUtil.steps(descriptor, xpath, namespaces).get(0);
    QName rootQName = new QName(name.getNamespaceURI(), name.getLocalPart());
    assertEquals(rootQName, step.getName());
    expected = Collections.singletonList(new XPathUtil.Step(rootQName, 1));
    xpath = "wq_plus";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
    expected = Collections.singletonList(new XPathUtil.Step(rootQName, 1));
    xpath = "/wq_plus";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
    expected = Collections.singletonList(new XPathUtil.Step(rootQName, 1));
    xpath = "wq_plus/measurement/result/../../measurement/determinand_description/../..";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
    expected = Arrays.asList(new XPathUtil.Step[] {
            new XPathUtil.Step(new QName(rootQName.getNamespaceURI(), "measurement"), 2),
            new XPathUtil.Step(new QName(rootQName.getNamespaceURI(), "result"), 1) });
    xpath = "wq_plus/measurement/result/../../measurement[2]/result";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
    expected = Arrays.asList(new XPathUtil.Step[] {
            new XPathUtil.Step(new QName(rootQName.getNamespaceURI(), "measurement"), 1),
            new XPathUtil.Step(new QName(rootQName.getNamespaceURI(), "result"), 1) });
    xpath = "wq_plus/measurement/result/../result/.";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
    expected = Arrays.asList(new XPathUtil.Step[] { new XPathUtil.Step(new QName(rootQName
            .getNamespaceURI(), "measurement"), 5) });
    xpath = "measurement/result/../../measurement[5]";
    assertEquals(expected, XPathUtil.steps(descriptor, xpath, namespaces));
}