JcrSession session = repository.login();
AbstractJcrNode node1 = session.getNode("/node1");
AbstractJcrNode node2 = session.getNode("/node2");
AbstractJcrNode node3 = session.getNode("/node3");
Property hard_ref11 = node1.getProperty("hard_ref11");
assertEquals(javax.jcr.PropertyType.REFERENCE, hard_ref11.getType());
assertEquals(node2.getIdentifier(), hard_ref11.getNode().getIdentifier());
Property hard_ref12 = node1.getProperty("hard_ref12");
assertEquals(javax.jcr.PropertyType.REFERENCE, hard_ref12.getType());
assertTrue(hard_ref12.isMultiple());
List<String> nodeIdentifiers = new ArrayList<>();
for (Value value : hard_ref12.getValues()) {
nodeIdentifiers.add(value.getString());
}
assertTrue(nodeIdentifiers.remove(node2.getIdentifier()));
assertTrue(nodeIdentifiers.remove(node3.getIdentifier()));
Property weak_ref11 = node1.getProperty("weak_ref11");
assertEquals(javax.jcr.PropertyType.WEAKREFERENCE, weak_ref11.getType());
assertEquals(node2.getIdentifier(), weak_ref11.getNode().getIdentifier());
Property weak_ref12 = node1.getProperty("weak_ref12");
assertEquals(javax.jcr.PropertyType.WEAKREFERENCE, weak_ref12.getType());
assertEquals(node2.getIdentifier(), weak_ref12.getNode().getIdentifier());
Property simple_ref11 = node1.getProperty("simple_ref11");
assertEquals(PropertyType.SIMPLE_REFERENCE, simple_ref11.getType());
assertEquals(node2.getIdentifier(), simple_ref11.getNode().getIdentifier());
Property simple_ref12 = node1.getProperty("simple_ref12");
assertEquals(PropertyType.SIMPLE_REFERENCE, simple_ref12.getType());
assertEquals(node2.getIdentifier(), simple_ref12.getNode().getIdentifier());
Property hard_ref21 = node2.getProperty("hard_ref21");
assertEquals(javax.jcr.PropertyType.REFERENCE, hard_ref21.getType());
assertEquals(node1.getIdentifier(), hard_ref21.getNode().getIdentifier());
Property hard_ref22 = node2.getProperty("hard_ref22");
assertEquals(javax.jcr.PropertyType.REFERENCE, hard_ref22.getType());
assertTrue(hard_ref22.isMultiple());
nodeIdentifiers = new ArrayList<>();
for (Value value : hard_ref22.getValues()) {
nodeIdentifiers.add(value.getString());
}
assertTrue(nodeIdentifiers.remove(node1.getIdentifier()));
assertTrue(nodeIdentifiers.remove(node3.getIdentifier()));
Property weak_ref21 = node2.getProperty("weak_ref21");
assertEquals(javax.jcr.PropertyType.WEAKREFERENCE, weak_ref21.getType());
assertEquals(node1.getIdentifier(), weak_ref21.getNode().getIdentifier());
Property weak_ref22 = node2.getProperty("weak_ref22");
assertEquals(javax.jcr.PropertyType.WEAKREFERENCE, weak_ref22.getType());
assertEquals(node1.getIdentifier(), weak_ref22.getNode().getIdentifier());
Property simple_ref21 = node2.getProperty("simple_ref21");
assertEquals(PropertyType.SIMPLE_REFERENCE, simple_ref21.getType());
assertEquals(node1.getIdentifier(), simple_ref21.getNode().getIdentifier());
Property simple_ref22 = node2.getProperty("simple_ref22");
assertEquals(PropertyType.SIMPLE_REFERENCE, simple_ref22.getType());
assertEquals(node1.getIdentifier(), simple_ref22.getNode().getIdentifier());
}