add & use is working with little testsuite. information about hits/misses added.
[mir.git] / source / mir / storage / store / test / TestStore.java
index e8903b4..29c15e5 100755 (executable)
@@ -29,11 +29,39 @@ public class TestStore {
        }
 
        public void startTest() {
-               //System.out.println(o_store.toString());
+
                EntityC1 c1 = new EntityC1("1");
                o_store.add(c1.getStoreIdentifier());
-               EntityC1 c2 = new EntityC1("2");
-               o_store.add(c2.getStoreIdentifier());
+               EntityC1 c12 = new EntityC1("2");
+               o_store.add(c12.getStoreIdentifier());
+    o_store.add(c12.getStoreIdentifier()); // should not be added as it's there already
+
+    EntityC2 c2;
+    for (int i=0; i<20; i++) {
+      c2 = new EntityC2(""+i);
+      o_store.add(c2.getStoreIdentifier());
+    } // should contain only 10
+
+    // test cycle: search in store
+
+    StorableObject reference; StoreIdentifier search_sid;
+
+    // search for EntityC1
+    search_sid=new StoreIdentifier(EntityC1.class,"1");
+    reference=o_store.use(search_sid);
+    if (reference==null)
+      System.out.println("--- should have found" + search_sid.toString());
+
+    search_sid=new StoreIdentifier(EntityC1.class,"A");
+    reference=o_store.use(search_sid);
+    if (reference!=null)
+      System.out.println("--- should not have found" + search_sid.toString());
+
+    search_sid=new StoreIdentifier(EntityC3.class,"1");
+    reference=o_store.use(search_sid);
+    if (reference!=null)
+      System.out.println("--- should not have found" + search_sid.toString());
+
 
                System.out.println(o_store.toString());
     /** @todo compare values of store and state failed if values are not