Imrpove stability of tests

This commit is contained in:
Peter Lawrey
2015-05-19 20:29:26 +01:00
parent fe929fe605
commit f541496c1a
5 changed files with 17 additions and 19 deletions
@@ -18,6 +18,7 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.hash.impl.util.CloseablesManager;
import net.openhft.chronicle.hash.replication.ThrottlingConfig;
import net.openhft.chronicle.map.ReplicatedChronicleMap.BytesReplicatedContextFactory;
@@ -150,7 +151,7 @@ abstract class AbstractChannelReplicator implements Closeable {
* @return
*/
private static Selector openSelector(@NotNull final Selector selector,
@NotNull final SelectedSelectionKeySet selectedKeySet) {
@NotNull final SelectedSelectionKeySet selectedKeySet) {
try {
Class<?> selectorImplClass =
@@ -210,16 +211,12 @@ abstract class AbstractChannelReplicator implements Closeable {
abstract void processEvent() throws IOException;
final void start() {
future = executorService.submit(
new Runnable() {
@Override
public void run() {
try {
context = VanillaContext.get(BytesReplicatedContextFactory.INSTANCE);
processEvent();
} catch (Exception e) {
LOG.error("", e);
}
future = executorService.submit(() -> {
try {
context = VanillaContext.get(BytesReplicatedContextFactory.INSTANCE);
processEvent();
} catch (Exception e) {
LOG.error("", e);
}
}
);
@@ -286,9 +283,7 @@ abstract class AbstractChannelReplicator implements Closeable {
sb.append(lastThread);
sb.append(" isAlive= ");
sb.append(lastThread.isAlive());
for (StackTraceElement ste : lastThread.getStackTrace()) {
sb.append("\n\t").append(ste);
}
Jvm.trimStackTrace(sb, lastThread.getStackTrace());
LOG.warn(sb.toString());
}
}
@@ -85,7 +85,7 @@ public class ConstantSizeBySampleTest {
}
}
@Test
@Test(expected = IllegalStateException.class)
public void testUnexpectedlyLongConstantExternalizableValues() throws IOException {
try ( ChronicleMap<Long, ExternalizableData> map =
ChronicleMapBuilder.of(Long.class, ExternalizableData.class)
@@ -111,7 +111,7 @@ public class ConstantSizeBySampleTest {
}
}
@Test
@Test(expected = IllegalStateException.class)
public void testUnexpectedlyLongConstantSerializableValues() throws IOException {
try ( ChronicleMap<Long, SerializableData> map =
ChronicleMapBuilder.of(Long.class, SerializableData.class)
@@ -29,7 +29,7 @@ import static org.junit.Assert.assertSame;
public class RecursiveRefereneChMapTest {
public static final String TMP = System.getProperty("java.io.tmpdir");
@Test
@Test(expected = IllegalStateException.class)
public void testRecursive() throws IOException {
File file = new File(TMP + "/test." + System.nanoTime() + ".tmp");
file.deleteOnExit();
@@ -59,7 +59,7 @@ public class SingleMapChannelTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8086, new InetSocketAddress("localhost", 8087))
.of(18086, new InetSocketAddress("localhost", 18087))
.autoReconnectedUponDroppedConnection(true)
.heartBeatInterval(1, SECONDS);
@@ -75,7 +75,7 @@ public class SingleMapChannelTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8087, new InetSocketAddress("localhost", 8086))
.of(18087, new InetSocketAddress("localhost", 18086))
.autoReconnectedUponDroppedConnection(true)
.heartBeatInterval(1, SECONDS);
@@ -24,6 +24,7 @@ import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.lang.io.ByteBufferBytes;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.serialization.JDKZObjectSerializer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -374,6 +375,8 @@ public class StatelessClientTest {
try (ChronicleMap<String, Map> serverMap = ChronicleMapBuilder
.of(String.class, Map.class)
.entries(1000)
.averageValueSize(2000)
.objectSerializer(JDKZObjectSerializer.INSTANCE)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8056))
.create()) {
try (ChronicleMap<String, Map> statelessMap = localClient(8056)) {