Changeset 30221
- Timestamp:
- 02/18/08 14:43:02 (9 months ago)
- Files:
-
- org.nuxeo.ecm.core/branches/1.4/nuxeo-core-facade/src/test/java/org/nuxeo/ecm/core/api/TestLocalAPI.java (modified) (3 diffs)
- org.nuxeo.ecm.core/branches/1.4/nuxeo-core-jcr-connector/src/main/java/org/nuxeo/ecm/core/repository/jcr/JCRBlob.java (modified) (2 diffs)
- org.nuxeo.ecm.core/branches/1.4/nuxeo-core-jcr-connector/src/main/java/org/nuxeo/ecm/core/repository/jcr/JCRBlobInputStream.java (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
org.nuxeo.ecm.core/branches/1.4/nuxeo-core-facade/src/test/java/org/nuxeo/ecm/core/api/TestLocalAPI.java
r30097 r30221 20 20 package org.nuxeo.ecm.core.api; 21 21 22 import java.io.File; 23 import java.lang.reflect.Array; 22 24 import java.net.URL; 25 import java.util.Arrays; 23 26 import java.util.Calendar; 24 27 import java.util.List; … … 27 30 import org.nuxeo.ecm.core.api.impl.DocumentModelImpl; 28 31 import org.nuxeo.ecm.core.api.impl.VersionModelImpl; 32 import org.nuxeo.ecm.core.api.impl.blob.ByteArrayBlob; 33 import org.nuxeo.ecm.core.api.impl.blob.FileBlob; 29 34 import org.nuxeo.ecm.core.api.model.DocumentPart; 30 35 import org.nuxeo.ecm.core.api.model.Property; … … 328 333 } 329 334 335 public static byte[] createBytes(int size, byte val) { 336 byte[] bytes = new byte[size]; 337 Arrays.fill(bytes, val); 338 return bytes; 339 } 340 341 @SuppressWarnings("unchecked") 342 public void testLazyBlob() throws Exception { 343 DocumentModel root = getRootDocument(); 344 DocumentModel doc = new DocumentModelImpl(root.getPathAsString(), 345 "mydoc", "File"); 346 347 doc = remote.createDocument(doc); 348 byte[] bytes = createBytes(1024*1024, (byte)24); 349 350 Blob blob = new ByteArrayBlob(bytes); 351 doc.getPart("file").get("content").setValue(blob); 352 doc = remote.saveDocument(doc); 353 354 blob = (Blob)doc.getPart("file").get("content").getValue(); 355 assertTrue(Arrays.equals(bytes, blob.getByteArray())); 356 357 // test that reset works 358 blob.getStream().reset(); 359 360 blob = (Blob)doc.getPart("file").get("content").getValue(); 361 assertTrue(Arrays.equals(bytes, blob.getByteArray())); 362 363 } 364 365 330 366 // TODO: fix and reenable SF 2007/05/23 331 367 public void XXXtestProxy() throws Exception { org.nuxeo.ecm.core/branches/1.4/nuxeo-core-jcr-connector/src/main/java/org/nuxeo/ecm/core/repository/jcr/JCRBlob.java
r28924 r30221 194 194 } 195 195 196 public InputStream getStream() throws IOException { 196 /** 197 * Get the underlying stream. Use getStream() instead 198 * @return 199 * @throws IOException 200 */ 201 public InputStream _getStream() throws IOException { 197 202 try { 198 203 return node.getProperty(DATA).getStream(); … … 202 207 throw (IOException) (new IOException("could fetch stream").initCause(e)); 203 208 } 209 } 210 211 /** 212 * Do not return the jackrabbit stream directly. Wrap it inside a JCRBlobInputStream to be able to 213 * reset the stream and read it more than once. 214 * <p> 215 * Fix for NXP-2072 216 * @see JCRBlobInputStream 217 * @see NXP-2072 218 */ 219 public InputStream getStream() throws IOException { 220 return new JCRBlobInputStream(this); 204 221 } 205 222
