Author: clebert.suconic(a)jboss.com
Date: 2010-11-15 13:22:27 -0500 (Mon, 15 Nov 2010)
New Revision: 9888
Modified:
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
branches/Branch_New_Paging/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
Log:
Fixing tests
Modified:
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
---
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2010-11-15
01:38:36 UTC (rev 9887)
+++
branches/Branch_New_Paging/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2010-11-15
18:22:27 UTC (rev 9888)
@@ -654,6 +654,7 @@
// The current page is empty... which means we reached the end of the
pages
if (returnPage.getNumberOfMessages() == 0)
{
+ stopPaging();
returnPage.open();
returnPage.delete();
Modified:
branches/Branch_New_Paging/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
---
branches/Branch_New_Paging/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2010-11-15
01:38:36 UTC (rev 9887)
+++
branches/Branch_New_Paging/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java 2010-11-15
18:22:27 UTC (rev 9888)
@@ -222,7 +222,7 @@
storeImpl.start();
- Assert.assertEquals(2, storeImpl.getNumberOfPages());
+ Assert.assertEquals(1, storeImpl.getNumberOfPages());
}
@@ -358,6 +358,8 @@
for (int pageNr = 0; pageNr < 2; pageNr++)
{
Page page = storeImpl.depage();
+
+ System.out.println("numberOfPages = " +
storeImpl.getNumberOfPages());
page.open();
@@ -370,9 +372,7 @@
for (int i = 0; i < 5; i++)
{
Assert.assertEquals(sequence++, msg.get(i).getMessage().getMessageID());
- UnitTestCase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i), msg.get(i)
-
.getMessage()
-
.getBodyBuffer());
+ UnitTestCase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i),
msg.get(i).getMessage().getBodyBuffer());
}
}
@@ -644,6 +644,8 @@
long lastMessageId = messageIdGenerator.incrementAndGet();
ServerMessage lastMsg = createMessage(lastMessageId, storeImpl, destination,
createRandomBuffer(lastMessageId, 5));
+
+ storeImpl2.forceAnotherPage();
storeImpl2.page(lastMsg, new RoutingContextImpl(null));
buffers2.put(lastMessageId, lastMsg);
@@ -691,6 +693,46 @@
Assert.assertEquals(0, storeImpl.getAddressSize());
}
+ public void testRestartPage() throws Throwable
+ {
+ clearData();
+ SequentialFileFactory factory = new NIOSequentialFileFactory(this.getPageDir());
+
+ PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
+
+ final int MAX_SIZE = 1024 * 10;
+
+ AddressSettings settings = new AddressSettings();
+ settings.setPageSizeBytes(MAX_SIZE);
+ settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
+
+ final TestSupportPageStore storeImpl = new
PagingStoreImpl(PagingStoreImplTest.destinationTestName,
+ createMockManager(),
+
createStorageManagerMock(),
+ createPostOfficeMock(),
+ factory,
+ storeFactory,
+ new
SimpleString("test"),
+ settings,
+ getExecutorFactory(),
+ true);
+
+ storeImpl.start();
+
+ Assert.assertEquals(0, storeImpl.getNumberOfPages());
+
+ // Marked the store to be paged
+ storeImpl.startPaging();
+
+ storeImpl.depage();
+
+ assertNull(storeImpl.getCurrentPage());
+
+ storeImpl.startPaging();
+
+ assertNotNull(storeImpl.getCurrentPage());
+ }
+
public void testOrderOnPaging() throws Throwable
{
clearData();
@@ -794,7 +836,7 @@
{
page.open();
List<PagedMessage> messages = page.read();
-
+
for (PagedMessage pgmsg : messages)
{
ServerMessage msg = pgmsg.getMessage();
@@ -803,13 +845,13 @@
assertEquals(msg.getMessageID(),
msg.getLongProperty("count").longValue());
}
-
+
page.close();
page.delete();
}
else
{
- System.out.println("Depaged!!!!");
+ System.out.println("Depaged!!!! numerOfMessages = " +
msgsRead + " of " + NUMBER_OF_MESSAGES);
Thread.sleep(500);
}
}
@@ -833,7 +875,7 @@
storeImpl.stop();
- for (Throwable e: errors)
+ for (Throwable e : errors)
{
throw e;
}
@@ -856,15 +898,15 @@
{
return new FakePostOffice();
}
-
+
private ExecutorFactory getExecutorFactory()
{
return new ExecutorFactory()
{
-
+
public Executor getExecutor()
{
- return executor;
+ return executor;
}
};
}
@@ -1047,7 +1089,7 @@
public void processReload()
{
// TODO Auto-generated method stub
-
+
}
}
@@ -1532,7 +1574,7 @@
public void storeCursorAcknowledge(long queueID, PagePosition position)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
@@ -1541,7 +1583,7 @@
public void storeCursorAcknowledgeTransactional(long txID, long queueID,
PagePosition position)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
@@ -1550,7 +1592,7 @@
public void deleteCursorAcknowledgeTransactional(long txID, long ackID) throws
Exception
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
@@ -1559,7 +1601,7 @@
public void updatePageTransaction(PageTransactionInfo pageTransaction, int depage)
throws Exception
{
// TODO Auto-generated method stub
-
+
}
}