29c15e5e1e7d979ef99cbb54164d5922a31366f5
[mir.git] / source / mir / storage / store / test / TestStore.java
1 package mir.storage.store.test;
2
3 /**
4  * Title:
5  * Description:
6  * Copyright:    Copyright (c) 2002
7  * Company:
8  * @author
9  * @version 1.0
10  */
11
12 import mir.storage.store.*;
13
14 public class TestStore {
15
16         private static ObjectStore o_store = ObjectStore.getInstance();
17
18         public TestStore() {
19
20         }
21
22         public static void main(String[] args) {
23                 long startTime = System.currentTimeMillis();
24                 System.out.println("Starting testrun on ObjectStore...");
25                 TestStore testStore1 = new TestStore();
26                 testStore1.startTest();
27                 System.out.println("Finished testrun on ObjectStore. ("
28                                 + (System.currentTimeMillis() - startTime) + " ms)");
29         }
30
31         public void startTest() {
32
33                 EntityC1 c1 = new EntityC1("1");
34                 o_store.add(c1.getStoreIdentifier());
35                 EntityC1 c12 = new EntityC1("2");
36                 o_store.add(c12.getStoreIdentifier());
37     o_store.add(c12.getStoreIdentifier()); // should not be added as it's there already
38
39     EntityC2 c2;
40     for (int i=0; i<20; i++) {
41       c2 = new EntityC2(""+i);
42       o_store.add(c2.getStoreIdentifier());
43     } // should contain only 10
44
45     // test cycle: search in store
46
47     StorableObject reference; StoreIdentifier search_sid;
48
49     // search for EntityC1
50     search_sid=new StoreIdentifier(EntityC1.class,"1");
51     reference=o_store.use(search_sid);
52     if (reference==null)
53       System.out.println("--- should have found" + search_sid.toString());
54
55     search_sid=new StoreIdentifier(EntityC1.class,"A");
56     reference=o_store.use(search_sid);
57     if (reference!=null)
58       System.out.println("--- should not have found" + search_sid.toString());
59
60     search_sid=new StoreIdentifier(EntityC3.class,"1");
61     reference=o_store.use(search_sid);
62     if (reference!=null)
63       System.out.println("--- should not have found" + search_sid.toString());
64
65
66                 System.out.println(o_store.toString());
67     /** @todo compare values of store and state failed if values are not
68      *  right*/
69
70     /** @todo test cycle: search in store */
71     /** @todo test cycle: invalidation */
72
73         }
74 }