Package org.exoplatform.services.jcr.core.value

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


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

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = exv.getLength() + 20;

      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


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

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

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

      exv.setLength(pos);

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

      if ((fmemAfter - fmem) >= pos)
         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, 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

      testRoot.setProperty(pname, new ByteArrayInputStream(new byte[]{}));

      testRoot.save();

      // change after save
      EditableBinaryValue newexv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();
      long pos = newexv.getLength() + 1024 * 1024 * 5;

      long tmem = Runtime.getRuntime().totalMemory();

      newexv.setLength(pos);

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

      long tmemAfter = Runtime.getRuntime().totalMemory();

      if ((tmemAfter - tmem) >= pos)
         log.warn("JVM total memory should not be increased on size of the new Value but does. Was " + tmem
            + " current " + tmemAfter);

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

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

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

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

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = exv.getLength() - (testFile.length() - 20);

      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

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

      EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
      long pos = exv.getLength() - 5;

      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

      dataNode.setProperty("jcr:lastModified", Calendar.getInstance());
      dataNode.setProperty("jcr:data", new ByteArrayInputStream(new byte[]{}));

      testRoot.save();

      EditableBinaryValue exv =
         (EditableBinaryValue)testRoot.getNode(name).getNode("jcr:content").getProperty("jcr:data").getValue();
      long pos = 1024 * 1024 * 5;

      exv.setLength(pos);

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

      // apply to the Property and save
      testRoot.getNode(name).getNode("jcr:content").getProperty("jcr:data").setValue(exv);
      testRoot.save();
   }
View Full Code Here

      // create property, prepare the data to be readed
      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;

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

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

      // read partial
      exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      long res = exv.read(baos, 5, pos + 2); // read 'date#' bytes

      String expected = update1String.substring(2, 7);

      assertEquals(expected.length() + " bytes must be read", expected.length(), res);

      assertEquals("Readed content not equals to expected", expected, new String(baos.toByteArray()));

      // next read
      baos = new ByteArrayOutputStream();
      res = exv.read(baos, 3, pos + 1); // read 'pda' bytes

      expected = update1String.substring(1, 4);

      assertEquals(expected.length() + " bytes must be read", expected.length(), res);

View Full Code Here

      // create property, prepare the data to be readed
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new FileInputStream(testFile));

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

      String update1String = "update#1";

      long pos = testFile.length();

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

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

      // read partial greater the value size
      exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      long res = exv.read(baos, 1024, pos + 2); // read 'date#1' bytes

      String expected = update1String.substring(2);

      assertEquals(expected.length() + " bytes must be read", expected.length(), res);
View Full Code Here

      // create property, prepare the data to be readed
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new ByteArrayInputStream("short message".getBytes()));

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

      String update1String = "update#1";

      long pos = 6;

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

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

      // read partial
      exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      long res = exv.read(baos, 5, pos + 2); // read 'date#' bytes

      String expected = update1String.substring(2, 7);

      assertEquals(expected.length() + " bytes must be read", expected.length(), res);
View Full Code Here

      // create property, prepare the data to be readed
      String pname = "file@" + testFile.getName();
      Property p = testRoot.setProperty(pname, new ByteArrayInputStream("short message".getBytes()));

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

      String update1String = "update#1";

      long pos = exv.getLength() + 1;

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

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

      // read partial greater the value size
      exv = (EditableBinaryValue)testRoot.getProperty(pname).getValue();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      long res = exv.read(baos, 1024, pos + 2); // read 'date#1' bytes

      String expected = update1String.substring(2);

      assertEquals(expected.length() + " bytes must be read", expected.length(), res);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.value.EditableBinaryValue

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.