>>>>> Grzegorz Grzybek <gr.grzybek-re5jqeeqqe8avxtiumw...@public.gmane.org>:

> Hello
> I'd like to help, but seeing this in your shared test:

>         final MavenArtifactUrlReference sampleappFeatureRepo = maven()
>> .groupId("no.priv.bang.karaf")
>> .artifactId("karaf.liquibase.sample.datasource.receiver")
>> 

> doesn't help - this is your private artifact and you'd have to share entire
> project and not a @Test method.

Ah, sorry!  It is the integration test for my liquibase karaf feature
 https://github.com/steinarb/liquibase-karaf-feature

Liquibase is a database migration tool, similar to flyway.

The integration test is here:
 
https://github.com/steinarb/liquibase-karaf-feature/tree/master/liquibase-integration-test

The test consists of three OSGi bundles and a karaf pax exam test that
loads the feature, and tries to use the database enough to prove that
the loaded feature actually works and can be used to create a database
schema.

The integration test used to be just loading the feature, but I found
out a while back that that was not enough to signal if the new karaf
release I was creating was actually working in an OSGi context: create a
row in a database and reading the results back.

So now the test consists of three bundles:
 karaf.liquibase.sample
  Contains a pax jdbc PreHook DS component

 karaf.liquibase.sample.services
  The OSGi service used in the pax exam test to add data to the database
  and read data back from the database

 karaf.liquibase.sample.datasource.receiver
  Contains a DS component exposing the OSGi service used in the karaf
  pax exam test, with feature dependencies to both of the above bundles'
  attached feature repositories

 karaf.liquibase.tests
  The karaf pax exam test where the asserts are weird

> I completely support red-green-red-green-... cycle. But I'm pretty sure
> Martin Fowler didn't have integration tests in mind. It was about unit
> tests.

Oh I agree, but it looked like a JUnit test, and when the behaviour got
weird I started looking for problems in the code being executed by the
test (and this code is just dummy code, since what I'm trying to do is
verify that the liquibase loaded by the karaf feature is actually able
to create a database schema).

> You seem to be testing everything including verification of database
> content. Getting assertion exceptions in your tests code _may_ lead to
> transaction rollback (I have no idea if this is true - I'd have to see
> your entire test setup).

Maybe...? There shouldn't be any open transactions across the asserts or
even across the methods called between the asserts.

I wrap all of my read and write interactions with JDBC in a
try-with-resource for a JDBC Connection instance.

> I can't help with any particular issue here - I recommend you to check
> Karaf's own Pax Exam integration tests:
> https://github.com/apache/karaf/tree/main/itests/test - see how the tests
> are structured.
> I also can suggest Pax Web tests where I tried very hard to put as many
> comments/explanations I could:
> https://github.com/ops4j/org.ops4j.pax.web/tree/main/pax-web-itest/pax-web-itest-karaf

Thanks!

FWIW the pax exam test works fine for me, when all of the asserts are green.

It's just the 

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/87r0qnhs8l.fsf%40dod.no.

Reply via email to