Hi!
You have decided that you need integration tests in addition to your unit tests. How can we automate integration testing of J2EE code?
Arquillian to rescue! Arquillian is integration testing framework for Java EE. To get started you need an Arquillian library, adapter container, container and test :-).
Is sounds a lot like to configure. Well no so many by hand. For the integration test I have chosen Wildfly 8.2.1. Also I want that Arquillian itself managed starting and stopping of wildfly.
For those who are impatient look into github: https://github.com/chernykhalexander/arquillian_db2_J2EE.git.
The easiest way to add the arquillian in pom.xml is to you jBoss forge tool. Forge is a special utility to manage java projects. Or you can look into pom.xml on github.
This pom also:
1) downloads the wildfly 8.2.1 distribution and expand it into the target directory.
2) copy the IBM DB2 driver into the expanded wildfly
3) uses maven-failsafe-plugin to run integration-tests. It's execution is bounded to integration-test and verify goals. If you need to execute integration test make sure integration test files end with "IT".
How to define the JNDI datasource? This is what wildfly-ds.xml responsible for.
Other interesting part is integration test itself. Again, you can ease the creation of test with forge tool.
When creating the test pay attention to the @deployment method. You need to specify all classes and files your test uses.
After all have been done mvn integration-test and that is all! Happy testing.
This blog is a collection of minds around linux, java, javascript, etc. Looking for great opportunities.
Показаны сообщения с ярлыком integration test. Показать все сообщения
Показаны сообщения с ярлыком integration test. Показать все сообщения
пятница, 4 декабря 2015 г.
вторник, 19 февраля 2013 г.
Apache CXF integration testing
Sometimes it is necessary to make the test of web-service client and service.
If you have an Apache CXF service and client then you can try to use local transport for your test.
So, here is an example.
The client you define like this:
<jaxws:client id="client" serviceClass="IIdentificationService" address="local://test"/>.
And here is how you test the integration:
IIdentificationServiceImpl impl = new IIdentificationServiceImpl();
Endpoint ep = Endpoint.publish("local://test", impl);
IIdentificationService client = (IIdentificationService) context.getBean("client");
Result res = client.call("123");
ep.stop();
What is important here is the address of endpoint and client. Both uses the prefix "local". This means that messages will transport inside the JVM.
For reference see http://cxf.apache.org/docs/local-transport.html.
If you have an Apache CXF service and client then you can try to use local transport for your test.
So, here is an example.
The client you define like this:
<jaxws:client id="client" serviceClass="IIdentificationService" address="local://test"/>.
And here is how you test the integration:
IIdentificationServiceImpl impl = new IIdentificationServiceImpl();
Endpoint ep = Endpoint.publish("local://test", impl);
IIdentificationService client = (IIdentificationService) context.getBean("client");
Result res = client.call("123");
ep.stop();
What is important here is the address of endpoint and client. Both uses the prefix "local". This means that messages will transport inside the JVM.
For reference see http://cxf.apache.org/docs/local-transport.html.
Подписаться на:
Комментарии (Atom)