wood burning stoves*
The moose likes Testing and the fly likes j2ee testing for beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "j2ee testing for beginner" Watch "j2ee testing for beginner" New topic
Author

j2ee testing for beginner

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
After I completed a 20-class, 5-jsp, 1 servlet system, I found myself overwhelmed on how to test the whole thing. I am stuck even on testing individual components.

Any tips for new j2ee developer? (you can include ejb and web service on your comments.)

(I come from procedural programming background that is why I am a 'dummy' at testing this mentioned system.)

Will appreciate your comment.

(This is one of the 2 items I got stuck in this system; the other one is 'designing the system'.)
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I suspect this is an HTML-based web application we're talking about? If so, I'd suggest starting with looking into the JWebUnit library. JWebUnit is a library for simulating a web browser. In other words, you can tell it to "navigate" to a URL and then perform assertions against the HTML content the library received from the URL in question.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
Yes it is an html internet application; although it does jdbc and mq at the back.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jesus Angeles:
Yes it is an html internet application; although it does jdbc and mq at the back.

By "MQ" do you mean standard JMS or is your code using proprietary APIs from a specific vendor such as IBM (WebSphere MQ)?

If it's all standard interfaces, I might try the following setup:
  • Let the tests start an embedded HSQLDB instance (for JDBC)
  • Let the tests start an embedded ActiveMQ instance (for JMS)
  • Deploy the web application on an embedded Jetty instance (configured to connect to HSQLDB and ActiveMQ)
  • Exercise the user interface with JWebUnit
  • Exercise suitable portions of business logic directly since you're running within the same JVM as the system under test

  • Jesus Angeles
    Ranch Hand

    Joined: Feb 26, 2005
    Posts: 2053
    It is an IBM MQ type.
    Dan Walin
    Ranch Hand

    Joined: Nov 11, 2003
    Posts: 109
    I didn't notice what development environment you use. We use Rational Application Developer which includes Websphere Application Server. So to test, I can just take an HTML for, example, and click "Run on Server" and my local server starts up and runs the application. It also has testing capability built in for Web services so that you can just test a web service directly or start up the web service requester and then watch a TCPIP monitor that shows you the SOAP messages going between them. In otherwords, Rational has everything. Sounds like a commercial but I'm not sure how I would do this type of testing without it.
    Jesus Angeles
    Ranch Hand

    Joined: Feb 26, 2005
    Posts: 2053
    Originally posted by Dan Walin:
    In otherwords, Rational has everything. Sounds like a commercial but I'm not sure how I would do this type of testing without it.


    I am hoping my company upgrades from WSAD 5.X to RAD. (Being a government company who is trying to keep in budget so that the government wont outsource the whole IT department, upgrading is a little slow.)

    Are you able to do both unit test, and system test on RAD? So if you need unit test and system test only, RAD is all you need?

    I have seen RAD include stuff like code coverage.
    Dan Walin
    Ranch Hand

    Joined: Nov 11, 2003
    Posts: 109
    By "system test" I assume you mean connect to other components (other than the code I'm working on)? The answer to that is "yes" - at least with the limited scope of the things I develop. For example, we pull messages from a Websphere MQ queue on one server or write to DB2 on another server but the servlet we're testing can still run on the local WAS6 environment. You can create the necessary JNDI datasources locally to do that. You can even have another workstation call your servlet if you have it running and give the other person your ip address. I keep learning new things we can do all the time.
    Jesus Angeles
    Ranch Hand

    Joined: Feb 26, 2005
    Posts: 2053
    Originally posted by Dan Walin:
    By "system test" I assume you mean connect to other components (other than the code I'm working on)? The answer to that is "yes" - at least with the limited scope of the things I develop. For example, we pull messages from a Websphere MQ queue on one server or write to DB2 on another server but the servlet we're testing can still run on the local WAS6 environment. You can create the necessary JNDI datasources locally to do that. You can even have another workstation call your servlet if you have it running and give the other person your ip address. I keep learning new things we can do all the time.


    That is done also where I work. To lessen traffic in the test server, we are encouraged to use local server, while still connecting to the same DB2 and MQ system.

    Actually, I dont even know how to test. (I am familiar with procedural stuff.)
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: j2ee testing for beginner