@Test
public void testParseConfiguration() throws IOException {

  // ATTRIBUTE_NAME,ATTRIBUTE_TYPE,ATTRIBUTE_VALUE
  String attributesStr = "hostname,STRING,host1234:uptime,STRING,321543";
  Set<NodeAttribute> attributes = nodeAttributesProvider
      .parseAttributes(attributesStr);
  Assert.assertEquals(2, attributes.size());
  Iterator<NodeAttribute> ait = attributes.iterator();
  while(ait.hasNext()) {
    NodeAttribute attr = ait.next();
    NodeAttributeKey at = attr.getAttributeKey();
    if (at.getAttributeName().equals("hostname")) {
      Assert.assertEquals("hostname", at.getAttributeName());
      Assert.assertEquals(NodeAttribute.PREFIX_DISTRIBUTED,
          at.getAttributePrefix());
      Assert.assertEquals(NodeAttributeType.STRING,
          attr.getAttributeType());
      Assert.assertEquals("host1234", attr.getAttributeValue());
    } else if (at.getAttributeName().equals("uptime")) {
      Assert.assertEquals("uptime", at.getAttributeName());
      Assert.assertEquals(NodeAttribute.PREFIX_DISTRIBUTED,
          at.getAttributePrefix());
      Assert.assertEquals(NodeAttributeType.STRING,
          attr.getAttributeType());
      Assert.assertEquals("321543", attr.getAttributeValue());
    } else {
      Assert.fail("Unexpected attribute");
    }
  }
  // Missing type
  attributesStr = "hostname,host1234";
  try {
    nodeAttributesProvider.parseAttributes(attributesStr);
    Assert.fail("Expecting a parsing failure");
  } catch (IOException e) {
    Assert.assertNotNull(e);
    Assert.assertTrue(e.getMessage().contains("Invalid value"));
  }
  // Extra prefix
  attributesStr = "prefix/hostname,STRING,host1234";
  try {
    nodeAttributesProvider.parseAttributes(attributesStr);
    Assert.fail("Expecting a parsing failure");
  } catch (IOException e) {
    Assert.assertNotNull(e);
    Assert.assertTrue(e.getMessage()
        .contains("should not contain any prefix."));
  }
  // Invalid type
  attributesStr = "hostname,T,host1234";
  try {
    nodeAttributesProvider.parseAttributes(attributesStr);
    Assert.fail("Expecting a parsing failure");
  } catch (IOException e) {
    e.printStackTrace();
    Assert.assertNotNull(e);
    Assert.assertTrue(e.getMessage()
        .contains("Invalid node attribute type"));
  }
}