Emulation

jonasbn on 2006-08-27T12:59:36

I was hired to do a web app in a proprietary framework with one of my clients - a large danish Telco (I will save this for another journal entry).

The framework is implemented in Perl and uses XSLT and mod_perl.

I am implementing a service/application in the framework, this is part of the original idea behind the framework, of which I was one of the original architects (I still consider this one of the bigger achievements in my career). So we can extend the web sites functionality using services/application without reinventing the wheel every 3-6 months (we did that).

Well anyhow, the framework which was implemented back in 2001, has not had the same pace as some of the other frameworks around. So if you want to develop stuff you actually need quite a heavy setup of application and frontend servers, databases etc.

This has all of course been provided to be, if I show up on location, and still there are problems, dependency on other departments to deliver test-data, working API's etc.

So to begin with I had to wait for the business system backend, which we access via an XML interface via HTTP. This was ok I had time to set up the skeleton of the application I was going to build using a subclass of Module::Build and a simple configuration system honouring a dev/test7prod separation (I made these modules the last time I had a gig with the client), the configuration part might have to be revisited for improvements, but it's a poor man's configuration management and it works - for now.

Finally the backend was finished, in the meantime I had been idling so I had introduced an emulation of the backend, responding with static XML, this is done the old fashion way with a test flag, I should look into using Test::MockClass, but timeconstraints pushed me to the old fashioned way.

Just the day after the delivery of the backend, somebody flushed the test database, and I was back to square one, luckily I had my emulation, but it was far from satisfying and the project was moving into a critical phase. So going with the emulation I started focussing on the frontend of the application.

I started using xsltproc heavily. I had started using this tool too develop my XSL stylesheet, since debugging on the real platform was not as accessible, since I had to deploy a lot of things is I just changed a comma and I was not able to take things with me off site.

So all the XSL got into a good state, the backend emulation was somewhat working (not acting as a complete emulation, but at least it responded with data), but I needed to test the integrity of the actual application, I had written up a lot of tests testing the API, but I had still not done a complete end-to-end test of the app.

So I looked at the code, I had written up a small CGI script to echo submitted data for testing the product of the xslt processing. So I copied this script to another script, integrated it with XML::LibXSLT

So now I emulated backend and the frontend as a CGI script and I could navigate around in the application and see that buttons change names and that data get transferred.

So in order for this project to be a success in my book the following should be done:

  • The backend emulation should respond with dynamically generated XML instead of static
  • The backend emulation should be accessible using Test::MockClass to the application code would be transparent to this
  • The frontend emulation should be able to emulate the framework's session handling


Life is too short to do things 100% right, especially if you are a contractor and code as slowly as I do - I often wish I was just sitting as a hired employee in a R&D department with reasonable deadlines and time! time, time, time.

Well enough journalling I should be coding, deadline coming up tomorrow and YAPC::Europe is scheduled for all of next week.