Author: shawkins
Date: 2010-06-24 15:41:21 -0400 (Thu, 24 Jun 2010)
New Revision: 2296
Modified:
branches/7.0.x/engine/src/main/java/org/teiid/common/buffer/FileStore.java
branches/7.0.x/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java
Log:
TEIID-913 fix to the filestoreoutputstream to implement flush, which is needed for proper
processing of xmldocument models.
Modified: branches/7.0.x/engine/src/main/java/org/teiid/common/buffer/FileStore.java
===================================================================
--- branches/7.0.x/engine/src/main/java/org/teiid/common/buffer/FileStore.java 2010-06-24
17:36:11 UTC (rev 2295)
+++ branches/7.0.x/engine/src/main/java/org/teiid/common/buffer/FileStore.java 2010-06-24
19:41:21 UTC (rev 2296)
@@ -105,12 +105,17 @@
}
@Override
- public void close() throws IOException {
+ public void flush() throws IOException {
if (bytesWritten) {
flushBuffer();
}
}
+ @Override
+ public void close() throws IOException {
+ flush();
+ }
+
}
static class CleanupReference extends PhantomReference<Object> {
Modified:
branches/7.0.x/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java
===================================================================
---
branches/7.0.x/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java 2010-06-24
17:36:11 UTC (rev 2295)
+++
branches/7.0.x/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java 2010-06-24
19:41:21 UTC (rev 2296)
@@ -33,11 +33,12 @@
import org.junit.Test;
import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.StorageManager;
+import org.teiid.common.buffer.FileStore.FileStoreOutputStream;
import org.teiid.common.buffer.impl.FileStorageManager;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.UnitTestUtil;
-
+@SuppressWarnings("nls")
public class TestFileStorageManager {
public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles,
String dir) throws TeiidComponentException {
@@ -81,6 +82,16 @@
assertEquals(0, cache.size());
}
+
+ @Test public void testFlush() throws Exception {
+ FileStorageManager sm = getStorageManager(null, null, null);
+ FileStore store = sm.createFileStore("0");
+ FileStoreOutputStream fsos = store.createOutputStream(2);
+ fsos.write(new byte[3]);
+ fsos.write(1);
+ fsos.flush();
+ assertEquals(0, fsos.getCount());
+ }
static Random r = new Random();