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

Examples of org.exoplatform.services.jcr.impl.core.value.BinaryValue


   }

   public void testGetBinaryAsStream() throws RepositoryException, IOException
   {

      node.setProperty("stream", new BinaryValue("inputStream"));
      Value value = node.getProperty("stream").getValue();
      InputStream iS = value.getStream();
      byte[] bytes = new byte[iS.available()];
      iS.read(bytes);
      assertEquals("inputStream", new String(bytes));
View Full Code Here


   public void testGetBinaryAsString() throws RepositoryException, IOException
   {

      // System.out.println("STREAM>>>>>>");

      node.setProperty("stream", new BinaryValue("inputStream"));
      // System.out.println("STREAM>>>>>>");

      // log.debug("STREAM>>>>>>");
      Value value = node.getProperty("stream").getValue();
      assertEquals("inputStream", value.getString());
View Full Code Here

      Node node = root.addNode("node1", "nt:resource");
      NodeType type = node.getPrimaryNodeType();
      assertFalse(type.canAddChildNode("jcr:anyNode"));
      assertFalse(type.canAddChildNode("jcr:anyNode", "nt:base"));
      // assertTrue(type.canSetProperty("jcr:data", new BinaryValue("test")));
      assertFalse(type.canSetProperty("jcr:data", new BinaryValue[]{new BinaryValue("test")}));
      assertFalse(type.canSetProperty("jcr:notFound", new BinaryValue("test")));
      // [PN] 06.03.06 Row below commented
      // assertFalse(type.canSetProperty("jcr:data", new StringValue("test")));
      assertFalse(type.canRemoveItem("jcr:data"));
      assertFalse(type.canRemoveItem("jcr:notFound"));
View Full Code Here

         FileOutputStream out = new FileOutputStream(file);
         out.write(buf);
         out.close();

         FileInputStream fs1 = new FileInputStream(file);
         BinaryValue val = new BinaryValue(fs1, testFileCleaner, tempDirectory, maxFufferSize);
         InputStream str1 = val.getStream();
         assertNotNull(str1);

         // obj returned by getStream() is not the same as incoming stream
         assertNotSame(str1, fs1);

         // streams returned by subsequent call of val.getStream() are equals
         assertEquals(str1, val.getStream());

         // another one value using the same string
         BinaryValue val2 = new BinaryValue(fs1, testFileCleaner, tempDirectory, maxFufferSize);
         InputStream str2 = val2.getStream();

         // are not the same although created from same Stream
         assertNotSame(str1, str2);

         // stream already consumed
View Full Code Here

   }

   public void testNewBinaryValueFromString() throws Exception
   {

      BinaryValue val = new BinaryValue("string");
      InputStream str1 = val.getStream();
      assertNotNull(str1);
      // stream already consumed
      try
      {
         val.getString();
         fail("IllegalStateException should have been thrown");
      }
      catch (IllegalStateException e)
      {
      }

      BinaryValue val2 = new BinaryValue("stream");
      String str2 = val2.getString();
      assertNotNull(str2);
      // string already consumed
      try
      {
         val2.getStream();
         fail("IllegalStateException should have been thrown");
      }
      catch (IllegalStateException e)
      {
      }
View Full Code Here

      }

      property = root.getNode("childNode/childNode2/jcr:content").getProperty("jcr:data");

      assertEquals("this is the content", property.getString());
      Value val = new BinaryValue("this is the NEW content");
      node = root.getNode("childNode/childNode2/jcr:content");
      node.setProperty("jcr:data", val);
      // property.setValue(val);

      node = root.getNode("childNode");
      session.save();
      root = repository.login(credentials, WORKSPACE).getRootNode();
      // System.out.println("------------------");
      property = root.getNode("childNode/childNode2/jcr:content").getProperty("jcr:data");

      assertEquals("this is the NEW content", property.getString());

      session = (SessionImpl)repository.login(credentials, WORKSPACE);
      root = session.getRootNode();
      node = root.getNode("childNode");
      assertEquals(node.toString(), root.getNode("childNode").toString());

      // not allowed!
      // root.getNode("childNode/childNode2/jcr:content").setProperty("myapp:temp",
      // new
      // StringValue("Temp"));

      Session session2 = repository.login(credentials, WORKSPACE);
      Node root2 = session2.getRootNode();
      Node node2 = root2.getNode("childNode/childNode2/jcr:content");
      node2.setProperty("jcr:data", new BinaryValue("Temp"));
      session2.save();

      session.refresh(false);

      root = session.getRootNode();
View Full Code Here

      }
   }

   public void testGetStream() throws RepositoryException, IOException
   {
      Value value = new BinaryValue(new String("inputStream"));
      InputStream iS = value.getStream();
      int aval = iS.available();
      byte[] bytes = new byte[iS.available()];
      iS.read(bytes);
      assertEquals("inputStream", new String(bytes));

      // assertEquals(aval, value.getStream().available());
      assertEquals(aval, bytes.length);

      value = session.getValueFactory().createValue("text");
      iS = value.getStream();
      bytes = new byte[2];
      iS.read(bytes);
      assertEquals("te", new String(bytes));
      // Once a Value object has been read once using getStream(),
      // all subsequent calls to getStream() will return the same stream object.
      iS = value.getStream();
      bytes = new byte[2];
      iS.read(bytes);
      assertEquals("xt", new String(bytes));

   }
View Full Code Here

      Node file = root.addNode("childNode", "nt:folder").addNode("childNode2", "nt:file");

      Node contentNode = file.addNode("jcr:content", "nt:resource");
      try
      {
         Value value = new BinaryValue("this is the content");
         contentNode.setProperty("jcr:data", value);
         contentNode.setProperty("jcr:mimeType", "application/octet-stream");
      }
      catch (IOException e)
      {
View Full Code Here

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

      BinaryValue exv = (BinaryValue)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

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

      testRoot.save();

      BinaryValue exv = (BinaryValue)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

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.value.BinaryValue

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.