View Javadoc

1   package org.apache.torque.mojo;
2   
3   import java.util.Collections;
4   import java.util.Comparator;
5   import java.util.Vector;
6   
7   import org.apache.torque.util.TransactionComparator;
8   import org.junit.Test;
9   import org.kuali.db.Transaction;
10  
11  public class TransactionComparatorTest {
12  
13  	@Test
14  	public void testComparator() {
15  		Comparator<Transaction> comparator = new TransactionComparator<Transaction>("ks-embedded-db");
16  		Vector<Transaction> transactions = new Vector<Transaction>();
17  		transactions.add(getTransaction("003.sql"));
18  		transactions.add(getTransaction("004.sql"));
19  		transactions.add(getTransaction("001.sql"));
20  		transactions.add(getTransaction("sql/oracle/ks-embedded-db.sql"));
21  		transactions.add(getTransaction("002.sql"));
22  		transactions.add(getTransaction("sql/oracle/ks-embedded-db-constraints.sql"));
23  		transactions.add(getTransaction("001.sql"));
24  		transactions.add(getTransaction("000.sql"));
25  		transactions.add(getTransaction("zzz000.sql"));
26  		Collections.sort(transactions, comparator);
27  		showTransactions(transactions);
28  	}
29  
30  	protected void showTransactions(Vector<Transaction> transactions) {
31  		for (Transaction t : transactions) {
32  			System.out.println(t.getResourceLocation());
33  		}
34  	}
35  
36  	protected Transaction getTransaction(String location) {
37  		Transaction t = new Transaction();
38  		t.setResourceLocation(location);
39  		return t;
40  	}
41  }