下面列出了java.util.concurrent.ConcurrentNavigableMap#putIfAbsent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testDescendingPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testDescendingPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testDescendingPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
private void addPathPrefix(
ConcurrentNavigableMap<String, ConcurrentNavigableMap<String, Collection<Class<?>>>> map,
String suffix, String prefix, Class<?> role) {
ConcurrentNavigableMap<String, Collection<Class<?>>> m, o;
m = map.get(suffix);
if (m == null) {
m = new ConcurrentSkipListMap<String, Collection<Class<?>>>();
o = map.putIfAbsent(suffix, m);
if (o != null) {
m = o;
}
}
add(m, prefix, role);
}
private void addPath(
ConcurrentNavigableMap<String, ConcurrentMap<String, Collection<Class<?>>>> map,
String suffix, String prefix, Class<?> role) {
ConcurrentMap<String, Collection<Class<?>>> m, o;
m = map.get(suffix);
if (m == null) {
m = new ConcurrentHashMap<String, Collection<Class<?>>>();
o = map.putIfAbsent(suffix, m);
if (o != null) {
m = o;
}
}
add(m, prefix, role);
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent(null, x) throws NPE
*/
public void testDescendingPutIfAbsent1_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
/**
* putIfAbsent works when the given key is not present
*/
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testDescendingPutIfAbsent() {
ConcurrentNavigableMap map = dmap5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testDescendingPutIfAbsent() {
ConcurrentNavigableMap map = dmap5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testDescendingPutIfAbsent() {
ConcurrentNavigableMap map = dmap5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
/**
* putIfAbsent works when the given key is not present
*/
public void testDescendingPutIfAbsent() {
ConcurrentNavigableMap map = dmap5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}