activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r785525 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java
Date Wed, 17 Jun 2009 09:31:56 GMT
Author: dejanb
Date: Wed Jun 17 09:31:54 2009
New Revision: 785525

URL: http://svn.apache.org/viewvc?rev=785525&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/AMQ-2292 - ReadOnlyAsyncDataManager NPE

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java?rev=785525&r1=785524&r2=785525&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ReadOnlyAsyncDataManager.java
Wed Jun 17 09:31:54 2009
@@ -48,6 +48,8 @@
         }
 
         started = true;
+
+        accessorPool = new DataFileAccessorPool(this);
                 
         ArrayList<File> files = new ArrayList<File>();
         for (File directory : dirs) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java?rev=785525&r1=785524&r2=785525&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/impl/async/JournalImplTest.java
Wed Jun 17 09:31:54 2009
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 
 import junit.framework.TestCase;
 
@@ -26,6 +27,8 @@
 import org.apache.activeio.packet.ByteArrayPacket;
 import org.apache.activeio.packet.Packet;
 import org.apache.activemq.kaha.impl.async.JournalFacade.RecordLocationFacade;
+import org.apache.activemq.kaha.impl.async.ReadOnlyAsyncDataManager;
+import org.apache.activemq.util.ByteSequence;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -126,6 +129,37 @@
         log.info(journal);
     }
 
+    public void testReadOnlyRead() throws InvalidRecordLocationException, InterruptedException,
IOException {
+    	
+    	Packet data1 = createPacket("Hello World 1");
+        RecordLocation location1 = journal.write(data1, false);
+        Packet data2 = createPacket("Hello World 2");
+        RecordLocation location2 = journal.write(data2, false);
+        Packet data3 = createPacket("Hello World 3");
+        RecordLocation location3 = journal.write(data3, false);
+        
+        Packet packet;
+        packet = journal.read(location2);
+        assertEquals(data2, packet);
+        packet = journal.read(location1);
+        assertEquals(data1, packet);
+        packet = journal.read(location3);
+        assertEquals(data3, packet);
+    	
+        ArrayList<File> data = new ArrayList<File>();
+        data.add(logDirectory);
+        ReadOnlyAsyncDataManager rodm = new ReadOnlyAsyncDataManager(data);
+        rodm.start();
+        try {
+            for (Location curr = rodm.getFirstLocation(); curr != null; curr = rodm.getNextLocation(curr))
{
+                ByteSequence bs = rodm.read(curr);
+                assertNotNull(bs);
+            }
+        } finally {
+    	    rodm.close();
+        }
+    }
+
     public void testCanReadFromArchivedLogFile() throws InvalidRecordLocationException, InterruptedException,
IOException {
 
         Packet data1 = createPacket("Hello World 1");



Mime
View raw message