Package org.apache.jackrabbit.ocm.testmodel

Examples of org.apache.jackrabbit.ocm.testmodel.A



            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);
           
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");
           
            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");
           
           
            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
           
            a.setCollection(collection);
           
            ocm.insert(a);
            ocm.save();
           

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
           
            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));
           
            // --------------------------------------------------------------------------------
            // Lock the object
            // --------------------------------------------------------------------------------          
           
            Lock lock = ocm.lock("/test", true, false);
            assertTrue("the Lock owner is not correct", lock.getLockOwner().equals("superuser"));
           
            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertTrue("the object is not locked", ocm.isLocked("/test"));
           
            // --------------------------------------------------------------------------------
            // Unlock the object
            // --------------------------------------------------------------------------------          
            ocm.unlock("/test", lock.getLockToken());

            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));

            // --------------------------------------------------------------------------------
            // Lock & update
            // --------------------------------------------------------------------------------
            lock = ocm.lock("/test", true, false);
            a = (A) ocm.getObject("/test");
            a.setA1("new a1 Value");
            ocm.update(a);
            ocm.save();
            ocm.unlock("/test", lock.getLockToken());
           
           
View Full Code Here



            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);
           
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");
           
            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");
           
           
            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
           
            a.setCollection(collection);
           
            ocm.insert(a);
            ocm.save();
           

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
           
            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));
           
            // --------------------------------------------------------------------------------
            // Lock the object
            // --------------------------------------------------------------------------------          
           
            Lock lock = ocm.lock("/test", true, false);
            assertTrue("the Lock owner is not correct", lock.getLockOwner().equals("superuser"));
           
            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertTrue("the object is not locked", ocm.isLocked("/test"));
           
            // --------------------------------------------------------------------------------
            // Unlock the object
            // --------------------------------------------------------------------------------          
            ocm.unlock("/test", lock.getLockToken());

            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));

            // --------------------------------------------------------------------------------
            // Lock & update
            // --------------------------------------------------------------------------------
            lock = ocm.lock("/test", true, false);
            a = (A) ocm.getObject("/test");
            a.setA1("new a1 Value");
            ocm.update(a);
            ocm.save();
            ocm.unlock("/test", lock.getLockToken());
           
           
View Full Code Here

      try
      {
        // ------------------------------------------------------------------------
        // Create a main object (a) with a null attribute (A.b)
        // ------------------------------------------------------------------------       
      A a = new A();
      a.setPath("/test");
      a.setA1("a1");
      ocm.insert(a);
      ocm.save();
     
        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNull("attribute is not null", a.getB());
     
      B b = new B();
      b.setB1("b1");
      b.setB2("b2");
      a.setB(b);
     
      ocm.update(a);
      ocm.save();

        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNotNull("attribute is null", a.getB());
     
        // ------------------------------------------------------------------------
      // Remove object
        // ------------------------------------------------------------------------     
      ocm.remove("/test");
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object with a null collection field
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");              
           
            ocm.insert(a);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());
           
            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");
           
            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");
           
           
            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
           
            a.setCollection(collection);
           
            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect collection size", a.getCollection().size() == 3);
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
           
            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setCollection(null);
            ocm.update(a);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());
           
            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------          
            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);        
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");
           
            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");
           
           
            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
           
            a.setCollection(collection);
           
            ocm.insert(a);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect a.collection size", 3, a.getCollection().size());
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
           
            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            c1 = new C();
            c1.setId("new first");
            c1.setName("First Element");
           
            c2 = new C();
            c2.setId("new second");
            c2.setName("Second Element");
           
            collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            a.setCollection(collection);
           
            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect collection size", a.getCollection().size() == 2);
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("new first"));
           
            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------          
            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);        
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");
           
            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");
           
           
            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
           
            a.setCollection(collection);
           
            ocm.insert(a);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect a.collection size", 3, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());
           
            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c4 = new C();
            c4.setId("Fourth");
            c4.setName("Fourth Element");
               
            collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
            collection.add(c4);
            a.setCollection(collection);
           
            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect collection size", 4, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());
           
        }
        catch (Exception e)
        {
            e.printStackTrace();
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object with a null collection field
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");

            ocm.insert(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect collection size", a.getCollection().size() == 3);
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setCollection(null);
            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());

            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------
            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect a.collection size", 3, a.getCollection().size());
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            c1 = new C();
            c1.setId("new first");
            c1.setName("First Element");

            c2 = new C();
            c2.setId("new second");
            c2.setName("Second Element");

            collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            a.setCollection(collection);

            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect collection size", a.getCollection().size() == 2);
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("new first"));

            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------
            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);
View Full Code Here

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect a.collection size", 3, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c4 = new C();
            c4.setId("Fourth");
            c4.setName("Fourth Element");

            collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
            collection.add(c4);
            a.setCollection(collection);

            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect collection size", 4, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());

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

          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object with a null collection field
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");

            ocm.insert(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect collection size", a.getCollection().size() == 3);
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setCollection(null);
            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNull("a.collection is not null", a.getCollection());

            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------
            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.testmodel.A

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.