@Test
public void testGenerateNodeIdFromPropsFileReadsExistingFile() throws Exception {

    // Create temporary nodeId.properties file
    ECKey key = new ECKey();
    String expectedNodePrivateKey = Hex.toHexString(key.getPrivKeyBytes());
    String expectedNodeId = Hex.toHexString(key.getNodeId());
    createNodeIdPropertiesFile("database-test", key);
    new GetNodeIdFromPropsFile("database-test").getNodePrivateKey();
    assertTrue(nodeIdPropertiesFile.exists());
    String contents = FileCopyUtils.copyToString(new FileReader(nodeIdPropertiesFile));
    String[] lines = StringUtils.tokenizeToStringArray(contents, "\n");
    assertEquals(4, lines.length);
    assertTrue(lines[0].startsWith("#Generated NodeID."));
    assertTrue(lines[1].startsWith("#"));
    assertTrue(lines[2].startsWith("nodeIdPrivateKey=" + expectedNodePrivateKey));
    assertTrue(lines[3].startsWith("nodeId=" + expectedNodeId));
}