1 package org.apache.torque.util; 2 3 21 22 import junit.framework.TestCase; 23 24 31 public class QueryTest extends TestCase 32 { 33 34 38 public QueryTest(String arg0) 39 { 40 super(arg0); 41 } 42 43 46 public void testColumns() 47 { 48 String expected 49 = "SELECT tableA.column1, tableA.column2, tableB.column1 FROM "; 50 Query query = new Query(); 51 52 UniqueList columns = new UniqueList(); 53 columns.add("tableA.column1"); 54 columns.add("tableA.column2"); 55 columns.add("tableB.column1"); 56 query.setSelectClause(columns); 57 58 assertEquals(expected, query.toString()); 59 } 60 61 64 public void testToString() 65 { 66 String expected = "SELECT tableA.column1, tableA.column2, " 67 + "tableB.column1 FROM tableA, tableB WHERE tableA.A = tableB.A" 68 + " AND tableA.B = 1234"; 69 Query query = new Query(); 70 71 UniqueList columns = new UniqueList(); 72 columns.add("tableA.column1"); 73 columns.add("tableA.column2"); 74 columns.add("tableB.column1"); 75 query.setSelectClause(columns); 76 77 UniqueList tables = new UniqueList(); 78 tables.add(new Query.FromElement("tableA", null, null)); 79 tables.add(new Query.FromElement("tableB", null, null)); 80 query.setFromClause(tables); 81 82 UniqueList where = new UniqueList(); 83 where.add("tableA.A = tableB.A"); 84 where.add("tableA.B = 1234"); 85 query.setWhereClause(where); 86 87 assertEquals(expected, query.toString()); 88 } 89 } 90 | Popular Tags |