dcsimg
Junit cant access DAO of the application
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Brijesh_Jaggi
Posted On:   Thursday, June 1, 2006 06:02 AM

Hi , Guys . I was trying to write some junit testcases to for my application that is almost complete . But i am getting a strange error . I am using jboss 4.0 and oracle 9i . When i try and test the DAO using junit test class i get the following exception . javax.naming.NameNotFoundException: vldev not bound My oracle-ds.xml has the following entry java:vldev false My test class has the following code protected void setUp() throws Exception { super.setUp(); Properties properties = new Properti   More>>

Hi ,
Guys . I was trying to write some junit testcases to for my application that is almost complete . But i am getting a strange error .

I am using jboss 4.0 and oracle 9i .


When i try and test the DAO using junit test class i get the following exception .




javax.naming.NameNotFoundException: vldev not bound



My oracle-ds.xml has the following entry







java:vldev

false





My test class has the following code


protected void setUp() throws Exception {



super.setUp();


Properties properties = new Properties();

properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");



properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");



properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");


properties.put(Context.SECURITY_AUTHENTICATION,"none");


context = new InitialContext(properties);

userDAO = new UserDAO();
}







I tried to test run a sample method add(i1,i2) to test junit , it ran that with no errors . Some more configuration on the database has to be done that is not allowing junit to get connection to the databse . Any suggestions will be welcome .





assertEquals(3,userDAO.add(1,2));
// Works


assertEquals("",userDAO.getUser("Arvind")); throws exception

   <<Less

Re: Junit cant access DAO of the application

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, June 10, 2006 05:12 PM

Could it be maybe that you need to refer to it by some variant prefix, e.g. "java:comp/env/vldev" in the client? and/or change the oracle config, on the server, to just call it "vldev" instead of "java:vldev"? and maybe the server automatically prepends the namespace onto the name?



I get confused by this stuff too, trying to write portable client code that will run against different vendors' JNDI server implementations, with different prepended namespaces.
About | Sitemap | Contact