edits
authorbdemsky <bdemsky@uci.edu>
Thu, 29 Mar 2018 15:28:45 +0000 (08:28 -0700)
committerbdemsky <bdemsky@uci.edu>
Thu, 29 Mar 2018 15:28:45 +0000 (08:28 -0700)
version2/src/C/Test.C [deleted file]
version2/src/C/Test.ino [new file with mode: 0644]

diff --git a/version2/src/C/Test.C b/version2/src/C/Test.C
deleted file mode 100644 (file)
index 0f6c96c..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "Table.h"
-#include "IoTString.h"
-#include "TimingSingleton.h"
-#include "TransactionStatus.h"
-
-#define NUMBER_OF_TESTS 2
-
-int main(int numargs, char ** args) {
-       TimingSingleton * timer = TimingSingleton_getInstance();
-
-       bool foundError = false;
-       Vector<TransactionStatus *> * transStatusList = new Vector<TransactionStatus *>();
-
-       // Setup the 2 clients
-       IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
-       IoTString * password = new IoTString("reallysecret");
-       Table * t1 = new Table(baseurl, password, 321, -1);
-       t1->initTable();
-       printf("T1 Ready\n");
-
-       Table * t2 = new Table(baseurl, password, 351, -1);
-       t2->update();
-       printf("T2 Ready\n");
-
-       delete baseurl; delete password;
-       
-       // Make the Keys
-       printf("Setting up keys\n");
-       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               printf("%d\n",i);
-               char buffer[80];
-               sprintf(buffer, "a%d", i);
-               IoTString *ia = new IoTString(buffer);
-               sprintf(buffer, "b%d", i);
-               IoTString *ib = new IoTString(buffer);
-               sprintf(buffer, "c%d", i);
-               IoTString *ic = new IoTString(buffer);
-               sprintf(buffer, "d%d", i);
-               IoTString *id = new IoTString(buffer);
-               t1->createNewKey(ia, 321);
-               t1->createNewKey(ib, 351);
-               t2->createNewKey(ic, 321);
-               t2->createNewKey(id, 351);
-               delete ia;
-               delete ib;
-               delete ic;
-               delete id;
-       }
-       
-       // Do Updates for the keys
-       printf("Setting Key-Values...\n");
-       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               printf("%d\n", i);
-               char buffer[80];
-               sprintf(buffer, "a%d", i);
-               IoTString * iKeyA = new IoTString(buffer);
-               IoTString * iValueA = new IoTString(buffer);
-
-               sprintf(buffer, "b%d", i);
-               IoTString * iKeyB = new IoTString(buffer);
-               IoTString * iValueB = new IoTString(buffer);
-               
-               sprintf(buffer, "c%d", i);
-               IoTString * iKeyC = new IoTString(buffer);
-               IoTString * iValueC = new IoTString(buffer);
-               
-               sprintf(buffer, "d%d", i);
-               IoTString * iKeyD = new IoTString(buffer);
-               IoTString * iValueD = new IoTString(buffer);
-
-               t1->startTransaction();
-               t1->put(iKeyA, iValueA);
-               transStatusList->add(t1->commitTransaction());
-               delete iKeyA; delete iValueA;
-               
-               t1->startTransaction();
-               t1->put(iKeyB, iValueB);
-               transStatusList->add(t1->commitTransaction());
-               delete iKeyB; delete iValueB;
-               
-               t2->startTransaction();
-               t2->put(iKeyC, iValueC);
-               transStatusList->add(t2->commitTransaction());
-               delete iKeyC; delete iValueC;
-               
-               t2->startTransaction();
-               t2->put(iKeyD, iValueD);
-               transStatusList->add(t2->commitTransaction());
-               delete iKeyD; delete iValueD;
-       }
-       
-       printf("Updating Clients...\n");
-       t1->update();
-       t2->update();
-       
-       printf("Checking Key-Values...\n");
-       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               char buffer[80];
-               sprintf(buffer, "a%d", i);
-               IoTString * iKeyA = new IoTString(buffer);
-               IoTString * iValueA = new IoTString(buffer);
-
-               sprintf(buffer, "b%d", i);
-               IoTString * iKeyB = new IoTString(buffer);
-               IoTString * iValueB = new IoTString(buffer);
-               
-               sprintf(buffer, "c%d", i);
-               IoTString * iKeyC = new IoTString(buffer);
-               IoTString * iValueC = new IoTString(buffer);
-               
-               sprintf(buffer, "d%d", i);
-               IoTString * iKeyD = new IoTString(buffer);
-               IoTString * iValueD = new IoTString(buffer);
-               
-               IoTString *testValA1 = t1->getCommitted(iKeyA);
-               IoTString *testValB1 = t1->getCommitted(iKeyB);
-               IoTString *testValC1 = t1->getCommitted(iKeyC);
-               IoTString *testValD1 = t1->getCommitted(iKeyD);
-               
-               IoTString *testValA2 = t2->getCommitted(iKeyA);
-               IoTString *testValB2 = t2->getCommitted(iKeyB);
-               IoTString *testValC2 = t2->getCommitted(iKeyC);
-               IoTString *testValD2 = t2->getCommitted(iKeyD);
-               
-               if ((testValA1 == NULL) || (testValA1->equals(iValueA) == false)) {
-                       printf("Key-Value t1 incorrect: keyA\n");
-                       foundError = true;
-               }
-               
-               if ((testValB1 == NULL) || (testValB1->equals(iValueB) == false)) {
-                       printf("Key-Value t1 incorrect: keyB\n");
-                       foundError = true;
-               }
-
-               if ((testValC1 == NULL) || (testValC1->equals(iValueC) == false)) {
-                       printf("Key-Value t1 incorrect: keyC\n");
-                       foundError = true;
-               }
-               
-               if ((testValD1 == NULL) || (testValD1->equals(iValueD) == false)) {
-                       printf("Key-Value t1 incorrect: keyD\n");
-                       foundError = true;
-               }
-               
-               if ((testValA2 == NULL) || (testValA2->equals(iValueA) == false)) {
-                       printf("Key-Value t2 incorrect: keyA     testValA2\n");
-                       foundError = true;
-               }
-               
-               if ((testValB2 == NULL) || (testValB2->equals(iValueB) == false)) {
-                       printf("Key-Value t2 incorrect: keyB     testValB2\n");
-                       foundError = true;
-               }
-               
-               if ((testValC2 == NULL) || (testValC2->equals(iValueC) == false)) {
-                       printf("Key-Value t2 incorrect: keyC     testValC2\n");
-                       foundError = true;
-               }
-               
-               if ((testValD2 == NULL) || (testValD2->equals(iValueD) == false)) {
-                       printf("Key-Value t2 incorrect: keyD     testValD2\n");
-                       foundError = true;
-               }
-               delete iKeyA; delete iValueA;
-               delete iKeyB; delete iValueB;
-               delete iKeyC; delete iValueC;
-               delete iKeyD; delete iValueD;
-               delete testValA1; delete testValA2;
-               delete testValB1; delete testValB2;
-               delete testValC1; delete testValC2;
-               delete testValD1; delete testValD2;
-       }
-
-       for (uint i = 0; i < transStatusList->size(); i++) {
-               TransactionStatus * status = transStatusList->get(i);
-               if (status->getStatus() != TransactionStatus_StatusCommitted) {
-                       foundError = true;
-                       printf("Status error\n");
-               }
-               delete status;
-       }
-       
-       if (foundError) {
-               printf("Found Errors...\n");
-       } else {
-               printf("No Errors Found...\n");
-       }
-
-       delete transStatusList;
-       delete t1;
-       delete t2;
-}
-
diff --git a/version2/src/C/Test.ino b/version2/src/C/Test.ino
new file mode 100644 (file)
index 0000000..4378081
--- /dev/null
@@ -0,0 +1,199 @@
+#include "Table.h"
+#include "IoTString.h"
+#include "TimingSingleton.h"
+#include "TransactionStatus.h"
+
+#define NUMBER_OF_TESTS 2
+
+TimingSingleton *timer;
+bool foundError;
+MyVector<TransactionStatus *> * transStatusList;
+Table *t1;
+Table *t2;
+
+void setup() {
+       timer = TimingSingleton_getInstance();
+       foundError = false;
+       transStatusList = new MyVector<TransactionStatus *>();
+       // Setup the 2 clients
+       IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
+       IoTString * password = new IoTString("reallysecret");
+       t1 = new Table(baseurl, password, 321, -1);
+       t1->initTable();
+       printf("T1 Ready\n");
+
+       t2 = new Table(baseurl, password, 351, -1);
+       t2->update();
+       printf("T2 Ready\n");
+
+       delete baseurl; delete password;
+
+       // Make the Keys
+       printf("Setting up keys\n");
+       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               printf("%d\n",i);
+               char buffer[80];
+               sprintf(buffer, "a%d", i);
+               IoTString *ia = new IoTString(buffer);
+               sprintf(buffer, "b%d", i);
+               IoTString *ib = new IoTString(buffer);
+               sprintf(buffer, "c%d", i);
+               IoTString *ic = new IoTString(buffer);
+               sprintf(buffer, "d%d", i);
+               IoTString *id = new IoTString(buffer);
+               t1->createNewKey(ia, 321);
+               t1->createNewKey(ib, 351);
+               t2->createNewKey(ic, 321);
+               t2->createNewKey(id, 351);
+               delete ia;
+               delete ib;
+               delete ic;
+               delete id;
+       }
+}
+
+
+void loop() {
+       
+       // Do Updates for the keys
+       printf("Setting Key-Values...\n");
+       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               printf("%d\n", i);
+               char buffer[80];
+               sprintf(buffer, "a%d", i);
+               IoTString * iKeyA = new IoTString(buffer);
+               IoTString * iValueA = new IoTString(buffer);
+
+               sprintf(buffer, "b%d", i);
+               IoTString * iKeyB = new IoTString(buffer);
+               IoTString * iValueB = new IoTString(buffer);
+               
+               sprintf(buffer, "c%d", i);
+               IoTString * iKeyC = new IoTString(buffer);
+               IoTString * iValueC = new IoTString(buffer);
+               
+               sprintf(buffer, "d%d", i);
+               IoTString * iKeyD = new IoTString(buffer);
+               IoTString * iValueD = new IoTString(buffer);
+
+               t1->startTransaction();
+               t1->put(iKeyA, iValueA);
+               transStatusList->add(t1->commitTransaction());
+               delete iKeyA; delete iValueA;
+               
+               t1->startTransaction();
+               t1->put(iKeyB, iValueB);
+               transStatusList->add(t1->commitTransaction());
+               delete iKeyB; delete iValueB;
+               
+               t2->startTransaction();
+               t2->put(iKeyC, iValueC);
+               transStatusList->add(t2->commitTransaction());
+               delete iKeyC; delete iValueC;
+               
+               t2->startTransaction();
+               t2->put(iKeyD, iValueD);
+               transStatusList->add(t2->commitTransaction());
+               delete iKeyD; delete iValueD;
+       }
+       
+       printf("Updating Clients...\n");
+       t1->update();
+       t2->update();
+       
+       printf("Checking Key-Values...\n");
+       for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               char buffer[80];
+               sprintf(buffer, "a%d", i);
+               IoTString * iKeyA = new IoTString(buffer);
+               IoTString * iValueA = new IoTString(buffer);
+
+               sprintf(buffer, "b%d", i);
+               IoTString * iKeyB = new IoTString(buffer);
+               IoTString * iValueB = new IoTString(buffer);
+               
+               sprintf(buffer, "c%d", i);
+               IoTString * iKeyC = new IoTString(buffer);
+               IoTString * iValueC = new IoTString(buffer);
+               
+               sprintf(buffer, "d%d", i);
+               IoTString * iKeyD = new IoTString(buffer);
+               IoTString * iValueD = new IoTString(buffer);
+               
+               IoTString *testValA1 = t1->getCommitted(iKeyA);
+               IoTString *testValB1 = t1->getCommitted(iKeyB);
+               IoTString *testValC1 = t1->getCommitted(iKeyC);
+               IoTString *testValD1 = t1->getCommitted(iKeyD);
+               
+               IoTString *testValA2 = t2->getCommitted(iKeyA);
+               IoTString *testValB2 = t2->getCommitted(iKeyB);
+               IoTString *testValC2 = t2->getCommitted(iKeyC);
+               IoTString *testValD2 = t2->getCommitted(iKeyD);
+               
+               if ((testValA1 == NULL) || (testValA1->equals(iValueA) == false)) {
+                       printf("Key-Value t1 incorrect: keyA\n");
+                       foundError = true;
+               }
+               
+               if ((testValB1 == NULL) || (testValB1->equals(iValueB) == false)) {
+                       printf("Key-Value t1 incorrect: keyB\n");
+                       foundError = true;
+               }
+
+               if ((testValC1 == NULL) || (testValC1->equals(iValueC) == false)) {
+                       printf("Key-Value t1 incorrect: keyC\n");
+                       foundError = true;
+               }
+               
+               if ((testValD1 == NULL) || (testValD1->equals(iValueD) == false)) {
+                       printf("Key-Value t1 incorrect: keyD\n");
+                       foundError = true;
+               }
+               
+               if ((testValA2 == NULL) || (testValA2->equals(iValueA) == false)) {
+                       printf("Key-Value t2 incorrect: keyA     testValA2\n");
+                       foundError = true;
+               }
+               
+               if ((testValB2 == NULL) || (testValB2->equals(iValueB) == false)) {
+                       printf("Key-Value t2 incorrect: keyB     testValB2\n");
+                       foundError = true;
+               }
+               
+               if ((testValC2 == NULL) || (testValC2->equals(iValueC) == false)) {
+                       printf("Key-Value t2 incorrect: keyC     testValC2\n");
+                       foundError = true;
+               }
+               
+               if ((testValD2 == NULL) || (testValD2->equals(iValueD) == false)) {
+                       printf("Key-Value t2 incorrect: keyD     testValD2\n");
+                       foundError = true;
+               }
+               delete iKeyA; delete iValueA;
+               delete iKeyB; delete iValueB;
+               delete iKeyC; delete iValueC;
+               delete iKeyD; delete iValueD;
+               delete testValA1; delete testValA2;
+               delete testValB1; delete testValB2;
+               delete testValC1; delete testValC2;
+               delete testValD1; delete testValD2;
+       }
+
+       for (uint i = 0; i < transStatusList->size(); i++) {
+               TransactionStatus * status = transStatusList->get(i);
+               if (status->getStatus() != TransactionStatus_StatusCommitted) {
+                       foundError = true;
+                       printf("Status error\n");
+               }
+               delete status;
+       }
+       
+       if (foundError) {
+               printf("Found Errors...\n");
+       } else {
+               printf("No Errors Found...\n");
+       }
+
+       transStatusList->clear();
+}
+