[jboss-cvs] JBoss Messaging SVN: r4782 - trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 7 13:01:03 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-08-07 13:01:03 -0400 (Thu, 07 Aug 2008)
New Revision: 4782
Modified:
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
Log:
https://jira.jboss.org/jira/browse/JBMESSAGING-1408 - fixing test - pre-filling file, what would fix the test on slow computers (VMs)
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2008-08-07 12:16:17 UTC (rev 4781)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2008-08-07 17:01:03 UTC (rev 4782)
@@ -241,64 +241,79 @@
sf.open();
- String s1 = "orange";
- byte[] bytes1 = s1.getBytes("UTF-8");
- ByteBuffer bb1 = factory.wrapBuffer(bytes1);
-
- String s2 = "grapefruit";
- byte[] bytes2 = s1.getBytes("UTF-8");
- ByteBuffer bb2 = factory.wrapBuffer(bytes2);
-
- String s3 = "lemon";
- byte[] bytes3 = s3.getBytes("UTF-8");
- ByteBuffer bb3 = factory.wrapBuffer(bytes3);
-
- int bytesWritten = sf.write(bb1, true);
-
- assertEquals(bb1.limit(), bytesWritten);
-
- bytesWritten = sf.write(bb2, true);
-
- assertEquals(bb2.limit(), bytesWritten);
-
- bytesWritten = sf.write(bb3, true);
-
- assertEquals(bb3.limit(), bytesWritten);
-
- byte[] rbytes1 = new byte[bytes1.length];
-
- byte[] rbytes2 = new byte[bytes2.length];
-
- byte[] rbytes3 = new byte[bytes3.length];
-
- ByteBuffer rb1 = factory.newBuffer(rbytes1.length);
- ByteBuffer rb2 = factory.newBuffer(rbytes2.length);
- ByteBuffer rb3 = factory.newBuffer(rbytes3.length);
-
- sf.position(bb1.limit() + bb2.limit());
-
- int bytesRead = sf.read(rb3);
- assertEquals(rb3.limit(), bytesRead);
- rb3.rewind();
- rb3.get(rbytes3);
- assertEqualsByteArrays(bytes3, rbytes3);
-
- sf.position(rb1.limit());
-
- bytesRead = sf.read(rb2);
- assertEquals(rb2.limit(), bytesRead);
- rb2.get(rbytes2);
- assertEqualsByteArrays(bytes2, rbytes2);
-
- sf.position(0);
-
- bytesRead = sf.read(rb1);
- assertEquals(rb1.limit(), bytesRead);
- rb1.get(rbytes1);
-
- assertEqualsByteArrays(bytes1, rbytes1);
-
- sf.close();
+ try
+ {
+
+ sf.fill(0, 3 * 512, (byte)0);
+
+ String s1 = "orange";
+ byte[] bytes1 = s1.getBytes("UTF-8");
+ ByteBuffer bb1 = factory.wrapBuffer(bytes1);
+
+ String s2 = "grapefruit";
+ byte[] bytes2 = s1.getBytes("UTF-8");
+ ByteBuffer bb2 = factory.wrapBuffer(bytes2);
+
+ String s3 = "lemon";
+ byte[] bytes3 = s3.getBytes("UTF-8");
+ ByteBuffer bb3 = factory.wrapBuffer(bytes3);
+
+ int bytesWritten = sf.write(bb1, true);
+
+ assertEquals(bb1.limit(), bytesWritten);
+
+ bytesWritten = sf.write(bb2, true);
+
+ assertEquals(bb2.limit(), bytesWritten);
+
+ bytesWritten = sf.write(bb3, true);
+
+ assertEquals(bb3.limit(), bytesWritten);
+
+ byte[] rbytes1 = new byte[bytes1.length];
+
+ byte[] rbytes2 = new byte[bytes2.length];
+
+ byte[] rbytes3 = new byte[bytes3.length];
+
+ ByteBuffer rb1 = factory.newBuffer(rbytes1.length);
+ ByteBuffer rb2 = factory.newBuffer(rbytes2.length);
+ ByteBuffer rb3 = factory.newBuffer(rbytes3.length);
+
+ sf.position(bb1.limit() + bb2.limit());
+
+ int bytesRead = sf.read(rb3);
+ assertEquals(rb3.limit(), bytesRead);
+ rb3.rewind();
+ rb3.get(rbytes3);
+ assertEqualsByteArrays(bytes3, rbytes3);
+
+ sf.position(rb1.limit());
+
+ bytesRead = sf.read(rb2);
+ assertEquals(rb2.limit(), bytesRead);
+ rb2.get(rbytes2);
+ assertEqualsByteArrays(bytes2, rbytes2);
+
+ sf.position(0);
+
+ bytesRead = sf.read(rb1);
+ assertEquals(rb1.limit(), bytesRead);
+ rb1.get(rbytes1);
+
+ assertEqualsByteArrays(bytes1, rbytes1);
+
+ }
+ finally
+ {
+ try
+ {
+ sf.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
}
public void testOpenClose() throws Exception
@@ -307,6 +322,8 @@
sf.open();
+ sf.fill(0, 512, (byte)0);
+
String s1 = "cheesecake";
byte[] bytes1 = s1.getBytes("UTF-8");
ByteBuffer bb1 = factory.wrapBuffer(bytes1);
More information about the jboss-cvs-commits
mailing list