1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.components.util;
18
19 import junit.framework.TestCase;
20
21 import org.apache.commons.pool.impl.GenericObjectPool;
22 import org.apache.jetspeed.components.datasource.BoundDBCPDatasourceComponent;
23 import org.apache.jetspeed.components.jndi.JNDIComponent;
24 import org.apache.jetspeed.components.jndi.TyrexJNDIComponent;
25
26 /***
27 * @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver </a>
28 *
29 */
30 public class DatasourceTestCase extends TestCase
31 {
32
33 protected BoundDBCPDatasourceComponent datasourceComponent;
34
35 protected JNDIComponent jndi;
36
37 /***
38 *
39 */
40 public DatasourceTestCase()
41 {
42 super();
43
44 }
45
46 /***
47 * @param arg0
48 */
49 public DatasourceTestCase(String arg0)
50 {
51 super(arg0);
52
53 }
54
55 /***
56 * @see junit.framework.TestCase#setUp()
57 */
58 protected void setUp() throws Exception
59 {
60 super.setUp();
61 jndi = new TyrexJNDIComponent();
62 String url = System.getProperty("org.apache.jetspeed.database.url");
63 String driver = System.getProperty("org.apache.jetspeed.database.driver");
64 String user = System.getProperty("org.apache.jetspeed.database.user");
65 String password = System.getProperty("org.apache.jetspeed.database.password");
66 datasourceComponent = new BoundDBCPDatasourceComponent(user, password, driver, url, 20, 5000,
67 GenericObjectPool.WHEN_EXHAUSTED_GROW, true, "jetspeed", jndi);
68 datasourceComponent.start();
69
70 }
71
72 /***
73 * @see junit.framework.TestCase#tearDown()
74 */
75 protected void tearDown() throws Exception
76 {
77 datasourceComponent.stop();
78 jndi.unbindFromCurrentThread();
79 super.tearDown();
80 }
81
82 }