3 #include "TimingSingleton.h"
4 #include "TransactionStatus.h"
6 #define NUMBER_OF_TESTS 2
8 TimingSingleton *timer;
10 MyVector<TransactionStatus *> * transStatusList;
15 timer = TimingSingleton_getInstance();
17 transStatusList = new MyVector<TransactionStatus *>();
18 IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
19 IoTString * password = new IoTString("reallysecret");
20 t1 = new Table(baseurl, password, 321, -1);
23 baseurl->releaseRef();
24 password->releaseRef();
27 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
29 sprintf(buffer, "a%d", i);
30 IoTString *ia = new IoTString(buffer);
31 sprintf(buffer, "b%d", i);
32 IoTString *ib = new IoTString(buffer);
33 t1->createNewKey(ia, 321);
34 t1->createNewKey(ib, 351);
42 // Do Updates for the keys
43 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
45 sprintf(buffer, "a%d", i);
46 IoTString * iKeyA = new IoTString(buffer);
47 IoTString * iValueA = new IoTString(buffer);
49 sprintf(buffer, "b%d", i);
50 IoTString * iKeyB = new IoTString(buffer);
51 IoTString * iValueB = new IoTString(buffer);
53 t1->startTransaction();
54 t1->put(iKeyA, iValueA);
55 transStatusList->add(t1->commitTransaction());
57 iValueA->releaseRef();
59 t1->startTransaction();
60 t1->put(iKeyB, iValueB);
61 transStatusList->add(t1->commitTransaction());
63 iValueB->releaseRef();
68 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
70 sprintf(buffer, "a%d", i);
71 IoTString * iKeyA = new IoTString(buffer);
72 IoTString * iValueA = new IoTString(buffer);
74 sprintf(buffer, "b%d", i);
75 IoTString * iKeyB = new IoTString(buffer);
76 IoTString * iValueB = new IoTString(buffer);
78 IoTString *testValA1 = t1->getCommitted(iKeyA);
79 IoTString *testValB1 = t1->getCommitted(iKeyB);
81 if ((testValA1 == NULL) || (testValA1->equals(iValueA) == false)) {
82 // printf("Key-Value t1 incorrect: keyA\n");
86 if ((testValB1 == NULL) || (testValB1->equals(iValueB) == false)) {
87 // printf("Key-Value t1 incorrect: keyB\n");
92 iValueA->releaseRef();
94 iValueB->releaseRef();
95 testValA1->releaseRef();
96 testValB1->releaseRef();
99 for (uint i = 0; i < transStatusList->size(); i++) {
100 TransactionStatus * status = transStatusList->get(i);
101 if (status->getStatus() != TransactionStatus_StatusCommitted) {
103 // printf("Status error\n");
109 // printf("Found Errors...\n");
113 delete transStatusList;