Spring integration testing without XML - testing

Could anyone provide a complete flow test example (channels, gateways, etc) using jUnit4 or other Test tool for spring integration? I am working without XML, thus I prefer a Java-config test initiation.

It depends on your application; for pure annotation configuration start with this framework test class, it has lots of tests.
If you're using the Java DSL, start here.

Related

How to do code coverage for a remote repository deployed in Jboss server using Emma?

Here is my scenario.
I have a code base, which is built and deployed as EAR on jBoss server.
I have a separate testing framework.
Now I want to run the classes of that EAR using my testing framework.
The test cases are written in TestNG.
Also I want to know the code coverage of the EAR.
I have used eclEmma to do code coverage for Junits, it was simple as the code and tests are at same place.
How can I use Emma in the case of remote code base. Please help.
EclEmma is Eclipse plugin based on JaCoCo - Java Code Coverage Library. JaCoCo provides various ways for collection of code coverage. In particular you can attach it to the server as a Java agent and request information about coverage remotely. And even import and show it in Eclipse using EclEmma.

Automation tests using Cucumber, SoapUI and Selenium

I'd like to use Cucumber linked with SoapUI and Selenium in order to create an automation functional test.
I only found one website about it, describing that first I have to create a SoapUI project and save it as a .xml file. Then I should include this file into the test project using Cucumber and Selenium.
My first question is what configuration do I have to do for that ? (in the pom.xml file when using Maven for example or in any configuration file for Jenkins)
My second and last question is : if I launch every night with Jenkins (let's say that as an example) my tests, do I have to launch first the SoapUI project and import it again in the test project to run my tests in a good way ?
Thanks for your answers
I think you can use REST Assured for you API testing.
Use cucumber for your BDD statement, use java for there step definition and REST Assured for all the API request stuff.
Wrap all your automation with well written Gherkin and you'll need no other documentation. Think about that. BDD (specification by example) is a requirements approach, not a testing approach.

How does Arquillian compare to Pax Exam for OSGi (integration) testing?

I am currently investigating how best to test our OSGi application intended to run on Apache Karaf. The obvious option is Pax Exam with labs-paxexam-karaf (see http://iocanel.blogspot.com/2012/01/advanced-integration-testing-with-pax.html for a tutorial). However, I am concerned about performance (since Pax Exam apparently starts a new framework for every test method). I've also found that Arquillian has some OSGi support, though that isn't its main focus. JUnit4osgi isn't an option, as it only supports JUnit 3.
For someone unfamiliar with either framework, which is better to start with? What are the tradeoffs?
Why use Arquillian if you're after proper OSGi support? =)
When looking at PaxExam make sure the docs refer to PaxExam 2 - there are substantial differences between v 1 and 2.
PaxExam will take a while to get to grips with, but you'll learn heaps about OSGi in the process (definitely a good thing, but can still hurt).
In parallel to #Dmytro's answer, the Test Containers include a Native container which is run with the same VM as the junit test - meaning you can launch with debug in Eclipse. This works especially well with the org.eclipse.m2e:lifecycle-mapping maven eclipse plugin and the org.ops4j.pax.exam:maven-paxexam-plugin. This method is fantastic, complete IDE integration.
PaxExam documentation is a bit sparse, but there are some good examples (see the Native launcher with main method that provides interactive shell) and wiki doc. If you get stuck the mailing list people (general#lists.ops4j.org) are very helpful.
Another alternative is to look at Karaf's paxexam, very slick and easy to get a Karaf instance up and running (features.xml etc).
Personally, I just use PaxExam2 as I'd prefer to have no explicit dependencies on the framework provider (nothing against Karaf at all, it rocks).
Based on Reactor Strategies Pax-Exam can run all test methods in the same OSGi container.
The EagerSingleStagedReactorFactory of Pax Exam 2.x (aliased to PerClass in Pax 3.0) lets you run all test methods of a given class in the same OSGi container.
With the PerSuite strategy introduced in Pax Exam 3.0.0.M1, all test classes of your suite run in the same container.
By the way, Pax Exam 3.0 supports Java EE and CDI containers in addition to OSGi, so there is even more functional similarity with Arquillian, only Pax Exam is coming from the opposite end.
With Pax Exam, there is no need to assemble deployments in ShrinkWrap style, they are built automatically from the classpath. Moreover, you can run suites of test classes with a shared configuration.

How to swap in mock services during Selenium ui testing?

We wish to introduce Selenium testing to our maven build process. Happily, there is a ton of information available on how to do this, but I'm having trouble figuring out how to handle one of our requirements.
In an effort to separate our testing layers, we want to use mock service objects for the ui tests. All of these objects are already defined in Spring configuration files that we use in unit tests. Wiring these services is easy in a unit test (we're using #ContextConfiguration), but I don't know how to handle this configuration swap when we're deploying the war to Jetty for Selenium tests.
We're using:
Spring MVC 3.0
Maven
Hudson
Worst: introduce special user/interface parameter/checkbox/role. In an application remember to use mocks for this special case everywhere in the code. Horrible in maintenance, error-prone and, let's face it, pretty lame. Most common thou...
Easiest solution: develop conditional includes in your Spring application context:
<import resource="services-${env}.xml"/>
where ${env} comes from pom.xml:
<properties>
<env>prd</env> <!-- or test depending on build profile -->
</properties>
Remember to turn on resources filtering and use build profiles.
when doing Selenium tests. Switching can be done during Maven build or by some other filtering tool. Both files (services-prd.xml and services-test.xml) define same beans (same interfaces and/or ids), but of course the latter one uses mock implementations.
Best (IMHO): if you need to change the implementation at runtime, AOP + JMX will be great. Just wrap your real services with aspects and depending on some flag (accessible via JMX), use real services or mocks. Very clean and noninvasive.

How to do testing with lift applications?

How to do testing and is there something similar like Rack::Test with ruby frameworks?
You can use Specs, ScalaTest and JUnit (and any other java test framework), theres some examples on the new wiki.
Read this!
I don't know much about ruby, so maybe don't get your point. But what about Jitr?
Jitr (pronounced "jitter") is a JUnit
Integration Test Runner.
It allows your web application
integration tests to easily run
against a lightweight web container in
the same JVM as your tests.
You can use it with JUnit 4's #RunWith annotation. In Scala: #RunWith(classOf[Jitr]).
This may be of help, it's on Lifts wiki pages. There are examples using Junit, Scalatest and and Specs.
How To: Unit test lift snippets with a logged in user