• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

testing a startup class in weblogic

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How do I do JUnit testing for a startup class in weblogic with methods public void setServices(T3ServicesDef services) and public String startup(String className, Hashtable args)
Thanks,
vijay
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, a couple of questions:
- Do you really need to test your startup class?
- Could you perhaps extract the functionality into a separate class (used by the startup class), which is easier to test.
Now, if you still need to test a method that takes complex objects as parameter, your best bet is often mock objects.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Testing is pretty easy if T3ServicesDef presents a small interface (i.e. if you don't invoke too many methods on it). I haven't written a startup class, so haven't looked at T3ServicesDef. If T3ServicesDef is an interface, just create mock object with something like EasyMock. If T3ServicesDef is a non-final class then just extend it to override the methods you'll be exercising in the test. If it is a final class then life is tougher. You'll need to have wrapper methods in your code that would have called on T3ServicesDef methods, but you override those wrapper methods in your test to exercise your startup code.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having written a number WebLogic Startup classes in the past I can say that Lasse's second suggestion is probably the best way to go. Extract the functionality of the Startup class into a separate class. This new class could then be tested easily outside of WebLogic. You also get the additional benefit that it would be easy to port the Startup class to a number of other J2EE Servers, which isn't usually necessary but never hurts.
 
vijay peyyala
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The second idea given by Lasse Koskela would be much easier for me. Thanks you all for helping me improve my work.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

How do we pass parameters to the startUp class in WebLogic 10+.
They have introduced the listeners.
But can we any way pass parameters to this listener.

Thanks,
reply
    Bookmark Topic Watch Topic
  • New Topic