Added default file loading also to pclCreatePath function; fixed bugs 199 and 203
[profile/ivi/persistence-client-library.git] / test / persistence_client_library_test.c
index 56fd931..18d0dbf 100644 (file)
@@ -10,7 +10,6 @@
 ******************************************************************************/
  /**
  * @file           persistence_client_library_test.c
- * @ingroup        Persistence client library test
  * @author         Ingo Huerner
  * @brief          Test of persistence client library
  * @see            
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>     /* exit */
-#include <check.h>
 #include <time.h>
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#include "../include/persistence_client_library_key.h"
+#include <dlt/dlt.h>
+#include <dlt/dlt_common.h>
+
+#include "persCheck.h"
+
+
 #include "../include/persistence_client_library_file.h"
+#include "../include/persistence_client_library_key.h"
+#include "../include/persistence_client_library.h"
 #include "../include/persistence_client_library_error_def.h"
 
 
-// protected header, should be used only be persistence components
-// included here for testing purpose
-#include "../include_protected/persistence_client_library_db_access.h"
-
 
 #define BUF_SIZE     64
 #define NUM_OF_FILES 3
 #define READ_SIZE    1024
+#define MaxAppNameLen 256
+
+/// application id
+char gTheAppId[MaxAppNameLen] = {0};
 
 // definition of weekday
 char* dayOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
 
+int myChangeCallback(pclNotification_s * notifyStruct)
+{
+   printf(" ==> * - * myChangeCallback * - *\n");
 
-
+   return 1;
+}
 /**
  * Test the key value interface using different logicalDB id's, users and seats.
  * Each resource below has an entry in the resource configuration table where the
  * storage location (cached or write through) and type (e.g. custom) has been configured.
  */
-START_TEST (test_GetData)
+START_TEST(test_GetData)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of get data");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int ret = 0;
-   unsigned char buffer[READ_SIZE];
-   memset(buffer, 0, READ_SIZE);
+   unsigned int shutdownReg = (PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL);
+
+   unsigned char buffer[READ_SIZE] = {0};
 
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+
+#if 1
    /**
     * Logical DB ID: 0xFF with user 0 and seat 0
     *       ==> local value accessible by all users (user 0, seat 0)
     */
-   ret = pclKeyReadData(0xFF, "language/country_code",         0, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle",
+   ret = pclKeyReadData(0xFF, "pos/last_position",         0, 0, buffer, READ_SIZE);
+   x_fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
                strlen((char*)buffer)) == 0, "Buffer not correctly read");
-   fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
+   x_fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
 
    memset(buffer, 0, READ_SIZE);
 
@@ -71,19 +91,22 @@ START_TEST (test_GetData)
     * Logical DB ID: 0xFF with user 0 and seat 0
     *       ==> local value accessible by all users (user 0, seat 0)
     */
-   ret = pclKeyReadData(0xFF, "pos/last_position",         0, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "CACHE_ +48° 10' 38.95\", +8° 44' 39.06\"",
+   /*
+   ret = pclKeyReadData(0xFF, "language/country_code",         0, 0, buffer, READ_SIZE);
+   x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data: secure!",
                strlen((char*)buffer)) == 0, "Buffer not correctly read");
-   fail_unless(ret = strlen("CACHE_ +48° 10' 38.95\", +8° 44' 39.06\""));
+   x_fail_unless(ret = strlen("Custom plugin -> plugin_get_data_handle"));
 
    memset(buffer, 0, READ_SIZE);
+   */
+
 
    /**
     * Logical DB ID: 0 with user 3 and seat 0
     *       ==> public shared user value (user 3, seat 0)
     */
    ret = pclKeyReadData(0,    "language/current_language", 3, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "CACHE_ Kisuaheli", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
 
@@ -92,7 +115,7 @@ START_TEST (test_GetData)
     *       ==> local USER value (user 3, seat 2)
     */
    ret = pclKeyReadData(0xFF, "status/open_document",      3, 2, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "WT_ /var/opt/user_manual_climateControl.pdf", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
 
@@ -101,7 +124,7 @@ START_TEST (test_GetData)
     *       ==> shared user value accessible by a group (user 4 and seat 0)
     */
    ret = pclKeyReadData(0x20, "address/home_address",      4, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "WT_ 55327 Heimatstadt, Wohnstrasse 31", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
 
@@ -110,7 +133,7 @@ START_TEST (test_GetData)
     *       ==> local value accessible by ALL USERS (user 0, seat 0)
     */
    ret = pclKeyReadData(0xFF, "pos/last_satellites",       0, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "WT_ 17", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
 
@@ -119,7 +142,7 @@ START_TEST (test_GetData)
     *       ==> shared user value accessible by A GROUP (user 4 and seat 0)
     */
    ret = pclKeyReadData(0x84, "links/last_link",           2, 0, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/brooklyn", strlen((char*)buffer)) == 0, "Buffer not correctly read");
 
    memset(buffer, 0, READ_SIZE);
 
@@ -128,7 +151,9 @@ START_TEST (test_GetData)
     *       ==> local merge value
     */
    ret = pclKeyReadData(0x84, "links/last_link",           2, 1, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "CACHE_ /last_exit/queens", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -141,13 +166,24 @@ END_TEST
  */
 START_TEST (test_GetDataHandle)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of get data handle");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int ret = 0, handle = 0, handle2 = 0, handle3 = 0, handle4 = 0, size = 0;
-   unsigned char buffer[READ_SIZE];
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   unsigned char buffer[READ_SIZE] = {0};
    struct tm *locTime;
-   time_t t = time(0);
 
    char sysTimeBuffer[128];
-   memset(buffer, 0, READ_SIZE);
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+   time_t t = time(0);
 
    locTime = localtime(&t);
 
@@ -161,13 +197,14 @@ START_TEST (test_GetDataHandle)
     *       ==> local value accessible by ALL USERS (user 0, seat 0)
     */
    handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
-   fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
+   x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
 
    ret = pclKeyHandleReadData(handle, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", ret-1) == 0, "Buffer not correctly read");
+   printf("* * * * * => => => B U F F E R : \"%s\"\n", buffer);
+   x_fail_unless(strncmp((char*)buffer, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", ret-1) == 0, "Buffer not correctly read => 1");
 
    size = pclKeyHandleGetSize(handle);
-   fail_unless(size = strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
+   x_fail_unless(size == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
    // ---------------------------------------------------------------------------------------------
 
 
@@ -177,10 +214,10 @@ START_TEST (test_GetDataHandle)
     *       ==> local USER value (user 3, seat 2)
     */
    handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
-   fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
+   x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
 
    size = pclKeyHandleWriteData(handle2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
-   fail_unless(size = strlen(sysTimeBuffer));
+   x_fail_unless(size == strlen(sysTimeBuffer));
    // close
    ret = pclKeyHandleClose(handle2);
    // ---------------------------------------------------------------------------------------------
@@ -191,17 +228,20 @@ START_TEST (test_GetDataHandle)
     * Logical DB ID: 0xFF with user 0 and seat 0
     *       ==> local value accessible by ALL USERS (user 0, seat 0)
     */
+#if 0 // plugin test case
    memset(buffer, 0, READ_SIZE);
    handle4 = pclKeyHandleOpen(0xFF, "language/country_code", 0, 0);
-   fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
+   printf("H A N D L E: %d\n", handle4);
+   x_fail_unless(handle4 >= 0, "Failed to open handle /language/country_code");
 
    ret = pclKeyHandleReadData(handle4, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle", -1) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, "Custom plugin -> plugin_get_data_handle: secure!", -1) == 0, "Buffer not correctly read => 2");
 
    size = pclKeyHandleGetSize(handle4);
-   fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
+   x_fail_unless(size = strlen("Custom plugin -> plugin_get_data_handle"));
 
    ret = pclKeyHandleWriteData(handle4, (unsigned char*)"Only dummy implementation behind custom library", READ_SIZE);
+#endif
    // ---------------------------------------------------------------------------------------------
 
 
@@ -211,13 +251,13 @@ START_TEST (test_GetDataHandle)
     *       ==> local USER value (user 3, seat 2)
     */
    handle3 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
-   fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
+   x_fail_unless(handle3 >= 0, "Failed to open handle /statusHandle/open_document");
 
    ret = pclKeyHandleReadData(handle3, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read => 3");
 
    size = pclKeyHandleGetSize(handle3);
-   fail_unless(size = strlen(sysTimeBuffer));
+   x_fail_unless(size = strlen(sysTimeBuffer));
    // ---------------------------------------------------------------------------------------------
 
 
@@ -225,11 +265,12 @@ START_TEST (test_GetDataHandle)
    ret = pclKeyHandleClose(handle);
    ret = pclKeyHandleClose(handle3);
    ret = pclKeyHandleClose(handle4);
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
 
-
 /*
  * Write data to a key using the key interface.
  * First write data to different keys and after
@@ -237,19 +278,44 @@ END_TEST
  */
 START_TEST(test_SetData)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of set data");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int ret = 0;
-   unsigned char buffer[READ_SIZE];
-   char write1[READ_SIZE];
-   char write2[READ_SIZE];
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+   unsigned char buffer[READ_SIZE]  = {0};
+   char write1[READ_SIZE] = {0};
+   char write2[READ_SIZE] = {0};
    char sysTimeBuffer[256];
 
    struct tm *locTime;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+
+#if 1
+   /**
+    * Logical DB ID: 0xFF with user 3 and seat 2
+    *       ==> local USER value (user 3, seat 2)
+    */
+   ret = pclKeyWriteData(0xFF, "status/open_document",      3, 2, "WT_ /var/opt/user_manual_climateControl.pdf", strlen("WT_ /var/opt/user_manual_climateControl.pdf"));
+   x_fail_unless(ret == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Wrong write size");
+
+
+   ret = pclKeyWriteData(0x84, "links/last_link",      2, 1, "CACHE_ /last_exit/queens", strlen("CACHE_ /last_exit/queens"));
+   x_fail_unless(ret == strlen("CACHE_ /last_exit/queens"), "Wrong write size");
+
+   ret = pclKeyWriteData(0xFF, "posHandle/last_position", 0, 0, "WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\"", strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""));
+   x_fail_unless(ret == strlen("WT_ H A N D L E: +48° 10' 38.95\", +8° 44' 39.06\""), "Wrong write size");
+#endif
+
+#if 1
    time_t t = time(0);
 
    locTime = localtime(&t);
-   memset(buffer, 0, READ_SIZE);
-   memset(write1, 0, READ_SIZE);
-   memset(write2, 0, READ_SIZE);
 
    // write data
    snprintf(sysTimeBuffer, 128, "\"%s %d.%d.%d - %d:%.2d:%.2d Uhr\"", dayOfWeek[locTime->tm_wday], locTime->tm_mday, locTime->tm_mon, (locTime->tm_year+1900),
@@ -261,8 +327,8 @@ START_TEST(test_SetData)
     * Resource ID: 69
     */
    ret = pclKeyWriteData(0xFF, "69", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
-   fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
-
+   x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
+#if 1
    snprintf(write1, 128, "%s %s", "/70",  sysTimeBuffer);
    /**
     * Logical DB ID: 0xFF with user 1 and seat 2
@@ -270,7 +336,7 @@ START_TEST(test_SetData)
     * Resource ID: 70
     */
    ret = pclKeyWriteData(0xFF, "70", 1, 2, (unsigned char*)write1, strlen(write1));
-   fail_unless(ret == strlen(write1), "Wrong write size");
+   x_fail_unless(ret == strlen(write1), "Wrong write size");
 
    snprintf(write2, 128, "%s %s", "/key_70",  sysTimeBuffer);
    /**
@@ -279,7 +345,7 @@ START_TEST(test_SetData)
     * Resource ID: key_70
     */
    ret = pclKeyWriteData(0xFF, "key_70", 1, 2, (unsigned char*)write2, strlen(write2));
-   fail_unless(ret == strlen(write2), "Wrong write size");
+   x_fail_unless(ret == strlen(write2), "Wrong write size");
 
 
    /*******************************************************************************************************************************************/
@@ -291,8 +357,9 @@ START_TEST(test_SetData)
     *
     *       ==> used for shared testing
     */
-   printf("Write data to trigger change notification\n");
+   //printf("Write data to trigger change notification\n");
    ret = pclKeyWriteData(0x84, "links/last_link2",  2, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
+   x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
 
    /**
     * Logical DB ID: 0x84 with user 2 and seat 1
@@ -300,8 +367,9 @@ START_TEST(test_SetData)
     *
     *       ==> used for shared testing
     */
-   printf("Write data to trigger change notification\n");
+   //printf("Write data to trigger change notification\n");
    ret = pclKeyWriteData(0x84, "links/last_link3",  3, 2, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
+   x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
 
    /**
     * Logical DB ID: 0x84 with user 2 and seat 1
@@ -309,8 +377,9 @@ START_TEST(test_SetData)
     *
     *       ==> used for shared testing
     */
-   printf("Write data to trigger change notification\n");
+   //printf("Write data to trigger change notification\n");
    ret = pclKeyWriteData(0x84, "links/last_link4",  4, 1, (unsigned char*)"Test notify shared data", strlen("Test notify shared data"));
+   x_fail_unless(ret == strlen("Test notify shared data"), "Wrong write size");
    /*******************************************************************************************************************************************/
    /*******************************************************************************************************************************************/
 
@@ -322,21 +391,23 @@ START_TEST(test_SetData)
    memset(buffer, 0, READ_SIZE);
 
    ret = pclKeyReadData(0xFF, "69", 1, 2, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
-   fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
+   x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
 
    memset(buffer, 0, READ_SIZE);
 
    ret = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
-   fail_unless(ret == strlen(write1), "Wrong read size");
+   x_fail_unless(strncmp((char*)buffer, write1, strlen(write1)) == 0, "Buffer not correctly read");
+   x_fail_unless(ret == strlen(write1), "Wrong read size");
 
    memset(buffer, 0, READ_SIZE);
 
    ret = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
-   fail_unless(ret == strlen(write2), "Wrong read size");
-
+   x_fail_unless(strncmp((char*)buffer, write2, strlen(write2)) == 0, "Buffer not correctly read");
+   x_fail_unless(ret == strlen(write2), "Wrong read size");
+#endif
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -349,13 +420,23 @@ END_TEST
  */
 START_TEST(test_SetDataNoPRCT)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of set data no PRCT");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int ret = 0;
-   unsigned char buffer[READ_SIZE];
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+   unsigned char buffer[READ_SIZE] = {0};
    struct tm *locTime;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
    time_t t = time(0);
 
    char sysTimeBuffer[128];
-   memset(buffer, 0, READ_SIZE);
 
    locTime = localtime(&t);
 
@@ -367,17 +448,18 @@ START_TEST(test_SetDataNoPRCT)
     *       ==> local USER value (user 1, seat 2)
     */
    ret = pclKeyWriteData(0xFF, "NoPRCT", 1, 2, (unsigned char*)sysTimeBuffer, strlen(sysTimeBuffer));
-   fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
-   printf("Write Buffer : %s\n", sysTimeBuffer);
+   x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong write size");
+   //printf("Write Buffer : %s\n", sysTimeBuffer);
 
    // read data again and and verify datat has been written correctly
    memset(buffer, 0, READ_SIZE);
 
    ret = pclKeyReadData(0xFF, "NoPRCT", 1, 2, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
-   fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
-   printf("read buffer  : %s\n", buffer);
-
+   x_fail_unless(strncmp((char*)buffer, sysTimeBuffer, strlen(sysTimeBuffer)) == 0, "Buffer not correctly read");
+   x_fail_unless(ret == strlen(sysTimeBuffer), "Wrong read size");
+   //printf("read buffer  : %s\n", buffer);
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -389,14 +471,25 @@ END_TEST
  */
 START_TEST(test_GetDataSize)
 {
-   int size = 0;
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of get data size");
+   X_TEST_REPORT_TYPE(GOOD);
+
+   int size = 0, ret = 0;
+
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
    /**
     * Logical DB ID: 0xFF with user 3 and seat 2
     *       ==> local USER value (user 3, seat 2)
     */
    size = pclKeyGetSize(0xFF, "status/open_document", 3, 2);
-   fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
+   x_fail_unless(size == strlen("WT_ /var/opt/user_manual_climateControl.pdf"), "Invalid size");
 
 
    /**
@@ -404,7 +497,9 @@ START_TEST(test_GetDataSize)
     *       ==> shared user value accessible by A GROUP (user 2 and seat 1)
     */
    size = pclKeyGetSize(0x84, "links/last_link", 2, 1);
-   fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
+   x_fail_unless(size == strlen("CACHE_ /last_exit/queens"), "Invalid size");
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -416,34 +511,46 @@ END_TEST
  */
 START_TEST(test_DeleteData)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of delete data");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int rval = 0;
    unsigned char buffer[READ_SIZE];
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
+   rval = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(rval <= 1, "Failed to init PCL");
+#if 1
    // read data from key
    rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
-   fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
+   x_fail_unless(rval != EPERS_NOKEY, "Read form key key_70 fails");
 
    // delete key
    rval = pclKeyDelete(0xFF, "key_70", 1, 2);
-   fail_unless(rval == 0, "Failed to delete key");
+   x_fail_unless(rval >= 0, "Failed to delete key");
 
    // after deleting the key, reading from key must fail now!
    rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
-   fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
+   x_fail_unless(rval == EPERS_NOKEY, "Read form key key_70 works, but should fail");
 
 
 
    // read data from key
    rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
-   fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
+   x_fail_unless(rval != EPERS_NOKEY, "Read form key 70 fails");
 
    // delete key
    rval = pclKeyDelete(0xFF, "70", 1, 2);
-   fail_unless(rval == 0, "Failed to delete key");
+   x_fail_unless(rval >= 0, "Failed to delete key");
 
    // after deleting the key, reading from key must fail now!
    rval = pclKeyReadData(0xFF, "70", 1, 2, buffer, READ_SIZE);
-   fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
+   x_fail_unless(rval == EPERS_NOKEY, "Read form key 70 works, but should fail");
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -459,13 +566,25 @@ END_TEST
  */
 START_TEST(test_DataFile)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of data file");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int fd = 0, i = 0, idx = 0;
    int size = 0, ret = 0;
    int writeSize = 16*1024;
-   unsigned char buffer[READ_SIZE];
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   unsigned char buffer[READ_SIZE] = {0};
    const char* refBuffer = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media";
    char* writeBuffer;
    char* fileMap = NULL;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
    writeBuffer = malloc(writeSize);
 
 
@@ -481,8 +600,6 @@ START_TEST(test_DataFile)
       writeBuffer[idx++] = 'F';
       writeBuffer[idx++] = ' ';
    }
-   memset(buffer, 0, READ_SIZE);
-
    // create file
    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",
              O_CREAT|O_RDWR|O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
@@ -490,80 +607,96 @@ START_TEST(test_DataFile)
 
    // open ------------------------------------------------------------
    fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
-   fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
+   x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDB.db");
 
    size = pclFileGetSize(fd);
-   fail_unless(size == 68, "Wrong file size");
+   x_fail_unless(size == 68, "Wrong file size");
 
    size = pclFileReadData(fd, buffer, READ_SIZE);
-   fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
-   fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned");      // strlen + 1 ==> inlcude cr/lf
+   x_fail_unless(strncmp((char*)buffer, refBuffer, strlen(refBuffer)) == 0, "Buffer not correctly read => media/mediaDB.db");
+   x_fail_unless(size == (strlen(refBuffer)+1), "Wrong size returned");      // strlen + 1 ==> inlcude cr/lf
 
    ret = pclFileClose(fd);
-   fail_unless(ret == 0, "Failed to close file");
-
+   x_fail_unless(ret == 0, "Failed to close file");
 
    // open ------------------------------------------------------------
    fd = pclFileOpen(0xFF, "media/mediaDBWrite.db", 1, 1);
-   fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
+   x_fail_unless(fd != -1, "Could not open file ==> /media/mediaDBWrite.db");
 
    size = pclFileWriteData(fd, writeBuffer, strlen(writeBuffer));
-   fail_unless(size == strlen(writeBuffer), "Failed to write data");
-
+   x_fail_unless(size == strlen(writeBuffer), "Failed to write data");
    ret = pclFileClose(fd);
-   fail_unless(ret == 0, "Failed to close file");
-
+   x_fail_unless(ret == 0, "Failed to close file");
 
    // remove ----------------------------------------------------------
    ret = pclFileRemove(0xFF, "media/mediaDBWrite.db", 1, 1);
-   fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
+   x_fail_unless(ret == 0, "File can't be removed ==> /media/mediaDBWrite.db");
 
    fd = open("/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDBWrite.db",O_RDWR);
-   fail_unless(fd == -1, "Failed to remove file, file still exists");
+   x_fail_unless(fd == -1, "Failed to remove file, file still exists");
    close(fd);
 
-
    // map file --------------------------------------------------------
+
    fd = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
 
    size = pclFileGetSize(fd);
    pclFileMapData(fileMap, size, 0, fd);
-   fail_unless(fileMap != MAP_FAILED, "Failed to map file");
+   x_fail_unless(fileMap != MAP_FAILED, "Failed to map file");
 
    ret = pclFileUnmapData(fileMap, size);
-   fail_unless(ret != -1, "Failed to unmap file");
+   x_fail_unless(ret != -1, "Failed to unmap file");
 
    // negative test
    size = pclFileGetSize(1024);
-   fail_unless(ret == 0, "Got size, but should not");
+   x_fail_unless(ret == 0, "Got size, but should not");
 
    ret = pclFileClose(fd);
-   fail_unless(ret == 0, "Failed to close file");
+   x_fail_unless(ret == 0, "Failed to close file");
 
    free(writeBuffer);
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
 
 
 
+
 START_TEST(test_DataFileRecovery)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of data file recovery");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int fd_RW = 0, fd_RO = 0;
    int ret = 0;
    char* wBuffer = "This is a buffer to write";
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
 
    // test backup creation --------------------------------------------
    fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
-   fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
+   x_fail_unless(fd_RO != -1, "Could not open file ==> /media/mediaDB_ReadOnly.db");
 
    fd_RW = pclFileOpen(0xFF, "media/mediaDB_ReadWrite.db", 1, 1);
-   fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
+   x_fail_unless(fd_RW != -1, "Could not open file ==> /media/mediaDB_ReadWrite.db");
    pclFileWriteData(fd_RW, wBuffer, strlen(wBuffer));
 
    ret = pclFileClose(fd_RW);
+   if(ret == -1)
+
    ret = pclFileClose(fd_RO);
+   if(ret == -1)
 
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -572,33 +705,91 @@ END_TEST
  */
 START_TEST(test_DataHandle)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of data handle");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int handle1 = 0, handle2 = 0;
+   int handleArray[4] = {0};
    int ret = 0;
+   unsigned char buffer[READ_SIZE] = {0};
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
    // test file handles
    handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
-   fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
+   x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB.db");
 
    ret = pclFileClose(handle1);
-   fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
+   x_fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
 
    ret = pclFileClose(1024);
-   fail_unless(ret == -1, "Could close file, but should not!!");
+   x_fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
 
    ret = pclFileClose(17);
-   fail_unless(ret == -1, "Could close file, but should not!!");
+   x_fail_unless(ret == -1, "Could close file, but should not!!");
+
+   // test multiple handles
+   handleArray[0] = pclFileOpen(0xFF, "media/mediaDB_write_01.db", 1, 1);
+   x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_01.db");
+
+   handleArray[1] = pclFileOpen(0xFF, "media/mediaDB_write_02.db", 1, 1);
+   x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_02.db");
+
+   handleArray[2] = pclFileOpen(0xFF, "media/mediaDB_write_03.db", 1, 1);
+   x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_03.db");
 
+   handleArray[3] = pclFileOpen(0xFF, "media/mediaDB_write_04.db", 1, 1);
+   x_fail_unless(handle1 != -1, "Could not open file ==> /media/mediaDB_write_04.db");
 
+   ret = pclFileReadData(handleArray[0], buffer, READ_SIZE);
+   x_fail_unless(ret >= 0, "Failed to read handle idx \"0\"!!");
+   x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_01.db",
+         strlen("/user/1/seat/1/media/mediaDB_write_01.db"))
+         == 0, "Buffer not correctly read => mediaDB_write_01.db");
+
+   ret = pclFileReadData(handleArray[1], buffer, READ_SIZE);
+   x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_02.db",
+         strlen("/user/1/seat/1/media/mediaDB_write_02.db"))
+         == 0, "Buffer not correctly read => mediaDB_write_02.db");
+
+   ret = pclFileReadData(handleArray[2], buffer, READ_SIZE);
+   x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_03.db",
+         strlen("/user/1/seat/1/media/mediaDB_write_03.db"))
+         == 0, "Buffer not correctly read => mediaDB_write_03.db");
+
+   (void)pclFileReadData(handleArray[3], buffer, READ_SIZE);
+   x_fail_unless(strncmp((char*)buffer, "/user/1/seat/1/media/mediaDB_write_04.db",
+         strlen("/user/1/seat/1/media/mediaDB_write_04.db"))
+         == 0, "Buffer not correctly read => mediaDB_write_04.db");
+
+   ret = pclKeyHandleClose(handleArray[0]);
+   x_fail_unless(ret != -1, "Failed to close handle idx \"0\"!!");
+
+   ret = pclKeyHandleClose(handleArray[1]);
+   x_fail_unless(ret != -1, "Failed to close handle idx \"1\"!!");
+
+   ret = pclKeyHandleClose(handleArray[2]);
+   x_fail_unless(ret != -1, "Failed to close handle idx \"2\"!!");
+
+   ret = pclKeyHandleClose(handleArray[3]);
+   x_fail_unless(ret != -1, "Failed to close handle idx \"3\"!!");
 
    // test key handles
    handle2 = pclKeyHandleOpen(0xFF, "statusHandle/open_document", 3, 2);
-   fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
+   x_fail_unless(handle2 >= 0, "Failed to open handle /statusHandle/open_document");
 
    ret = pclKeyHandleClose(handle2);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(1024);
-   fail_unless(ret == -1, "Could close, but should not!!");
+   x_fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
@@ -610,140 +801,303 @@ END_TEST
  */
 START_TEST(test_DataHandleOpen)
 {
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of data handle open");
+   X_TEST_REPORT_TYPE(GOOD);
+
    int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
    // open handles ----------------------------------------------------
    hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
-   fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
+   x_fail_unless(hd1 == 1, "Failed to open handle ==> /posHandle/last_position1");
 
    hd2 = pclKeyHandleOpen(0xFF, "posHandle/last_position2", 0, 0);
-   fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
+   x_fail_unless(hd2 == 2, "Failed to open handle ==> /posHandle/last_position2");
 
    hd3 = pclKeyHandleOpen(0xFF, "posHandle/last_position3", 0, 0);
-   fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
+   x_fail_unless(hd3 == 3, "Failed to open handle ==> /posHandle/last_position3");
 
    // close handles ---------------------------------------------------
    ret = pclKeyHandleClose(hd1);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd2);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd3);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    // open handles ----------------------------------------------------
    hd4 = pclKeyHandleOpen(0xFF, "posHandle/last_position4", 0, 0);
-   fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
+   x_fail_unless(hd4 == 3, "Failed to open handle ==> /posHandle/last_position4");
 
    hd5 = pclKeyHandleOpen(0xFF, "posHandle/last_position5", 0, 0);
-   fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
+   x_fail_unless(hd5 == 2, "Failed to open handle ==> /posHandle/last_position5");
 
    hd6 = pclKeyHandleOpen(0xFF, "posHandle/last_position6", 0, 0);
-   fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
+   x_fail_unless(hd6 == 1, "Failed to open handle ==> /posHandle/last_position6");
 
    hd7 = pclKeyHandleOpen(0xFF, "posHandle/last_position7", 0, 0);
-   fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
+   x_fail_unless(hd7 == 4, "Failed to open handle ==> /posHandle/last_position7");
 
    hd8 = pclKeyHandleOpen(0xFF, "posHandle/last_position8", 0, 0);
-   fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
+   x_fail_unless(hd8 == 5, "Failed to open handle ==> /posHandle/last_position8");
 
    hd9 = pclKeyHandleOpen(0xFF, "posHandle/last_position9", 0, 0);
-   fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
+   x_fail_unless(hd9 == 6, "Failed to open handle ==> /posHandle/last_position9");
 
    // close handles ---------------------------------------------------
    ret = pclKeyHandleClose(hd4);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd5);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd6);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd7);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd8);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
 
    ret = pclKeyHandleClose(hd9);
-   fail_unless(ret != -1, "Failed to close handle!!");
+   x_fail_unless(ret != -1, "Failed to close handle!!");
+#endif
+   pclDeinitLibrary();
 }
 END_TEST
 
 
 
-/**
- * Test for  i n t e r n a l  structures.
- * Test the cursor functions.
- */
-START_TEST(test_Cursor)
+START_TEST(test_Plugin)
 {
-   int handle = -1, rval = 0, size = 0, handle1 = 0;
-   char bufferKeySrc[READ_SIZE];
-   char bufferDataSrc[READ_SIZE];
-   char bufferKeyDst[READ_SIZE];
-   char bufferDataDst[READ_SIZE];
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of plugins");
+   X_TEST_REPORT_TYPE(GOOD);
+
+       int ret = 0;
+       unsigned char buffer[READ_SIZE]  = {0};
+
+       unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+       ret = pclKeyReadData(0xFF, "language/country_code",           0, 0, buffer, READ_SIZE);
+       x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: secure!",
+               strlen((char*)buffer)) == 0, "Buffer SECURE not correctly read");
+
+
+       ret = pclKeyReadData(0xFF, "language/country_code_early",     0, 0, buffer, READ_SIZE);
+       x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+       //printf("B U F F E R - early: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: early!",
+               strlen((char*)buffer)) == 0, "Buffer EARLY not correctly read");
+
+       ret = pclKeyReadData(0xFF, "language/country_code_emergency", 0, 0, buffer, READ_SIZE);
+       x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+       //printf("B U F F E R - emergency: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: emergency!",
+               strlen((char*)buffer)) == 0, "Buffer EMERGENCY not correctly read");
+
+       ret = pclKeyReadData(0xFF, "language/info",                   0, 0, buffer, READ_SIZE);
+       x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+       //printf("B U F F E R - hwinfo: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: hwinfo!",
+               strlen((char*)buffer)) == 0, "Buffer HWINFO not correctly read");
+
+   ret = pclKeyReadData(0xFF, "language/country_code_custom3",   0, 0, buffer, READ_SIZE);
+   x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   //printf("B U F F E R - hwinfo: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"Custom plugin -> plugin_get_data: custom3!",
+               strlen((char*)buffer)) == 0, "Buffer CUSTOM 3 not correctly read");
+#endif
+       pclDeinitLibrary();
+}
+END_TEST
+
 
-   memset(bufferKeySrc, 0, READ_SIZE);
-   memset(bufferDataSrc, 0, READ_SIZE);
 
-   memset(bufferKeyDst, 0, READ_SIZE);
-   memset(bufferDataDst, 0, READ_SIZE);
 
-   // create cursor
-   handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
 
-   fail_unless(handle != -1, "Failed to create cursor!!");
+START_TEST(test_ReadDefault)
+{
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of read default");
+   X_TEST_REPORT_TYPE(GOOD);
 
-   // create cursor
-   handle1 = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/wt.itz");
+   int ret = 0;
+   unsigned char buffer[READ_SIZE]  = {0};
+
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+   ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
+   x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   //printf("B U F F E R: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
+   x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   //printf("B U F F E R: %s\n", buffer);
+   x_fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+#endif
+   pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_ReadConfDefault)
+{
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of configurable default data");
+   X_TEST_REPORT_TYPE(GOOD);
+
+   int ret = 0;
+   unsigned char buffer[READ_SIZE]  = {0};
+
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+   ret = pclKeyReadData(0xFF, "statusHandle/confdefault01",     3, 2, buffer, READ_SIZE);
+   x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+
+   ret = pclKeyReadData(0xFF, "statusHandle/confdefault02",     3, 2, buffer, READ_SIZE);
+   x_fail_unless(ret != EPERS_NOT_INITIALIZED);
+   x_fail_unless(strncmp((char*)buffer,"CONF_DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
+#endif
+   pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_GetPath)
+{
+   X_TEST_REPORT_TEST_NAME("persistence_client_library_test");
+   X_TEST_REPORT_COMP_NAME("libpersistence_client_library");
+   X_TEST_REPORT_REFERENCE("NONE");
+   X_TEST_REPORT_DESCRIPTION("Test of get path");
+   X_TEST_REPORT_TYPE(GOOD);
+
+   int ret = 0;
+   char* path = NULL;
+   const char* thePath = "/Data/mnt-wt/lt-persistence_client_library_test/user/1/seat/1/media/mediaDB_create.db";
+   unsigned int pathSize = 0;
 
-   fail_unless(handle1 != -1, "Failed to create cursor!!");
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
 
-   do
+   ret = pclInitLibrary(gTheAppId, shutdownReg);
+   x_fail_unless(ret <= 1, "Failed to init PCL");
+#if 1
+   ret = pclFileCreatePath(0xFF, "media/mediaDB_create.db", 1, 1, &path, &pathSize);
+
+   x_fail_unless(strncmp((char*)path, thePath, strlen((char*)path)) == 0, "Path not correct");
+   x_fail_unless(pathSize == strlen((char*)path), "Path size not correct");
+
+   pclFileReleasePath(ret);
+#endif
+   pclDeinitLibrary();
+}
+END_TEST
+
+
+
+START_TEST(test_InitDeinit)
+{
+   int i = 0;
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   for(i=0; i< 3; i++)
    {
-      memset(bufferKeySrc, 0, READ_SIZE);
-      memset(bufferDataSrc, 0, READ_SIZE);
-      memset(bufferKeyDst, 0, READ_SIZE);
-      memset(bufferDataDst, 0, READ_SIZE);
-
-      // get key
-      rval = pers_db_cursor_get_key(handle, bufferKeySrc, 128);
-      fail_unless(rval != -1, "Cursor failed to get key!!");
-      // get data
-      rval = pers_db_cursor_get_data(handle, bufferDataSrc, 128);
-      fail_unless(rval != -1, "Cursor failed to get data!!");
-      // get size
-      size = pers_db_cursor_get_data_size(handle);
-      fail_unless(size != -1, "Cursor failed to get size!!");
-      //printf("1. Key: %s | Data: %s » Size: %d \n", bufferKeySrc, bufferDataSrc, size);
-
-      // get key
-      rval = pers_db_cursor_get_key(handle1, bufferKeyDst, 128);
-      fail_unless(rval != -1, "Cursor failed to get key!!");
-      // get data
-      rval = pers_db_cursor_get_data(handle1, bufferDataDst, 128);
-      fail_unless(rval != -1, "Cursor failed to get data!!");
-      // get size
-      size = pers_db_cursor_get_data_size(handle1);
-      fail_unless(size != -1, "Cursor failed to get size!!");
-      //printf("  2. Key: %s | Data: %s » Size: %d \n", bufferKeyDst, bufferDataDst, size);
+      // initialize and deinitialize 1. time
+      (void)pclInitLibrary(gTheAppId, shutdownReg);
+      pclDeinitLibrary();
+
+
+      // initialize and deinitialize 2. time
+      (void)pclInitLibrary(gTheAppId, shutdownReg);
+      pclDeinitLibrary();
+
+
+      // initialize and deinitialize 3. time
+      (void)pclInitLibrary(gTheAppId, shutdownReg);
+      pclDeinitLibrary();
    }
-   while( (pers_db_cursor_next(handle) == 0) && (pers_db_cursor_next(handle1) == 0) ); // next cursor
+}
+END_TEST
+
+
+
+START_TEST(test_NegHandle)
+{
+   int handle = -1, ret = 0;;
+   int negativeHandle = -17;
+   unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
+
+   unsigned char buffer[128] = {0};
 
-   // destory cursor
-   rval = pers_db_cursor_destroy(handle);
-   fail_unless(rval != -1, "Failed to destroy cursor!!");
+   (void)pclInitLibrary(gTheAppId, shutdownReg);
 
-   rval = pers_db_cursor_destroy(handle1);
-   fail_unless(rval != -1, "Failed to destroy cursor!!");
+   handle = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
+   x_fail_unless(handle >= 0, "Failed to open handle ==> /posHandle/last_position");
+
+
+
+   ret = pclKeyHandleReadData(negativeHandle, buffer, READ_SIZE);
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
+
+   ret = pclKeyHandleClose(negativeHandle);
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleClose => negative handle not detected");
+
+   ret = pclKeyHandleGetSize(negativeHandle);
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleGetSize => negative handle not detected");
+
+   ret = pclKeyHandleReadData(negativeHandle, buffer, 128);
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleReadData => negative handle not detected");
+
+   ret = pclKeyHandleRegisterNotifyOnChange(negativeHandle, &myChangeCallback);
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleRegisterNotifyOnChange => negative handle not detected");
+
+   ret = pclKeyHandleWriteData(negativeHandle, (unsigned char*)"Whatever", strlen("Whatever"));
+   x_fail_unless(ret == EPERS_MAXHANDLE, "pclKeyHandleWriteData => negative handle not detected");
+
+
+   // close handle
+   ret = pclKeyHandleClose(handle);
+
+   pclDeinitLibrary();
 }
 END_TEST
 
 
 
+
+
+
+
+
 static Suite * persistencyClientLib_suite()
 {
    Suite * s  = suite_create("Persistency client library");
@@ -763,6 +1117,8 @@ static Suite * persistencyClientLib_suite()
    TCase * tc_persDeleteData = tcase_create("DeleteData");
    tcase_add_test(tc_persDeleteData, test_DeleteData);
 
+
+
    TCase * tc_persGetDataHandle = tcase_create("GetDataHandle");
    tcase_add_test(tc_persGetDataHandle, test_GetDataHandle);
 
@@ -778,11 +1134,26 @@ static Suite * persistencyClientLib_suite()
    TCase * tc_persDataFileRecovery = tcase_create("DataFileRecovery");
    tcase_add_test(tc_persDataFileRecovery, test_DataFileRecovery);
 
-   TCase * tc_Cursor = tcase_create("Cursor");
-   tcase_add_test(tc_Cursor, test_Cursor);
+   TCase * tc_Plugin = tcase_create("Plugin");
+   tcase_add_test(tc_Plugin, test_Plugin);
+
+   TCase * tc_ReadDefault = tcase_create("ReadDefault");
+   tcase_add_test(tc_ReadDefault, test_ReadDefault);
+
+   TCase * tc_ReadConfDefault = tcase_create("ReadConfDefault");
+   tcase_add_test(tc_ReadConfDefault, test_ReadConfDefault);
+
+   TCase * tc_GetPath = tcase_create("GetPath");
+   tcase_add_test(tc_GetPath, test_GetPath);
+
+   TCase * tc_InitDeinit = tcase_create("InitDeinit");
+   tcase_add_test(tc_InitDeinit, test_InitDeinit);
+
+   TCase * tc_NegHandle = tcase_create("NegHandle");
+   tcase_add_test(tc_NegHandle, test_NegHandle);
 
-   suite_add_tcase(s, tc_persGetData);
    suite_add_tcase(s, tc_persSetData);
+   suite_add_tcase(s, tc_persGetData);
    suite_add_tcase(s, tc_persSetDataNoPRCT);
    suite_add_tcase(s, tc_persGetDataSize);
    suite_add_tcase(s, tc_persDeleteData);
@@ -791,24 +1162,60 @@ static Suite * persistencyClientLib_suite()
    suite_add_tcase(s, tc_persDataHandleOpen);
    suite_add_tcase(s, tc_persDataFile);
    suite_add_tcase(s, tc_persDataFileRecovery);
-   suite_add_tcase(s, tc_Cursor);
+   suite_add_tcase(s, tc_ReadDefault);
+   suite_add_tcase(s, tc_ReadConfDefault);
+   suite_add_tcase(s, tc_GetPath);
+   suite_add_tcase(s, tc_InitDeinit);
+   suite_add_tcase(s, tc_NegHandle);
+
+   //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
 
    return s;
 }
 
 
-
-
 int main(int argc, char *argv[])
 {
-   int nr_failed = 0;
+   int nr_failed = 0,
+          nr_run = 0,
+               i = 0;
+   //int fail = 0;
 
+   TestResult** tResult;
+
+   // assign application name
+   strncpy(gTheAppId, "lt-persistence_client_library_test", MaxAppNameLen);
+   gTheAppId[MaxAppNameLen-1] = '\0';
+
+   /// debug log and trace (DLT) setup
+   DLT_REGISTER_APP("PCLt","tests the persistence client library");
+
+#if 1
    Suite * s = persistencyClientLib_suite();
    SRunner * sr = srunner_create(s);
-   srunner_run_all(sr, CK_VERBOSE);
+   srunner_set_xml(sr, "/tmp/persistenceClientLibraryTest.xml");
+   srunner_set_log(sr, "/tmp/persistenceClientLibraryTest.log");
+   srunner_run_all(sr, CK_VERBOSE /*CK_NORMAL CK_VERBOSE*/);
+
    nr_failed = srunner_ntests_failed(sr);
+   nr_run = srunner_ntests_run(sr);
+
+   tResult = srunner_results(sr);
+   for(i = 0; i< nr_run; i++)
+   {
+      (void)tr_rtype(tResult[i]);  // get status of each test
+      //fail = tr_rtype(tResult[i]);  // get status of each test
+      //printf("[%d] Fail: %d \n", i, fail);
+   }
 
    srunner_free(sr);
+#endif
+
+   // unregister debug log and trace
+   DLT_UNREGISTER_APP();
+
+   dlt_free();
+
    return (0==nr_failed)?EXIT_SUCCESS:EXIT_FAILURE;
 
 }