Example #1
0
 def testWrappingStringFunctionWithInterceptor(self):
     service = ProxyFactoryObject()
     service.target = SampleService()
     service.interceptors = [WrappingInterceptor()]
     self.assertEquals("This is a sample service.", service.target.__str__())
     self.assertEquals("This is a sample service.", str(service.target))
     self.assertEquals("<Wrapped>This is a sample service.</Wrapped>", str(service))
     self.assertEquals("<Wrapped>This is a sample service.</Wrapped>", service.__str__())
Example #2
0
 def testWrappingStringFunctionWithInterceptor(self):
     service = ProxyFactoryObject()
     service.target = SampleService()
     service.interceptors = [WrappingInterceptor()]
     self.assertEquals("This is a sample service.",
                       service.target.__str__())
     self.assertEquals("This is a sample service.", str(service.target))
     self.assertEquals("<Wrapped>This is a sample service.</Wrapped>",
                       str(service))
     self.assertEquals("<Wrapped>This is a sample service.</Wrapped>",
                       service.__str__())
Example #3
0
    def testProxyFactoryObjectInterceptorsNotWrappedInAList(self):
        service = ProxyFactoryObject()
        service.target = SampleService()

        # Note that it isn't wrapped in a list.
        service.interceptors = WrappingInterceptor()

        self.assertEquals("This is a sample service.", service.target.__str__())
        self.assertEquals("This is a sample service.", str(service.target))
        self.assertEquals("<Wrapped>This is a sample service.</Wrapped>", str(service))
        self.assertEquals("<Wrapped>This is a sample service.</Wrapped>", service.__str__())

        # sampleService6 has an interceptor which isn't wrapped in a list
        # inside its XMLConfig.
        service = self.appContext.get_object("sampleService6")
        self.assertEquals("<Wrapped>Alright!</Wrapped>", service.doSomething())
        self.assertEquals("<Wrapped>You made it! => test</Wrapped>", service.method("test"))
        self.assertEquals("sample", service.attribute)
Example #4
0
    def testProxyFactoryObjectInterceptorsNotWrappedInAList(self):
        service = ProxyFactoryObject()
        service.target = SampleService()

        # Note that it isn't wrapped in a list.
        service.interceptors = WrappingInterceptor()

        self.assertEquals("This is a sample service.",
                          service.target.__str__())
        self.assertEquals("This is a sample service.", str(service.target))
        self.assertEquals("<Wrapped>This is a sample service.</Wrapped>",
                          str(service))
        self.assertEquals("<Wrapped>This is a sample service.</Wrapped>",
                          service.__str__())

        # sampleService6 has an interceptor which isn't wrapped in a list
        # inside its XMLConfig.
        service = self.appContext.get_object("sampleService6")
        self.assertEquals("<Wrapped>Alright!</Wrapped>", service.doSomething())
        self.assertEquals("<Wrapped>You made it! => test</Wrapped>",
                          service.method("test"))
        self.assertEquals("sample", service.attribute)