Adding functionality to Controller

"patelr08" <[email protected]> Tue, 04 Jan 2011 22:48:43 -0000
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
Hi all,

finally assigned my new task today and its a challenge!!!

So I have a controller - the framework in use is JSF which I know very little about.

The controller has quite a lot of methods triggered by the front end.

These services are not wired in using constructor or setter injection but by the use of a static class which wraps the ServletContext to get the service references.

Not sure if that's how JSF is meant to work but the bottom line is I can't instantiate the controller by itself.

The controller is part of an inheritance hierarchy where they have tried to reuse code but it looks a mess.

There are no unit tests whatsoever.

I want to do some refactoring but am fearful because there are no tests to fall back on and they have NO automated tests for the GUI(!).

I can see 2 possible approaches:

1. try and make the controller instantiable inside my junit class and pass in mock services (overriding the ones it gets from the context).

2. Try and capture the main business logic in a separate class that can be unit tested thoroughly and then reference it in the controller using the ServletContext. I'll have to manually test the controller to make sure it works with my new class by deploying.

I'm skimming through WEWLC now before I go to bed for ideas but it would be great to get some input from you guys.

Thanks

Rakesh



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/