tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@shareowner.com
Subject RE: How To Unit Testing Tomcat Datasource
Date Wed, 19 Feb 2003 18:41:48 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message