1 /*
2 * Created on 25/Jan/2004
3 *
4 * To change the template for this generated file go to
5 * Window>Preferences>Java>Code Generation>Code and Comments
6 */
7 package replica.database.commands;
8
9 import java.sql.Connection;
10 import java.sql.SQLException;
11
12 import org.hsqldb.Server;
13 import org.springframework.jdbc.datasource.DriverManagerDataSource;
14
15 import replica.session.SessionManager;
16 import replica.session.support.SimpleSessionManager;
17 import junit.framework.TestCase;
18
19 /***
20 * @author Pedro
21 *
22 * To change the template for this generated type comment go to
23 * Window>Preferences>Java>Code Generation>Code and Comments
24 */
25 public class DatabaseCommandProcessorTest extends TestCase {
26
27 /***
28 * Constructor for DatabaseCommandProcessorTest.
29 * @param arg0
30 */
31 public DatabaseCommandProcessorTest(String arg0) {
32 super(arg0);
33 }
34
35 public void testGetConnection() {
36
37 Server server = new Server();
38 server.putPropertiesFromString("database.0=dbcomproctest");
39 server.setPort(9002);
40 server.start();
41
42 try{ Thread.sleep(500); }catch(InterruptedException e){ }
43
44 DatabaseCommandProcessor cp = new DatabaseCommandProcessor();
45
46 SessionManager sm = new SimpleSessionManager();
47 String sid = sm.createSession("sa",null);
48
49 cp.setSessionManager(sm);
50
51 // BasicDataSource dataSource = new BasicDataSource();
52 DriverManagerDataSource dataSource = new DriverManagerDataSource();
53 dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
54 dataSource.setUrl("jdbc:hsqldb:hsql://localhost:9002");
55
56 cp.setDataSource(dataSource);
57
58 try{
59 Connection c = cp.getConnection(sid);
60
61 assertNotNull(c);
62 }
63 catch(SQLException e){
64 e.printStackTrace();
65 fail(e.getMessage());
66 }
67 finally{
68 server.stop();
69 while( server.getState() != 16 /*ServerConstants.SERVER_STATE_SHUTDOWN*/ ){
70 try{ Thread.sleep(200); }catch(InterruptedException e){}
71 }
72 }
73 }
74
75 }
This page was automatically generated by Maven