View Javadoc

1   
2   package oscon2006.common;
3   
4   
5   import java.lang.reflect.*;
6   import java.sql.*;
7   import java.util.ArrayList;
8   import java.util.Date;
9   import java.util.Calendar;
10  import java.util.List;
11  import java.math.*;
12  import java.net.*;
13  import javax.swing.*;
14  import javax.swing.table.*;
15  
16  import oscon2006.mock.MockResultSet;
17  import oscon2006.mock.MockTableModel;
18  
19  
20  import com.healthmarketscience.jackcess.DataType;
21  import com.healthmarketscience.jackcess.Database;
22  import com.healthmarketscience.jackcess.Table;
23  
24  import java.io.*;
25  
26  public class TestUtil
27  {
28  	
29  	static public TableModel createTableModel(int rows)
30  	{
31  	      return new MockTableModel(rows);
32  	}
33  	
34  	static public ResultSet createResultSet(int rowCount)
35  	{
36  		return new MockResultSet(rowCount);
37  	}
38  
39  	static public File getMdbFile()
40  	{
41  		File mdbFile = new File("test.mdb");
42  		mdbFile.delete();
43  		
44  		try
45  		{
46  			Database db = Database.create(mdbFile);
47  			
48  			List<com.healthmarketscience.jackcess.Column> columns = new ArrayList<com.healthmarketscience.jackcess.Column>();
49  			
50  			com.healthmarketscience.jackcess.Column make = new com.healthmarketscience.jackcess.Column();
51  			make.setName("make");
52  			make.setType(DataType.TEXT);
53  			
54  			com.healthmarketscience.jackcess.Column model = new com.healthmarketscience.jackcess.Column();
55  			model.setName("model");
56  			model.setType(DataType.TEXT);
57  			
58  			columns.add(make);
59  			columns.add(model);
60  			
61  			db.createTable("cars", columns);
62  			
63  			Table t = db.getTable("cars");
64  			t.addRow(new Object[] { "Acura", "TL" });
65  			t.addRow(new Object[] { "Honda", "Accord" });
66  			t.addRow(new Object[] { "Toyota", "Prius" });
67  			
68  			db.close();
69  			
70  			return mdbFile;
71  		}
72  		catch (Exception ex)
73  		{
74  			throw new RuntimeException(ex);
75  		}
76  	}
77  }