1   /*
2    * HivemindObjectAspecTest.java
3    * Created on 10 Июнь 2006 г., 23:51
4    */
5   
6   package org.weda.enhance;
7   
8   import org.weda.test.WedaTestCase;
9   import org.weda.cache.CacheManager;
10  import org.weda.enhance.impl.AspectHelperImpl;
11  import org.weda.message.MessagesRegistry;
12  
13  /**
14   *
15   * @author Mikhail Titov
16   */
17  public class HivemindObjectAspectTest 
18          extends WedaTestCase implements AspectHelper
19  {
20      private AspectHelper realInstance;
21      private int callCounter = 0;
22      
23      public HivemindObjectAspectTest(String name) throws Exception {
24          super(name);
25      }
26      
27      public void test() throws Exception {
28          TestObject object = new TestObject();
29          assertNotNull(object.getAspectHelper());
30          assertNotNull(object.getAspectHelper());
31          assertNotNull(object.getList());
32      }
33      
34      public void test2() throws Exception {
35          realInstance = AspectHelperImpl.INSTANCE;
36          AspectHelperImpl.INSTANCE = this;
37          //
38          TestObject object = new TestObject();
39          assertNotNull(object.getAspectHelper());
40          assertNotNull(object.getAspectHelper());        
41          assertEquals(1, callCounter);
42      }
43  
44      public Object getHivemindObject(String ref) {
45          callCounter++;
46          return realInstance.getHivemindObject(ref);
47      }
48  
49      public MessagesRegistry getMessagesRegistry() {
50          return realInstance.getMessagesRegistry();
51      }
52  
53      public CacheManager getCacheManager() {
54          return realInstance.getCacheManager();
55      }
56      
57  }