Merge master

This commit is contained in:
Edward Capriolo
2016-03-29 15:37:05 -04:00
parent 5a5f16515f
commit 3cbd29cfe2
2 changed files with 18 additions and 22 deletions

View File

@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import com.google.code.gossip.GossipMember; import com.google.code.gossip.GossipMember;

View File

@ -8,11 +8,14 @@ import org.apache.log4j.Logger;
import org.json.JSONException; import org.json.JSONException;
import org.junit.Test; import org.junit.Test;
import io.teknek.tunit.TUnit;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -31,30 +34,24 @@ public class StartupSettingsTest {
log.debug( "Using settings file: " + settingsFile.getAbsolutePath() ); log.debug( "Using settings file: " + settingsFile.getAbsolutePath() );
settingsFile.deleteOnExit(); settingsFile.deleteOnExit();
writeSettingsFile(settingsFile); writeSettingsFile(settingsFile);
final GossipService firstService = new GossipService(
// Start the other simple node that the settings file points to
GossipService firstService = new GossipService(
"127.0.0.1", 50000, UUID.randomUUID().toString(), "127.0.0.1", 50000, UUID.randomUUID().toString(),
new ArrayList<GossipMember>(), new GossipSettings(), null new ArrayList<GossipMember>(), new GossipSettings(), null);
);
firstService.start(); firstService.start();
// Start a node with the settings file TUnit.assertThat(new Callable<Integer> (){
GossipService serviceUnderTest = new GossipService( public Integer call() throws Exception {
return firstService.get_gossipManager().getMemberList().size();
}}).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo(0);
final GossipService serviceUnderTest = new GossipService(
StartupSettings.fromJSONFile( settingsFile ) StartupSettings.fromJSONFile( settingsFile )
); );
serviceUnderTest.start(); serviceUnderTest.start();
TUnit.assertThat(new Callable<Integer> (){
// Let the sync up public Integer call() throws Exception {
TimeUnit.SECONDS.sleep(2); return serviceUnderTest.get_gossipManager().getMemberList().size();
}}).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo(1);
// Check the results
assertEquals(1, firstService.get_gossipManager().getMemberList().size() );
assertEquals(1, serviceUnderTest.get_gossipManager().getMemberList().size() );
assertTrue(
firstService.get_gossipManager().getMemberList().size() ==
serviceUnderTest.get_gossipManager().getMemberList().size() );
firstService.shutdown(); firstService.shutdown();
serviceUnderTest.shutdown(); serviceUnderTest.shutdown();
} }