dev@glassfish.java.net

Re: Hk2 JUnit integration

From: Jerome Dochez <jerome.dochez_at_oracle.com>
Date: Fri, 28 May 2010 11:43:13 -0700

ok I will look at it...

On May 28, 2010, at 11:41 AM, Marina Vatkina wrote:

> Yes, if I do not use hk2 integration (no @RunWith) in my junit tests, everything is fine.
>
> Jerome Dochez wrote:
>> I don't understand. Are you saying that not using dependency injection inside your junit tests make System.out work ?
>>
>> On May 28, 2010, at 11:13 AM, Marina Vatkina wrote:
>>
>>
>>> I can visually check that everything is to my liking ;)
>>>
>>> Jerome Dochez wrote:
>>>
>>>> and how does that resolve your junit console problem ?
>>>>
>>>> On May 28, 2010, at 11:06 AM, Marina Vatkina wrote:
>>>>
>>>>
>>>>> Jerome Dochez wrote:
>>>>>
>>>>>> On May 27, 2010, at 6:56 PM, Marina Vatkina wrote:
>>>>>>
>>>>>>
>>>>>>> Amazingly they closed exactly the same issue (http://jira.codehaus.org/browse/SUREFIRE-477) as not reproducible :(
>>>>>>>
>>>>>>> I'll stick with the plain old junit for now...
>>>>>>>
>>>>>>>
>>>>>> what does "old" junit means here ?
>>>>>>
>>>>> setting variables that in an hk2 run would be injected, manually from inside junit tests.
>>>>>
>>>>>>
>>>>>>> thanks,
>>>>>>> -marina
>>>>>>>
>>>>>>> Jerome Dochez wrote:
>>>>>>>
>>>>>>>> not sure if you can change that.
>>>>>>>> look at the docs at
>>>>>>>> http://maven.apache.org/plugins/maven-surefire-plugin/
>>>>>>>>
>>>>>>>> On May 27, 2010, at 5:44 PM, Marina Vatkina wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> OK. There was a 1-arg constructor in the AppTest, so no default one.
>>>>>>>>>
>>>>>>>>> Where does the console output go? I see in both, the output and the target/surefire-reports/com.sun.enterprise.transaction.jts.AppTest.txt only the summary of the result...
>>>>>>>>>
>>>>>>>>> thanks,
>>>>>>>>> -marina
>>>>>>>>>
>>>>>>>>> Marina Vatkina wrote:
>>>>>>>>>
>>>>>>>>>> It's a lot of traces :(
>>>>>>>>>>
>>>>>>>>>> What kind of constructor does it need?
>>>>>>>>>>
>>>>>>>>>> Caused by: java.lang.InstantiationException: com.sun.enterprise.transaction.jts.AppTest
>>>>>>>>>> at java.lang.Class.newInstance0(Class.java:340)
>>>>>>>>>> at java.lang.Class.newInstance(Class.java:308)
>>>>>>>>>> at com.sun.hk2.component.ConstructorWomb.create(ConstructorWomb.java:68)
>>>>>>>>>>
>>>>>>>>>> thanks,
>>>>>>>>>> -marina
>>>>>>>>>>
>>>>>>>>>> Jerome Dochez wrote:
>>>>>>>>>>
>>>>>>>>>>> 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
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>