Contains the application classes for the Phone Bill project.
+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillXmlHelperTest.java b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillXmlHelperTest.java new file mode 100644 index 0000000000..43cefe97f2 --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/java/PhoneBillXmlHelperTest.java @@ -0,0 +1,55 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +class PhoneBillXmlHelperTest { + + @Test + void canParseValidXmlFile() throws ParserConfigurationException, IOException, SAXException { + PhoneBillXmlHelper helper = new PhoneBillXmlHelper(); + + + DocumentBuilderFactory factory = + DocumentBuilderFactory.newInstance(); + factory.setValidating(true); + + DocumentBuilder builder = + factory.newDocumentBuilder(); + builder.setErrorHandler(helper); + builder.setEntityResolver(helper); + + builder.parse(this.getClass().getResourceAsStream("valid-${artifactId}.xml")); + } + + @Test + void cantParseInvalidXmlFile() throws ParserConfigurationException { + PhoneBillXmlHelper helper = new PhoneBillXmlHelper(); + + + DocumentBuilderFactory factory = + DocumentBuilderFactory.newInstance(); + factory.setValidating(true); + + DocumentBuilder builder = + factory.newDocumentBuilder(); + builder.setErrorHandler(helper); + builder.setEntityResolver(helper); + + assertThrows(SAXParseException.class, () -> + builder.parse(this.getClass().getResourceAsStream("invalid-${artifactId}.xml")) + ); + } + +} diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 0000000000..a579da692a --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +Contains the test classes for the Phone Bill project.
+ \ No newline at end of file diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-__artifactId__.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-__artifactId__.xml new file mode 100644 index 0000000000..a912ef8777 --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/invalid-__artifactId__.xml @@ -0,0 +1,23 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + + + + +