|
25 | 25 | from springpython.context import ApplicationContext |
26 | 26 | from springpython.remoting.pyro import PyroDaemonHolder |
27 | 27 | from springpythontest.support.testSupportClasses import BeforeAndAfterInterceptor |
28 | | -from springpythontest.support.testSupportClasses import SampleService |
| 28 | +from springpythontest.support.testSupportClasses import SampleService, NewStyleSampleService |
29 | 29 | from springpythontest.support.testSupportClasses import WrappingInterceptor |
30 | 30 |
|
31 | 31 | class AopInterfaceTestCase(unittest.TestCase): |
@@ -56,6 +56,15 @@ def testCreatingAProxyFactoryAndAddingAnInterceptorProgrammatically(self): |
56 | 56 | self.assertEquals("<Wrapped>You made it! => test</Wrapped>", service.method("test")) |
57 | 57 | self.assertEquals("sample", service.attribute) |
58 | 58 |
|
| 59 | + def testCreatingAopProxyFactoryAndAddingInterceptorToNewStyleClassProgammatically(self): |
| 60 | + factory = ProxyFactory() |
| 61 | + factory.target = NewStyleSampleService() |
| 62 | + factory.interceptors.append(WrappingInterceptor()) |
| 63 | + service = factory.getProxy() |
| 64 | + self.assertEquals("<Wrapped>Even better!</Wrapped>", service.doSomething()) |
| 65 | + self.assertEquals("<Wrapped>You made it to a new style class! => test</Wrapped>", service.method("test")) |
| 66 | + self.assertEquals("new_sample", service.attribute) |
| 67 | + |
59 | 68 | def testCreatingAProxyFactoryAndAddingAnInterceptorIoC(self): |
60 | 69 | factory = self.appContext.get_object("factory") |
61 | 70 | service = factory.getProxy() |
|
0 commit comments