### Question:
IterableXPath implements Iterable<String> { public String getXPath() { return xPath; } IterableXPath(@Nullable String xPath); String getXPath(); @Override Iterator<String> iterator(); @Override String toString();  }### Answer:
@Test public void testValidXPathWithLeadingSlash() { String xPath = "/Envelope/RequestHeader/SomeValue"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Test public void testValidXPathWithoutLeadingSlash() { String xPath = "Envelope/RequestHeader/SomeValue"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Test public void testValidXPathWithTrailingSlash() { String xPath = "/Envelope/RequestHeader/SomeValue/"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Test public void testEmptyXPath() { String xPath = ""; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); assertArrayEquals(new String[0], Iterables.toArray(iterableXPath, String.class)); }
@Test public void testNullXPath() { String xPath = null; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); assertArrayEquals(new String[0], Iterables.toArray(iterableXPath, String.class)); }