On 19/09/2007, Peter Ledbrook <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Sorry for hitting the list again, but I have a significant problem
> with the functional tests of my Grails app.
>
> I have a security service which is accessed via Spring's HttpInvoker,
> and a user interface that allows a user to configure that service. For
> my functional tests, I want to test that changes made via the user
> interface are reflected in the responses from the security service.
>
> I am currently creating webtests and adding some 'assert' statements
> between steps that access the security service and check the response.
> However, this isn't working because the security service calls are
> happening before any of the steps within a single webtest (I assume
> because WebTest builds the test in memory before executing it once the
> closure has completed).
>
> So, is it feasible to mix webtest steps and calls to a remote service
> like this? One option might be to embed calls to the security service
> in 'groovy' or 'scriptStep' steps, but in that case, how do I pass the
> security service client object and other parameters into the step? Are
> there any other approaches that I can take?
>
> Thanks for any help,
>
> Peter
If anyone's interested, I have gone for a really horrible hack by
adding this group to the beginning of each webtest:
ant.group(description: 'Bind the security service to Groovy steps.'){
// Store the security service URL in a webtest property
storeProperty(
property: 'ssUrl',
value:
"${configMap.protocol}://${configMap.host}:${configMap.port}/\
${configMap.basepath}/httpinvoker/SecurityService")
// Store the security service client in the webtest's binding.
// Big hack!
groovy('''\
import net.ixico.security.IxicoSecurityService
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean
HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean()
factoryBean.setServiceUrl(step.webtestProperties.ssUrl)
factoryBean.setServiceInterface(IxicoSecurityService.class)
factoryBean.afterPropertiesSet()
def ss = factoryBean.getObject()
def binding =
step.webtestProperties.get('com.canoo.webtest.extension.groovy.GroovyInvoker#binding')
binding.setVariable('securityService', ss)
''')
}
I can then use 'groovy' steps and reference the 'securityService'
variable directly from within them.
Cheers,
Peter
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest