try {
String[] files = { "./src/test/test-config/jcrmapping.xml",
"./src/test/test-config/jcrmapping-jcrnodetypes.xml"};
Mapper mapper = new DigesterMapperImpl(files);
assertNotNull("Mapper is null", mapper);
ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(B.class);
assertNotNull("ClassDescriptor is null", classDescriptor);
assertTrue("Invalid classname", classDescriptor.getClassName()
.equals(B.class.getName()));
assertEquals(classDescriptor.getJcrSuperTypes(), "nt:base");
FieldDescriptor b1Field = classDescriptor.getFieldDescriptor("b1");
assertNotNull("FieldDescriptor is null", b1Field);
assertEquals(b1Field.getFieldName(), "b1");
assertEquals(b1Field.getJcrType(), "String");
assertFalse(b1Field.isJcrAutoCreated());
assertFalse(b1Field.isJcrMandatory());
assertFalse(b1Field.isJcrProtected());
assertFalse(b1Field.isJcrMultiple());
assertEquals(b1Field.getJcrOnParentVersion(), "IGNORE");
FieldDescriptor b2Field = classDescriptor.getFieldDescriptor("b2");
assertNotNull("FieldDescriptor is null", b2Field);
assertEquals(b2Field.getFieldName(), "b2");
assertEquals(b2Field.getJcrType(), "String");
assertFalse(b2Field.isJcrAutoCreated());
assertFalse(b2Field.isJcrMandatory());
assertFalse(b2Field.isJcrProtected());
assertFalse(b2Field.isJcrMultiple());
assertEquals(b2Field.getJcrOnParentVersion(), "IGNORE");
ClassDescriptor classDescriptor2 = mapper
.getClassDescriptorByClass(A.class);
assertNotNull("ClassDescriptor is null", classDescriptor2);
assertTrue("Invalid classname", classDescriptor2.getClassName()
.equals(A.class.getName()));
BeanDescriptor beanDescriptor = classDescriptor2
.getBeanDescriptor("b");
assertNotNull(beanDescriptor);
assertEquals(beanDescriptor.getFieldName(), "b");
assertEquals(beanDescriptor.getJcrType(), "nt:unstructured");
assertFalse(beanDescriptor.isJcrAutoCreated());
assertFalse(beanDescriptor.isJcrMandatory());
assertFalse(beanDescriptor.isJcrProtected());
assertFalse(beanDescriptor.isJcrSameNameSiblings());
assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");
CollectionDescriptor collectionDescriptor = classDescriptor2
.getCollectionDescriptor("collection");
assertNotNull(collectionDescriptor);
assertEquals(collectionDescriptor.getJcrType(), "ocm:C");
assertFalse(collectionDescriptor.isJcrAutoCreated());
assertFalse(collectionDescriptor.isJcrMandatory());
assertFalse(collectionDescriptor.isJcrProtected());
assertFalse(collectionDescriptor.isJcrSameNameSiblings());
assertEquals(collectionDescriptor.getJcrOnParentVersion(), "IGNORE");
classDescriptor = mapper.getClassDescriptorByClass(PropertyTest.class);
assertNotNull(classDescriptor);
FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor("requiredWithConstraintsProp");
assertNotNull(fieldDescriptor.getJcrValueConstraints());
assertTrue("Invalid constaint", fieldDescriptor.getJcrValueConstraints()[0].equals("abc") );
assertTrue("Invalid constaint", fieldDescriptor.getJcrValueConstraints()[1].equals("def") );