Exemplo n.º 1
0
 @Test
 public void gettingChildrenFromJava() throws Exception {
   Node category = with(XML).get("shopping.category[0]");
   final NodeChildren categoryChildren = category.children();
   assertThat(categoryChildren.size(), equalTo(2));
   for (Node item : categoryChildren.nodeIterable()) {
     assertThat(item.children().size(), equalTo(2));
     final Node name = item.get("name");
     final Node price = item.get("price");
     assertThat(name.value(), anyOf(equalTo("Chocolate"), equalTo("Coffee")));
     assertThat(price.value(), anyOf(equalTo("10"), equalTo("20")));
   }
 }
Exemplo n.º 2
0
 @Test
 public void firstCategoryAttributeFromJava() throws Exception {
   Node node = with(XML).get("shopping.category[0]");
   assertThat(node.getAttribute("@type"), equalTo("groceries"));
   assertThat(node.getAttribute("type"), equalTo("groceries"));
   assertThat((String) node.get("@type"), equalTo("groceries"));
 }