def testCreatingAopProxyFactoryAndAddingInterceptorToNewStyleClassProgammatically(self):
     factory = ProxyFactory()
     factory.target = NewStyleSampleService()
     factory.interceptors.append(WrappingInterceptor())
     service = factory.getProxy()
     self.assertEquals("<Wrapped>Even better!</Wrapped>", service.doSomething())
     self.assertEquals("<Wrapped>You made it to a new style class! => test</Wrapped>", service.method("test"))
     self.assertEquals("new_sample", service.attribute)
 def testCreatingAProxyFactoryAndAddingAnInterceptorProgrammatically(self):
     factory = ProxyFactory()
     factory.target = SampleService()
     factory.interceptors.append(WrappingInterceptor())
     service = factory.getProxy()
     self.assertEquals("<Wrapped>Alright!</Wrapped>", service.doSomething())
     self.assertEquals("<Wrapped>You made it! => test</Wrapped>", service.method("test"))
     self.assertEquals("sample", service.attribute)
Exemple #3
0
 def testCreatingAProxyFactoryAndAddingAnInterceptorProgrammatically(self):
     factory = ProxyFactory()
     factory.target = SampleService()
     factory.interceptors.append(WrappingInterceptor())
     service = factory.getProxy()
     self.assertEquals("<Wrapped>Alright!</Wrapped>", service.doSomething())
     self.assertEquals("<Wrapped>You made it! => test</Wrapped>",
                       service.method("test"))
     self.assertEquals("sample", service.attribute)
Exemple #4
0
 def testCreatingAopProxyFactoryAndAddingInterceptorToNewStyleClassProgammatically(
         self):
     factory = ProxyFactory()
     factory.target = NewStyleSampleService()
     factory.interceptors.append(WrappingInterceptor())
     service = factory.getProxy()
     self.assertEquals("<Wrapped>Even better!</Wrapped>",
                       service.doSomething())
     self.assertEquals(
         "<Wrapped>You made it to a new style class! => test</Wrapped>",
         service.method("test"))
     self.assertEquals("new_sample", service.attribute)
Exemple #5
0
from springpython.aop import ProxyFactory
from ScriptifyInterceptor import ScriptifyInterceptor
from LibCalcul import LibCalcul

scriptFilename = "testScriptify.py"
with open(scriptFilename, 'w') as script:
    script.write("from LibCalcul import LibCalcul\n\n")

factory = ProxyFactory()
factory.target = LibCalcul()
factory.interceptors.append(ScriptifyInterceptor(scriptFilename))
service = factory.getProxy()

nombre1 = service.getNombre(10)
chiffre1 = service.getChiffre(5)
nombre2 = service.additionne(nombre1, chiffre1)
service.printNombre(nombre2)