diff options
author | Simon Rettberg | 2023-04-26 14:44:47 +0200 |
---|---|---|
committer | Simon Rettberg | 2023-04-26 14:44:47 +0200 |
commit | 51040e0f9d74b047e8838784e6119d0a6cfca5c0 (patch) | |
tree | e093bc3912e84c99a94426a0f278eb642700285a /src | |
parent | [libvirt] Update rng files (diff) | |
download | master-sync-shared-51040e0f9d74b047e8838784e6119d0a6cfca5c0.tar.gz master-sync-shared-51040e0f9d74b047e8838784e6119d0a6cfca5c0.tar.xz master-sync-shared-51040e0f9d74b047e8838784e6119d0a6cfca5c0.zip |
[libvirt] Remove config validation on construction
Instead, we should do this explicitly after instantiating, so we can
give the user the option to ignore this error and proceed.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/openslx/libvirt/xml/LibvirtXmlDocument.java | 28 | ||||
-rw-r--r-- | src/test/java/org/openslx/libvirt/xml/LibvirtXmlDocumentTest.java | 3 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/main/java/org/openslx/libvirt/xml/LibvirtXmlDocument.java b/src/main/java/org/openslx/libvirt/xml/LibvirtXmlDocument.java index c428988..06f8ba8 100644 --- a/src/main/java/org/openslx/libvirt/xml/LibvirtXmlDocument.java +++ b/src/main/java/org/openslx/libvirt/xml/LibvirtXmlDocument.java @@ -117,10 +117,9 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( String xml ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this( xml, null ); } @@ -133,14 +132,12 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( String xml, InputStream rngSchema ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this.createXmlContext( rngSchema ); this.fromXml( xml ); - this.validateXml(); } /** @@ -150,10 +147,9 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( File xml ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this( xml, null ); } @@ -166,14 +162,12 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( File xml, InputStream rngSchema ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this.createXmlContext( rngSchema ); this.fromXml( xml ); - this.validateXml(); } /** @@ -183,10 +177,9 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( InputStream xml ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this( xml, null ); } @@ -199,14 +192,12 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( InputStream xml, InputStream rngSchema ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this.createXmlContext( rngSchema ); this.fromXml( xml ); - this.validateXml(); } /** @@ -216,10 +207,9 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( InputSource xml ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this( xml, null ); } @@ -232,14 +222,12 @@ public abstract class LibvirtXmlDocument implements LibvirtXmlSerializable, Libv * * @throws LibvirtXmlDocumentException creation of XML context failed. * @throws LibvirtXmlSerializationException serialization of the XML content failed. - * @throws LibvirtXmlValidationException XML content is not a valid Libvirt XML. */ public LibvirtXmlDocument( InputSource xml, InputStream rngSchema ) - throws LibvirtXmlDocumentException, LibvirtXmlSerializationException, LibvirtXmlValidationException + throws LibvirtXmlDocumentException, LibvirtXmlSerializationException { this.createXmlContext( rngSchema ); this.fromXml( xml ); - this.validateXml(); } /** diff --git a/src/test/java/org/openslx/libvirt/xml/LibvirtXmlDocumentTest.java b/src/test/java/org/openslx/libvirt/xml/LibvirtXmlDocumentTest.java index 15d203c..56ceeed 100644 --- a/src/test/java/org/openslx/libvirt/xml/LibvirtXmlDocumentTest.java +++ b/src/test/java/org/openslx/libvirt/xml/LibvirtXmlDocumentTest.java @@ -152,7 +152,8 @@ public class LibvirtXmlDocumentTest public void testValidateIncorrectXmlFile() { Executable validateXmlDocument = () -> { - this.newLibvirtXmlDocumentValidationInstance( "qemu-kvm_default-ubuntu-20-04-vm-invalid.xml", "domain.rng" ); + LibvirtXmlDocument doc = this.newLibvirtXmlDocumentValidationInstance( "qemu-kvm_default-ubuntu-20-04-vm-invalid.xml", "domain.rng" ); + doc.validateXml(); }; assertThrows( LibvirtXmlValidationException.class, validateXmlDocument ); |