any interest in spring bean slim runner

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

any interest in spring bean slim runner

Gojko Adzic
Hi,

i'm thinking of building a slim variant that will not instantiate
fixtures by class name but by using spring bean names, and autowire them
properly. at the moment, i'm working on a project with lots of
spring-wired fixtures and the code is becoming to look silly. with fit
it is not that easy to rewire stuff but slim makes it easy, so i'm
thinking of moving to slim. is there any interest in the community for this?

gojko
Reply | Threaded
Open this post in threaded view
|

Re: any interest in spring bean slim runner

david sam-4
I was thinking on the similar lines . We have a framework of testworkflow in spring . And I was thinking of how to provide a test interface using the cool things of fit . But then I was thinking about the challenges of fixtures in integration with a spring framework and was proceeding on similar lines as of SLIM as its plain java . We like to see how you would approach this ..

--- In [hidden email], Gojko Adzic <gojko-yahoolist@...> wrote:

>
> Hi,
>
> i'm thinking of building a slim variant that will not instantiate
> fixtures by class name but by using spring bean names, and autowire them
> properly. at the moment, i'm working on a project with lots of
> spring-wired fixtures and the code is becoming to look silly. with fit
> it is not that easy to rewire stuff but slim makes it easy, so i'm
> thinking of moving to slim. is there any interest in the community for this?
>
> gojko
>


Reply | Threaded
Open this post in threaded view
|

Re: Re: any interest in spring bean slim runner

Lars Vonk
Hi,

I am using FitNesse for some time now, but haven't really had problems with
wiring Fit of Slim Fixtures with Spring beans.

My approach so far has always been:

Create a class containing the Spring context that looks something like this:

public class SpringContext {

    private static AutowireCapableBeanFactory beanFactory;
    private static ClassPathXmlApplicationContext xmlApplicationContext;

    private SpringContext(String applicationContextFile) {
        xmlApplicationContext = new
ClassPathXmlApplicationContext(applicationContextFile);
        xmlApplicationContext.registerShutdownHook();
        beanFactory = xmlApplicationContext.getAutowireCapableBeanFactory();
    }

    public static void init() {
        new SpringContext("classpath:/application-context.xml");
    }

    public static void wire(Object instance) {
        beanFactory.autowireBeanProperties(instance,
AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    }

    public static void close() {
        beanFactory = null;
        xmlApplicationContext.close();
        xmlApplicationContext = null;
    }

}

Then call the SpringContext.init() and the SpringContext.close() in the
setup and teardown of your pages. What I also did is to put these calls on
the toplevel Suite.Setup And TearDown so all child pages inherit it.

Then in your Fixtures you can say:

public class MyDriver {
  private MyRepository myRepository;

  public MyDriver() {
    SpringContext.wire(this);
  }

  public void setMyRepository(MyRepository myRepository) { this.myRepository
= myRepository}
}


With the above approach it doesn't really matter if you are using Fit or
Slim Fixtures.

-- Lars



On Sun, May 10, 2009 at 11:55 PM, David Sam <[hidden email]> wrote:

>
>
> I was thinking on the similar lines . We have a framework of testworkflow
> in spring . And I was thinking of how to provide a test interface using the
> cool things of fit . But then I was thinking about the challenges of
> fixtures in integration with a spring framework and was proceeding on
> similar lines as of SLIM as its plain java . We like to see how you would
> approach this ..
>
> --- In [hidden email] <fitnesse%40yahoogroups.com>, Gojko Adzic
> <gojko-yahoolist@...> wrote:
> >
> > Hi,
> >
> > i'm thinking of building a slim variant that will not instantiate
> > fixtures by class name but by using spring bean names, and autowire them
> > properly. at the moment, i'm working on a project with lots of
> > spring-wired fixtures and the code is becoming to look silly. with fit
> > it is not that easy to rewire stuff but slim makes it easy, so i'm
> > thinking of moving to slim. is there any interest in the community for
> this?
> >
> > gojko
> >
>
>  
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: any interest in spring bean slim runner

seema
This post has NOT been accepted by the mailing list yet.
Hi,

I am really interested to know how we can execute tests from Fitnesse using Spring. I was trying with below approach but it dint help me. could you please share your bean xml, fitnesse test, and all the methods that you are using for autowiring?


Thanks & Regards,
Seema