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