001    package org.apache.torque.mojo;
002    
003    import java.util.Collections;
004    import java.util.Comparator;
005    import java.util.Vector;
006    
007    import org.apache.torque.util.TransactionComparator;
008    import org.junit.Test;
009    import org.kuali.db.Transaction;
010    
011    public class TransactionComparatorTest {
012    
013            @Test
014            public void testComparator() {
015                    Comparator<Transaction> comparator = new TransactionComparator<Transaction>("ks-embedded-db");
016                    Vector<Transaction> transactions = new Vector<Transaction>();
017                    transactions.add(getTransaction("003.sql"));
018                    transactions.add(getTransaction("004.sql"));
019                    transactions.add(getTransaction("001.sql"));
020                    transactions.add(getTransaction("sql/oracle/ks-embedded-db.sql"));
021                    transactions.add(getTransaction("002.sql"));
022                    transactions.add(getTransaction("sql/oracle/ks-embedded-db-constraints.sql"));
023                    transactions.add(getTransaction("001.sql"));
024                    transactions.add(getTransaction("000.sql"));
025                    transactions.add(getTransaction("zzz000.sql"));
026                    Collections.sort(transactions, comparator);
027                    showTransactions(transactions);
028            }
029    
030            protected void showTransactions(Vector<Transaction> transactions) {
031                    for (Transaction t : transactions) {
032                            System.out.println(t.getResourceLocation());
033                    }
034            }
035    
036            protected Transaction getTransaction(String location) {
037                    Transaction t = new Transaction();
038                    t.setResourceLocation(location);
039                    return t;
040            }
041    }