Author: shawkins
Date: 2010-12-24 16:23:50 -0500 (Fri, 24 Dec 2010)
New Revision: 2809
Modified:
tags/teiid-parent-7.3.0.Alpha2/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
tags/teiid-parent-7.3.0.Alpha2/engine/src/main/java/org/teiid/common/buffer/LobManager.java
tags/teiid-parent-7.3.0.Alpha2/engine/src/test/java/org/teiid/common/buffer/TestLobManager.java
Log:
updating with changes from trunk
Modified:
tags/teiid-parent-7.3.0.Alpha2/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
===================================================================
---
tags/teiid-parent-7.3.0.Alpha2/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2010-12-24
21:19:38 UTC (rev 2808)
+++
tags/teiid-parent-7.3.0.Alpha2/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2010-12-24
21:23:50 UTC (rev 2809)
@@ -95,7 +95,7 @@
return out.toByteArray();
}
- public static void write(final OutputStream out, final InputStream is, byte[]
l_buffer, int length) throws IOException {
+ public static int write(final OutputStream out, final InputStream is, byte[]
l_buffer, int length) throws IOException {
int writen = 0;
try {
int l_nbytes = 0; // Number of bytes read
@@ -107,6 +107,7 @@
out.write(l_buffer,0,l_nbytes);
writen += l_nbytes;
}
+ return writen;
} finally {
try {
is.close();
Modified:
tags/teiid-parent-7.3.0.Alpha2/engine/src/main/java/org/teiid/common/buffer/LobManager.java
===================================================================
---
tags/teiid-parent-7.3.0.Alpha2/engine/src/main/java/org/teiid/common/buffer/LobManager.java 2010-12-24
21:19:38 UTC (rev 2808)
+++
tags/teiid-parent-7.3.0.Alpha2/engine/src/main/java/org/teiid/common/buffer/LobManager.java 2010-12-24
21:23:50 UTC (rev 2809)
@@ -141,7 +141,7 @@
};
InputStream is = isf.getInputStream();
OutputStream fsos = store.createOutputStream();
- ObjectConverterUtil.write(fsos, is, bytes, -1);
+ length = ObjectConverterUtil.write(fsos, is, bytes, -1);
} catch (IOException e) {
throw new TeiidComponentException(e);
}
Modified:
tags/teiid-parent-7.3.0.Alpha2/engine/src/test/java/org/teiid/common/buffer/TestLobManager.java
===================================================================
---
tags/teiid-parent-7.3.0.Alpha2/engine/src/test/java/org/teiid/common/buffer/TestLobManager.java 2010-12-24
21:19:38 UTC (rev 2808)
+++
tags/teiid-parent-7.3.0.Alpha2/engine/src/test/java/org/teiid/common/buffer/TestLobManager.java 2010-12-24
21:23:50 UTC (rev 2809)
@@ -21,10 +21,8 @@
*/
package org.teiid.common.buffer;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
@@ -39,6 +37,7 @@
import org.teiid.core.types.ClobType;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.types.Streamable;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.ReaderInputStream;
@SuppressWarnings("nls")
@@ -79,20 +78,8 @@
lob = lobManager.getLobReference(blob.getReferenceStreamId());
assertTrue(lob.getClass().isAssignableFrom(BlobType.class));
BlobType blobRead = (BlobType)lob;
- assertTrue(Arrays.equals(read(blob.getBinaryStream()),
read(blobRead.getBinaryStream())));
+ assertTrue(Arrays.equals(ObjectConverterUtil.convertToByteArray(blob.getBinaryStream()),
ObjectConverterUtil.convertToByteArray(blobRead.getBinaryStream())));
}
- private byte[] read(InputStream in) throws Exception {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] bytes = new byte[100];
- while (true) {
- int c = in.read(bytes, 0, 100);
- if (c == -1) {
- break;
- }
- out.write(c);
- }
- return out.toByteArray();
- }
}
Show replies by date