@Test
public void readIntAttribute() throws XMLStreamException, FactoryConfigurationError, IOException {

  URL url = XmlHelperTest.class.getResource("/xml/default/kb-layout.xml");
  XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(url.openStream());
  reader.next();
  reader.require(XMLStreamConstants.START_ELEMENT, null, XmlHelper.KEYBOARD);
  assertEquals(Integer.valueOf(40),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_WIDTH).orElse(-1));
  assertEquals(Integer.valueOf(30),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_HEIGHT).orElse(-1));
  assertEquals(Integer.valueOf(0),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_H_GAP).orElse(-1));
  assertEquals(Integer.valueOf(0),
      XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_V_GAP).orElse(-1));
  assertNull(XmlHelper.readIntAttribute(reader, "verticalGapX").orElse(null));
  assertEquals(40, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_WIDTH, 1));
  assertEquals(30, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_KEY_HEIGHT, 1));
  assertEquals(0, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_H_GAP, 1));
  assertEquals(0, XmlHelper.readIntAttribute(reader, XmlHelper.ATTR_V_GAP, 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, "verticalGapX", 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, "", 1));
  assertEquals(1, XmlHelper.readIntAttribute(reader, null, 1));
}