deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: CdiTestRunner fails to create proxy for the test class so @Transactional annotation is ignored
Date Mon, 14 Dec 2015 08:35:57 GMT
hi paul,

you are welcome - great that it works for you!

regards,
gerhard

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans



2015-12-14 4:15 GMT+01:00 Paul Wills <paul.wills@engsol.com.au>:

> Hi Gerhard,
>
> adding
>
> deltaspike.testcontrol.use_test_class_as_cdi_bean=true
>
> to src/test/resources/META-INF/apache-deltaspike.properties fixed the
> problem.
>
> Thanks,
>
> Paul
>
> On 10 December 2015 at 18:57, Gerhard Petracek <gerhard.petracek@gmail.com
> > wrote:
>
>> hi paul,
>>
>> if the test-class itself should be handled as a cdi-bean, you need to
>> enable
>>  deltaspike.testcontrol.use_test_class_as_cdi_bean
>> in META-INF/apache-deltaspike.properties.
>> it's disabled per default, because there are some limitations.
>>
>> regards,
>> gerhard
>>
>> http://www.irian.at
>>
>> Your JavaEE powerhouse -
>> JavaEE Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache
>> MyFaces, DeltaSpike and OpenWebBeans
>>
>>
>>
>> 2015-12-10 5:56 GMT+01:00 Paul Wills <paul.wills@engsol.com.au>:
>>
>>> I don't know if this is viewed as a problem or not, but when I wrote a
>>> test
>>> class and annotated it with
>>> @RunWith(CdiTestRunner.*class*)
>>> the following test method is called as a non proxied method call from
>>> reflection, indicating to me that the @Transactional annotation cannot be
>>> having any effect.
>>>
>>> @Test
>>> @Transactional
>>> *public* *void testSaveAndFetchUser() {*
>>>
>>>     // Given - a new user
>>>     *final* User randomUser = createRandomUser(*false*);
>>>
>>>     // When - saved
>>>     *final* User savedUser = userService.saveUser(randomUser);
>>>
>>>     // Then - user is saved as well as history and can be retrieved by id
>>> and username
>>>     *assertThat*(savedUser.getRoles(), *hasSize*(*greaterThan*(0)));
>>>     ...
>>> }
>>>
>>> Regards,
>>> Paul Wills
>>>
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message