Commit e6caee25 authored by Dr. Martin Goik's avatar Dr. Martin Goik

Better test understanding

parent 261b28ea
......@@ -18,4 +18,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "base_valid.xml" ?>
\ No newline at end of file
preconditionValid = "100valid_minimum.xml" ?>
<?xml version="1.0" encoding="UTF-8"?>
<movieDb
<movieDb
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/movie.xsd">
<persons>
<person id="stanleyKubrick" birthYear="1928">
<person id="sKubrick" birthYear="1928">
<name>Stanley Kubrick</name>
</person>
......@@ -16,4 +16,4 @@
<movies/>
</movieDb>
\ No newline at end of file
</movieDb>
......@@ -21,4 +21,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "base_valid.xml" ?>
\ No newline at end of file
preconditionValid = "200valid_multiplePersons.xml" ?>
......@@ -45,4 +45,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "movie_valid.xml" ?>
\ No newline at end of file
preconditionValid = "300valid_movie.xml" ?>
......@@ -16,4 +16,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -17,4 +17,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -26,4 +26,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -28,4 +28,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
<?xml version="1.0" encoding="UTF-8"?>
<movieDb
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/movie.xsd">
<persons>
<!-- Missing required attributes id and birthYear -->
<person birthYear="1980" id="killme">
<name>K. Ill Me</name>
</person>
</persons>
<movies/>
</movieDb>
\ No newline at end of file
......@@ -16,4 +16,5 @@
</movieDb>
<?xmlTest
points = "1"
expectedToBeValid = "false" ?>
\ No newline at end of file
expectedToBeValid = "false"
preconditionValid = "505valid_person.xml" ?>
......@@ -23,4 +23,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -19,4 +19,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
preconditionValid = "600valid_personRef.xml" ?>
......@@ -26,4 +26,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -30,4 +30,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -39,4 +39,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "rating_valid.xml" ?>
\ No newline at end of file
preconditionValid = "700valid_rating.xml" ?>
\ No newline at end of file
......@@ -25,20 +25,41 @@ below.</p><h1>Hints</h1><ul>
project's <code>src/test/java</code> branch as a Junit test. For a correct
schema implementation in <code>Schema/movie.xsd</code> you'll read
something like:</p><pre>++Instance SchemaTest/directorRef_invalid.xml: Gaining 1 point.
++Instance SchemaTest/movieAttribs_invalid.xml: Gaining 1 point.
++Instance SchemaTest/idRequired.xml: Gaining 1 point.
++Instance SchemaTest/actorRef_invalid.xml: Gaining 1 point.
++Instance SchemaTest/rating_invalid.xml: Gaining 1 point.
++Instance SchemaTest/personBio.xml: Gaining 1 point.
++Instance SchemaTest/year_invalid.xml: Gaining 1 point.
++Instance SchemaTest/uniqueCast_invalid.xml: Gaining 1 point.
++Instance SchemaTest/name_invalid.xml: Gaining 1 point.
++Instance SchemaTest/personIdNameToken_invalid.xml: Gaining 1 point.
++Instance SchemaTest/personRequiredAtts_invalid.xml: Gaining 1 point.
++Instance SchemaTest/uniquePersonId_invalid.xml: Gaining 1 point.
++Instance SchemaTest/base_invalid.xml: Gaining 1 point.
...
++Instance SchemaTest/personRef_invalid.xml: Gaining 1 point.
<b>14 of 14 points have been reached</b></pre></li>
<b>14 of 14 points have been reached</b></pre><p>Possible errors:</p><dl>
<dt>Problem: Invalid dependency file.</dt>
<dd><pre>-- SchemaTest/210invalid_duplicateId.xml:
Precondition file <strong>»SchemaTest/200valid_multiplePersons.xml«</strong> is invalid:
cvc-identity-constraint.4.2.2: Duplicate key value [sKubrick] declared for identity constraint "uniquePersonId" of element "movieDb".
Missing 1 point.</pre><p>Explanation: You will only gain points for
<code>210invalid_duplicateId.xml</code> if the related file
<strong>»SchemaTest/200valid_multiplePersons.xml«</strong> is valid
with respect to your schema.</p></dd>
<dt>Solution</dt>
<dd>Correct your <code>Schema/movie.xsd</code> so that
<strong>»SchemaTest/200valid_multiplePersons.xml«</strong> becomes
valid.</dd>
<dt style="color:red;"><strong>Problem: File should be valid /
invalid.</strong></dt>
<dd style="color:red;"><p>You'll find either of:</p><ul>
<li><pre>-- <strong>SchemaTest/110invalid_duplicates.xml</strong> is expected to be invalid! Missing 1 point.</pre></li>
<li><pre>-- <strong>SchemaTest/345valid_foo.xml</strong> is expected to be valid! Missing 1 point.</pre></li>
</ul></dd>
<dt style="color:green;"><strong>Solution:</strong></dt>
<dd style="color:green;"><p>Correct your <code>Schema/movie.xsd</code>
so that the file in question becomes valid or invalid respectively.
The file may contain XML comments describing the expected
error.</p></dd>
</dl></li>
</ul><h1 id="dataModel">Data model description</h1><p>We consider
<code>Schema/sampledata.xml</code> illustrating a data store containing
dictionary data for translation services:</p><pre>&lt;movieDb xsi:noNamespaceSchemaLocation="movie.xsd"
......
......@@ -18,4 +18,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "base_valid.xml" ?>
\ No newline at end of file
preconditionValid = "100valid_minimum.xml" ?>
<?xml version="1.0" encoding="UTF-8"?>
<movieDb
<movieDb
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/movie.xsd">
<persons>
<person id="stanleyKubrick" birthYear="1928">
<person id="sKubrick" birthYear="1928">
<name>Stanley Kubrick</name>
</person>
......@@ -16,4 +16,4 @@
<movies/>
</movieDb>
\ No newline at end of file
</movieDb>
......@@ -21,4 +21,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "base_valid.xml" ?>
\ No newline at end of file
preconditionValid = "200valid_multiplePersons.xml" ?>
......@@ -45,4 +45,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "movie_valid.xml" ?>
\ No newline at end of file
preconditionValid = "300valid_movie.xml" ?>
......@@ -16,4 +16,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -17,4 +17,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -26,4 +26,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
......@@ -28,4 +28,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "name_valid.xml" ?>
\ No newline at end of file
preconditionValid = "400valid_name.xml" ?>
<?xml version="1.0" encoding="UTF-8"?>
<movieDb
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../Schema/movie.xsd">
<persons>
<!-- Missing required attributes id and birthYear -->
<person birthYear="1980" id="killme">
<name>K. Ill Me</name>
</person>
</persons>
<movies/>
</movieDb>
\ No newline at end of file
......@@ -16,4 +16,5 @@
</movieDb>
<?xmlTest
points = "1"
expectedToBeValid = "false" ?>
\ No newline at end of file
expectedToBeValid = "false"
preconditionValid = "505valid_person.xml" ?>
......@@ -23,4 +23,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -19,4 +19,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
preconditionValid = "600valid_personRef.xml" ?>
......@@ -26,4 +26,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -30,4 +30,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "personRef.xml" ?>
\ No newline at end of file
preconditionValid = "600valid_personRef.xml" ?>
\ No newline at end of file
......@@ -39,4 +39,4 @@
<?xmlTest
points = "1"
expectedToBeValid = "false"
preconditionValid = "rating_valid.xml" ?>
\ No newline at end of file
preconditionValid = "700valid_rating.xml" ?>
\ No newline at end of file
......@@ -133,7 +133,7 @@ public class InstanceTest {
e.getMessage() + "\n ";
log.info(tmpPreconditionErrMsg + ": " + e.getCause() + ":" + e.getMessage());
} catch (final IOException e) {
tmpPreconditionErrMsg = "Instance '" + xmlInstance + ": Precondition file '" + preconditionValidFilename.get() + "' cannot be read:" + e.getMessage();
tmpPreconditionErrMsg = " " + xmlInstance + ": Precondition file '" + preconditionValidFilename.get() + "' cannot be read:" + e.getMessage();
log.info(tmpPreconditionErrMsg, e);
}
}
......@@ -145,18 +145,18 @@ public class InstanceTest {
tmpInstanceIsValid = true;
} catch (final SAXException e) {
log.info("Instance file " + xmlInstance + " is invalid:" + e.getMessage());
log.info(" " + xmlInstance + " is invalid:" + e.getMessage());
} catch (final IOException e) {
log.info("Instance file " + xmlInstance + " cannot be read:" + e.getMessage());
log.info(" " + xmlInstance + " cannot be read:" + e.getMessage());
}
testSucceeded = expectedToBeValid == tmpInstanceIsValid;
if (testSucceeded) {
errMsg = Optional.empty();
} else if (expectedToBeValid) {
errMsg = Optional.of("Instance " + xmlInstance +
errMsg = Optional.of(" " + xmlInstance +
" is expected to be valid!");
} else {
errMsg = Optional.of("Instance " + xmlInstance +
errMsg = Optional.of(" " + xmlInstance +
" is expected to be invalid!");
}
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment