X Tutup
Skip to content

Commit 0a4d67a

Browse files
author
Greg Turnquist
committed
SESPRINGPYTHONPY-134: Created a test case to reproduce the problem Tom spotted.
1 parent 58f90b9 commit 0a4d67a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

test/springpythontest/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
springpython.db

test/springpythontest/aopTestCases.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from springpython.context import ApplicationContext
2626
from springpython.remoting.pyro import PyroDaemonHolder
2727
from springpythontest.support.testSupportClasses import BeforeAndAfterInterceptor
28-
from springpythontest.support.testSupportClasses import SampleService
28+
from springpythontest.support.testSupportClasses import SampleService, NewStyleSampleService
2929
from springpythontest.support.testSupportClasses import WrappingInterceptor
3030

3131
class AopInterfaceTestCase(unittest.TestCase):
@@ -56,6 +56,15 @@ def testCreatingAProxyFactoryAndAddingAnInterceptorProgrammatically(self):
5656
self.assertEquals("<Wrapped>You made it! => test</Wrapped>", service.method("test"))
5757
self.assertEquals("sample", service.attribute)
5858

59+
def testCreatingAopProxyFactoryAndAddingInterceptorToNewStyleClassProgammatically(self):
60+
factory = ProxyFactory()
61+
factory.target = NewStyleSampleService()
62+
factory.interceptors.append(WrappingInterceptor())
63+
service = factory.getProxy()
64+
self.assertEquals("<Wrapped>Alright!</Wrapped>", service.doSomething())
65+
self.assertEquals("<Wrapped>You made it! => test</Wrapped>", service.method("test"))
66+
self.assertEquals("sample", service.attribute)
67+
5968
def testCreatingAProxyFactoryAndAddingAnInterceptorIoC(self):
6069
factory = self.appContext.get_object("factory")
6170
service = factory.getProxy()

test/springpythontest/support/testSupportClasses.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ def doSomething(self):
149149
def __str__(self):
150150
return "This is a sample service."
151151

152+
class NewStyleSampleService(object):
153+
def __init__(self):
154+
self.attribute = "new_sample"
155+
def method(self, data):
156+
return "You made it to a new style class! => %s" % data
157+
def doSomething(self):
158+
return "Even better!"
159+
def __str__(self):
160+
return "This is a new style sample service."
161+
152162
class RemoteService1(object):
153163
def getData(self, param):
154164
return "You got remote data => %s" % param

0 commit comments

Comments
 (0)
X Tutup