@Test
public void testAttributeNamespace() throws XMLStreamException {

	XMLStreamReader reader = createXmlStreamReader("<alice david=\"edgar\" xmlns=\"http://foo\"/>");
	StartElement startElement = eventAllocator.allocate(reader).asStartElement();
	verify(startElement, XMLStreamConstants.START_ELEMENT, "<alice xmlns=\"http://foo\" david=\"edgar\">");
	Iterator<?> attributes = startElement.getAttributes();
	Assert.assertTrue(attributes.hasNext());
	Attribute attribute = (Attribute)attributes.next();
	verify(attribute, XMLStreamConstants.ATTRIBUTE, "david=\"edgar\"");
	Assert.assertEquals(new QName("david"), attribute.getName());
	Assert.assertEquals("edgar", attribute.getValue());
	Assert.assertFalse(attributes.hasNext());
	
	Iterator<?> namespaces = startElement.getNamespaces();
	Assert.assertTrue(namespaces.hasNext());
	Namespace namespace = (Namespace)namespaces.next();
	verify(namespace, XMLStreamConstants.NAMESPACE, "xmlns=\"http://foo\"");
	Assert.assertEquals(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns"), namespace.getName());
	Assert.assertEquals("http://foo", namespace.getValue());
	Assert.assertEquals(XMLConstants.DEFAULT_NS_PREFIX, namespace.getPrefix());
	Assert.assertEquals("http://foo", namespace.getNamespaceURI());
	Assert.assertFalse(namespaces.hasNext());
	reader = createXmlStreamReader("<alice p:david=\"edgar\" xmlns:p=\"http://foo\"/>");
	startElement = eventAllocator.allocate(reader).asStartElement();
	verify(startElement, XMLStreamConstants.START_ELEMENT, "<alice xmlns:p=\"http://foo\" p:david=\"edgar\">");
	attributes = startElement.getAttributes();
	Assert.assertTrue(attributes.hasNext());
	attribute = (Attribute)attributes.next();
	verify(attribute, XMLStreamConstants.ATTRIBUTE, "p:david=\"edgar\"");
	Assert.assertEquals(new QName("http://foo", "david", "p"), attribute.getName());
	Assert.assertEquals("edgar", attribute.getValue());
	Assert.assertFalse(attributes.hasNext());
	
	namespaces = startElement.getNamespaces();
	Assert.assertTrue(namespaces.hasNext());
	namespace = (Namespace)namespaces.next();
	verify(namespace, XMLStreamConstants.NAMESPACE, "xmlns:p=\"http://foo\"");
	Assert.assertEquals(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "p", "xmlns"), namespace.getName());
	Assert.assertEquals("http://foo", namespace.getValue());
	Assert.assertEquals("p", namespace.getPrefix());
	Assert.assertEquals("http://foo", namespace.getNamespaceURI());
	Assert.assertFalse(namespaces.hasNext());
}