Favor use of Properties vs. for configuration

This reverts a number of changes made in commit 3033a19. Primary changes
include:

 - Restoring the immutability of the Node class

 - The argparse4j Namespace object is no longer passed down through
   Guice modules

 - Instead, arguments are eagerly read from the Namespace object by the
   #main method and these values are used to populate the Properties
   object that is already supplied to each Guice module

Other changes include:

 - The addition of a BootstrapNodes#DEFAULT_BOOTSTRAP_NODE field as
   a convenient alias to BootstrapNodes#DIGITAL_OCEAN_1 (or whatever the
   future default bootstrap node may be)

 - A Node#getPortAsString method has been added for convenience when
   dealing with String-based properties

 - A variant of the Node#at static factory method has been added which
   accepts the port value as a String vs. an int--again this is for
   convenience when dealing with String-based properties

 - Tests have been added to NodeTests to reflect the above
This commit is contained in:
Chris Beams 2014-11-09 22:14:18 +01:00
parent 017ebb3f38
commit 162fc3da0e
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
9 changed files with 64 additions and 57 deletions

View file

@ -25,6 +25,7 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import java.util.HashMap;
import java.util.Properties;
import javafx.application.Application;
import javafx.stage.Stage;
@ -63,9 +64,7 @@ public class ViewLoaderTests {
@Before
public void setUp() {
Injector injector = Guice.createInjector(new MainModule("testApp",
new Namespace(new HashMap<>()),
TestApp.primaryStage));
Injector injector = Guice.createInjector(new MainModule(new Properties(), "testApp", TestApp.primaryStage));
ViewLoader.setInjector(injector);
}

View file

@ -44,6 +44,14 @@ public class NodeTests {
Node node2 = Node.at("bitsquare2.example.com", "203.0.113.2");
assertThat(node1a.hashCode(), equalTo(node1b.hashCode()));
assertThat(node1a.hashCode(), not(equalTo(node2.hashCode())));
assertThat(node1a.getPort(), equalTo(Node.DEFAULT_PORT));
assertThat(node1a.getPortAsString(), equalTo(String.valueOf(Node.DEFAULT_PORT)));
Node node3a = Node.at("bitsquare3.example.com", "203.0.113.3", 1234);
Node node3b = Node.at("bitsquare3.example.com", "203.0.113.3", "1234");
assertThat(node3a, equalTo(node3b));
}
@Test