1 22 package org.jboss.test.proxyfactory.test; 23 24 import junit.framework.Test; 25 26 import org.jboss.test.proxyfactory.AbstractProxyTest; 27 import org.jboss.test.proxyfactory.support.InstanceInterceptor; 28 import org.jboss.test.proxyfactory.support.Simple; 29 import org.jboss.test.proxyfactory.support.SimpleBean; 30 31 37 public class InstanceAdvisedTestCase extends AbstractProxyTest 38 { 39 public void testInstanceAdvised() throws Exception 40 { 41 SimpleBean bean1 = new SimpleBean(); 42 Simple simple1 = (Simple) assertCreateProxy(bean1, Simple.class); 43 SimpleBean bean2 = new SimpleBean(); 44 Simple simple2 = (Simple) assertCreateProxy(bean2, Simple.class); 45 InstanceInterceptor.last = null; 46 simple1.doSomething(); 47 assertTrue(bean1.invoked); 48 Object instance1 = InstanceInterceptor.last; 49 assertNotNull(instance1); 50 InstanceInterceptor.last = null; 51 simple2.doSomething(); 52 assertTrue(bean2.invoked); 53 Object instance2 = InstanceInterceptor.last; 54 assertNotNull(instance2); 55 assertFalse(instance1 == instance2); 56 } 57 58 public static Test suite() 59 { 60 return suite(InstanceAdvisedTestCase.class); 61 } 62 63 public InstanceAdvisedTestCase(String name) 64 { 65 super(name); 66 } 67 } 68 | Popular Tags |