Examples of EditableBinaryValue


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

      // 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();

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

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      // from begin
      long res = exv.read(baos, 0, 0);

      assertEquals("Zero bytes must be read", 0, res);

      assertEquals("Zero bytes must be read", 0, baos.size());

      // from middle
      baos = new ByteArrayOutputStream();

      res = exv.read(baos, 0, 5);

      assertEquals("Zero bytes must be read", 0, res);

      assertEquals("Zero bytes must be read", 0, baos.size());

      // out of end
      try
      {
         exv.read(baos, 0, exv.getLength() + 10);
         fail("The out-of-range exception should be thrown");
      }
      catch (IOException e)
      {
         // ok
View Full Code Here

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

      // 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();

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

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      // from begin
      long res = exv.read(baos, 0, 0);

      assertEquals("Zero bytes must be read", 0, res);

      assertEquals("Zero bytes must be read", 0, baos.size());

      // from middle
      baos = new ByteArrayOutputStream();

      res = exv.read(baos, 0, 1024 * 1024);

      assertEquals("Zero bytes must be read", 0, res);

      assertEquals("Zero bytes must be read", 0, baos.size());

      // out of end
      try
      {
         exv.read(baos, 0, exv.getLength() + 1024);
         fail("The out-of-range exception should be thrown");
      }
      catch (IOException e)
      {
         // ok
View Full Code Here

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

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

      testRoot.save();

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

      long pos = 0;

      int size = 61440;

      byte[] data = new byte[size];
      Random random = new Random();

      random.nextBytes(data);

      // update
      exv.update(new ByteArrayInputStream(data), size, pos);

      // transient, before the save
      try
      {
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.