@Test(expectedExceptions = IllegalArgumentException.class) public void checkExtensionsMissingRootElement() throws ParserConfigurationException { final DocumentBuilderFactory dbf = XMLProvider.provider().documentBuilderFactory(); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document doc = db.newDocument(); XML.checkExtensions(doc); }
static Document checkExtensions(final Document extensions) { if (extensions != null) { final Element root = extensions.getDocumentElement(); if (root == null) { throw new IllegalArgumentException( "'extensions' has no document element." ); } if (!"extensions".equals(root.getNodeName())) { throw new IllegalArgumentException(format( "Expected 'extensions' root element, but got '%s'.", root.getNodeName() )); } if (root.getNamespaceURI() != null) { final String ns = root.getNamespaceURI(); if (!ns.isEmpty() && !ns.startsWith("http: !ns.startsWith("http: { throw new IllegalArgumentException(format( "Invalid document namespace: '%s'.", ns )); } } } return extensions; }
XML { static Document checkExtensions(final Document extensions) { if (extensions != null) { final Element root = extensions.getDocumentElement(); if (root == null) { throw new IllegalArgumentException( "'extensions' has no document element." ); } if (!"extensions".equals(root.getNodeName())) { throw new IllegalArgumentException(format( "Expected 'extensions' root element, but got '%s'.", root.getNodeName() )); } if (root.getNamespaceURI() != null) { final String ns = root.getNamespaceURI(); if (!ns.isEmpty() && !ns.startsWith("http: !ns.startsWith("http: { throw new IllegalArgumentException(format( "Invalid document namespace: '%s'.", ns )); } } } return extensions; } }
XML { static Document checkExtensions(final Document extensions) { if (extensions != null) { final Element root = extensions.getDocumentElement(); if (root == null) { throw new IllegalArgumentException( "'extensions' has no document element." ); } if (!"extensions".equals(root.getNodeName())) { throw new IllegalArgumentException(format( "Expected 'extensions' root element, but got '%s'.", root.getNodeName() )); } if (root.getNamespaceURI() != null) { final String ns = root.getNamespaceURI(); if (!ns.isEmpty() && !ns.startsWith("http: !ns.startsWith("http: { throw new IllegalArgumentException(format( "Invalid document namespace: '%s'.", ns )); } } } return extensions; } private  XML(); }
XML { static Document checkExtensions(final Document extensions) { if (extensions != null) { final Element root = extensions.getDocumentElement(); if (root == null) { throw new IllegalArgumentException( "'extensions' has no document element." ); } if (!"extensions".equals(root.getNodeName())) { throw new IllegalArgumentException(format( "Expected 'extensions' root element, but got '%s'.", root.getNodeName() )); } if (root.getNamespaceURI() != null) { final String ns = root.getNamespaceURI(); if (!ns.isEmpty() && !ns.startsWith("http: !ns.startsWith("http: { throw new IllegalArgumentException(format( "Invalid document namespace: '%s'.", ns )); } } } return extensions; } private  XML();  }
XML { static Document checkExtensions(final Document extensions) { if (extensions != null) { final Element root = extensions.getDocumentElement(); if (root == null) { throw new IllegalArgumentException( "'extensions' has no document element." ); } if (!"extensions".equals(root.getNodeName())) { throw new IllegalArgumentException(format( "Expected 'extensions' root element, but got '%s'.", root.getNodeName() )); } if (root.getNamespaceURI() != null) { final String ns = root.getNamespaceURI(); if (!ns.isEmpty() && !ns.startsWith("http: !ns.startsWith("http: { throw new IllegalArgumentException(format( "Invalid document namespace: '%s'.", ns )); } } } return extensions; } private  XML();   }