Examples of Atomic


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

      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 = this.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 = this.getQueryManager();
      filter = queryManager.createFilter(Atomic.class)
      filter.setScope("/");
View Full Code Here

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

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

      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 = this.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 = this.getQueryManager();
      filter = queryManager.createFilter(Atomic.class)
      filter.setScope("/");
View Full Code Here

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

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

        try {
      // --------------------------------------------------------------------------------
      // Create and store an object graph in the repository
      // --------------------------------------------------------------------------------

          Atomic atomic =  new Atomic();
          atomic.setPath("/source");
          atomic.setString("test atomic");
          ocm.insert(atomic);
          ocm.save();
     
      // --------------------------------------------------------------------------------
      // Copy the object
      // --------------------------------------------------------------------------------
          ocm.move("/source", "/result");

      // --------------------------------------------------------------------------------
      // Get the object
      // --------------------------------------------------------------------------------
      atomic = (Atomic) ocm.getObject("/result");
      assertNotNull("atomic is null", atomic);
      assertTrue("Invalid field a1", atomic.getString().equals("test atomic"));             

      assertFalse("Object with path /source still exists", ocm.objectExists("/source"));

      // --------------------------------------------------------------------------------
      // Check exceptions
View Full Code Here

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

        try {
      // --------------------------------------------------------------------------------
      // Create and store an object graph in the repository
      // --------------------------------------------------------------------------------

          Atomic atomic =  new Atomic();
          atomic.setPath("/source");
          atomic.setString("test atomic");
          ocm.insert(atomic);
          ocm.save();
     
      // --------------------------------------------------------------------------------
      // Copy the object
      // --------------------------------------------------------------------------------
          ocm.move("/source", "/result");

      // --------------------------------------------------------------------------------
      // Get the object
      // --------------------------------------------------------------------------------
      atomic = (Atomic) ocm.getObject("/result");
      assertNotNull("atomic is null", atomic);
      assertTrue("Invalid field a1", atomic.getString().equals("test atomic"));             

      assertFalse("Object with path /source still exists", ocm.objectExists("/source"));

      // --------------------------------------------------------------------------------
      // Check exceptions
View Full Code Here

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

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

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

          Date date = new Date();
          Calendar calendar = Calendar.getInstance();
            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            Atomic a = new Atomic();
            a.setPath("/test");
            a.setBooleanObject(new Boolean(true));
            a.setBooleanPrimitive(true);
            a.setIntegerObject(new Integer(100));
            a.setIntPrimitive(200);
            a.setString("Test String");
            a.setDate(date);
            a.setInt2boolean(true);
           
            byte[] content = "Test Byte".getBytes();
            a.setByteArray(content);
            a.setCalendar(calendar);
            a.setDoubleObject(new Double(2.12));
            a.setDoublePrimitive(1.23);
            long now = System.currentTimeMillis();
            a.setTimestamp(new Timestamp(now));
           
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Test Stream".getBytes());
            a.setInputStream(byteArrayInputStream);
            a.setNamedProperty("ocm:test");
            a.setPathProperty("/node1/node2");
            a.setUndefinedProperty("aStringData");
           
            ocm.insert(a);
            ocm.save();

            
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = null;
            a = (Atomic) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("Boolean object is null", a.getBooleanObject());
            assertTrue("Incorrect boolean object", a.getBooleanObject().booleanValue());
            assertTrue("Incorrect boolean primitive", a.isBooleanPrimitive());
            assertNotNull("Integer Object is null", a.getIntegerObject());
            assertTrue("Incorrect Integer object", a.getIntegerObject().intValue() == 100);
            assertTrue("Incorrect int primitive", a.getIntPrimitive() == 200);
            assertNotNull("String object is null", a.getString());
            assertTrue("Incorrect boolean object", a.getString().equals("Test String"));
            assertNotNull("Byte array object is null", a.getByteArray());
            assertTrue("Incorrect byte object", new String(a.getByteArray()).equals("Test Byte"));
           
            assertNotNull("date object is null", a.getDate());
            assertTrue("Invalid date", a.getDate().equals(date));           
            assertNotNull("calendar object is null", a.getCalendar());
           
            log.debug("Calendar : " + a.getCalendar().get(Calendar.YEAR) + "-" + a.getCalendar().get(Calendar.MONTH) + "-" + a.getCalendar().get(Calendar.DAY_OF_MONTH));
            assertTrue("Invalid calendar object", a.getCalendar().equals(calendar));
           
            assertNotNull("Double object is null", a.getDoubleObject());
            assertTrue("Incorrect double object", a.getDoubleObject().doubleValue() == 2.12);
            assertTrue("Incorrect double primitive", a.getDoublePrimitive() == 1.23);
           
            assertNotNull("Incorrect input stream primitive", a.getInputStream());
            assertNotNull("Incorrect timestamp", a.getTimestamp());
            assertTrue("Invalid timestamp value ", a.getTimestamp().getTime() == now);           
            assertTrue("Invalid int2boolean value ", a.isInt2boolean());
           
            assertTrue("Invalid namedProperty value ", a.getNamedProperty().equals("ocm:test"));
            assertTrue("Invalid pathProperty value ", a.getPathProperty().equals("/node1/node2"));
            assertTrue("Invalid undefinedProperty value ", ((String) a.getUndefinedProperty()).equals("aStringData"));
            // --------------------------------------------------------------------------------
            // Update the property "namedProperty" with an invalid value
            // --------------------------------------------------------------------------------           
            try
            {
               // update with an incorrect namespace - Should throws an exception
               a.setNamedProperty("unknown:test");              
               ocm.update(a);
               fail("Exception was not triggered with an invalid namespace");
               ocm.save();
            }
            catch (Exception e)
            {
              
               
            }
           
            // --------------------------------------------------------------------------------
            // Update the property "pathProperty" with an invalid value
            // --------------------------------------------------------------------------------           
            try
            {
               // update with an incorrect namespace - Should throws an exception
               a.setPathProperty("//node1");              
               ocm.update(a);
               fail("Exception was not triggered with an invalid path");
               ocm.save();
            }
            catch (Exception e)
            {
              
               
            }
           
            // --------------------------------------------------------------------------------
            // Update the property "undefinedProperty" with an invalid value
            // --------------------------------------------------------------------------------           
            a = null;
            a = (Atomic) ocm.getObject( "/test");

            a.setUndefinedProperty(new Double(1.2));
            ocm.update(a);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = null;
            a = (Atomic) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertTrue("Invalid undefinedProperty value ", ((Double) a.getUndefinedProperty()).doubleValue() == 1.2);
           
        }
        catch (Exception e)
        {
            e.printStackTrace();
View Full Code Here

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

      ObjectContentManager ocm = getObjectContentManager();
     
      for (int i = 1; i <= 100; 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.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.setString("Test String JCR " + i);
             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 ocm repository".getBytes());
           a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
           a.setString("Test String " + i);
        }
        ocm.insert(a);
       
       
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.