Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] Fwd: [Codehaus] Subscription confirmation for user@jmock.codehaus.org

Noam Ledany

2012-01-30

Replies: Find Java Web Hosting

Author LoginPost Reply
Hello,

I'm currently studying the jMock framework using your site.
I run into the following example ( about overrding expectations ) and it seems to me there is a mistake in the code:

@RunWith(JMock.class)
public class ChildTest {
    Mockery context = new JUnit4Mockery();
    States test = mockery.states("test");

    Parent parent = context.mock(Parent.class);

    // This is created in setUp
    Child child;
    
    @Before
    public void createChildOfParent() {
        mockery.checking(new Expectations() {{
            ignoring (parent).addChild(child); when(test.isNot("fully-set-up"));
        }});
        
        // Creating the child adds it to the parent
        child = new Child(parent);
        
        test.become("fully-set-up");
    }
    
    @Test
    public void removesItselfFromOldParentWhenAssignedNewParent() {
        Parent newParent = context.mock(Parent.class, "newParent");
        
        context.checking(new Expectations() {{
            oneOf (parent).removeChild(child);
            oneOf (newParent).addChild(child);
        }});
        
        child.reparent(newParent);
    }
}
What is mockery  variable? Did you mean context and it's a misprint? or I'm getting it the wrong way?

Thanks,

Noam.



---------- Forwarded message ----------
From: <xircles@codehaus.org>
Date: Mon, Jan 30, 2012 at 8:52 AM
Subject: [Codehaus] Subscription confirmation for user@jmock.codehaus.org
To: noam@fashion-traffic.com


Hello noam@fashion-traffic.com

You have successfully subscribed to user@jmock.codehaus.org using this email address.

Thanks,

Codehaus


©2008 gg3721.com - Jax Systems, LLC, U.S.A.