dev@glassfish.java.net

Re: Hk2 JUnit integration

From: Jerome Dochez <jerome.dochez_at_oracle.com>
Date: Wed, 26 May 2010 20:47:51 -0700

actually what you see below is just traces, I don't see the real reason
for the failure.

you need to look into
target/surefire-reports/com.sun.enterprise.transaction.jts.AppTest.txt
for the real reason...


On 05/26/2010 04:34 PM, Marina Vatkina wrote:
> Hi Jerome,
>
> I tried to add @RunWith(Hk2Runner.class) to get a hold of the habitat
> in one of my junit tests, but it failed with a lot of messages in the
> console output like this:
>
> Beginning parsing ...
> Ignoring service-less ...
>
> then it came to these lines (what is car?) and failed:
>
> Finished introspecting hk2-core-1.0.19.jar
> Finished introspecting test-classes
> Finished introspecting auto-depends-1.0.19.jar
> Finished introspecting osgi-adapter-1.0.19.jar
> Finished introspecting annotation-framework-3.1-SNAPSHOT.jar
> Finished introspecting ejb-internal-api-3.1-SNAPSHOT.jar
> Starting to introspect
> finished introspecting
> Starting to introspect
> finished introspecting
> Found contract : com.sun.enterprise.connectors.ActiveResourceAdapter
> --> com.sun.enterprise.connectors.ActiveResourceAdapterImpl {index:
> {com.sun.enterprise.connectors.ActiveResourceAdapter,}
> class: {com.sun.enterprise.connectors.ActiveResourceAdapterImpl,}
> }
> <...>
> -->
> com.sun.enterprise.deployment.annotation.introspection.AppClientPersistenceDependencyAnnotationScanner
> {index: {com.sun.enterpr
> ise.deployment.annotation.introspection.AnnotationScanner:car,}
> class:
> {com.sun.enterprise.deployment.annotation.introspection.AppClientPersistenceDependencyAnnotationScanner,}
>
> com.sun.enterprise.deployment.annotation.introspection.AnnotationScanner:
> {car,}
> }
>
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running com.sun.enterprise.transaction.jts.AppTest
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.138
> sec <<< FAILURE!
>
> Results :
>
> Tests in error:
> com.sun.enterprise.transaction.jts.AppTest
>
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
>
> thanks,
> -marina
>
> Jerome Dochez wrote:
>> I have made good progress integrating Hk2 injection inside JUnit
>> tests so I have written a wiki page on how to better unit test your
>> modules with JUnit and Hk2.
>>
>> http://wiki.glassfish.java.net/Wiki.jsp?page=TestingWithHk2
>>
>> Now you can use @Inject inside junit tests and have habitat services
>> injected and tested. It should simplify the testing of individual
>> modules, please try to use this as soon as possible for unit testing.
>> I believe we should be able to do the same with TestNG but I have no
>> cycles for that, if anyone wants to pick that up, it would be great...
>>
>> jerome
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>