1 22 package org.jboss.test.proxyfactory.test; 23 24 25 import junit.framework.Test; 26 27 import org.jboss.aop.proxy.container.AOPProxyFactoryMixin; 28 import org.jboss.test.proxyfactory.AbstractProxyTest; 29 import org.jboss.test.proxyfactory.support.Another; 30 import org.jboss.test.proxyfactory.support.AnotherMixin; 31 import org.jboss.test.proxyfactory.support.Other; 32 import org.jboss.test.proxyfactory.support.ReturningInterceptor; 33 import org.jboss.test.proxyfactory.support.Simple; 34 import org.jboss.test.proxyfactory.support.SimpleInterceptor; 35 import org.jboss.test.proxyfactory.support.SimpleMixin; 36 import org.jboss.test.proxyfactory.support.Tagging; 37 38 44 public class HollowInterfaceAndMixinTestCase extends AbstractProxyTest 45 { 46 public void testInterfaceAndMixin() throws Exception 47 { 48 SimpleMixin.invoked = false; 49 SimpleInterceptor.invoked = null; 50 ReturningInterceptor.invoked = null; 51 AnotherMixin.invoked = false; 52 53 AOPProxyFactoryMixin[] mixins = { 54 new AOPProxyFactoryMixin(SimpleMixin.class, new Class []{Simple.class}), 55 new AOPProxyFactoryMixin(AnotherMixin.class, new Class [] {Another.class})}; 56 Object proxy = assertCreateHollowProxy( 57 new Class [] {Other.class, Tagging.class}, 58 mixins, 59 null, 60 new Class [] {Other.class, Simple.class, Tagging.class, Another.class}); 61 62 Simple simple = (Simple)proxy; 63 simple.doSomething(); 64 assertTrue(SimpleMixin.invoked); 65 assertNotNull(SimpleInterceptor.invoked); 66 assertEquals("doSomething", SimpleInterceptor.invoked.getName()); 67 assertNull(ReturningInterceptor.invoked); 68 assertFalse(AnotherMixin.invoked); 69 70 SimpleInterceptor.invoked = null; 71 SimpleMixin.invoked = false; 72 Other other = (Other)proxy; 73 other.otherMethod(); 74 assertFalse(SimpleMixin.invoked); 75 assertNotNull(ReturningInterceptor.invoked); 76 assertEquals("otherMethod", ReturningInterceptor.invoked.getName()); 77 assertNull(SimpleInterceptor.invoked); 78 assertFalse(AnotherMixin.invoked); 79 80 SimpleInterceptor.invoked = null; 81 ReturningInterceptor.invoked = null; 82 SimpleMixin.invoked = false; 83 Another another = (Another)proxy; 84 another.anotherMethod(); 85 assertFalse(SimpleMixin.invoked); 86 assertNull(ReturningInterceptor.invoked); 87 assertNull(SimpleInterceptor.invoked); 88 assertTrue(AnotherMixin.invoked); 89 } 90 91 public static Test suite() 92 { 93 return suite(HollowInterfaceAndMixinTestCase.class); 94 } 95 96 public HollowInterfaceAndMixinTestCase(String name) 97 { 98 super(name); 99 } 100 } 101 | Popular Tags |