LOG4J2-1343 update test for new garbage-free Layout mechanism, logic for 
dealing with messages larger than buffer size changed


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/95c26139
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/95c26139
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/95c26139

Branch: refs/heads/LOG4J2-1356
Commit: 95c261395212c2896ac88f33d845df3cda934cc0
Parents: 8b7028a
Author: rpopma <[email protected]>
Authored: Thu Apr 7 03:09:30 2016 +0900
Committer: rpopma <[email protected]>
Committed: Thu Apr 7 03:09:30 2016 +0900

----------------------------------------------------------------------
 .../core/appender/RandomAccessFileManagerTest.java   | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/95c26139/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
index 07e8ab2..b048e8a 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
@@ -49,13 +49,14 @@ public class RandomAccessFileManagerTest {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final RandomAccessFileManager manager = new 
RandomAccessFileManager(raf, file.getName(), os, false,
                     RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, 
true);
+            
manager.setByteBufferDestination(manager.createByteBufferDestination(false));
 
             final int size = RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3;
             final byte[] data = new byte[size];
             manager.write(data); // no buffer overflow exception
 
-            // buffer is full but not flushed yet
-            assertEquals(RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 2, 
raf.length());
+            // all data is written if exceeds buffer size
+            assertEquals(RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3, 
raf.length());
         }}
 
     /**
@@ -70,16 +71,18 @@ public class RandomAccessFileManagerTest {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final RandomAccessFileManager manager = new 
RandomAccessFileManager(raf, file.getName(), os, false,
                     RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, 
true);
+            
manager.setByteBufferDestination(manager.createByteBufferDestination(false));
 
             final int size = RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3 + 
1;
             final byte[] data = new byte[size];
             manager.write(data); // no exception
-            assertEquals(RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3, 
raf.length());
+            // all data is written if exceeds buffer size
+            assertEquals(RandomAccessFileManager.DEFAULT_BUFFER_SIZE * 3 + 1, 
raf.length());
 
             manager.flush();
             assertEquals(size, raf.length()); // all data written to file now
         }}
-    
+
     @Test
     public void testConfigurableBufferSize() throws IOException {
         final File file = folder.newFile();
@@ -103,11 +106,13 @@ public class RandomAccessFileManagerTest {
             final int bufferSize = 1;
             final RandomAccessFileManager manager = new 
RandomAccessFileManager(raf, file.getName(), os, false,
                     bufferSize, null, null, true);
+            
manager.setByteBufferDestination(manager.createByteBufferDestination(false));
 
             final int size = bufferSize * 3 + 1;
             final byte[] data = new byte[size];
             manager.write(data); // no exception
-            assertEquals(bufferSize * 3, raf.length());
+            // all data is written if exceeds buffer size
+            assertEquals(bufferSize * 3 + 1, raf.length());
 
             manager.flush();
             assertEquals(size, raf.length()); // all data written to file now

Reply via email to