legacy testing web app

16 views
Skip to first unread message

ian godman

unread,
May 24, 2012, 9:48:30 AM5/24/12
to testng-users
I have to make changes to a web application that has zero unit tests.

So the first task is to provide unit tests that can be used to
regression test the changes.

I am using Maven and TestNG but have an problem.

The code required to lookup the data source via JNDI from within a
webapp running in Tomcat but I dont want to run the whole app just to
unit test a part of it - that would be integration testing which comes
later :)

I have been trying all kinds of methods to get the JNDI lookup to
work. Using for example

System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory");
System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1098");
java.rmi.registry.LocateRegistry.createRegistry(1098);
InitialContext ic = new InitialContext();

Reference ref = new Reference("javax.sql.DataSource",
"org.apache.commons.dbcp.BasicDataSourceFactory", null);
ref.add(new StringRefAddr("driverClassName",
"com.mysql.jdbc.Driver"));
ref.add(new StringRefAddr("url", "jdbc:mysql://127.0.0.1:3306/
xxxxxx"));
ref.add(new StringRefAddr("username", "xxxxxxxx"));
ref.add(new StringRefAddr("password", "xxxxxxxx"));
ic.bind("xxxxxxx", ref);


Here is get a timeout exception on the IP address of the DNS server
doing any lookup !

The code will run in Tomcat (its live) so I am thinking that may be
the way to go is runt he tests within tomcat so the question is how do
I start Tomcat on the Maven test phase and stop it when that phase
ends.

Any suggestions much appreciated, been beating my head against this
for some time.

Many thanks.

Krishnan Mahadevan

unread,
May 24, 2012, 2:10:59 PM5/24/12
to testng...@googlegroups.com

http://stackoverflow.com/questions/1681017/start-stop-tomcat-using-maven

Pls check if this helps. 
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.



--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
Reply all
Reply to author
Forward
0 new messages