Skip to content

Commit

Permalink
SYMMETRICDS-104 - Allow blank external ids
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 30, 2009
1 parent 8ca0fbd commit ea36409
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Expand Up @@ -42,7 +42,10 @@ public String selectNodeId(INodeService nodeService, Node node) {
return nodeId;
}
nodeId = buildNodeId(nodeService, node) + "-" + sequence;
}
}

return nodeId;

}
return node.getNodeId();
}
Expand All @@ -65,7 +68,7 @@ public String generateNodeId(INodeService nodeService, Node node) {
}

protected String buildNodeId(INodeService nodeService, Node node) {
return node.getExternalId();
return StringUtils.isBlank(node.getExternalId()) ? "0" : node.getExternalId();
}

public String generatePassword(INodeService nodeService, Node node) {
Expand Down
Expand Up @@ -109,11 +109,27 @@ public void testRegisterNode() throws Exception {
assertEquals(security.isRegistrationEnabled(), false, "Wrong isRegistrationEnabled");
assertNotSame(security.getRegistrationTime(), null, "Wrong registrationTime");
}

@Test
public void testRegisterWithBlankExternalId() throws Exception {
Node node = new Node();
node.setNodeGroupId(TestConstants.TEST_CLIENT_NODE_GROUP);
node.setExternalId(null);
node.setSyncURL("http://localhost:8080/sync");
node.setSchemaVersion("1");
node.setDatabaseType("MySQL");
node.setDatabaseVersion("5");
ByteArrayOutputStream out = new ByteArrayOutputStream();
assertFalse(registrationService.registerNode(node, out, true), "Node should not be allowed to register");
registrationService.openRegistration(TestConstants.TEST_CLIENT_NODE_GROUP, "0");
node.setExternalId(null);
node.setNodeId(null);
assertTrue(registrationService.registerNode(node, out, true), "Node should be allowed to register");
}

@Test
public void testRegisterNodeAutomatic() throws Exception {
try {

getParameterService().saveParameter(ParameterConstants.AUTO_REGISTER_ENABLED, true);
doTestRegisterNodeAutomatic();
} finally {
Expand Down

0 comments on commit ea36409

Please sign in to comment.