History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: UNI-135
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Tim Ducheyne
Reporter: Pieter Valcke
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Unitils

Mocking methods with return values of type long doesn't work

Created: 14/May/09 02:17 PM   Updated: 01/Nov/09 10:13 PM
Component/s: None
Affects Version/s: 2.2
Fix Version/s: 2.3


 Description  « Hide
The below code is a test where for no apparent reason the methods with long or Long as return value fail. The resulting stack trace is also somewhat confusing :)

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.unitils.UnitilsJUnit4;
import org.unitils.mock.Mock;

public class IntLongTest extends UnitilsJUnit4 {

    interface TestInterface {

        public int getInt(String argument);
        
        public Integer getIntObject(String argument);
        
        public long getLong(String argument);
        
        public Long getLongObject(String argument);
    }

    private Mock<TestInterface> testInterface;

    @Test
    public void testLong() {
        testInterface.onceReturns(1l).getLong("blubber");
        assertEquals(1, testInterface.getMock().getLong("blubber"));
    }
    
    @Test
    public void testLongObject() {
        testInterface.onceReturns(new Long(1l)).getLongObject("blubber2");
        assertEquals(new Long(1l), testInterface.getMock().getLongObject("blubber"));
    }
    
    @Test
    public void testInt() {
        testInterface.onceReturns(1).getInt("blub");
        assertEquals(1, testInterface.getMock().getInt("blub"));
    }
    
    @Test
    public void testIntObject() {
        testInterface.onceReturns(new Integer(1)).getIntObject("blub2");
        assertEquals(new Integer(1), testInterface.getMock().getIntObject("blub2"));
    }
}


 All   Comments   Change History      Sort Order:
Maarten Van Avermaet - 30/Oct/09 02:50 PM
I tried to execute this piece of code on unitils 2.4
but the Long-tests still fail...

Maarten Van Avermaet - 01/Nov/09 10:13 PM
Please ignore my previous comment...

The String parameter in the testLongObject are not matching "blubber2" vs "blubber".

Regards,
M.