Package org.apache.jackrabbit.ocm.testmodel

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


      ObjectContentManager ocm = getObjectContentManager();

      for (int i = 1; i <= 10; i++)
      {
        Atomic a = new Atomic();
        a.setPath("/test" + i);
        a.setBooleanObject(new Boolean(i % 2 == 0));
        a.setBooleanPrimitive(true);
        a.setIntegerObject(new Integer(100 * i));
        a.setIntPrimitive(200 + i);
        a.setString("Test String " + i);
        a.setDate(date);
        Calendar calendar = Calendar.getInstance();
        calendar.set(1976, 4, 20, 15, 40);
        a.setCalendar(calendar);
        a.setDoubleObject(new Double(2.12 + i));
        a.setDoublePrimitive(1.23 + i);
        long now = System.currentTimeMillis();
        a.setTimestamp(new Timestamp(now));
        if ((i % 2) == 0)
        {
          a.setByteArray("This is small object stored in a JCR repository".getBytes());
          a.setInputStream(new ByteArrayInputStream("Test inputstream".getBytes()));
        }
        else
        {
          a.setByteArray("This is small object stored in the repository".getBytes());
          a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
        }
        ocm.insert(a);

      }
      ocm.save();
View Full Code Here


      Query query = queryManager.createQuery(filter);
      Collection result = ocm.getObjects(query);
            assertEquals("Incorrect number of objects found", 10, result.size());

            // Get objects
            Atomic atomic = (Atomic) ocm.getObject( "/test[2]");
            assertNotNull("Object /test[2] not found", atomic);

            atomic = (Atomic) ocm.getObject( "/test[10]");
            assertNotNull("Object /test[2] not found", atomic);

            // Update the object
            atomic.setString("Modified Test String 10");
            ocm.update(atomic);
            ocm.save();

            // Query on the attribute "string"
            queryManager = ocm.getQueryManager();
      filter = queryManager.createFilter(Atomic.class)
      filter.addLike("string", "Modified%");     
      query = queryManager.createQuery(filter);
      result = ocm.getObjects(query);
      assertTrue("Incorrect number of objects found", result.size() == 1);

      atomic = (Atomic) ocm.getObject(query);
      assertNotNull("Object not found", atomic);
      assertTrue("Incorrect Object", atomic.getString().equals("Modified Test String 10"));
     
            // Delete all objects
            queryManager = ocm.getQueryManager();
      filter = queryManager.createFilter(Atomic.class)
      filter.setScope("/");
View Full Code Here

      ObjectContentManager ocm = getObjectContentManager();
     
     
      for (int i = 1; i <= 10; i++)
      {
        Atomic a = new Atomic();
        a.setPath("/test");
        a.setBooleanObject(new Boolean(i%2==0));
        a.setBooleanPrimitive(true);
        a.setIntegerObject(new Integer(100 * i));
        a.setIntPrimitive(200 + i);
        a.setString("Test String " + i);
        a.setDate(date);
        Calendar calendar = Calendar.getInstance();
        calendar.set(1976, 4, 20, 15, 40);
        a.setCalendar(calendar);
        a.setDoubleObject(new Double(2.12 + i));
        a.setDoublePrimitive(1.23 + i);
        long now = System.currentTimeMillis();
        a.setTimestamp(new Timestamp(now));
        if ((i % 2) == 0)
        {
             a.setByteArray("This is small object stored in a JCR repository".getBytes());
             a.setInputStream(new ByteArrayInputStream("Test inputstream".getBytes()));
        }
        else
        {
           a.setByteArray("This is small object stored in the repository".getBytes());
           a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
        }
        ocm.insert(a);
        if (i==1)
        {
            assertTrue("Invalid Path" , a.getPath().equals("/test") );
        }
        else
        {
          assertTrue("Invalid Path" , a.getPath().equals("/test" + "[" + i + "]") );
        }
       
       
      }
      ocm.save();
View Full Code Here

      ObjectContentManager ocm = getObjectContentManager();

      for (int i = 1; i <= 10; i++)
      {
        Atomic a = new Atomic();
        a.setPath("/test" + i);
        a.setBooleanObject(new Boolean(i % 2 == 0));
        a.setBooleanPrimitive(true);
        a.setIntegerObject(new Integer(100 * i));
        a.setIntPrimitive(200 + i);
        a.setString("Test String " + i);
        a.setDate(date);
        Calendar calendar = Calendar.getInstance();
        calendar.set(1976, 4, 20, 15, 40);
        a.setCalendar(calendar);
        a.setDoubleObject(new Double(2.12 + i));
        a.setDoublePrimitive(1.23 + i);
        long now = System.currentTimeMillis();
        a.setTimestamp(new Timestamp(now));
        if ((i % 2) == 0)
        {
          a.setByteArray("This is small object stored in a JCR repository".getBytes());
          a.setInputStream(new ByteArrayInputStream("Test inputstream".getBytes()));
        }
        else
        {
          a.setByteArray("This is small object stored in the repository".getBytes());
          a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
        }
        ocm.insert(a);

      }
      ocm.save();
View Full Code Here

TOP

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

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.