KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > proxyfactory > test > DataSourceTestCase


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.proxyfactory.test;
23
24 import java.sql.Connection JavaDoc;
25
26 import javax.resource.spi.ConnectionManager JavaDoc;
27 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
28 import javax.sql.DataSource JavaDoc;
29
30 import junit.framework.Test;
31
32 import org.jboss.aop.metadata.SimpleMetaData;
33 import org.jboss.test.proxyfactory.AbstractProxyTest;
34 import org.jboss.test.proxyfactory.support.ConnectionFactoryInterceptor;
35 import org.jboss.test.proxyfactory.support.TestConnection;
36 import org.jboss.test.proxyfactory.support.TestConnectionManager;
37 import org.jboss.test.proxyfactory.support.TestManagedConnectionFactory;
38
39 /**
40  * DataSourceTestCase.
41  *
42  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
43  * @version $Revision: 41173 $
44  */

45 public class DataSourceTestCase extends AbstractProxyTest
46 {
47    public void testConnectionManager() throws Exception JavaDoc
48    {
49       ConnectionManager JavaDoc cm = new TestConnectionManager();
50       ManagedConnectionFactory JavaDoc mcf = new TestManagedConnectionFactory();
51       SimpleMetaData metadata = new SimpleMetaData();
52       
53       metadata.addMetaData(ConnectionFactoryInterceptor.CONNECTION_FACTORY, ConnectionFactoryInterceptor.CONNECTION_MANAGER, cm);
54       metadata.addMetaData(ConnectionFactoryInterceptor.CONNECTION_MANAGER, ConnectionFactoryInterceptor.MANAGED_CONNECTION_FACTORY, mcf);
55       DataSource JavaDoc ds = (DataSource JavaDoc) assertCreateHollowProxy(new Class JavaDoc[] { DataSource JavaDoc.class }, metadata, DataSource JavaDoc.class);
56       Connection JavaDoc c = ds.getConnection();
57       assertNotNull(c);
58       assertTrue(c instanceof TestConnection);
59       TestConnection tc = (TestConnection) c;
60       assertNotNull(tc.getManagedConnectionFactory());
61       assertTrue(mcf == tc.getManagedConnectionFactory());
62    }
63    
64    public static Test suite()
65    {
66       return suite(DataSourceTestCase.class);
67    }
68
69    public DataSourceTestCase(String JavaDoc name)
70    {
71       super(name);
72    }
73 }
74
Popular Tags