|
SimpleRecorderTest
Recording Actual Invocation Sequences with jSupervisor.
The source for this test (or example) is available in SimpleRecorderTest.java This example is very unlike the others. In other cases, the scenario is described in a method typically named as "describeScenario" in my examples. In this particular example, I will not describe the scenario, but instead extract it my monitoring the execution of the target objects attached to the proxies. This is illustrated in the method testRecording(). It first sets up the recording environment which is the attachments of targets to the proxies. 1. MyApp targetApp = new MyApp() ; 2. MyAuthentication targetAuthentication = new MyAuthentication() ; 3. MyAuthenticationServer targetAuthenticationServer = new MyAuthenticationServer(); 4. attachImplementations(targetApp, targetAuthentication, targetAuthenticationServer) ; Next, a recording session is executed. 5. supervisor.record(new RecordingSession() {
6. public void recording() {
7. myApp.start();
8. }
9. }) ; The recording is initiated in Line 7 which invokes the scenario (collaboration sequence). Now, that the invocation is recorded, you can print or play the invocation sequence. 10. supervisor.getSpecifier().print() ; 11. ExecutionState state = supervisor.play() ; 12. assertEquals(state, ExecutionState.COMPLETED); This is just a simple example to show how the scenario is recorded. The recorded sequence is useful in several ways. It can be used for debugging. It can be used for testing to compare the results of different recorded sequences. However, such examples have yet to be developed. What I have now is merely a recording mechanism. |