Testing Cloudfork AWS SimpleDB based classes
The Cloudfork framework includes an alternate implementation of CFSimpleBase that stores all items in memory. The CFSimpleDBEmulator was initially created to support the unit testing of the ActiveItem framework. With the exception of some query constructs, it implements the complete api and therefore is suitable for unit testing your own applications as well.
| emulator domain item | emulator := CFSimpleDBEmulator new. domain := (emulator createDomain: 'myapp.development') result. item := CFSimpleDBItem newNamed: 'user.dennis'. item valueAt: 'birthday' put: '20060916' ;valueAt: 'hobby' put: 'soccer'. domain putItem: item.
After running the tests, you can inspect the emulator to see what items have been stored in which domains and what attributes they have. If you store the emulator in some class var then you can keep the data around for development too.
ActiveItem
Because the ActiveItem framework is build on top of SimpleDB, the same emulator class can be used to unit test those applications. ActiveItem uses a globally shared CFSimpleDB instance so you only need to replace that with an emulated instance.
CFActiveItem activateWithSimpleDB: CFSimpleDBEmulator new.
Using the CFActiveItemSerializer you can even dump the items to a local Filesystem for development convenience.
Tags: aws, Cloudfork, emulation, simpledb, smalltalk, unit
You can comment below, or link to this permanent URL from your own site.