Unit-testing Spring applications using Scala's Specs - spring

We have a large infrastructure that's highly dependent on Spring Framework. Recently I began writing code in Scala and test it using Specs. This is all great but at some point I need to use Spring-dependent features (Such as a HibernateDaoSupport-based DAO).
Has anyone managed to use the SpringJUnit4ClassRunner class to run Specs tests? Does anyone have a different direction as to how to achieve this goal?
Thanks

I've struggled with the class runner in a similarly awkward scenario once and then I created a MethodRule implementation called TemporarySpringContext that could also solve your problem I think.

Related

#WithMockUser and kotlin test

I'm a big fan of Kotlintest syntax and I'd like to know if it's possible to make it work with WebMvcTest. More particularly, I don't manage to annotate the test methods with #WithMockUser.
Does somebody know if it's feasible?
Thanks beforehand.
It's not something that is currently built into KotlinTest but there is a Spring module, so it should be fairly easy to create another extension that provides this.
This is the source for the spring module.
https://github.com/kotlintest/kotlintest/tree/master/kotlintest-samples/kotlintest-samples-spring

How to integrate Vaadin 7 with OSGi?

I want to integrate vaadin 7 with osgi but there is no longer any AbstractApplicationServlet class.
I've followed the integration using the vaadin bridge by Neil Bartlett https://github.com/njbartlett/VaadinOSGi.
I've tried using the VaadinServlet somehow but with no luck.
I've also searched for other solutions but found none.
Do you have any suggestions?
Thanks
Vaadin 7 has a lot of design changes that are not visible for default use cases, but especially for OSGi integration you have to do some extra work.
To get you started you should try to understand the initialization process concerning the classes:
VaadinServlet, VaadinServletService, VaadinSession and UIProvider.
The problematic parts are the methods that use classname parameters as arguments, you will have to work around this by e.g. implementing a factory that directly injects your instances.
If you look at the source for UIProvider.createInstance(..) you can see that the original implementation tries to create a new instance, this will fail since vaadin does not see your classes in OSGi. The same principle applies for the other classes i mentioned as well.
Another thing you have to look at is the new separation of jars in Vaadin 7.
A good approach is to attach a bundle fragment with a blueprint context. that registers a BundleHttpContext the same way it worked in Vaadin 6. Attaching fragments also works for the themes you want to use.
Sorry that i can't provide a turnkey solution, but i hope this helps you to look into it yourself.

Spring framework self-training

I'd like to learn Spring MVC framework basis.
My personal experience tells clearly that more than reading manuals, docs, howtos only is only one important part of self-training, but to capitalize real experience you need to solve real problems.
May someone suggest a fake-project that I can implement in my free-time, avoiding only-theoretical approaches and at the same time watch at the main issues of Spring programming?
Does a NerdDinner.com-like free-chapter somewhere exists for Spring?
You could go through each of the Spring samples, and attempt to recreate them on your own.
I have found that a very effective method for learning Spring is to go on the Spring JIRA and solve a bug. It forces you to get down and dirty in the code, and you get to see what's really going on behind the scenes.

What is the best approach for unit testing/integration testing GXT code?

I have been tasked to setup a continuous integration environment for a GXT 2.1.1 and GWT 2.0.1 environment. Unfortunately I am new to AJAX and Web Services and have little idea how to setup unit tests in the browser environment. Unit tests for the server backend I already have done, since I am a pro at that. GXT is not quite pure GWT which provides some unit testing structure. If anyone has a good starting point...
I feel the article here is fairly elaborate, Have you gone through that ?
I am assuming you are planning to test only the Async's and Server side (RemoteServiceServlet) part, so I don't understand how gwt/gxt differ in that, all the rules that apply to GWT, will still apply to GXT testing as well.
I think the best approach is unit testing and I will recommend using JUnit .

Spring-managed Clojure beans

I'm just wondering if it's possible to create Spring managed beans backed by Clojure code (Clojure namespace I guess, would implement regular Java interface)? If so, the example would be appreciated.
Thanks,
Dmitriy.
I haven't tried that yet, but section 3.3 of Programming Clojure explains how to create class files with the :gen-class form. Use it with :implements and :extends, build a JAR from your classes and import them into your Spring project. That should - theoretically - do the trick.
I'd be very interested in any example code, too, by the way.
See this as an example of clojure, spring, junit and swt integration.

Resources