Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 13549 invoked from network); 19 Feb 2003 18:42:22 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 19 Feb 2003 18:42:22 -0000 Received: (qmail 22785 invoked by uid 97); 19 Feb 2003 18:43:58 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 22778 invoked from network); 19 Feb 2003 18:43:58 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 19 Feb 2003 18:43:58 -0000 Received: (qmail 11954 invoked by uid 500); 19 Feb 2003 18:41:59 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 11933 invoked from network); 19 Feb 2003 18:41:58 -0000 Received: from www.shareowner.com (HELO shareowner.com) (66.46.24.147) by daedalus.apache.org with SMTP; 19 Feb 2003 18:41:58 -0000 Received: from exchange.int.shareowner.com (gw.shareowner.com [66.46.24.163]) by shareowner.com (8.11.6/8.11.6) with ESMTP id h1JIPpc08956 for ; Wed, 19 Feb 2003 13:25:51 -0500 Received: by exchange.int.shareowner.com with Internet Mail Service (5.5.2653.19) id ; Wed, 19 Feb 2003 13:41:57 -0500 Message-ID: From: pqin@shareowner.com To: tomcat-user@jakarta.apache.org Subject: RE: How To Unit Testing Tomcat Datasource Date: Wed, 19 Feb 2003 13:41:48 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2D846.8FA041B0" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C2D846.8FA041B0 Content-Type: text/plain No idea about JBoss. Tomcat's JNDI is not a real directory service but a "simulation". Look at struts' test suites. C:\jakarta-struts-1.1-b3-src\src\test\org\apache\struts\action Class TestActionServlet might be helpful. Regards, PQ "This Guy Thinks He Knows Everything" "This Guy Thinks He Knows What He Is Doing" -----Original Message----- From: Haytham Samad [mailto:haytham@speakeasy.net] Sent: February 19, 2003 1:30 PM To: Tomcat Users List Subject: RE: How To Unit Testing Tomcat Datasource PQ, Thanks for the reply. I actually use that in my factory class to connect to JNDI, get the datasource and use it to create connections for my database specific DAO implementations by calling getConnection(). In any case, I am running this code external to Tomcat. So the actual JDNI resource is in TOmcat but I am testing the DAO code externally using a JUnit TestCases. I guess the big question is, can I access JNDI resources in Tomcat from external code (not deployed in tomcat)? If so, are there any properties I need to set to be able to access Tomcat's JNDI resources: Like ctx.INITIAL_CONTEXT_FACTORY, ctx.PROVIDER_URL, etc. This can be done with JBoss for example. If so, what are the values used (I have not seen any documentation on this anywhere)? Thanks, Haytham -----Original Message----- From: pqin@shareowner.com [mailto:pqin@shareowner.com] Sent: Wednesday, February 19, 2003 12:14 PM To: tomcat-user@jakarta.apache.org Subject: RE: How To Unit Testing Tomcat Datasource Always use java:comp/env/yourdatasource Regards, PQ "This Guy Thinks He Knows Everything" "This Guy Thinks He Knows What He Is Doing" -----Original Message----- From: Haytham Samad [mailto:haytham@speakeasy.net] Sent: February 19, 2003 1:13 PM To: Tomcat Users List Subject: How To Unit Testing Tomcat Datasource I have set up a datasource in Tomcat's server.xml using dbcp. It works fine, I get connections connect to the database, etc. Now, I am in the process of putting together quite a bit of DAO code and would like to unit test each call as I am going through the coding using my JUnit tests. How can I connect to Tomcat's JNDI and get a reference to the datasource there to pass to the classes I am testing? Or should I just rework my test code to just create a connection from the DriverManager and go from there? Anybody doing anything like this with suggestions? I appreciate any help.... BTW: I tried to connect to Tomcat's JDNI using the InitialContext and that did not work because I could not get a datasource. Peace, Haytham --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org ------_=_NextPart_001_01C2D846.8FA041B0--