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 // Setup the 2 clients
19 IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
20 IoTString * password = new IoTString("reallysecret");
21 t1 = new Table(baseurl, password, 321, -1);
24 t2 = new Table(baseurl, password, 351, -1);
27 delete baseurl; delete password;
30 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
32 sprintf(buffer, "a%d", i);
33 IoTString *ia = new IoTString(buffer);
34 sprintf(buffer, "b%d", i);
35 IoTString *ib = new IoTString(buffer);
36 sprintf(buffer, "c%d", i);
37 IoTString *ic = new IoTString(buffer);
38 sprintf(buffer, "d%d", i);
39 IoTString *id = new IoTString(buffer);
40 t1->createNewKey(ia, 321);
41 t1->createNewKey(ib, 351);
42 t2->createNewKey(ic, 321);
43 t2->createNewKey(id, 351);
54 // Do Updates for the keys
55 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
57 sprintf(buffer, "a%d", i);
58 IoTString * iKeyA = new IoTString(buffer);
59 IoTString * iValueA = new IoTString(buffer);
61 sprintf(buffer, "b%d", i);
62 IoTString * iKeyB = new IoTString(buffer);
63 IoTString * iValueB = new IoTString(buffer);
65 sprintf(buffer, "c%d", i);
66 IoTString * iKeyC = new IoTString(buffer);
67 IoTString * iValueC = new IoTString(buffer);
69 sprintf(buffer, "d%d", i);
70 IoTString * iKeyD = new IoTString(buffer);
71 IoTString * iValueD = new IoTString(buffer);
73 t1->startTransaction();
74 t1->put(iKeyA, iValueA);
75 transStatusList->add(t1->commitTransaction());
76 delete iKeyA; delete iValueA;
78 t1->startTransaction();
79 t1->put(iKeyB, iValueB);
80 transStatusList->add(t1->commitTransaction());
81 delete iKeyB; delete iValueB;
83 t2->startTransaction();
84 t2->put(iKeyC, iValueC);
85 transStatusList->add(t2->commitTransaction());
86 delete iKeyC; delete iValueC;
88 t2->startTransaction();
89 t2->put(iKeyD, iValueD);
90 transStatusList->add(t2->commitTransaction());
91 delete iKeyD; delete iValueD;
97 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
99 sprintf(buffer, "a%d", i);
100 IoTString * iKeyA = new IoTString(buffer);
101 IoTString * iValueA = new IoTString(buffer);
103 sprintf(buffer, "b%d", i);
104 IoTString * iKeyB = new IoTString(buffer);
105 IoTString * iValueB = new IoTString(buffer);
107 sprintf(buffer, "c%d", i);
108 IoTString * iKeyC = new IoTString(buffer);
109 IoTString * iValueC = new IoTString(buffer);
111 sprintf(buffer, "d%d", i);
112 IoTString * iKeyD = new IoTString(buffer);
113 IoTString * iValueD = new IoTString(buffer);
115 IoTString *testValA1 = t1->getCommitted(iKeyA);
116 IoTString *testValB1 = t1->getCommitted(iKeyB);
117 IoTString *testValC1 = t1->getCommitted(iKeyC);
118 IoTString *testValD1 = t1->getCommitted(iKeyD);
120 IoTString *testValA2 = t2->getCommitted(iKeyA);
121 IoTString *testValB2 = t2->getCommitted(iKeyB);
122 IoTString *testValC2 = t2->getCommitted(iKeyC);
123 IoTString *testValD2 = t2->getCommitted(iKeyD);
125 if ((testValA1 == NULL) || (testValA1->equals(iValueA) == false)) {
126 // printf("Key-Value t1 incorrect: keyA\n");
130 if ((testValB1 == NULL) || (testValB1->equals(iValueB) == false)) {
131 // printf("Key-Value t1 incorrect: keyB\n");
135 if ((testValC1 == NULL) || (testValC1->equals(iValueC) == false)) {
136 // printf("Key-Value t1 incorrect: keyC\n");
140 if ((testValD1 == NULL) || (testValD1->equals(iValueD) == false)) {
141 // printf("Key-Value t1 incorrect: keyD\n");
145 if ((testValA2 == NULL) || (testValA2->equals(iValueA) == false)) {
146 // printf("Key-Value t2 incorrect: keyA testValA2\n");
150 if ((testValB2 == NULL) || (testValB2->equals(iValueB) == false)) {
151 // printf("Key-Value t2 incorrect: keyB testValB2\n");
155 if ((testValC2 == NULL) || (testValC2->equals(iValueC) == false)) {
156 // printf("Key-Value t2 incorrect: keyC testValC2\n");
160 if ((testValD2 == NULL) || (testValD2->equals(iValueD) == false)) {
161 // printf("Key-Value t2 incorrect: keyD testValD2\n");
164 delete iKeyA; delete iValueA;
165 delete iKeyB; delete iValueB;
166 delete iKeyC; delete iValueC;
167 delete iKeyD; delete iValueD;
168 delete testValA1; delete testValA2;
169 delete testValB1; delete testValB2;
170 delete testValC1; delete testValC2;
171 delete testValD1; delete testValD2;
174 for (uint i = 0; i < transStatusList->size(); i++) {
175 TransactionStatus * status = transStatusList->get(i);
176 if (status->getStatus() != TransactionStatus_StatusCommitted) {
178 // printf("Status error\n");
184 // printf("Found Errors...\n");
188 transStatusList->clear();