diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 2d6e6e6f3b..1721a943e8 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -45,6 +45,7 @@ src/test/resources **/*.txt + **/*.xml diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillXmlHelper.java b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillXmlHelper.java new file mode 100644 index 0000000000..78ce6a19a2 --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/PhoneBillXmlHelper.java @@ -0,0 +1,19 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import edu.pdx.cs.joy.ProjectXmlHelper; + +public class PhoneBillXmlHelper extends ProjectXmlHelper { + + /** + * The Public ID for the Phone Bill DTD + */ + protected static final String PUBLIC_ID = + "-//Joy of Coding at PSU//DTD Phone Bill//EN"; + + protected PhoneBillXmlHelper() { + super(PUBLIC_ID, "phonebill.dtd"); + } +} diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java index 4c2293a9ef..2df0a2f93c 100644 --- a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/java/TextDumper.java @@ -3,10 +3,8 @@ #set( $symbol_escape = '\' ) package ${package}; -import edu.pdx.cs.joy.AppointmentBookDumper; import edu.pdx.cs.joy.PhoneBillDumper; -import java.io.IOException; import java.io.PrintWriter; import java.io.Writer; diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html new file mode 100644 index 0000000000..6d4adf245a --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/main/javadoc/edu/pdx/cs410J/__artifactId__/package.html @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +

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 = '\' ) + + + + + + Dave + + 503-245-2345 + + + + + + + + + diff --git a/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-__artifactId__.xml b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-__artifactId__.xml new file mode 100644 index 0000000000..7fd53d021f --- /dev/null +++ b/projects-parent/archetypes-parent/phonebill-archetype/src/main/resources/archetype-resources/src/test/resources/__packageInPathFormat__/valid-__artifactId__.xml @@ -0,0 +1,36 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + + + + + + Dave + + 503-245-2345 + 607-777-1369 + + + + + + + + + + 603-868-1932 + 765-497-8254 + + + + + + + +