From 8975dff97fe8c388fcef5e6030254977bd765a01 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Mon, 19 Feb 2018 08:21:23 +0100 Subject: [PATCH] Solution Sda1 winter 2017 --- Klausuren/Sda1/2017winter/Solve/.gitignore | 4 + Klausuren/Sda1/2017winter/Solve/Doc/exam.xml | 564 ++++++++++++++++++ Klausuren/Sda1/2017winter/Solve/Schema/fs.xsd | 63 ++ .../2017winter/Solve/Schema/sampledata.xml | 17 + .../Sda1/2017winter/Solve/Schema/schema.sql | 44 ++ .../Solve/SchemaTest/0100valid_minimum.xml | 7 + .../SchemaTest/0120valid_uniqueComponents.xml | 8 + .../SchemaTest/0122invalid_inodeString.xml | 12 + .../SchemaTest/0125invalid_missingName.xml | 15 + .../SchemaTest/0130invalid_missingInode.xml | 14 + .../SchemaTest/0135invalid_missingTarget.xml | 13 + .../0140invalid_duplicateObjectName.xml | 14 + .../SchemaTest/0160invalid_duplicateInode.xml | 13 + .../0165invalid_uniqueComponentsOrder.xml | 15 + .../Solve/SchemaTest/0180valid_hierarchy.xml | 15 + .../0200invalid_hierarchyDuplicateInode.xml | 18 + .../0220invalid_hierarchyDuplicateName.xml | 18 + .../0300invalid_hierarchyReference.xml | 18 + .../SchemaTest/0320invalid_hierarchyOrder.xml | 20 + .../Sda1/2017winter/Solve/Sql/Student.sql | 19 + Klausuren/Sda1/2017winter/Solve/pom.xml | 101 ++++ .../mi/sda1/exam/dataexport/Db2Html.java | 121 ++++ .../Solve/src/main/resources/log4j2.xml | 21 + .../mi/sda1/exam/xsd/test/SchemaTest.java | 26 + 24 files changed, 1180 insertions(+) create mode 100644 Klausuren/Sda1/2017winter/Solve/.gitignore create mode 100644 Klausuren/Sda1/2017winter/Solve/Doc/exam.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/Schema/fs.xsd create mode 100644 Klausuren/Sda1/2017winter/Solve/Schema/sampledata.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/Schema/schema.sql create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0100valid_minimum.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0120valid_uniqueComponents.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0122invalid_inodeString.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0125invalid_missingName.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0130invalid_missingInode.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0135invalid_missingTarget.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0140invalid_duplicateObjectName.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0160invalid_duplicateInode.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0165invalid_uniqueComponentsOrder.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0180valid_hierarchy.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0200invalid_hierarchyDuplicateInode.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0220invalid_hierarchyDuplicateName.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0300invalid_hierarchyReference.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/SchemaTest/0320invalid_hierarchyOrder.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/Sql/Student.sql create mode 100644 Klausuren/Sda1/2017winter/Solve/pom.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/Db2Html.java create mode 100644 Klausuren/Sda1/2017winter/Solve/src/main/resources/log4j2.xml create mode 100644 Klausuren/Sda1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java diff --git a/Klausuren/Sda1/2017winter/Solve/.gitignore b/Klausuren/Sda1/2017winter/Solve/.gitignore new file mode 100644 index 000000000..3498d4a33 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/.gitignore @@ -0,0 +1,4 @@ +/.classpath +/.project +A1.log + diff --git a/Klausuren/Sda1/2017winter/Solve/Doc/exam.xml b/Klausuren/Sda1/2017winter/Solve/Doc/exam.xml new file mode 100644 index 000000000..57971c6b7 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/Doc/exam.xml @@ -0,0 +1,564 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book version="5.0" xml:id="klausur_SoSe_2017" xml:lang="en" + xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes" + xmlns:xi="http://www.w3.org/2001/XInclude" + xmlns:trans="http://docbook.org/ns/transclusion" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:m="http://www.w3.org/1998/Math/MathML" + xmlns:html="http://www.w3.org/1999/xhtml" + xmlns:db="http://docbook.org/ns/docbook"> + <!-- saxon9he-xslt -s:klausur.xml -xsl:/usr/share/hdm-docbook-xsl/CustomLayer/Klausur/docbook2klausur.xsl --> + + <info> + <title/> + + <author> + <personname/> + </author> + + <pubdate/> + </info> + + <chapter xml:id="task1"> + <title>Representing file system meta data</title> + + <!-- Hier gemeinsames zip Archiv hochladen, auch von anderen Aufgaben. --> + + <section xml:id="aufgabe1_prepare"> + <title>Preparations</title> + + <para>Download and unzip the above file <filename>exam.zip</filename>. + Then import the resulting <filename>Exam</filename> folder as a Maven + project into your IntelliJ IDE.</para> + </section> + + <section xml:id="aufgabe1_descr"> + <title>Description</title> + + <para>We want to represent files system meta data like file and + directory names as XML data. Consider the following file system + containing nested directories, files and one symbolic link (symlink for + short) among with its XML sample representation:</para> + + <informaltable border="0"> + <tr> + <td valign="top"><screen>mkdir A +mkdir A/A_C +touch A/A_C/A_C_start.xml +mkdir B +touch B/B_calc.odt +touch a +touch b +ln -s A/A_C/A_C_start.xml symA.xml</screen></td> + + <td valign="top"><screen>A ++--A_C + +--A_C_start.xml +B ++--B_calc.odt +a +b +symA.xml</screen></td> + + <td valign="top"><programlisting language="xml"><partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + </directory> + <directory name="B" inode="101"> + <file name="B_calc.odt" inode="106"/> + </directory> + <file name="a" inode="102"/> + <file name="b" inode="103"/> + <symlink name="symA.xml" inode="107" target="105"/> + +</partition></programlisting></td> + </tr> + </informaltable> + + <para>The <link + xlink:href="data/iliasclient1/mobs/mm_2043/folderExample.png?il_wac_token=ac81cb5ba46c8aa1042baf7dfb7ca03d87304cc3&il_wac_ttl=3&il_wac_ts=1518350783">screenshot</link> + shows a visual representation.</para> + + <para>The XML implies the following integrity rules:</para> + + <itemizedlist> + <listitem> + <para>There are three distinct file system object types <tag + class="starttag">directory</tag>, <tag class="starttag">file</tag> + and <tag class="starttag">symlink</tag> each requiring a <code + language="xml">@name</code> of type string and <code + language="xml">@inode</code> of integer value.</para> + </listitem> + + <listitem> + <para>Within a given <tag class="starttag">directory</tag> or <tag + class="starttag">partition</tag> all <code + language="xml">@name</code> attribute values are unique. Example: + The <tag class="starttag">partition</tag> contains two <tag + class="starttag">directory</tag> entries <filename>A</filename> and + <filename>B</filename>, two <tag class="starttag">file</tag> entries + <filename>a</filename> and <filename>b</filename> and the symlink + named <filename>symA.xml</filename>. Thus for a case sensitive file + system these top level name values are unique.</para> + </listitem> + + <listitem> + <para>Each file system object receives an inode number (invisible in + the above listings) being unique within the given partition.</para> + </listitem> + + <listitem> + <para>The symlink <filename>symA.xml</filename> contains a reference + matching a target's inode number 105 namely the file + <filename>A_C_start.xml</filename>.</para> + </listitem> + </itemizedlist> + </section> + + <section xml:id="aufgabe1_task"> + <title>Tasks</title> + + <para>Implement the yet incomplete XML Schema file + <filename>Schema/fs.xsd</filename> modeling all former integrity + rules:</para> + + <orderedlist> + <listitem> + <para>The folder <filename>SchemaTest</filename> contains sample + files testing your schema for correctness.</para> + </listitem> + + <listitem> + <para>Executing + <classname>de.hdm_stuttgart.mi.sda1.exam.xsd.test.SchemaTest</classname> + as a Java application indicates which test documents in + <filename>SchemaTest</filename> yet fail the expected outcome being + either <quote>valid</quote> of <quote>invalid</quote>. You also get + the number of points reached so far.</para> + </listitem> + + <listitem> + <para>Open all XML related files in Oxygenxml: It does offer much + better schema support than IntelliJ.</para> + </listitem> + </orderedlist> + + <tip> + <itemizedlist> + <listitem> + <para>When defining <tag class="starttag">xs:key</tag> or <tag + class="starttag">xs:keyref</tag> definitions you may wand to + recursively descend using <code language="xml">//xyz</code> + expressions. Due to XML Schema restrictions only element local + recursive descents like <code language="xml">.//xyz</code> from + your <quote>current</quote> element in question rather than <code + language="xml">//xyz</code> from document root are allowed.</para> + </listitem> + + <listitem> + <para>Do not forget that both <tag + class="starttag">directory</tag> and <tag + class="starttag">partition</tag> must contain unique entries with + respect to the <code language="xml">@name</code> attribute. This + may require two distinct keys.</para> + </listitem> + + <listitem> + <para>Don't touch the unit test defines in your project's + <filename>SchemaTest</filename> folder: Your automated tests may + end up throwing meaningless exceptions.</para> + </listitem> + + <listitem> + <para>Edit <filename>Schema/fs.xsd</filename> by small steps and + always execute the tests: If you spoil it <quote>undo</quote> is + your friend.</para> + </listitem> + </itemizedlist> + </tip> + </section> + + <section version="5.1" xml:id="uploadFirst" xml:lang="de"> + <title>Project upload</title> + + <para>Zip up your complete project as + <filename>solution-1.zip</filename> (not <filename>.tgz</filename>, + <filename>.java</filename>, <filename>.tar.gz</filename> or similar). + Then hit <quote>choose</quote> and <quote>upload</quote>. Do not forget + to leave this exercise (i.e. by switching to the next question) because + this triggers saving the current question. Be careful:</para> + + <itemizedlist> + <listitem> + <para>Mind complete export, choose your project's root rather than + just a sub directory or single file.</para> + </listitem> + + <listitem> + <para>Upload the right archive: Avoid choosing the original + <filename>exam.zip</filename> skeleton.</para> + </listitem> + + <listitem> + <para>Watch out for <filename>solution_1.zip</filename> actually + being visible in the examination system.</para> + </listitem> + + <listitem> + <para>You may upload multiple versions i.e. + <filename>solution_2.zip</filename> etc. for security reasons. Only + your least upload in time will become subject to marking.</para> + </listitem> + </itemizedlist> + + <caution> + <itemizedlist> + <listitem> + <para>Check your input at examination end for completeness.</para> + </listitem> + + <listitem> + <para>Projects residing only on your local workstation cannot be + recovered.</para> + </listitem> + </itemizedlist> + </caution> + </section> + </chapter> + + <chapter xml:id="task2"> + <title>Relational file system meta data</title> + + <section xml:id="aufgabe2_prepare"> + <title>Preparation</title> + + <para>If you already started the first exercise just continue working on + your project using IntelliJ. Otherwise read the first exercise regarding + the skeleton project import. In case you need to configure a + <productname>JDBC</productname> connection in + <productname>Intellij</productname> you need:</para> + + <itemizedlist> + <listitem> + <para>Host: localhost</para> + </listitem> + + <listitem> + <para>Database: hdm</para> + </listitem> + + <listitem> + <para>User: hdmuser</para> + </listitem> + + <listitem> + <para>Pasword: XYZ</para> + </listitem> + </itemizedlist> + </section> + + <section xml:id="aufgabe2_descr"> + <title>Description</title> + + <para>Start from your project skeleton + <filename>Schema/schema.sql</filename> file and create a relational + model representing file system meta data: The same integrity constraints + as in the first exercise shall apply.</para> + + <tip> + <para>A single table suffices:</para> + + <itemizedlist> + <listitem> + <para>Introduce an attribute <code + language="sql">objectType</code>. Depending on the file system + object in question it will have three different values like <code + language="sql">"directory"</code>, <code + language="sql">"file"</code> or <code + language="sql">"symlink"</code>.</para> + </listitem> + + <listitem> + <para>There is an obvious primary key attribute candidate.</para> + </listitem> + + <listitem> + <para>Model composition of directories within each other and files + and symbolic links within directories by a foreign key like e.g. + <code language="sql">parent</code>.</para> + </listitem> + + <listitem> + <para>Introduce a nullable field <code + language="sql">target</code> which is only valid for symbolic + links and will otherwise be ignored.</para> + </listitem> + </itemizedlist> + + <para>A record my look like:</para> + + <programlisting language="sql">INSERT INTO FsObject VALUES( + 101, /* inode */ + "Dir_A_B", /* Directory name, subdir of "Dir_A" */ + 100, /* Parent directory "A" */ + 1, /* Typ directory */ + null); /* No symlink */</programlisting> + </tip> + </section> + + <section version="5.1" xml:id="uploadFollow" xml:lang="de"> + <title>Solution upload</title> + + <para>Upload your project using the previous exercise. Enter either of + the following two texts:</para> + + <itemizedlist> + <listitem> + <para>I'm expecting points for my work on the current + exercise.</para> + </listitem> + + <listitem> + <para>I did not work on this exercise.</para> + </listitem> + </itemizedlist> + </section> + </chapter> + + <chapter xml:id="task3"> + <title>Formatting arbitrary relational tables</title> + + <section xml:id="task3_prepare"> + <title>Preparation</title> + + <para>If you already started the first exercise just continue working on + your project using IntelliJ. Otherwise read the first exercise regarding + the skeleton project import. In case you need to configure a + <productname>JDBC</productname> connection in + <productname>Intellij</productname> you need:</para> + + <itemizedlist> + <listitem> + <para>Host: localhost</para> + </listitem> + + <listitem> + <para>Database: hdm</para> + </listitem> + + <listitem> + <para>User: hdmuser</para> + </listitem> + + <listitem> + <para>Pasword: XYZ</para> + </listitem> + </itemizedlist> + + <para>You may want to import the sample schema and data being found in + <filename>Sql/student.sql</filename> into your local + <productname>Mysql</productname> server prior to extending the provided + Java skeleton.</para> + </section> + + <section xml:id="task_2_descr"> + <title>Description</title> + + <para>Consider the following relational table and sample data:</para> + + <informaltable border="0"> + <tr> + <td valign="top"><programlisting language="sql">CREATE TABLE Student ( + id INT NOT NULL, + name VARCHAR(20) NOT NULL, + studyCourse CHAR(3) NULL, + gender CHAR(1), /* f (female) or m (male) */ + fullTime BOOLEAN NULL, + PRIMARY KEY (id) +); +INSERT INTO Student VALUES(100, 'Eve', 'MIB', 'f', TRUE ); +INSERT INTO Student VALUES(101, 'John', 'PMM', 'm', NULL ); +INSERT INTO Student VALUES(102, 'Bill', NULL, 'm', TRUE ); +INSERT INTO Student VALUES(103, 'Petra', 'CSM', 'm', FALSE );</programlisting></td> + + <td valign="top"><informaltable border="1"> + <tr> + <th>id</th> + + <th>name</th> + + <th>studyCourse</th> + + <th>gender</th> + + <th>fullTime</th> + </tr> + + <tr> + <td>100</td> + + <td>Eve</td> + + <td>MIB</td> + + <td>f</td> + + <td>1</td> + </tr> + + <tr> + <td>101</td> + + <td>John</td> + + <td>PMM</td> + + <td>m</td> + + <td><emphasis>NULL</emphasis></td> + </tr> + + <tr> + <td>102</td> + + <td>Bill</td> + + <td><emphasis>NULL</emphasis></td> + + <td>m</td> + + <td>1</td> + </tr> + + <tr> + <td>103</td> + + <td>Petra</td> + + <td>CSM</td> + + <td>m</td> + + <td>0</td> + </tr> + </informaltable></td> + </tr> + </informaltable> + + <para>In this exercise you will write a Java application reading an + <emphasis>arbitrary</emphasis> relational table producing a + corresponding HTML tree, <emphasis>not just covering the above + example</emphasis>.</para> + + <para>Consider the skeleton + <classname>de.hdm_stuttgart.mi.sda1.exam.dataexport.Db2Html</classname>. + To the right you see the intended generated + <productname>Jdom</productname> tree when being executed as Java + application:</para> + + <informaltable border="0"> + <tr> + <td valign="top"><programlisting language="java">private static Element getHtml( + final Connection connection, + final String tableName) throws SQLException { + + final Element html = new Element("html"); + + // TODO: Add basic HTML and a table containing + // tableName's header information + data + return html; +}</programlisting></td> + + <td valign="top"><programlisting language="xml"><html> + <head><title>Table Student data</title></head> + <body> + <table> + <tr> + <th>id</th> + <th>name</th> + <th>studyCourse</th> + <th>gender</th> + <th>fullTime</th> + </tr> + ... + <tr> + <td>101</td> + <td>John</td> + <td>PMM</td> + <td>m</td> + <td> + <strong>NULL</strong> + </td> + </tr> + ... + </table> + </body> +</html></programlisting></td> + </tr> + </informaltable> + + <para>Right now the only output reads just <tag + class="emptytag">html</tag>.Read the method's project skeleton Javadoc + and complete the implementation by adding required HTML markup.</para> + + <tip> + <para>Since your implementation starts from an arbitrary relational + table you cannot assume any prior knowledge about:</para> + + <orderedlist> + <listitem> + <para>The relational table's number of columns.</para> + </listitem> + + <listitem> + <para>The relational table's column names.</para> + </listitem> + </orderedlist> + + <para>Luckily a <classname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSet.html">ResultSet</classname> + provides the <methodname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSet.html#getMetaData--">getMetaData()</methodname> + method returning a <classname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSetMetaData.html">ResultSetMetaData</classname> + instance in turn offering two methods <methodname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSetMetaData.html#getColumnCount--">getColumnCount()</methodname> + and <methodname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSetMetaData.html#getColumnName-int-">getColumnName(int + column)</methodname>.</para> + + <para>Do not forget the <methodname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSet.html#wasNull--">wasNull()</methodname> + method for embedding <code language="sql">NULL</code> values in <tag + class="starttag">strong</tag> tags and use the generic <methodname + xlink:href="https://docs.oracle.com/javase/9/docs/api/java/sql/ResultSet.html#getString-int-">getString(int + columnIndex)</methodname> method for accessing table cell's + data.</para> + </tip> + </section> + + <section version="5.1" xml:id="task3_uploadFollow" xml:lang="de"> + <title>Solution upload </title> + + <para>Upload your project using the previous exercise. Enter either of + the following two texts:</para> + + <itemizedlist> + <listitem> + <para>I'm expecting points for my work on the current + exercise.</para> + </listitem> + + <listitem> + <para>I did not work on this exercise.</para> + </listitem> + </itemizedlist> + </section> + </chapter> +</book> diff --git a/Klausuren/Sda1/2017winter/Solve/Schema/fs.xsd b/Klausuren/Sda1/2017winter/Solve/Schema/fs.xsd new file mode 100644 index 000000000..a9b2055bc --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/Schema/fs.xsd @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > + + <xs:group name="directoryContent"> + <xs:sequence> + <xs:element ref="directory" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="file" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="symlink" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:group> + + + <xs:element name="partition"> + <xs:complexType> + <xs:group ref="directoryContent"/> + </xs:complexType> + + <xs:key name="uniquePartitionObjectName"> + <xs:selector xpath="directory|file|symlink"/> + <xs:field xpath="@name"/> + </xs:key> + <xs:key name="uniqueInode"> + <xs:selector xpath=".//directory|.//file|.//symlink"/> + <xs:field xpath="@inode"/> + </xs:key> + <xs:keyref refer="uniqueInode" name="symlinkReference"> + <xs:selector xpath=".//symlink"/> + <xs:field xpath="@target"/> + </xs:keyref> + </xs:element> + + <xs:element name="directory"> + <xs:complexType> + <xs:group ref="directoryContent"/> + <xs:attribute ref="name" use="required"/> + <xs:attribute ref="inode" use="required"/> + </xs:complexType> + + <xs:key name="uniqueDirectoryObjectName"> + <xs:selector xpath="directory|file|symlink"/> + <xs:field xpath="@name"/> + </xs:key> + </xs:element> + + <xs:element name="file"> + <xs:complexType> + <xs:attribute ref="name" use="required"/> + <xs:attribute ref="inode" use="required"/> + </xs:complexType> + </xs:element> + + <xs:element name="symlink"> + <xs:complexType> + <xs:attribute ref="name" use="required"/> + <xs:attribute ref="inode" use="required"/> + <xs:attribute name="target" type="xs:int" use="required"/> + </xs:complexType> + </xs:element> + + <xs:attribute type="xs:string" name="name"/> + <xs:attribute type="xs:int" name="inode"/> + +</xs:schema> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/Schema/sampledata.xml b/Klausuren/Sda1/2017winter/Solve/Schema/sampledata.xml new file mode 100644 index 000000000..44d2da12f --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/Schema/sampledata.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + </directory> + <directory name="B" inode="101"> + <file name="B_calc.odt" inode="106"/> + </directory> + <file name="a" inode="102"/> + <file name="b" inode="103"/> + <symlink name="symA.xml" inode="107" target="105"/> + +</partition> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/Schema/schema.sql b/Klausuren/Sda1/2017winter/Solve/Schema/schema.sql new file mode 100644 index 000000000..1a7849ba6 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/Schema/schema.sql @@ -0,0 +1,44 @@ +show tables; +show create TABLE FsObject; + +DROP TABLE IF EXISTS FsObject; + +CREATE TABLE FsObject ( + inode INT NOT NULL, + PRIMARY KEY (inode), + name VARCHAR(20) NOT NULL, + parent INT NULL, + FOREIGN KEY (parent) REFERENCES FsObject(inode), + UNIQUE (parent, name), + typ INT NOT NULL, /* 1=directory, 2 = file, 3 = symlink */ + target INT NULL, + FOREIGN KEY (target) REFERENCES FsObject(inode) +); + +INSERT INTO FsObject VALUES( + 100, /* inode */ + "Dir_A", /* Directory name */ + null, /* No parent node (top level) */ + 1, /* Typ directory */ + null); /* No symlink */ + +INSERT INTO FsObject VALUES( + 101, /* inode */ + "Dir_A_B", /* Directory name, subdir of "Dir_A" */ + 100, /* Parent directory "A" */ + 1, /* Typ directory */ + null); /* No symlink */ + +INSERT INTO FsObject VALUES( + 102, /* inode */ + "File_A_test.txt", /* File in "Dir_A" */ + 100, /* Directory "A" */ + 2, /* Typ file */ + null); /* No symlink */ + +INSERT INTO FsObject VALUES( + 103, /* inode */ + "Symlink_A_to_test.txt", /* File in "Dir_A" */ + 100, /* Directory "A" */ + 2, /* Typ file */ + null); /* No symlink */ \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0100valid_minimum.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0100valid_minimum.xml new file mode 100644 index 000000000..3e0366f09 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0100valid_minimum.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" /> + +<?xmlTest points = "1" + expectedToBeValid = "true" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0120valid_uniqueComponents.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0120valid_uniqueComponents.xml new file mode 100644 index 000000000..fce539fda --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0120valid_uniqueComponents.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + <directory name="A" inode="100"/> + <file name="b" inode="103"/> + <symlink name="symA" inode="107" target="100"/> +</partition> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0122invalid_inodeString.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0122invalid_inodeString.xml new file mode 100644 index 000000000..f8bfc106b --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0122invalid_inodeString.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + <directory name="A" inode="foo"/> <!-- Error: inode must be an int. --> + <file name="b" inode="103"/> + <symlink name="symA" inode="107" target="100"/> +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0120valid_uniqueComponents.xml" +?> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0125invalid_missingName.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0125invalid_missingName.xml new file mode 100644 index 000000000..fe2bbeae9 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0125invalid_missingName.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <!-- Missing @name attributes --> + <directory inode="100"/> + <file inode="103"/> + <symlink inode="107" target="100"/> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0120valid_uniqueComponents.xml" +?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0130invalid_missingInode.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0130invalid_missingInode.xml new file mode 100644 index 000000000..eb087d91f --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0130invalid_missingInode.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + <!-- Missing @inode attributes --> + <directory name="A" /> + <file name="b" /> + <symlink name="symA" target="100"/> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0120valid_uniqueComponents.xml" +?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0135invalid_missingTarget.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0135invalid_missingTarget.xml new file mode 100644 index 000000000..3e1181b5c --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0135invalid_missingTarget.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"/> + <file name="b" inode="103"/> + <symlink name="symA" inode="107"/> <!-- Missing @target attribute --> + +</partition> +<?xmlTest points = "2" + expectedToBeValid = "false" + preconditionValid = "0120valid_uniqueComponents.xml" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0140invalid_duplicateObjectName.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0140invalid_duplicateObjectName.xml new file mode 100644 index 000000000..e5d121e16 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0140invalid_duplicateObjectName.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"/> + <file name="b" inode="103"/> + <symlink name="b" inode="107" target="100"/> <!-- Duplicate @name value "b" --> + +</partition> +<?xmlTest points = "2" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" +?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0160invalid_duplicateInode.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0160invalid_duplicateInode.xml new file mode 100644 index 000000000..dfffa5217 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0160invalid_duplicateInode.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"/> + <file name="b" inode="100"/> <!-- duplicate @inode value "100" --> + +</partition> +<?xmlTest points = "2" + expectedToBeValid = "false" + preconditionValid = "0100valid_minimum.xml" +?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0165invalid_uniqueComponentsOrder.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0165invalid_uniqueComponentsOrder.xml new file mode 100644 index 000000000..137493e6d --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0165invalid_uniqueComponentsOrder.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <!-- Wrong order: directory*, file*, symlink* expected --> + <symlink name="symA" inode="107" target="100"/> + <file name="b" inode="103"/> + <directory name="A" inode="100"/> +</partition> + +<?xmlTest + points = "2" + expectedToBeValid = "false" + preconditionValid = "0120valid_uniqueComponents.xml" ?> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0180valid_hierarchy.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0180valid_hierarchy.xml new file mode 100644 index 000000000..b417e9070 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0180valid_hierarchy.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + <file name="A_C.odt" inode="106"/> + <symlink name="A_C_sym.txt" inode="107" target="105"/> + </directory> + <directory name="B" inode="101"/> + +</partition> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0200invalid_hierarchyDuplicateInode.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0200invalid_hierarchyDuplicateInode.xml new file mode 100644 index 000000000..a7f0b3369 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0200invalid_hierarchyDuplicateInode.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="101"/> + </directory> + <file name="A_C.odt" inode="106"/> + <symlink name="A_C_sym.txt" inode="107" target="101"/> + </directory> + <directory name="B" inode="101"/> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0180valid_hierarchy.xml" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0220invalid_hierarchyDuplicateName.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0220invalid_hierarchyDuplicateName.xml new file mode 100644 index 000000000..e68d0793d --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0220invalid_hierarchyDuplicateName.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + <file name="A_C.odt" inode="106"/> + <symlink name="A_C_sym.txt" inode="107" target="105"/> + </directory> + <directory name="A" inode="101"/> <!-- Error: prior <directory name="A" --> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0180valid_hierarchy.xml" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0300invalid_hierarchyReference.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0300invalid_hierarchyReference.xml new file mode 100644 index 000000000..4565cbba9 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0300invalid_hierarchyReference.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + <file name="A_C" inode="106"/> + <symlink name="A_C_sym.txt" inode="107" target="105"/> + </directory> + <directory name="B" inode="101"/> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0180valid_hierarchy.xml" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/SchemaTest/0320invalid_hierarchyOrder.xml b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0320invalid_hierarchyOrder.xml new file mode 100644 index 000000000..d73490946 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/SchemaTest/0320invalid_hierarchyOrder.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<partition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../Schema/fs.xsd" > + + <directory name="A" inode="100"> + <symlink name="A_C_sym.txt" inode="107" target="105"/> + + <!-- Error: Order directory*, file*, symlink* --> + <file name="A_C.odt" inode="106"/> + <directory name="A_C" inode="104"> + <file name="A_C_start.xml" inode="105"/> + </directory> + </directory> + <directory name="B" inode="101"/> + +</partition> +<?xmlTest points = "3" + expectedToBeValid = "false" + preconditionValid = "0180valid_hierarchy.xml" ?> diff --git a/Klausuren/Sda1/2017winter/Solve/Sql/Student.sql b/Klausuren/Sda1/2017winter/Solve/Sql/Student.sql new file mode 100644 index 000000000..8001ba823 --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/Sql/Student.sql @@ -0,0 +1,19 @@ + +DROP TABLE IF EXISTS Student; + +CREATE TABLE Student ( + + id INT NOT NULL, + name VARCHAR(20) NOT NULL, + studyCourse CHAR(3) NULL, + gender CHAR(1), /* f (female) or m (male) */ + fullTime BOOLEAN NULL, + PRIMARY KEY (id) +); + +INSERT INTO Student VALUES(100, 'Eve', 'MIB', 'f', TRUE ); +INSERT INTO Student VALUES(101, 'John', 'PMM', 'm', NULL ); +INSERT INTO Student VALUES(102, 'Bill', NULL, 'm', TRUE ); +INSERT INTO Student VALUES(103, 'Petra', 'CSM', 'm', FALSE ); + +SELECT * FROM Student; diff --git a/Klausuren/Sda1/2017winter/Solve/pom.xml b/Klausuren/Sda1/2017winter/Solve/pom.xml new file mode 100644 index 000000000..74925c58d --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/pom.xml @@ -0,0 +1,101 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>de.hdm-stuttgart.mi.sda1</groupId> + <artifactId>sda1_2017winter_solve</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>sda1_2017winter_solve</name> + + <url>http://freedocs.mi.hdm-stuttgart.de</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <repositories> + <repository> + <id>hdm-mi-internal-maven-repo</id> + <url>https://maven.mi.hdm-stuttgart.de/artifacts</url> + </repository> + </repositories> + + <dependencies> + + <dependency> + <groupId>org.opengis.cite.xerces</groupId> + <artifactId>xercesImpl-xsd11</artifactId> + <version>2.12-beta-r1667115</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + <optional>true</optional> + </dependency> + + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.36</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.1</version> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom2</artifactId> + <version>2.0.6</version> + </dependency> + + <dependency> + <groupId>jaxen</groupId> + <artifactId>jaxen</artifactId> + <version>1.1.6</version> + </dependency> + + <dependency> + <groupId>de.hdm_stuttgart.mi.exam</groupId> + <artifactId>unitmarking</artifactId> + <version>0.9</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <compilerArgument>-proc:none</compilerArgument> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.10.1</version> + <configuration /> + </plugin> + </plugins> + </build> +</project> diff --git a/Klausuren/Sda1/2017winter/Solve/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/Db2Html.java b/Klausuren/Sda1/2017winter/Solve/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/Db2Html.java new file mode 100644 index 000000000..717a23dfa --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/src/main/java/de/hdm_stuttgart/mi/sda1/exam/dataexport/Db2Html.java @@ -0,0 +1,121 @@ +package de.hdm_stuttgart.mi.sda1.exam.dataexport; + +import org.jdom2.Element; +import org.jdom2.output.Format; +import org.jdom2.output.XMLOutputter; + +import java.io.IOException; +import java.sql.*; + +/** + * Exporting company data. Execution requires importing corresponding + * schema and optionally sample data from Sql/sample.sql + */ +public class Db2Html { + + /** + * @param args Unused + * @throws SQLException Many things may fail ... + */ + public static void main(String[] args) throws SQLException, IOException { + final Connection conn = DriverManager.getConnection( + "jdbc:mysql://localhost:3306/hdm", + "hdmuser", + "XYZ"); + + final Element result = getHtml(conn, "Student"); + + final Format outFormat = Format.getPrettyFormat(); // Set output formatting + //outFormat.setTextMode(Format.TextMode.PRESERVE); + + final XMLOutputter printer = new XMLOutputter(outFormat); + printer.output(result, System.out); + } + + /** + * <p>Creating HTML tabular data corresponding to a single relational table. Typical output containing both + * data and meta-data:</p> + * <pre><html> + * <head><title>Table Student data</title></head> + * <body> + * <table> + * <tr> + * <th>id</th> + * <th>name</th> + * <th>studyCourse</th> + * <th>gender</th> + * <th>fullTime</th> + * </tr> + * ... + * <tr> + * <td>101</td> + * <td>John</td> + * <td>PMM</td> + * <td>m</td> + * <td> + * <strong>NULL</strong> + * </td> + * </tr> + * ... + * </table> + * </body> + *</html></pre> + * + * @param connection A database connection + * @param tableName A relational table name: Its meta information and contained data will be + * converted to HTML. + * @return The generated HTML tree containing a table similar to the example. + * @throws SQLException A lot of things my fail ... + */ + public static Element getHtml(final Connection connection, final String tableName) throws SQLException { + + final Element html = new Element("html"); + + final Element head = new Element("head"); + html.addContent(head); + + final Element title = new Element("title"); + head.addContent(title); + title.addContent("Table ").addContent(tableName).addContent(" data"); + + final Element body = new Element("body"); + html.addContent(body); + + final Element table = new Element("table"); + body.addContent(table); + + final Statement statement = connection.createStatement(); + final ResultSet data = statement.executeQuery("SELECT * FROM "+ tableName); + final ResultSetMetaData metaData = data.getMetaData(); + + { // Table header containg column names + final Element tr = new Element("tr"); + table.addContent(tr); + for (int i = 1; i <= metaData.getColumnCount(); i++) { + final Element th = new Element("th"); + th.addContent(metaData.getColumnName(i)); + tr.addContent(th); + } + } + + { // Table data + while (data.next()) { + final Element tr = new Element("tr"); + table.addContent(tr); + for (int i = 1; i <= metaData.getColumnCount(); i++) { + final Element td = new Element("td"); + tr.addContent(td); + + final String value = data.getString(i); + if (data.wasNull()) { + final Element strong = new Element("strong"); + td.addContent(strong); + strong.addContent("NULL"); + } + td.addContent(value); + } + } + } + return html; + } +} \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/src/main/resources/log4j2.xml b/Klausuren/Sda1/2017winter/Solve/src/main/resources/log4j2.xml new file mode 100644 index 000000000..c5115183f --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <Logger name="de.hdm_stuttgart.mi.unitmarking" level="info"> + <AppenderRef ref="A1"/> + </Logger> + + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Klausuren/Sda1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java b/Klausuren/Sda1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java new file mode 100644 index 000000000..b5b4c31ef --- /dev/null +++ b/Klausuren/Sda1/2017winter/Solve/src/test/java/de/hdm_stuttgart/mi/sda1/exam/xsd/test/SchemaTest.java @@ -0,0 +1,26 @@ +package de.hdm_stuttgart.mi.sda1.exam.xsd.test; + +import org.junit.Assert; +import org.junit.Test; + +import de.hdm_stuttgart.mi.unitmarking.xsd.InstanceSetEvaluation; + +/** + * Unit test for an XML instance set. + */ +@SuppressWarnings("static-method") +public class SchemaTest { + /** + * Testing a suite of XML instances. + */ + @Test + public void testXmlInstanceSet() { + + final InstanceSetEvaluation ise = + new InstanceSetEvaluation("SchemaTest", "Schema/fs.xsd"); + + System.out.println(ise.getMessages()); + + Assert.assertTrue(ise.getErrorMessages(), ise.allTestsSucceeded); + } +} \ No newline at end of file -- GitLab