-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from pixeltree/refactor_tests
Refactor tests
- Loading branch information
Showing
6 changed files
with
73 additions
and
60 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/org/opengis/cite/cdb10/metadataAndVersioning/GeomaticsAttributesXml.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.opengis.cite.cdb10.metadataAndVersioning; | ||
|
||
import org.testng.Assert; | ||
|
||
import java.nio.file.Files; | ||
|
||
/** | ||
* Created by martin on 2016-11-18. | ||
*/ | ||
public class GeomaticsAttributesXml extends MetadataXmlFile { | ||
public GeomaticsAttributesXml(String path) { | ||
super(path, "Geomatics_Attributes.xml", "Geomatics_Attributes.xsd"); | ||
} | ||
|
||
public void verifyGeomaticsAttributesXsdFileExists() { | ||
Assert.assertTrue(Files.exists(xsdFile.toPath()), | ||
"If Geomatics_Attributes.xml exists there should be a Geomatics_Attributes.xsd in the Schema folder"); | ||
} | ||
} |
35 changes: 7 additions & 28 deletions
35
...va/org/opengis/cite/cdb10/metadataAndVersioning/GeomaticsAttributesXmlStructureTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,28 @@ | ||
package org.opengis.cite.cdb10.metadataAndVersioning; | ||
|
||
import org.opengis.cite.cdb10.CommonFixture; | ||
import org.opengis.cite.cdb10.util.SchemaValidatorErrorHandler; | ||
import org.opengis.cite.cdb10.util.XMLUtils; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* Created by martin on 2016-09-10. | ||
*/ | ||
public class GeomaticsAttributesXmlStructureTests extends CommonFixture { | ||
|
||
@Test | ||
public void verifyGeomaticsAttributesXsdFileExists() { | ||
if (geomaticsAttributesXmlExists()) { | ||
Assert.assertTrue(Files.exists(Paths.get(path, "Metadata", "Schema", "Geomatics_Attributes.xsd")), | ||
"If Geomatics_Attributes.xml exists there should be a Geomatics_Attributes.xsd in the Schema folder"); | ||
} | ||
public void verifyGeomaticsAttributesXmlFileExists() { | ||
new GeomaticsAttributesXml(path); | ||
} | ||
|
||
@Test | ||
public void verifyGeomaticsAttributesXmlAgainstSchema() throws IOException, SAXException { | ||
if (geomaticsAttributesXmlExists() && geomaticsAttributesXsdExists()) { | ||
File xmlFile = Paths.get(path, "Metadata", "Geomatics_Attributes.xml").toFile(); | ||
File xsdFile = Paths.get(path, "Metadata", "Schema", "Geomatics_Attributes.xsd").toFile(); | ||
|
||
SchemaValidatorErrorHandler errorHandler = XMLUtils.validateXmlFileIsValid(xmlFile, xsdFile); | ||
|
||
if (!errorHandler.noErrors()) { | ||
Assert.fail(xmlFile.getName() + " does not contain valid XML. Errors: " + errorHandler.getMessages()); | ||
} | ||
} | ||
} | ||
|
||
private boolean geomaticsAttributesXmlExists() { | ||
return Paths.get(path, "Metadata", "Geomatics_Attributes.xml").toFile().exists(); | ||
public void verifyGeomaticsAttributesXsdFileExists() { | ||
new GeomaticsAttributesXml(path).verifyGeomaticsAttributesXsdFileExists(); | ||
} | ||
|
||
private boolean geomaticsAttributesXsdExists() { | ||
return Paths.get(path, "Metadata", "Schema", "Geomatics_Attributes.xsd").toFile().exists(); | ||
@Test | ||
public void verifyGeomaticsAttributesXmlAgainstSchema() throws IOException, SAXException { | ||
new GeomaticsAttributesXml(path).verifyXmlAgainstSchema(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/opengis/cite/cdb10/metadataAndVersioning/VendorAttributesXml.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.opengis.cite.cdb10.metadataAndVersioning; | ||
|
||
import org.testng.Assert; | ||
|
||
import java.nio.file.Files; | ||
|
||
/** | ||
* Created by martin on 2016-11-10. | ||
*/ | ||
public class VendorAttributesXml extends MetadataXmlFile { | ||
public VendorAttributesXml(String path) { | ||
super(path, "Vendor_Attributes.xml", "Vendor_Attributes.xsd"); | ||
} | ||
|
||
public void verifyVendorAttributesXsdFileExists() { | ||
Assert.assertTrue(Files.exists(xsdFile.toPath()), | ||
"If Vendor_Attributes.xml exists there should be a Vendor_Attributes.xsd in the Schema folder"); | ||
} | ||
} |
35 changes: 7 additions & 28 deletions
35
.../java/org/opengis/cite/cdb10/metadataAndVersioning/VendorAttributesXmlStructureTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,28 @@ | ||
package org.opengis.cite.cdb10.metadataAndVersioning; | ||
|
||
import org.opengis.cite.cdb10.CommonFixture; | ||
import org.opengis.cite.cdb10.util.SchemaValidatorErrorHandler; | ||
import org.opengis.cite.cdb10.util.XMLUtils; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* Created by martin on 2016-09-09. | ||
*/ | ||
public class VendorAttributesXmlStructureTests extends CommonFixture { | ||
|
||
@Test | ||
public void verifyVendorAttributesXsdFileExists() { | ||
if (vendorAttributesXmlExists()) { | ||
Assert.assertTrue(Files.exists(Paths.get(path, "Metadata", "Schema", "Vendor_Attributes.xsd")), | ||
"If Vendor_Attributes.xml exists there should be a Vendor_Attributes.xsd in the Schema folder"); | ||
} | ||
public void verifyVendorAttributesXmlFileExists() { | ||
new VendorAttributesXml(path); | ||
} | ||
|
||
@Test | ||
public void verifyVendorAttributesXmlAgainstSchema() throws IOException, SAXException { | ||
if (vendorAttributesXmlExists() && vendorAttributesXsdExists()) { | ||
File xmlFile = Paths.get(path, "Metadata", "Vendor_Attributes.xml").toFile(); | ||
File xsdFile = Paths.get(path, "Metadata", "Schema", "Vendor_Attributes.xsd").toFile(); | ||
|
||
SchemaValidatorErrorHandler errorHandler = XMLUtils.validateXmlFileIsValid(xmlFile, xsdFile); | ||
|
||
if (!errorHandler.noErrors()) { | ||
Assert.fail(xmlFile.getName() + " does not contain valid XML. Errors: " + errorHandler.getMessages()); | ||
} | ||
} | ||
} | ||
|
||
private boolean vendorAttributesXmlExists() { | ||
return Paths.get(path, "Metadata", "Vendor_Attributes.xml").toFile().exists(); | ||
public void verifyVendorAttributesXsdFileExists() { | ||
new VendorAttributesXml(path).verifyVendorAttributesXsdFileExists(); | ||
} | ||
|
||
private boolean vendorAttributesXsdExists() { | ||
return Paths.get(path, "Metadata", "Schema", "Vendor_Attributes.xsd").toFile().exists(); | ||
@Test | ||
public void verifyVendorAttributesXmlAgainstSchema() throws IOException, SAXException { | ||
new VendorAttributesXml(path).verifyXmlAgainstSchema(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters