Ashutosh Kumar | 13 Sep 06:46 2011
Picon

expects returns a default value for void return type

I have a method which returns void . However when I run the test I get error stating

 

java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)

expectations:

  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value

 

Here is my test :

 

public void testsaveUsers() {

            try {

                  final  Mockery context = new  JUnit4Mockery()  {{

                    setImposteriser(ClassImposteriser.INSTANCE);

                }};

                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);

                  final BrmUser user = new BrmUser();

                  BrmUserServiceImpl userService = new BrmUserServiceImpl();

                  userService.setBrmUserBo(userBo);

                  context.checking(new Expectations() {

                        {

                              allowing(userBo).saveUser(user);

                             

                        }

                  });

                  userService.saveUser(user);

            } catch (Exception e) {

                  fail();

            }

      }



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

Fedor Bobin | 13 Sep 07:14 2011
Picon

Re: expects returns a default value for void return type

What jmock version do you use?
Is userService.saveUser() create or use threads?

2011/9/13 Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ5yjigaA7mwwQ@public.gmane.org>

I have a method which returns void . However when I run the test I get error stating

 

java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)

expectations:

  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value

 

Here is my test :

 

public void testsaveUsers() {

            try {

                  final  Mockery context = new  JUnit4Mockery()  {{

                    setImposteriser(ClassImposteriser.INSTANCE);

                }};

                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);

                  final BrmUser user = new BrmUser();

                  BrmUserServiceImpl userService = new BrmUserServiceImpl();

                  userService.setBrmUserBo(userBo);

                  context.checking(new Expectations() {

                        {

                              allowing(userBo).saveUser(user);

                             

                        }

                  });

                  userService.saveUser(user);

            } catch (Exception e) {

                  fail();

            }

      }



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.


Ashutosh Kumar | 13 Sep 07:16 2011
Picon

RE: expects returns a default value for void return type

I am using 2.5.1 . It does not create any thread. Implementation classes use spring for dependency injection.

 

Thanks

Ashutosh

 

From: Fedor Bobin [mailto:fuudtorrentsru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Tuesday, September 13, 2011 10:45 AM
To: user-sXN/XchZ9OexIXFVlbCvtR2eb7JE58TQ@public.gmane.org
Subject: Re: [jmock-user] expects returns a default value for void return type

 

What jmock version do you use?
Is userService.saveUser() create or use threads?

 

2011/9/13 Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ5yjigaA7mwwQ@public.gmane.org>

I have a method which returns void . However when I run the test I get error stating

 

java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)

expectations:

  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value

 

Here is my test :

 

public void testsaveUsers() {

            try {

                  final  Mockery context = new  JUnit4Mockery()  {{

                    setImposteriser(ClassImposteriser.INSTANCE);

                }};

                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);

                  final BrmUser user = new BrmUser();

                  BrmUserServiceImpl userService = new BrmUserServiceImpl();

                  userService.setBrmUserBo(userBo);

                  context.checking(new Expectations() {

                        {

                              allowing(userBo).saveUser(user);

                             

                        }

                  });

                  userService.saveUser(user);

            } catch (Exception e) {

                  fail();

            }

      }

 


Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

 



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

Ashutosh Kumar | 13 Sep 09:46 2011
Picon

Re: expects returns a default value for void return type

Probably it is happening with transactional methods. Do I need to do something extra for transactional methods?
 
Thanks
Ashutosh

On Tue, Sep 13, 2011 at 10:46 AM, Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ5yjigaA7mwwQ@public.gmane.org> wrote:

I am using 2.5.1 . It does not create any thread. Implementation classes use spring for dependency injection.

 

Thanks

Ashutosh

 

From: Fedor Bobin [mailto:fuudtorrentsru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Tuesday, September 13, 2011 10:45 AM
To: user <at> jmock.codehaus.org
Subject: Re: [jmock-user] expects returns a default value for void return type

 

What jmock version do you use?
Is userService.saveUser() create or use threads?

 

2011/9/13 Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ4WUB6XyBwvMA@public.gmane.orgin>

I have a method which returns void . However when I run the test I get error stating

 

java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)

expectations:

  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value

 

Here is my test :

 

public void testsaveUsers() {

            try {

                  final  Mockery context = new  JUnit4Mockery()  {{

                    setImposteriser(ClassImposteriser.INSTANCE);

                }};

                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);

                  final BrmUser user = new BrmUser();

                  BrmUserServiceImpl userService = new BrmUserServiceImpl();

                  userService.setBrmUserBo(userBo);

                  context.checking(new Expectations() {

                        {

                              allowing(userBo).saveUser(user);

                             

                        }

                  });

                  userService.saveUser(user);

            } catch (Exception e) {

                  fail();

            }

      }

 


Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

 



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.


Fedor Bobin | 13 Sep 09:51 2011
Picon

Re: expects returns a default value for void return type

May be you can separate test and some classes so we can discover what is wrong.

2011/9/13 Ashutosh Kumar <ashutosh.k78 <at> gmail.com>
Probably it is happening with transactional methods. Do I need to do something extra for transactional methods?
 
Thanks
Ashutosh

On Tue, Sep 13, 2011 at 10:46 AM, Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ5yjigaA7mwwQ@public.gmane.org> wrote:

I am using 2.5.1 . It does not create any thread. Implementation classes use spring for dependency injection.

 

Thanks

Ashutosh

 

From: Fedor Bobin [mailto:fuudtorrentsru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Tuesday, September 13, 2011 10:45 AM
To: user <at> jmock.codehaus.org
Subject: Re: [jmock-user] expects returns a default value for void return type

 

What jmock version do you use?
Is userService.saveUser() create or use threads?

 

2011/9/13 Ashutosh Kumar <Ashutosh.Kumar-YELz9hDmLZ4WUB6XyBwvMA@public.gmane.orgin>

I have a method which returns void . However when I run the test I get error stating

 

java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)

expectations:

  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value

 

Here is my test :

 

public void testsaveUsers() {

            try {

                  final  Mockery context = new  JUnit4Mockery()  {{

                    setImposteriser(ClassImposteriser.INSTANCE);

                }};

                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);

                  final BrmUser user = new BrmUser();

                  BrmUserServiceImpl userService = new BrmUserServiceImpl();

                  userService.setBrmUserBo(userBo);

                  context.checking(new Expectations() {

                        {

                              allowing(userBo).saveUser(user);

                             

                        }

                  });

                  userService.saveUser(user);

            } catch (Exception e) {

                  fail();

            }

      }

 


Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

 



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.



Steve Freeman | 13 Sep 13:06 2011
Picon

Re: expects returns a default value for void return type

What about the equals() method on the brmUserBo? Is it not matching because of that? 

Incidentally, I wouldn't use a try/catch here. If you just declare the exception on the test method and let
it propagate up, junit will handle it appropriately.

S.

On 13 Sep 2011, at 06:46, Ashutosh Kumar wrote:
> I have a method which returns void . However when I run the test I get error stating
> 
> java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)
> expectations:
>  allowed, never invoked:
brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value
> 
> Here is my test :
> 
> public void testsaveUsers() {
>            try {
>                  final  Mockery context = new  JUnit4Mockery()  {{
>                    setImposteriser(ClassImposteriser.INSTANCE);
>                }};
>                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);
>                  final BrmUser user = new BrmUser();
>                  BrmUserServiceImpl userService = new BrmUserServiceImpl();
>                  userService.setBrmUserBo(userBo);
>                  context.checking(new Expectations() {
>                        {
>                              allowing(userBo).saveUser(user);
> 
>                        }
>                  });
>                  userService.saveUser(user);
>            } catch (Exception e) {
>                  fail();
>            }
>      }

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 797 179 4105
Twitter:  <at> sf105
Higher Order Logic Limited
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
Company registered in England & Wales. Number 7522677

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Ashutosh Kumar | 13 Sep 13:09 2011
Picon

Re: expects returns a default value for void return type

There is no equal method defined there. Moreever it works for getUser. It fails for save.
 
Thanks
Ashutosh

On Tue, Sep 13, 2011 at 4:36 PM, Steve Freeman <steve-/6t1Ty3A97Vaa/9Udqfwiw@public.gmane.org> wrote:
What about the equals() method on the brmUserBo? Is it not matching because of that?

Incidentally, I wouldn't use a try/catch here. If you just declare the exception on the test method and let it propagate up, junit will handle it appropriately.

S.

On 13 Sep 2011, at 06:46, Ashutosh Kumar wrote:
> I have a method which returns void . However when I run the test I get error stating
>
> java.lang.AssertionError: unexpected invocation: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)
> expectations:
>  allowed, never invoked: brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>); returns a default value
>
> Here is my test :
>
> public void testsaveUsers() {
>            try {
>                  final  Mockery context = new  JUnit4Mockery()  {{
>                    setImposteriser(ClassImposteriser.INSTANCE);
>                }};
>                  final BrmUserBoImpl userBo = context.mock(BrmUserBoImpl.class);
>                  final BrmUser user = new BrmUser();
>                  BrmUserServiceImpl userService = new BrmUserServiceImpl();
>                  userService.setBrmUserBo(userBo);
>                  context.checking(new Expectations() {
>                        {
>                              allowing(userBo).saveUser(user);
>
>                        }
>                  });
>                  userService.saveUser(user);
>            } catch (Exception e) {
>                  fail();
>            }
>      }

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 797 179 4105
Twitter: <at> sf105
Higher Order Logic Limited
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 7522677




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Ignat Zapolsky | 13 Sep 13:11 2011
Picon

Re: expects returns a default value for void return type

Do you mind posting code of BrmUserServiceImpl here?

On 13 Sep 2011 12:09, "Ashutosh Kumar" <ashutosh.k78-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> There is no equal method defined there. Moreever it works for getUser. It
> fails for save.
>
> Thanks
> Ashutosh
>
> On Tue, Sep 13, 2011 at 4:36 PM, Steve Freeman <steve-/6t1Ty3A97Vaa/9Udqfwiw@public.gmane.org> wrote:
>
>> What about the equals() method on the brmUserBo? Is it not matching because
>> of that?
>>
>> Incidentally, I wouldn't use a try/catch here. If you just declare the
>> exception on the test method and let it propagate up, junit will handle it
>> appropriately.
>>
>> S.
>>
>> On 13 Sep 2011, at 06:46, Ashutosh Kumar wrote:
>> > I have a method which returns void . However when I run the test I get
>> error stating
>> >
>> > java.lang.AssertionError: unexpected invocation:
>> brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)
>> > expectations:
>> > allowed, never invoked:
>> brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>);
>> returns a default value
>> >
>> > Here is my test :
>> >
>> > public void testsaveUsers() {
>> > try {
>> > final Mockery context = new JUnit4Mockery() {{
>> > setImposteriser(ClassImposteriser.INSTANCE);
>> > }};
>> > final BrmUserBoImpl userBo =
>> context.mock(BrmUserBoImpl.class);
>> > final BrmUser user = new BrmUser();
>> > BrmUserServiceImpl userService = new
>> BrmUserServiceImpl();
>> > userService.setBrmUserBo(userBo);
>> > context.checking(new Expectations() {
>> > {
>> > allowing(userBo).saveUser(user);
>> >
>> > }
>> > });
>> > userService.saveUser(user);
>> > } catch (Exception e) {
>> > fail();
>> > }
>> > }
>>
>> Steve Freeman
>>
>> Winner of the Agile Alliance Gordon Pask award 2006
>> Book: http://www.growing-object-oriented-software.com
>>
>> +44 797 179 4105
>> Twitter: <at> sf105
>> Higher Order Logic Limited
>> Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
>> Company registered in England & Wales. Number 7522677
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>
Ashutosh Kumar | 13 Sep 13:13 2011
Picon

RE: expects returns a default value for void return type

<at> Transactional(readOnly = false)

      public void saveUser(BrmUser user) {

 

            brmUserBo.saveUser(user);

      }

 

From: Ignat Zapolsky [mailto:izapolsky <at> gmail.com]
Sent: Tuesday, September 13, 2011 4:41 PM
To: user <at> jmock.codehaus.org
Subject: Re: [jmock-user] expects returns a default value for void return type

 

Do you mind posting code of BrmUserServiceImpl here?

On 13 Sep 2011 12:09, "Ashutosh Kumar" <ashutosh.k78 <at> gmail.com> wrote:
> There is no equal method defined there. Moreever it works for getUser. It
> fails for save.
>
> Thanks
> Ashutosh
>
> On Tue, Sep 13, 2011 at 4:36 PM, Steve Freeman <steve <at> m3p.co.uk> wrote:
>
>> What about the equals() method on the brmUserBo? Is it not matching because
>> of that?
>>
>> Incidentally, I wouldn't use a try/catch here. If you just declare the
>> exception on the test method and let it propagate up, junit will handle it
>> appropriately.
>>
>> S.
>>
>> On 13 Sep 2011, at 06:46, Ashutosh Kumar wrote:
>> > I have a method which returns void . However when I run the test I get
>> error stating
>> >
>> > java.lang.AssertionError: unexpected invocation:
>> brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>)
>> > expectations:
>> > allowed, never invoked:
>> brmUserBo.saveUser(<com.arisglobal.agBRM.user.entity.BrmUser <at> 16672d6>);
>> returns a default value
>> >
>> > Here is my test :
>> >
>> > public void testsaveUsers() {
>> > try {
>> > final Mockery context = new JUnit4Mockery() {{
>> > setImposteriser(ClassImposteriser.INSTANCE);
>> > }};
>> > final BrmUserBoImpl userBo =
>> context.mock(BrmUserBoImpl.class);
>> > final BrmUser user = new BrmUser();
>> > BrmUserServiceImpl userService = new
>> BrmUserServiceImpl();
>> > userService.setBrmUserBo(userBo);
>> > context.checking(new Expectations() {
>> > {
>> > allowing(userBo).saveUser(user);
>> >
>> > }
>> > });
>> > userService.saveUser(user);
>> > } catch (Exception e) {
>> > fail();
>> > }
>> > }
>>
>> Steve Freeman
>>
>> Winner of the Agile Alliance Gordon Pask award 2006
>> Book: http://www.growing-object-oriented-software.com
>>
>> +44 797 179 4105
>> Twitter: <at> sf105
>> Higher Order Logic Limited
>> Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
>> Company registered in England & Wales. Number 7522677
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>



Disclaimer: This transmission, including attachments, is confidential, proprietary, and may be privileged. It is intended solely for the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of this transmission and its attachments.

Steve Freeman | 13 Sep 13:14 2011
Picon

Re: expects returns a default value for void return type

Do you /have/ to use the class imposteriser? Perhaps there's some more complicated behaviour going on there?

S.

On 13 Sep 2011, at 13:09, Ashutosh Kumar wrote:

> There is no equal method defined there. Moreever it works for getUser. It
> fails for save.
> 
> Thanks
> Ashutosh

Steve Freeman

Winner of the Agile Alliance Gordon Pask award 2006
Book: http://www.growing-object-oriented-software.com

+44 797 179 4105
Twitter:  <at> sf105
Higher Order Logic Limited
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. 
Company registered in England & Wales. Number 7522677

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane