Examples of EditableBinaryValue


Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();

      String update1String = "update#1";

      long pos = 1024 * 1024;

      // update
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos);

      // transient, before the save
      try
      {

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      testRoot.save();

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();

      String update1String = "update#1";

      long pos = 1024 * 1024;

      // update
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos);

      // transient, before the save
      try
      {

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      testRoot.setProperty(pname, new FileInputStream(testFile));

      testRoot.save();

      // get the property value
      EditableBinaryValue exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      String update1String = "update#1";

      long pos = 1024 * 1024;

      // update length bytes from the stream stating from the position in existed Value data
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos);

      // transient, before the save
      try
      {

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();

      String update1String = "update#1";

      long pos1 = 1024 * 1024;

      // update 1
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos1);

      // apply to the Property and save
      p.setValue(exv);
      testRoot.save();

      String update2String = "UPDATE#2";

      long pos2 = (1024 * 1024) + 5;

      // update 2
      exv.update(new ByteArrayInputStream(update2String.getBytes()), update2String.length(), pos2);
      // apply to the Property
      p.setValue(exv);

      // check the content from the first updated char to the last char of second
      // update
View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();

      String update1String = "update#1";

      long pos1 = 1024 * 1024;

      // update 1
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos1);

      // apply to the Property in another session and save
      Session s1 = repository.login(credentials);

      try
      {
         Node troot = s1.getRootNode().getNode(testRoot.getName());

         byte[] s1Content = "__string_stream__".getBytes();
         p = troot.setProperty(pname, new ByteArrayInputStream(s1Content));

         BufferedInputStream exvStream = new BufferedInputStream(exv.getStream());
         // fill the buffer from exv
         exvStream.mark((int)exv.getLength() + 1);
         while ((exvStream.read(new byte[2048])) >= 0)
         {
         }
         exvStream.reset();

         p.setValue(exv);
         troot.save();

         // check if we has the exv value
         compareStream(exvStream, troot.getProperty(pname).getStream(), 0, pos1, update1String.length());

         String update2String = "UPDATE#2";

         long pos2 = (1024 * 1024) + 5;

         // update 2
         exv.update(new ByteArrayInputStream(update2String.getBytes()), update2String.length(), pos2);
         // apply to the Property
         p.setValue(exv);

         // check the content from the first updated char to the last char of
         // second update
View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();

      String update1String = "update#1";

      long pos = 1024 * 1024;

      // update
      exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos);
      // apply to the Property and save
      p.setValue(exv);
      testRoot.save();

      // test if the rollbacked value isn't saved

      String update2String = "UPDATE#2";

      long pos2 = (1024 * 1024) + 5;

      // update 2
      exv.update(new ByteArrayInputStream(update2String.getBytes()), update2String.length(), pos2);
      // apply to the Property
      p.setValue(exv);

      testRoot.refresh(false); // rollback

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      String update1String = "update#1";
      long pos = 3 * 1024 * 1024;

      // update
      try
      {

         // exv.setLength(pos + 1);
         // assertEquals("Value data length must be increased ", pos + 1, exv.getLength());

         exv.update(new ByteArrayInputStream(update1String.getBytes()), update1String.length(), pos);

         // apply to the Property and save
         p.setValue(exv);
         testRoot.save();

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      String content = "short message";
      Property p = testRoot.setProperty(pname, new ByteArrayInputStream(content.getBytes()));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = exv.getLength() + 1024 * 1024 * 5;

      long fmem = Runtime.getRuntime().freeMemory();

      exv.update(new FileInputStream(testFile), testFile.length(), pos);

      long fmemAfter = Runtime.getRuntime().freeMemory();

      if ((fmemAfter - fmem) >= (pos + testFile.length()))
         log.warn("Free memory must not be increased on value of the new Value size but does. Was " + fmem
            + " current " + fmemAfter);

      assertEquals("Value data length must be increased ", pos + testFile.length(), exv.getLength());

      // apply to the Property and save
      p.setValue(exv);
      testRoot.save();

      EditableBinaryValue newexv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      assertEquals("Value data length must be increased ", pos + testFile.length(), newexv.getLength());

      // update inside the big data
      int npos = 5;
      newexv.update(new FileInputStream(testFile), testFile.length(), npos);

      // apply to the Property and save
      p.setValue(newexv);
      testRoot.save();

View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = 3 * 1024 * 1024;

      exv.setLength(pos);

      assertEquals("Value data length must be increased ", pos, exv.getLength());

      // apply to the Property and save
      p.setValue(exv);
      testRoot.save();

      EditableBinaryValue newexv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();
      assertEquals("Value data length must be increased ", pos, newexv.getLength());
   }
View Full Code Here

Examples of org.exoplatform.services.jcr.core.value.EditableBinaryValue

      // create property
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = 1024 * 1024;

      exv.setLength(pos);

      assertEquals("Value data length must be decreased ", pos, exv.getLength());

      // apply to the Property and save
      p.setValue(exv);
      testRoot.save();

      EditableBinaryValue newexv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();
      assertEquals("Value data length must be decreased ", pos, newexv.getLength());
   }
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.