1 /***
2 * @(#)DataSourceFactoryTest.java
3 *
4 * JFoxSOAF, Service-Oriented Application Framework
5 *
6 * Copyright(c) JFoxSOAF Team
7 *
8 * Licensed under the GNU LGPL, Version 2.1 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.gnu.org/copyleft/lesser.html
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * For more information, please visit:
21 * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22 * http://www.huihoo.org/jfox/jfoxsoaf
23 */
24
25 package org.huihoo.jfox.soaf.services.jdbc;
26
27 import java.sql.SQLException;
28
29 import javax.sql.DataSource;
30
31 import org.huihoo.jfox.soaf.exception.DataSourceConfigurationException;
32
33 import junit.framework.TestCase;
34
35 /***
36 * JUnit test case for the
37 * {@link org.huihoo.jfox.soaf.services.jdbc.DataSourceFactory).
38 *
39 * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
40 * @version $Revision: 1.4 $ $Date: 2005/02/02 08:46:49 $
41 * @version Revision: 1.0
42 */
43
44 public class DataSourceFactoryTest extends TestCase {
45
46 /***
47 * @see TestCase#setUp()
48 */
49 protected void setUp() throws Exception {
50 super.setUp();
51 }
52
53 /***
54 * @see TestCase#tearDown()
55 */
56 protected void tearDown() throws Exception {
57 super.tearDown();
58 }
59
60 /***
61 * Test for method: DataSourceFactory()
62 *
63 * @see DataSourceFactory#DataSourceFactory()
64 */
65 public void testDataSourceFactory() {
66
67 }
68
69 /***
70 * Test for method: getInstance()
71 *
72 * @see DataSourceFactory#getInstance()
73 */
74 public void testGetInstance() {
75 try {
76 assertNotNull(DataSourceFactory.getFactory().getInstance());
77 } catch (DataSourceConfigurationException e) {
78 e.printStackTrace();
79 } catch (SQLException e) {
80 e.printStackTrace();
81 }
82 }
83
84 /***
85 * Test for method: removeAttribute()
86 *
87 * @see DataSourceFactory#removeAttribute()
88 */
89 public void testRemoveAttribute() {
90
91 }
92
93 /***
94 * Test for method: setAttribute()
95 *
96 * @see DataSourceFactory#setAttribute()
97 */
98 public void testSetAttribute() {
99
100 }
101
102 /***
103 * Test for method: getFactory()
104 *
105 * @see DataSourceFactory#getInstance()
106 */
107 public void testGetFactory() {
108 boolean result = false;
109 if (DataSourceFactory.getFactory() instanceof C3P0DataSourceFactory) {
110 result = true;
111 }
112 assertTrue(result);
113 }
114
115 /***
116 * Test for method: newFactory()
117 *
118 * @see DataSourceFactory#getInstance()
119 */
120 public void testNewFactory() {
121 boolean result = false;
122 String newClass = "org.huihoo.jfox.soaf.services.jdbc.C3P0DataSourceFactory";
123 if (DataSourceFactory.newFactory(newClass, this.getClass()
124 .getClassLoader()) instanceof C3P0DataSourceFactory) {
125 result = true;
126 }
127 assertTrue(result);
128 }
129
130 /***
131 * Test for method: getDataSource()
132 *
133 * @see DataSourceFactory#getInstance()
134 */
135 public void testGetDataSource() {
136 DataSource ds = DataSourceFactory.getDataSource();
137 assertNotNull(ds);
138 }
139
140 }