@Test public void testGetCurrentNode() { Node expected = activeNodes.get(0); NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(expected.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig); assertEquals(manager.getCurrentNode(), expected); }
public NodeInfo(String environment) { this(new NodeConfig().setEnvironment(environment)); }
public NodeInfo(String environment) { this(new NodeConfig().setEnvironment(environment)); }
@Override public void configure(Binder binder) { binder.bind(NodeInfo.class).in(Scopes.SINGLETON); NodeConfig nodeConfig = new NodeConfig() .setEnvironment(environment) .setNodeInternalAddress(InetAddresses.toAddrString(getV4Localhost())) .setNodeBindIp(getV4Localhost()); if (pool.isPresent()) { nodeConfig.setPool(pool.get()); } binder.bind(NodeConfig.class).toInstance(nodeConfig); newExporter(binder).export(NodeInfo.class).withGeneratedName(); }
@Override public void configure(Binder binder) { binder.bind(NodeInfo.class).in(Scopes.SINGLETON); NodeConfig nodeConfig = new NodeConfig() .setEnvironment(environment) .setNodeInternalAddress(InetAddresses.toAddrString(getV4Localhost())) .setNodeBindIp(getV4Localhost()); if (pool.isPresent()) { nodeConfig.setPool(pool.get()); } binder.bind(NodeConfig.class).toInstance(nodeConfig); newExporter(binder).export(NodeInfo.class).withGeneratedName(); }
@BeforeMethod public void setup() throws IOException { tempDir = Files.createTempDir().getCanonicalFile(); // getCanonicalFile needed to get around Issue 365 (http://code.google.com/p/guava-libraries/issues/detail?id=365) config = new HttpServerConfig() .setHttpPort(0) .setHttpsPort(0) .setLogPath(new File(tempDir, "http-request.log").getAbsolutePath()); nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeInternalAddress("localhost")); httpServerInfo = new HttpServerInfo(config, nodeInfo); }
@Test public void testValidations() { assertValidates(new NodeConfig() .setEnvironment("test") .setNodeId(UUID.randomUUID().toString())); assertFailsValidation(new NodeConfig().setNodeId("abc/123"), "nodeId", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig(), "environment", "may not be null", NotNull.class); assertFailsValidation(new NodeConfig().setEnvironment("FOO"), "environment", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig().setPool("FOO"), "pool", "is malformed", Pattern.class); } }
@Test public void testValidations() { assertValidates(new NodeConfig() .setEnvironment("test") .setNodeId(UUID.randomUUID().toString())); assertFailsValidation(new NodeConfig().setNodeId("abc/123"), "nodeId", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig(), "environment", "may not be null", NotNull.class); assertFailsValidation(new NodeConfig().setEnvironment("FOO"), "environment", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig().setPool("FOO"), "pool", "is malformed", Pattern.class); } }
@Test public void testValidations() { assertValidates(new NodeConfig() .setEnvironment("test") .setNodeId(UUID.randomUUID().toString())); assertFailsValidation(new NodeConfig().setNodeId("abc/123"), "nodeId", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig(), "environment", "may not be null", NotNull.class); assertFailsValidation(new NodeConfig().setEnvironment("FOO"), "environment", "is malformed", Pattern.class); assertFailsValidation(new NodeConfig().setPool("FOO"), "pool", "is malformed", Pattern.class); } }
@Test public void testGetCurrentNode() { Node expected = activeNodes.get(0); NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(expected.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient); assertEquals(manager.getCurrentNode(), expected); }
@BeforeMethod protected void setUp() throws Exception { nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool")); discoveryClient = new InMemoryDiscoveryClient(nodeInfo, MAX_AGE); serviceAnnouncement = ServiceAnnouncement.serviceAnnouncement(serviceType.value()).addProperty("a", "apple").build(); announcer = new Announcer(discoveryClient, ImmutableSet.of(serviceAnnouncement)); }
@BeforeMethod protected void setUp() throws Exception { nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool")); discoveryClient = new InMemoryDiscoveryClient(nodeInfo, MAX_AGE); serviceAnnouncement = ServiceAnnouncement.serviceAnnouncement(serviceType.value()).addProperty("a", "apple").build(); announcer = new Announcer(discoveryClient, ImmutableSet.of(serviceAnnouncement)); }
@BeforeMethod protected void setUp() throws Exception { nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool")); discoveryClient = new InMemoryDiscoveryClient(nodeInfo, MAX_AGE); serviceAnnouncement = ServiceAnnouncement.serviceAnnouncement(serviceType.value()).addProperty("a", "apple").build(); announcer = new Announcer(discoveryClient, ImmutableSet.of(serviceAnnouncement)); }
@Test public void testGetCurrentNode() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(currentNode.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig); try { assertEquals(manager.getCurrentNode(), currentNode); } finally { manager.stop(); } }
@Test public void testGetCurrentNode() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(currentNode.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig); try { assertEquals(manager.getCurrentNode(), currentNode); } finally { manager.stop(); } }
@Test public void testDefaults() { ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(NodeConfig.class) .setEnvironment(null) .setPool("general") .setNodeId(null) .setNodeInternalIp((String) null) .setNodeBindIp((String) null) .setNodeExternalAddress(null) .setLocation(null) .setBinarySpec(null) .setConfigSpec(null)); }
@Test public void testDefaults() { ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(NodeConfig.class) .setEnvironment(null) .setPool("general") .setNodeId(null) .setNodeInternalAddress(null) .setNodeBindIp((String) null) .setNodeExternalAddress(null) .setLocation(null) .setBinarySpec(null) .setConfigSpec(null) .setInternalAddressSource(IP)); }
@Test public void testDefaults() { ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(NodeConfig.class) .setEnvironment(null) .setPool("general") .setNodeId(null) .setNodeInternalAddress(null) .setNodeBindIp((String) null) .setNodeExternalAddress(null) .setLocation(null) .setBinarySpec(null) .setConfigSpec(null) .setInternalAddressSource(IP)); }
@Test public void testBuilderNodeInfo() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool")); ServiceDescriptor expected = new ServiceDescriptor( UUID.fromString("12345678-1234-1234-1234-123456789012"), nodeInfo.getNodeId(), "type", nodeInfo.getPool(), "location", ServiceState.STOPPED, ImmutableMap.of("a", "apple", "b", "banana")); ServiceDescriptor actual = serviceDescriptor(expected.getType()) .setId(expected.getId()) .setLocation(expected.getLocation()) .setNodeInfo(nodeInfo) .setState(expected.getState()) .addProperties(expected.getProperties()) .build(); assertDescriptorEquals(expected, actual); }
@Test public void testBuilderNodeInfo() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setPool("pool")); ServiceDescriptor expected = new ServiceDescriptor( UUID.fromString("12345678-1234-1234-1234-123456789012"), nodeInfo.getNodeId(), "type", nodeInfo.getPool(), "location", ServiceState.STOPPED, ImmutableMap.of("a", "apple", "b", "banana")); ServiceDescriptor actual = serviceDescriptor(expected.getType()) .setId(expected.getId()) .setLocation(expected.getLocation()) .setNodeInfo(nodeInfo) .setState(expected.getState()) .addProperties(expected.getProperties()) .build(); assertDescriptorEquals(expected, actual); }