rmock mock object only returns default value

Discussion in 'Java' started by mfaine, Aug 23, 2007.

  1. mfaine

    mfaine Guest

    rMock with JUnit 3.81 and Java 1.4.2

    I have a implemented method of an interface that changes the ACL of an
    object in a document management system:

    void changeACL(String docbase, IDfSysObject reference, String
    aclDomain, String aclName) throws DfServiceException

    I have a test method:

    public final void testChangeACL() {
    /* Set up Mock objects */
    IDfSysObject mockObj = (IDfSysObject) mock(IDfSysObject.class);
    IDoctypeSBO sbo = (IDoctypeSBO) mock(IDoctypeSBO.class);

    /* Expectations */
    try {
    sbo.changeACL("docbasename", mockObj, "newdomain", "newacl");
    mockObj.getACLName();
    mockObj.getACLDomain();
    } catch (DfException dfe) {
    }

    /* Verification */
    startVerification();
    try {
    sbo.changeACL("docbasename", mockObj, "newdomain", "newacl");
    assertThat(mockObj.getACLName(), is.eq("newacl"));
    assertThat(mockObj.getACLDomain(), is.eq("newdomain"));
    } catch (DfException dfe) {
    }
    }

    The problem is that the assertions fail with:

    com.agical.rmock.core.exception.RMockAssertionFailedException:
    ASSERTION FAILED!
    <null>
    does not pass the expression:
    <eq(<newacl>)>
    ....

    I think this is because mockObj.getACLName() is returning null because
    it is not affected by the changeACL method. How can I make the
    changeACL method have an affect, i.e. change attributes of the mocked
    object?

    thanks,
    -Mark
    mfaine, Aug 23, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken
    Replies:
    0
    Views:
    359
  2. John J. Lee

    Mock object creation by example?

    John J. Lee, Jul 9, 2003, in forum: Python
    Replies:
    0
    Views:
    474
    John J. Lee
    Jul 9, 2003
  3. John J. Lee
    Replies:
    4
    Views:
    368
    John J. Lee
    Nov 8, 2003
  4. Remy Blank
    Replies:
    3
    Views:
    878
    Lothar Scholz
    Mar 6, 2004
  5. Matthew Wilson
    Replies:
    1
    Views:
    257
    Gabriel Genellina
    Oct 18, 2007
Loading...

Share This Page