commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From britter <...@git.apache.org>
Subject [GitHub] commons-lang pull request: LANG-740 - Implementation of a Memomize...
Date Tue, 05 May 2015 18:20:04 GMT
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/80#discussion_r29696865
  
    --- Diff: src/test/java/org/apache/commons/lang3/concurrent/MemoizerTest.java ---
    @@ -0,0 +1,112 @@
    +package org.apache.commons.lang3.concurrent;
    +
    +import org.easymock.EasyMockRunner;
    +import org.easymock.Mock;
    +import org.junit.Test;
    +import org.junit.runner.RunWith;
    +
    +import static org.easymock.EasyMock.expect;
    +import static org.easymock.EasyMock.replay;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.fail;
    +
    +@RunWith(EasyMockRunner.class)
    +public class MemoizerTest {
    +
    +	@Mock
    +	private Computable<Integer, Integer> computable;
    +
    +	@Test
    +	public void testOnlyCallComputableOnceIfDoesNotThrowException() throws Exception {
    +		Integer input = 1;
    +		Memoizer<Integer, Integer> memoizer = new Memoizer<Integer, Integer>(computable);
    +		expect(computable.compute(input)).andReturn(input);
    +		replay(computable);
    +
    +		assertEquals("Should call computable first time", input, memoizer.compute(input));
    +		assertEquals("Should not call the computable the second time", input, memoizer.compute(input));
    +	}
    +
    +	@Test(expected = IllegalStateException.class)
    +	public void testDefaultBehaviourNotToRecalculateExecutionExceptions() throws Exception
{
    +		Integer input = 1;
    +		Integer answer = 3;
    --- End diff --
    
    answer is unused


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message