On 10/12/2012 13:26, Christian Schneider wrote:
Hi all,
while testing how adding the CXF libs influences the syncope tests I
found a problem with the current rest tests.
The problem is that at least some of the tests can not simply be rerun.
For example org.apache.syncope.core.rest.RoleTestITCase.create() only
seems to succeed once.
When I start the server and rerun the test from eclipse it fails as the
role is already there.
So one way to solve this would be to make each test method clean up
after itself. So at least after a successful test the db should be ready
for another run.
One other way would be to create some additional tests that work with a
mocked persistence layer. These tests would then always be able to rerun
as they do not need or change the db.
I think it makes sense to follow both of these approaches. So what do
you think?
Hi Christian,
as you have reported above, I wouldn't expect that REST tests are able
to run more than once, mainly because of different data constraints
enforced in the underlying database.
Moreover, considering the amount of relationships and different entities
accessing the persistence layer (Quartz, Activiti, Logback and...
Syncope via OpenJPA), I would rather prefer some kind of cleanup.
Since the core test environment relies upon an in-memory H2 instance, we
could find a way to re-initialize (possibly upon request) the Spring web
context, more or less as already happening with JUnit for unit tests
(managed via @RunWith(SpringJUnit4ClassRunner.class)). This should fit
the job.
Regards.
--
Francesco Chicchiriccò
ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/