01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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: protected BoundDBCPDatasourceComponent datasourceComponent;
33:
34: protected JNDIComponent jndi;
35:
36: /**
37: *
38: */
39: public DatasourceTestCase() {
40: super ();
41: // TODO Auto-generated constructor stub
42: }
43:
44: /**
45: * @param arg0
46: */
47: public DatasourceTestCase(String arg0) {
48: super (arg0);
49: // TODO Auto-generated constructor stub
50: }
51:
52: /**
53: * @see junit.framework.TestCase#setUp()
54: */
55: protected void setUp() throws Exception {
56: super .setUp();
57: jndi = new TyrexJNDIComponent();
58: String url = System
59: .getProperty("org.apache.jetspeed.database.url");
60: String driver = System
61: .getProperty("org.apache.jetspeed.database.driver");
62: String user = System
63: .getProperty("org.apache.jetspeed.database.user");
64: String password = System
65: .getProperty("org.apache.jetspeed.database.password");
66: datasourceComponent = new BoundDBCPDatasourceComponent(user,
67: password, driver, url, 20, 5000,
68: GenericObjectPool.WHEN_EXHAUSTED_GROW, true,
69: "jetspeed", jndi);
70: datasourceComponent.start();
71:
72: }
73:
74: /**
75: * @see junit.framework.TestCase#tearDown()
76: */
77: protected void tearDown() throws Exception {
78: datasourceComponent.stop();
79: jndi.unbindFromCurrentThread();
80: super.tearDown();
81: }
82:
83: }
|