1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.expectation; 3 4 import junit.framework.AssertionFailedError; 5 import org.jmock.AbstractTestCase; 6 7 public class TestReturnValue extends AbstractTestCase { 8 private ReturnValue value; 9 10 protected void setUp() throws Exception { 11 super.setUp(); 12 value = new ReturnValue(getName()); 13 } 14 15 public void testGetNull() { 16 value.setValue(null); 17 assertTrue(value.getValue() == null); 18 } 19 20 public void testGetValue() { 21 value.setValue(this); 22 assertEquals(this, value.getValue()); 23 } 24 25 public void testGetBooleanValue() { 26 value.setValue(true); 27 assertTrue(value.getBooleanValue()); 28 } 29 30 public void testIntValue() { 31 value.setValue(13); 32 assertEquals(13, value.getIntValue()); 33 } 34 35 public void testLongValue() { 36 long now = System.currentTimeMillis(); 37 value.setValue(now); 38 assertEquals(now, value.getLongValue()); 39 value.getIntValue(); 40 } 41 42 public void testValueNotSet() { 43 try { 44 value.getValue(); 45 fail("Error not thrown"); 46 } catch (AssertionFailedError e) { 47 assertEquals("The return value \"" + getName() + "\" has not been set.", e.getMessage()); 48 } 49 } 50 51 }

This page was automatically generated by Maven