1 18 package org.apache.activemq.kaha.impl.async; 19 20 import java.io.IOException ; 21 import java.util.ArrayList ; 22 import java.util.Collections ; 23 24 import org.apache.activemq.kaha.impl.async.Location; 25 import org.apache.activemq.kaha.impl.async.JournalFacade.RecordLocationFacade; 26 27 import junit.framework.TestCase; 28 29 34 public class LocationTest extends TestCase { 35 36 @SuppressWarnings ("unchecked") 37 synchronized public void testRecordLocationImplComparison() throws IOException { 38 Location l1 = new Location(); 39 l1.setDataFileId(0); 40 l1.setOffset(5); 41 Location l2 = new Location(l1); 42 l2.setOffset(10); 43 Location l3 = new Location(l2); 44 l3.setDataFileId(2); 45 l3.setOffset(0); 46 47 assertTrue( l1.compareTo(l2)<0 ); 48 49 ArrayList <RecordLocationFacade> l = new ArrayList <RecordLocationFacade>(); 51 l.add(new RecordLocationFacade(l2)); 52 l.add(new RecordLocationFacade(l3)); 53 l.add(new RecordLocationFacade(l1)); 54 Collections.sort(l); 55 56 System.out.println(l.get(0)); 58 assertSame( l.get(0).getLocation(), l1 ); 59 assertSame( l.get(1).getLocation(), l2 ); 60 assertSame( l.get(2).getLocation(), l3 ); 61 } 62 } 63 | Popular Tags |