Julien D | 1 Jun 15:03 2009
Picon

Re: exactly(n) function in JMock


Here's my test :

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Test;

public class ExactlyTest {

	private interface IDao {
		void someMetod();
	}
	
	private class SomeService {
		
		private IDao dao;
		
		private void someServiceMethod() {
			//First call
			dao.someMetod();
			//Second call
			dao.someMetod();
		}

		public void setDao(IDao dao) {
			this.dao = dao;
		}
	}
(Continue reading)

Julian Hall | 1 Jun 20:51 2009
Picon

Re: exactly(n) function in JMock

Julien D wrote:
> Here's my test :
>
> import org.jmock.Expectations;
> import org.jmock.Mockery;
> import org.jmock.integration.junit4.JUnit4Mockery;
> import org.junit.Before;
> import org.junit.Test;
>
> public class ExactlyTest {
>
> 	private interface IDao {
> 		void someMetod();
> 	}
> 	
> 	private class SomeService {
> 		
> 		private IDao dao;
> 		
> 		private void someServiceMethod() {
> 			//First call
> 			dao.someMetod();
> 			//Second call
> 			dao.someMetod();
> 		}
>
> 		public void setDao(IDao dao) {
> 			this.dao = dao;
> 		}
> 	}
(Continue reading)

Nat Pryce | 1 Jun 23:53 2009
Picon

Re: exactly(n) function in JMock

You have neither annotated the class with  <at> RunWith(JMock.class) nor
explicitly called context.assertIsSatisfied() in any of your tests.

--Nat

2009/6/1 Julien D <myrddin22@...>:
>
> Here's my test :
>
> import org.jmock.Expectations;
> import org.jmock.Mockery;
> import org.jmock.integration.junit4.JUnit4Mockery;
> import org.junit.Before;
> import org.junit.Test;
>
> public class ExactlyTest {
>
>        private interface IDao {
>                void someMetod();
>        }
>
>        private class SomeService {
>
>                private IDao dao;
>
>                private void someServiceMethod() {
>                        //First call
>                        dao.someMetod();
>                        //Second call
>                        dao.someMetod();
(Continue reading)

Julien D | 2 Jun 00:58 2009
Picon

Re: exactly(n) function in JMock


Indeed adding the annotation  <at> RunWith(JMock.class) or
context.assertIsSatisfied() solved my problem. Forgot this part oups.

Thanks guys

Nat Pryce wrote:
> 
> You have neither annotated the class with  <at> RunWith(JMock.class) nor
> explicitly called context.assertIsSatisfied() in any of your tests.
> 
> --Nat
> 
> 2009/6/1 Julien D <myrddin22@...>:
>>
>> Here's my test :
>>
>> import org.jmock.Expectations;
>> import org.jmock.Mockery;
>> import org.jmock.integration.junit4.JUnit4Mockery;
>> import org.junit.Before;
>> import org.junit.Test;
>>
>> public class ExactlyTest {
>>
>>        private interface IDao {
>>                void someMetod();
>>        }
>>
>>        private class SomeService {
(Continue reading)

Thomas Richter | 4 Jun 12:38 2009

Pojo matcher

Hi,
is a Pojo matcher available somewhere?
I have a data object with 10 attributes.
In the expected and the invoked object are 8 attributes equal an 2 differs.
I don't need a complete printout of expected and the invoked object. This is
is a bit confusing and unclear.
What I like to have is an output like:
Objects are not the same: attribute a and b are different.
Is this already available?

wkr Thomas

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

    http://xircles.codehaus.org/manage_email

Steve Freeman | 4 Jun 13:04 2009
Picon

Re: Pojo matcher

If your object conforms to bean properties, you can use  
samePropertyValuesAs()

S.

On 4 Jun 2009, at 11:38, Thomas Richter wrote:
> Hi,
> is a Pojo matcher available somewhere?
> I have a data object with 10 attributes.
> In the expected and the invoked object are 8 attributes equal an 2  
> differs.
> I don't need a complete printout of expected and the invoked object.  
> This is
> is a bit confusing and unclear.
> What I like to have is an output like:
> Objects are not the same: attribute a and b are different.
> Is this already available?

Steve Freeman
Winner of the Agile Alliance Gordon Pask award 2006

http://www.m3p.co.uk

M3P Limited.
Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ.
Company registered in England & Wales. Number 03689627

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

(Continue reading)

Thomas Richter | 4 Jun 15:12 2009

Re: Pojo matcher

Hi,
with JMock1.2 it would probably work, if I had no list ...

one(mocked).method(with(aPropertyValuesAsMatcher(expected)));

 <at> Factory
public Matcher<List<Entity>> aPropertyValuesAsMatcher(
    final List<Entity> expected) {
        return new SamePropertyValuesAs<List<Entity>>(expected);
}

some Ideas?

wkr T. (Thomas)

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

    http://xircles.codehaus.org/manage_email

Steve Freeman | 4 Jun 15:50 2009
Picon

Re: Pojo matcher

I'm confused. You want to match a list of entity objects?

S.

On 4 Jun 2009, at 14:12, Thomas Richter wrote:

> Hi,
> with JMock1.2 it would probably work, if I had no list ...
>
> one(mocked).method(with(aPropertyValuesAsMatcher(expected)));
>
>  <at> Factory
> public Matcher<List<Entity>> aPropertyValuesAsMatcher(
>    final List<Entity> expected) {
>        return new SamePropertyValuesAs<List<Entity>>(expected);
> }
>
> some Ideas?
>
> wkr T. (Thomas)
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

Steve Freeman
Winner of the Agile Alliance Gordon Pask award 2006
(Continue reading)

Thomas Richter | 4 Jun 16:03 2009

Re: Pojo matcher

2009/6/4 Thomas Richter <tricpod@...>:
> Hi,
> with JMock1.2 it would probably work, if I had no list ...
I mean hamcrest1.2 ...

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

    http://xircles.codehaus.org/manage_email

Thomas Richter | 5 Jun 10:08 2009

Re: Pojo matcher

Hi,

This should work:
one(mocked).method(with(aPropertyValuesAsMatcher(expected)));

 <at> Factory
public Matcher<Entity> aPropertyValuesAsMatcher(
   final Entity expected) {
       return new SamePropertyValuesAs<Entity>(expected);
}

but not this:

one(mocked).method(with(aPropertyValuesAsMatcher(expected)));

 <at> Factory
public Matcher<List<Entity>> aPropertyValuesAsMatcher(
   final List<Entity> expected) {
       return new SamePropertyValuesAs<List<Entity>>(expected);
}

I got
java.lang.NoSuchMethodError:
org.hamcrest.beans.PropertyUtil.propertyDescriptorsFor(Ljava/lang/Object;Ljava/lang/Class;)[Ljava/beans/PropertyDescriptor;
	at org.hamcrest.beans.SamePropertyValuesAs.<init>(SamePropertyValuesAs.java:27)

I know java.util.List is not a Bean ....

wkr Thomas

(Continue reading)


Gmane