1 2 3 Previous Next 96 Replies Latest reply: Jul 31, 2012 1:14 PM by Jakub Narloch RSS

GSoC - Arquillian Spring Integration

Aslak Knutsen Master

Extend Arquillian to support Spring testing (beans and MVC controllers)

 

Ref Mail:


There are a two different parts to this task. I can explain the first part, and Marius is probably a better person to explain the second.

  

Currently, we can test Spring in a EE deployed application by doing all the context/bean lookups etc manually or via a Spring to CDI bridge, but Arquillian has a SPI which is called TestEnricher[1]. What this does is to open up for injections into the TestClass instance.

 

e.g.

 

public class TestClass {

 

@Autowired

private Bean bean;

 

@Test

public void ....

}

 

So our SpringTestEnricher should simply scan the given TestClass for 'supported' annotations and do the ApplicationContext lookups. (unless Spring has some concept of non contextual injection where you can simply say, inject what ever you know into this 'instance').

 

Then, there is the DeployableContianer[2] implementation for Spring, another Arquillian SPI that is responsible for starting/stopping/deploying/undeploying Containers and Deployments. We have implementations of this for JBossAS, GLassFish, Tomcat, Jetty, WebLogic, WebSphere, OpenWebBeans, OpenEJB and Weld++. What this should do in the Spring case is basically accept a ShrinkWrap[3] Archive and 'convert' that into a Spring ApplicationContext.

 

ShrinkWrap is a library for creating in memory representations of resources, classes etc. It gives you the option to isolate your test environment from the full client classpath your test is running in. Micro deployments as we like to call them. Test isolation level.

 

 

We welcome Jakub Narloch to the Arquillian Familiy!

 

 

The work will be based out of this repository, fork and enjoy: https://github.com/arquillian/arquillian-container-spring

 

The two current tasks are :

 

https://issues.jboss.org/browse/ARQ-301 - Create a Spring framework integration (for non-embedded containers)

https://issues.jboss.org/browse/ARQ-219 - Implement an embedded Spring container

 

Jakub, I tried to assign the tasks to you, but I couldn't find you in Jira. You might need to login before I can do that..

 

 

For now I think we can keep an open dialog/discussion in this thread. But we start new threads as needed..

 


  • 1. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Thanks for warm welcome. I like Your enthusiasm :)

     

    I think that I understand Your idea but this is my first steps with Arquillian so currently I'm going thrugh the documentation and then planning to do some coding. After that I think i can come with some additional ideas so we could discuss them here.

     

    As for the JIRA I think that my account should work now.

  • 2. Re: GSoC - Arquillian Spring Integration
    Aslak Knutsen Master

    Brilliant, found you in Jira now and assigned you both tasks.

     

     

    A good starting point from a users perspective is the Guides

     

    The documentation on SPI is a bit low atm, but we have some work in progress that should help you some.

    Getting Started with the Containers SPI

     

    and

     

    Getting Started SPI

     

    And of cours browse some code in the other extensions and containers to see how they are done: https://github.com/arquillian/

  • 3. Re: GSoC - Arquillian Spring Integration
    Marius Bogoevici Expert

    Jakub,

     

    Thanks for your interest.

     

    To add to what Aslak has already said - the extent to which things can be done now is here: https://github.com/seam/spring/tree/develop/testsuite

     

    There are a few examples of what is done in Seam Spring for boostrapping Spring contexts. Obviously, accessing Spring instances needs to be streamlined, as they are currently accessed as CDI beans.

     

    Also for the second part, I think that we can get some awesomeness going on by simulating the doings of the DispatcherServlet. But that would be a more forward-looking goal.

  • 4. Re: GSoC - Arquillian Spring Integration
    Manuel Súarez Sánchez Newbie

    I´m interesting in this project but I don't know if one project and one student or maybe one project and few student work in it, someone can answer me this doubt¿?

     

  • 5. Re: GSoC - Arquillian Spring Integration
    Aslak Knutsen Master

    Manuel, it seems like that would be possible according to the GSoC FAQ:

     

    http://www.google-melange.com/gsoc/document/show/gsoc_program/google/gsoc2012/faqs#work_on_more

     

    9. Can a student work on more than one project?
    
    No, each participant may only work on one project and is only eligible for one stipend.
    
    10. Can a group apply for and work on a single proposal?
    
    No, only an individual may work on a given project. 
    
    11. What happens if two students are accepted to work on the same project, e.g. from an organization's Ideas list?
    
    That's fine, a little duplication is par for the course in open source.
    

     

    You're not applying as a group, but as two individuals, so I guess #11 covers that.

     

    I don't see a point of creating the same project twice tho, and not sure if the task is big enough for two studens to work on.

    What do you think Marius, would it make sense to split the two phases pr student?

     

    Manuel, any of the other ideas that could interest you?

    e.g. "Add support for scriptable data sets" or "Define an object-oriented API for defining test data "

  • 6. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Hi,

     

    During the weekend I went through the documentation, set up my dev environment and also build the Arquilian from source and run some test code.

    I think I could start working on proposal for SpringTestEnricher and see where I can get from here.

  • 7. Re: GSoC - Arquillian Spring Integration
    Manuel Súarez Sánchez Newbie

    Thanks for the information !!

     

    At the moment m doing business practices and In my company I work with Java, Spring, Jboss and Junit(Beans and MVC Controllers). I prefer to work in these technologies but I don´t mind working on other projects that you mention. For me the most important is improve as developper and I think that here I can get it.

     

    Can you confirm that if I have any possibility that I can work in this project?

     

    If I have bad lucky, I can choose about the others projects that you mention I like working in "Define an object-oriented API for defining test data " although my level working working with data is low maybe It´s a good opportunity that I can improve it !!

     


  • 8. Re: GSoC - Arquillian Spring Integration
    Marius Bogoevici Expert

    Aslak,

     

    I am trying to think of the best way to split this, but I find it hard to split it in 2 chunks of approx 2 months of work. Let me try to see if  the scope can be expanded in a meaningful way.

     

    Also, welcoming Martin Zukal to the discussion, he has expressed an interest in this theme, as well as expanding Arquillian in general.

     

    Cheers,

    Marius

  • 9. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Hi again,

     

    I guess I could use a bit help here.

     

    Briefly what I had done so far.

    I had created a mvn module similar to the one from the TestEnrichers, with fallowing classes:

     

    SpringEnricherExtension - boostraps the enrichers

    SpringEnricherArchiveAppender - adds the required classes into the archive

    ApplicationContextProducer - creates the application context from the classpath file

    SpringEnricherRemoteExtension - configures evertything in the container

    SpringInjectionEnricher - does the actual work, and injects the dependencies

     

    Now as that part was simple and quite straitforward, I have problem with another issue.

    The assembled archive is missing the spring required dependencies, and as I recall You had mentioned the DeployableContianer interface which in my understanding should be helpfull here. Could please give me a hint how can I use it?

  • 10. Re: GSoC - Arquillian Spring Integration
    Aslak Knutsen Master

    Jakub, awesome!

     

    What does your SpringEnricherArchiveAppender do? Add only your extensions classes?

     

    Assuming this is a AuxilliaryArchiveAppender, this is normally where we would add the Spring classes as well.

     

    Either by resolving the artifact from maven:

    https://github.com/arquillian/arquillian-extension-seam2/blob/master/src/main/java/org/jboss/arquillian/seam2/client/Seam2ArchiveProcessor.java#L58

     

    or by recreating the artifact:

    https://github.com/arquillian/arquillian-core/blob/master/junit/container/src/main/java/org/jboss/arquillian/junit/container/JUnitDeploymentAppender.java

     

    AuxilliaryArchiveAppender and ApplicationArchiveProcessor are both part of the Packaging process. The combined sum of these SPI impls will be the runtime incontianer representation of your self. "how to represent your self in a Remote process"

     

    The final output of the Packaging process is what will be deployed to the DeployableContainer. e.g. If the user in his test defined to deploy a WebArchive, your AuxilliaryArhcive JavaArchive will be a part of that WebArchive as a library. So you don't have to handle the DeployableContainer in your extension.    

  • 11. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Thanks Aslak,

     

    Your assumptions are right that I had used CachedAuxilliaryArchiveAppender, but I didn't know how to resolve the dependencies and add them to the archive. I will gave it a try to both solutions and see if I can make the enricher working.

     

    I'm willing to deliver a working prototype within next 2-3 days.

  • 12. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Good news everyone!

     

    I had made the first step to enable "native" Spring IOC integration in Arquilian.

     

    I finished the mentioned test enrhicher that actually seams to work, although it has for now it's limitations (i.e. currently the Spring version isn't configurable, it requires a applicationContext.xml in classpath in other to initialize correcly - although the file can be in any subdirectory in the archive but the name of the file can not be altered).

     

    As for the pros:

    • It fully supports the spring annotations like: @Autowired, @Required, @Qualifier, @Service, @Component, @Repository and more (probobly all the annotations from java-based configuration like @Configuration and @Bean and eventually the JSR-330 annotations - but that need to be tested)
    • Also it handles the part of the bean lifecycle, for now only the initalization - so You can annotated a bean method with @PostConstruct and it will be executed in runtime

     

    I'm willing to share the code with You. I had been working on https://github.com/arquillian/arquillian-container-spring repository. So I going to make a patch and send that on gsoc@lists.jboss.org for now, later on I could attach it to JIRA if You wish.

     

    You will find there two mvn modules the actual enricher extension (that need to be build and installed in mvn repo) and the sample test suite that I used for testing with remote JBoss 6.

  • 13. Re: GSoC - Arquillian Spring Integration
    Marius Bogoevici Expert

    Jakub,

     

    This is awesome. I suggest you work in your own fork of the github repository, makes easier to share, review, trace and apply.

     

    Cheers and keep up!

     

    Marius

  • 14. Re: GSoC - Arquillian Spring Integration
    Jakub Narloch Novice

    Ok Marius,

     

    I will create the repository and move the code there.

1 2 3 Previous Next