updated test cases

This commit is contained in:
Rob Austin
2014-12-22 14:44:54 +00:00
parent 0b765451a8
commit 7ad50e64ea
9 changed files with 518 additions and 242 deletions
@@ -0,0 +1,91 @@
package net.openhft.chronicle.map;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertTrue;
/**
* @author Rob Austin.
*/
public class KeyValueInstanceTest {
@Test(expected = IllegalStateException.class)
public void testLongNewKeyValueInstance() {
try (ChronicleMap map = ChronicleMapBuilder
.of(Long.class, Long.class)
.create()) {
map.newKeyInstance();
map.newValueInstance();
}
}
@Test(expected = IllegalStateException.class)
public void testNewKeyValueInstanceWithMapType() {
try (ChronicleMap map = ChronicleMapBuilder
.of(Map.class, Map.class)
.create()) {
map.newKeyInstance();
map.newValueInstance();
}
}
@Test
public void testNewKeyValueInstanceWithHahMapType() {
try (ChronicleMap map = ChronicleMapBuilder
.of(HashMap.class, HashMap.class)
.create()) {
Object key = map.newKeyInstance();
Object value = map.newValueInstance();
}
}
interface IBean {
long getLong();
void setLong(long num);
double getDouble();
void setDouble(double d);
int getInt();
void setInt(int i);
}
@Test
public void testNewKeyValueInstanceWithListType() {
try (ChronicleMap map = ChronicleMapBuilder
.of(HashMap.class, IBean.class)
.create()) {
map.newKeyInstance();
Object value = map.newValueInstance();
assertTrue(value.getClass().getCanonicalName().endsWith("$$Native"));
}
}
@Test(expected = IllegalStateException.class)
public void testNewKeyValueInstanceWithByteArray() {
try (ChronicleMap map = ChronicleMapBuilder
.of(byte[].class, byte[].class)
.create()) {
map.newKeyInstance();
map.newValueInstance();
}
}
}