more bug fixes
[iotcloud.git] / src / java / iotcloud / Test.java
index 101ca77983c555a97f7ea054edcb50429d656e07..dcd4f1e1b93a2a7cba880a1135798ba9b16a493d 100644 (file)
@@ -6,9 +6,61 @@ public class Test {
                        test1();
                else if(args[0].equals("2"))
                        test2();
+               else if(args[0].equals("3"))
+                       test3();
+               else if(args[0].equals("4"))
+                       test4();
 
        }
 
+       static Thread buildThread(String prefix, Table t) {
+               return new Thread() {
+                       public void run() {
+                               for(int i=0; i<600; i++) {
+                                       String a=prefix+i;
+                                       IoTString ia=new IoTString(a);
+                                       t.put(ia, ia);
+                                       System.out.println(ia+"->"+t.get(ia));
+                               }               
+                       }
+               };
+       }
+       
+       static void test4() {
+               Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t2=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t1.rebuild();
+               t2.rebuild();
+               Thread thr1=buildThread("p1", t1);
+               Thread thr2=buildThread("p2", t2);
+               thr1.start();
+               thr2.start();
+               try {
+                       thr1.join();
+                       thr2.join();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       static void test3() {
+               Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t2=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t1.rebuild();
+               t2.rebuild();
+               for(int i=0; i<600; i++) {
+                       String a="STR"+i;
+                       String b="ABR"+i;
+                       IoTString ia=new IoTString(a);
+                       IoTString ib=new IoTString(b);
+                       t1.put(ia, ia);
+                       t2.put(ib, ib);
+                       t1.update();
+                       System.out.println(ib+"->"+t1.get(ib));
+                       System.out.println(ia+"->"+t2.get(ia));
+               }
+       }
+
        static void test2() {
                Table t1=new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();