Skip to content

Commit

Permalink
xerces-plugin-arrays: add jenkins test case ElektraInitiative#1280, a…
Browse files Browse the repository at this point in the history
…dd root element array limitation note to readme ElektraInitiative#1451
  • Loading branch information
e1528532 committed Apr 4, 2017
1 parent 6f4014b commit e186796
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/plugins/xerces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ The main rules of an XML element name are:
- Element names can contain letters, digits, hyphens, underscores, and periods
- Element names cannot contain spaces

The root key is not allowed to be an array, as this would correspond to multiple
root elements in XML (see the
[github issue](https://github.com/ElektraInitiative/libelektra/issues/1451)).

XSD transformations, schemas or DTDs are not supported yet.

## Examples
Expand Down
47 changes: 47 additions & 0 deletions src/plugins/xerces/testmod_xerces.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,52 @@ static void test_maven_pom ()
fflush (stdout);
}

static void test_jenkins_config ()
{
printf ("test jenkins config\n");
fflush (stdout);

Key * parentKey = keyNew ("/sw/elektra/tests/xerces", KEY_VALUE, srcdir_file ("xerces/jenkins.xml"), KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("xerces");

KeySet * ks = ksNew (64, KS_END);
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "call to kdbGet was not successful");

// Its also another good deserialization test
Key * serializationParentKey = keyNew ("/sw/elektra/tests/xerces", KEY_VALUE, srcdir_file ("xerces/jenkins-gen.xml"), KEY_END);
succeed_if (plugin->kdbSet (plugin, ks, serializationParentKey) == 1, "call to kdbSet was not successful");

Key * resultParentKey = keyNew ("/sw/elektra/tests/xerces", KEY_VALUE, srcdir_file ("xerces/jenkins-gen.xml"), KEY_END);
KeySet * result = ksNew (64, KS_END);
succeed_if (plugin->kdbGet (plugin, result, resultParentKey) == 1, "call to kdbGet was not successful");

Key * current;

succeed_if (
current = ksLookupByName (
ks, "/sw/elektra/tests/xerces/temporaryOfflineCause/user/properties/jenkins.security.ApiTokenProperty/apiToken", 0),
"failed to find apiToken key");
succeed_if (strcmp (keyValue (current), "bee4ahGhOqua3ahzsai2Eef5quie5ohK/eiSe4eav+JhVlerBftAil8Ow5AejahBe9oiksKAlla/kk1/1=") == 0,
"api token is wrong");

succeed_if (86 == ksGetSize (ks), "pom file is expected to contain 64 keys");

compare_keyset (ks, result); // Should be the same

elektraUnlink (srcdir_file ("xerces/jenkins-gen.xml"));

keyDel (parentKey);
ksDel (ks);
keyDel (serializationParentKey);
keyDel (resultParentKey);
ksDel (result);
PLUGIN_CLOSE ();

printf ("test jenkins config finished\n");
fflush (stdout);
}

int main (int argc, char ** argv)
{
printf ("XERCES TESTS\n");
Expand All @@ -259,6 +305,7 @@ int main (int argc, char ** argv)
test_simple_read ();
test_simple_write ();
test_maven_pom ();
test_jenkins_config ();

printf ("\ntestmod_xerces RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

Expand Down

0 comments on commit e186796

Please sign in to comment.