Adding Fidelius manual.
[iotcloud.git] / version1 / 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                 else if(args[0].equals("3"))
14                         test3();
15                 else if(args[0].equals("4"))
16                         test4();
17                 else if(args[0].equals("5"))
18                         test5();
19
20         }
21
22         
23         
24         static Thread buildThread(String prefix, Table t) {
25                 return new Thread() {
26                         public void run() {
27                                 for(int i=0; i<10000; i++) {
28                                         String a=prefix+i;
29                                         IoTString ia=new IoTString(a);
30                                         t.put(ia, ia);
31                                         System.out.println(ia+"->"+t.get(ia));
32                                 }
33                         }
34                 };
35         }
36         
37         static void test5() {
38                 Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
39                 t1.rebuild();
40                 System.out.println(t1);
41         }
42         
43         static void test4() {
44                 Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
45                 Table t2=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
46                 t1.rebuild();
47                 t2.rebuild();
48                 Thread thr1=buildThread("p1", t1);
49                 Thread thr2=buildThread("p2", t2);
50                 thr1.start();
51                 thr2.start();
52                 try {
53                         thr1.join();
54                         thr2.join();
55                 } catch (Exception e) {
56                         e.printStackTrace();
57                 }
58         }
59
60         static void test3() {
61                 Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
62                 Table t2=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
63                 t1.rebuild();
64                 t2.rebuild();
65                 for(int i=0; i<600; i++) {
66                         String a="STR"+i;
67                         String b="ABR"+i;
68                         IoTString ia=new IoTString(a);
69                         IoTString ib=new IoTString(b);
70                         t1.put(ia, ia);
71                         t2.put(ib, ib);
72                         t1.update();
73                         System.out.println(ib+"->"+t1.get(ib));
74                         System.out.println(ia+"->"+t2.get(ia));
75                 }
76         }
77
78         static void test2() {
79                 Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
80                 t1.initTable();
81                 Table t2=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
82                 t2.update();
83                 for(int i=0; i<600; i++) {
84                         String a="STR"+i;
85                         String b="ABR"+i;
86                         IoTString ia=new IoTString(a);
87                         IoTString ib=new IoTString(b);
88                         t1.put(ia, ia);
89                         t2.put(ib, ib);
90                         t1.update();
91                         System.out.println(ib+"->"+t1.get(ib));
92                         System.out.println(ia+"->"+t2.get(ia));
93                 }
94         }
95 }