Created
November 22, 2016 14:46
-
-
Save dbrimley/e81f05e841e86336a0d13a798773e259 to your computer and use it in GitHub Desktop.
Value Method is called using putIfAbsent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.craftedbytes.concurrency; | |
import org.junit.Test; | |
import java.util.concurrent.ConcurrentHashMap; | |
/** | |
* Created by davidbrimley on 22/11/2016. | |
*/ | |
public class PutIfAbsentTest { | |
@Test | |
public void proveValueMethodIsCalledEvenWhenKeyIsPresent() throws Exception { | |
ConcurrentHashMap<Integer,String> map = new ConcurrentHashMap<Integer, String>(); | |
map.put(1,"Existing Value"); | |
map.putIfAbsent(1,callMethod()); | |
} | |
private String callMethod() throws Exception { | |
throw new Exception("Calling the method!!!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment