From 23d94257e183bebe5b88777ccb4f56811352739c Mon Sep 17 00:00:00 2001 From: leventov Date: Thu, 10 Sep 2015 17:00:38 +0300 Subject: [PATCH] HCOLL-384 add a test for issue #37 --- .../openhft/chronicle/map/Issue37Test.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/test/java/net/openhft/chronicle/map/Issue37Test.java diff --git a/src/test/java/net/openhft/chronicle/map/Issue37Test.java b/src/test/java/net/openhft/chronicle/map/Issue37Test.java new file mode 100644 index 000000000..4cf972da6 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/map/Issue37Test.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015 higherfrequencytrading.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package net.openhft.chronicle.map; + +import net.openhft.chronicle.hash.replication.ReplicationHub; +import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +public class Issue37Test { + + @Test + public void issue37Test() throws IOException { + int port = 1000; + String remoteHost = "localhost"; + int remotePort = 2000; + + TcpTransportAndNetworkConfig tcpReplicationConfig = TcpTransportAndNetworkConfig + .of(port, new InetSocketAddress(remoteHost, remotePort)) + .heartBeatInterval(1, TimeUnit.SECONDS) + .autoReconnectedUponDroppedConnection(true); + + ReplicationHub replicationHub = ReplicationHub.builder() + .tcpTransportAndNetwork(tcpReplicationConfig) + .maxNumberOfChannels(1024) + .createWithId((byte)1); + + File file1 = Builder.getPersistenceFile(); + ChronicleMap map1 = ChronicleMapBuilder.of(String.class, String.class) + .instance() + .replicatedViaChannel(replicationHub.createChannel(2)) + .persistedTo(file1) + .create(); + + File file2 = Builder.getPersistenceFile(); + ChronicleMap map2 = ChronicleMapBuilder.of(String.class, String.class) + .instance() + .replicatedViaChannel(replicationHub.createChannel(3)) + .persistedTo(file2) + .create(); + + map2.close(); + map1.close(); + } +}