View Javadoc

1   /**
2    * Copyright 2004-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }