Package org.apache.jackrabbit.ocm.mapper.impl.digester

Examples of org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl


     *            <code>Mapper</code> component
     */
    public ObjectContentManagerImpl(Session session, String[] xmlMappingFiles) {
        try {
            this.session = session;
            this.mapper = new DigesterMapperImpl(xmlMappingFiles);
            DefaultAtomicTypeConverterProvider converterProvider = new DefaultAtomicTypeConverterProvider();
            Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
            this.queryManager = new QueryManagerImpl(mapper, atomicTypeConverters, session.getValueFactory());
            this.requestObjectCache = new RequestObjectCacheImpl();
            this.objectConverter = new ObjectConverterImpl(mapper, converterProvider, new ProxyManagerImpl(), requestObjectCache);
View Full Code Here


     *            <code>Mapper</code> component
     */
    public ObjectContentManagerImpl(Session session, InputStream[] xmlMappingFiles) {
        try {
            this.session = session;
            this.mapper = new DigesterMapperImpl(xmlMappingFiles);
            DefaultAtomicTypeConverterProvider converterProvider = new DefaultAtomicTypeConverterProvider();
            Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
            this.queryManager = new QueryManagerImpl(mapper, atomicTypeConverters, session.getValueFactory());
            this.requestObjectCache = new RequestObjectCacheImpl();
            this.objectConverter = new ObjectConverterImpl(mapper, converterProvider, new ProxyManagerImpl(), requestObjectCache);
View Full Code Here

   *
   */
  public void testMapper() {
    try {

      Mapper mapper = new DigesterMapperImpl(
          "./src/test/test-config/jcrmapping-testdigester.xml");
         
      assertNotNull("Mapper is null", mapper);

      ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(A.class);
      assertNotNull("ClassDescriptor is null", classDescriptor);
      assertTrue("Invalid classname", classDescriptor.getClassName().equals(A.class.getName()));
      assertTrue("Invalid path field", classDescriptor.getPathFieldDescriptor().getFieldName().equals("path"));
      assertEquals("Invalid mixins", "mixin:a", classDescriptor.getJcrMixinTypes()[0]);

View Full Code Here

   *
   */
  public void testUuid() {
    try {

      Mapper mapper = new DigesterMapperImpl(
          "./src/test/test-config/jcrmapping-testdigester.xml");
         
      assertNotNull("Mapper is null", mapper);

      ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(org.apache.jackrabbit.ocm.testmodel.uuid.A.class);
      assertNotNull("ClassDescriptor is null", classDescriptor);
      assertTrue("Invalid uuid field", classDescriptor.getUuidFieldDescriptor().getFieldName().equals("uuid"));

    } catch (JcrMappingException e) {
      e.printStackTrace();
View Full Code Here

   *
   */
  public void testDiscriminatorSetting() {
    try {

      Mapper mapper = new DigesterMapperImpl("./src/test/test-config/jcrmapping-testdigester.xml");

      assertNotNull("Mapper is null", mapper);

      ClassDescriptor classDescriptor = mapper.getClassDescriptorByNodeType("ocm:C");
      //ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(C.class);
      assertNotNull("ClassDescriptor is null", classDescriptor);
      assertTrue("Invalid classname", classDescriptor.getClassName().equals(C.class.getName()));     
    } catch (JcrMappingException e) {
      e.printStackTrace();
View Full Code Here

    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") );
View Full Code Here

      String[] files = { "./src/test/test-config/jcrmapping.xml",
          "./src/test/test-config/jcrmapping-atomic.xml",
          "./src/test/test-config/jcrmapping-beandescriptor.xml",
          "./src/test/test-config/jcrmapping-inheritance.xml" };     
     
      Mapper mapper = new DigesterMapperImpl(files);

      assertNotNull("Mapper is null", mapper);

      ClassDescriptor classDescriptor = mapper
          .getClassDescriptorByClass(Ancestor.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertEquals("Incorrect path field", classDescriptor
          .getPathFieldDescriptor().getFieldName(), "path");
      assertTrue("The ancestor class has no discriminator",
          classDescriptor.hasDiscriminator());
      assertTrue("The ancestor class is not abstract", classDescriptor
          .isAbstract());
      assertNull("The ancestor class has an ancestor", classDescriptor
          .getSuperClassDescriptor());
      assertTrue(
          "Ancestor class doesn't have a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertFalse(
          "Ancestor class  have a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerConcreteClassStrategy());

      Collection descendandDescriptors = classDescriptor
          .getDescendantClassDescriptors();
      assertEquals("Invalid number of descendants", descendandDescriptors
          .size(), 2);

      classDescriptor = mapper.getClassDescriptorByClass(Descendant.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertEquals("Incorrect path field", classDescriptor
          .getPathFieldDescriptor().getFieldName(), "path");
      assertTrue("The descendant  class has no discriminator",
          classDescriptor.hasDiscriminator());
      assertNotNull("ancerstorField is null in the descendant class",
          classDescriptor.getFieldDescriptor("ancestorField"));
      assertFalse("The descendant class is abstract", classDescriptor
          .isAbstract());
      assertNotNull("The descendant class has not an ancestor",
          classDescriptor.getSuperClassDescriptor());
      assertEquals("Invalid ancestor class for the descendant class",
          classDescriptor.getSuperClassDescriptor().getClassName(),
          "org.apache.jackrabbit.ocm.testmodel.inheritance.Ancestor");
      descendandDescriptors = classDescriptor
          .getDescendantClassDescriptors();
      assertEquals("Invalid number of descendants", descendandDescriptors
          .size(), 1);
      assertTrue(
          "Descendant  class doesn't have a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertFalse(
          "Descendant class  have a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerConcreteClassStrategy());

      classDescriptor = mapper.getClassDescriptorByClass(SubDescendant.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertEquals("Incorrect path field", classDescriptor
          .getPathFieldDescriptor().getFieldName(), "path");
      assertTrue("The subdescendant  class has no discriminator",
          classDescriptor.hasDiscriminator());
View Full Code Here

          "./src/test/test-config/jcrmapping-atomic.xml",
          "./src/test/test-config/jcrmapping-beandescriptor.xml",
          "./src/test/test-config/jcrmapping-inheritance.xml" };
      //          String[] files = {  "./src/test/test-config/jcrmapping-inheritance.xml"};

      Mapper mapper = new DigesterMapperImpl(files);

      assertNotNull("Mapper is null", mapper);

      ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(CmsObjectImpl.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertEquals("Incorrect path field", classDescriptor
          .getPathFieldDescriptor().getFieldName(), "path");
      assertFalse("The cms object class  has discriminator",
          classDescriptor.hasDiscriminator());
      assertTrue("The cmsobject class is not abstract", classDescriptor
          .isAbstract());
      assertNull("The cmsobject class has an ancestor", classDescriptor
          .getSuperClassDescriptor());
      assertFalse(
          "The cmsobject class  have a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertTrue(
          "The cmsobject class  have not a node type per hierarchy strategy",
          classDescriptor.usesNodeTypePerConcreteClassStrategy());
      assertTrue("The cmsobject class has no descendant ",
          classDescriptor.hasDescendants());
      assertEquals("Invalid number of descendants", classDescriptor
          .getDescendantClassDescriptors().size(), 2);

      classDescriptor = mapper.getClassDescriptorByClass(DocumentImpl.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertEquals("Incorrect path field", classDescriptor
          .getPathFieldDescriptor().getFieldName(), "path");
      assertFalse("The document class  has discriminator",
          classDescriptor.hasDiscriminator());
View Full Code Here

   * Test interface setting
   */
  public void testInterfaceWithDiscriminator() {
    try {
      String[] files = {"./src/test/test-config/jcrmapping-inheritance.xml"};
      Mapper mapper = new DigesterMapperImpl(files);

      assertNotNull("Mapper is null", mapper);
      ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(Interface.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertTrue("Interface is not an interface", classDescriptor.isInterface());
      assertTrue("Interface  has not a discriminator", classDescriptor.hasDiscriminator());
      String[] mixinTypes = classDescriptor.getJcrMixinTypes();
      assertEquals("Invalid mixin type for the interface",mixinTypes.length , 0);
      assertNull("The interface has an ancestor", classDescriptor.getSuperClassDescriptor());
      assertTrue("The interface has not implementation/descendant", classDescriptor.hasDescendants());
      Collection descendants = classDescriptor.getDescendantClassDescriptors();
      assertEquals("Invalid number of implementation/descendants", descendants.size(), 1);
      assertEquals("Invalid interface implementation",( (ClassDescriptor) descendants.iterator().next()).getClassName(), "org.apache.jackrabbit.ocm.testmodel.inheritance.AnotherDescendant");
      assertTrue("Invalid extend strategy", classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertFalse("Incalid extend strategy", classDescriptor.usesNodeTypePerConcreteClassStrategy());
     
      classDescriptor = mapper.getClassDescriptorByClass(AnotherDescendant.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertFalse("Interface is  an interface", classDescriptor.isInterface());
      assertTrue("AnotherDescendant  has not a discriminator", classDescriptor.hasDiscriminator());
      assertEquals("Invalid number of implemented interface", classDescriptor.getImplements().size(), 1);
      assertEquals("Invalid  interface name", classDescriptor.getImplements().iterator().next(), "org.apache.jackrabbit.ocm.testmodel.interfaces.Interface");
View Full Code Here

   */
  public void testInterfaceWithoutDiscriminator()
  {
    try {
      String[] files = {"./src/test/test-config/jcrmapping-inheritance.xml"};
      Mapper mapper = new DigesterMapperImpl(files);

      assertNotNull("Mapper is null", mapper);
      ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(CmsObject.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertTrue("CmsObject is not an interface", classDescriptor.isInterface());
      assertFalse("Interface  has a discriminator", classDescriptor.hasDiscriminator());
      String[] mixinTypes = classDescriptor.getJcrMixinTypes();
      assertEquals("Invalid mixin type for the interface",mixinTypes.length , 0);
      assertNull("The interface has an ancestor", classDescriptor.getSuperClassDescriptor());
      assertTrue("The interface has not implementation/descendant", classDescriptor.hasDescendants());
      Collection descendants = classDescriptor.getDescendantClassDescriptors();
      assertEquals("Invalid number of implementation/descendants", descendants.size(),3);     
      assertFalse("Invalid extend strategy", classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertTrue("Invalid extend strategy", classDescriptor.usesNodeTypePerConcreteClassStrategy());
     
     
      classDescriptor = mapper.getClassDescriptorByClass(Document.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertTrue("Document is not  an interface", classDescriptor.isInterface());
      assertFalse("Document  has a discriminator", classDescriptor.hasDiscriminator());
      assertEquals("Invalid number of implemented interface", classDescriptor.getImplements().size(), 0);     
      assertFalse("Invalid extend strategy", classDescriptor.usesNodeTypePerHierarchyStrategy());
      assertTrue("Invalid extend strategy", classDescriptor.usesNodeTypePerConcreteClassStrategy());
      descendants = classDescriptor.getDescendantClassDescriptors();     
      assertEquals("Invalid number of implementation/descendants", descendants.size(),1);
   

      classDescriptor = mapper.getClassDescriptorByClass(DocumentImpl.class);
      assertNotNull("Classdescriptor is null", classDescriptor);
      assertFalse("DocumentImpl is  an interface", classDescriptor.isInterface());
      assertFalse("DocumentImpl  has a discriminator", classDescriptor.hasDiscriminator());
      assertTrue("DocumentImpl has not interface", classDescriptor.hasInterfaces())
      assertEquals("Invalid number of implemented interface", classDescriptor.getImplements().size(), 1);       
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.