Cleaned up git
[iotcloud.git] / version2 / src / java / iotcloud / Test.java
1 package iotcloud;
2
3 /**
4  * Test cases.
5  * @author Brian Demsky
6  * @version 1.0
7  */
8
9 public class Test {
10         public static void main(String[] args) {
11                 if (args[0].equals("2")) {
12                         test2();
13                 }
14         }
15
16         static void test2() {
17                 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
18                 t1.initTable();
19                 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
20                 t2.update();
21
22
23
24                 final int NUMBER_OF_TESTS = 200;
25
26                 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
27
28                         System.out.println("Doing: " + i);
29
30                         String a = "a" + i;
31                         String b = "b" + i;
32                         IoTString ia = new IoTString(a);
33                         IoTString ib = new IoTString(b);
34
35
36                         t1.createNewKey(ia, 351);
37                         t2.createNewKey(ib, 321);
38
39                         t1.startTransaction();
40                         t1.addKV(ia, ia);
41                         t1.commitTransaction();
42                 }
43
44                 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
45
46                         System.out.println("Doing: " + i);
47
48                         String a = "a" + i;
49                         String b = "b" + i;
50                         IoTString ia = new IoTString(a);
51                         IoTString ib = new IoTString(b);
52
53                         t2.startTransaction();
54                         t2.addKV(ib, ib);
55                         t2.commitTransaction();
56                 }
57
58
59
60                 t1.update();
61                 // t2.update();
62                 // t1.update();
63
64                 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
65                         String a = "a" + i;
66                         String b = "b" + i;
67                         IoTString ia = new IoTString(a);
68                         IoTString ib = new IoTString(b);
69
70                         System.out.println(ib + " -> " + t1.getCommitted(ib));
71                         System.out.println(ia + " -> " + t2.getCommitted(ia));
72                         System.out.println();
73                 }
74         }
75 }