Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues.

Similar presentations


Presentation on theme: "Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues."— Presentation transcript:

1 Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues

2 Laboratório de Engenharia de Software – PUC-Rio Agenda XMLaw –Using a XMLaw agent –Developing a XMLaw agent Scenario Simulation –Number of Stub agents analysis Generic Agents –Commands and Requests –Environment Variables –Stream approach Multiple Generic Agents –Example Conclusion

3 Laboratório de Engenharia de Software – PUC-Rio Using a XMLaw Agent

4 Laboratório de Engenharia de Software – PUC-Rio Developing a XMLaw Agent

5 Laboratório de Engenharia de Software – PUC-Rio Simulating Scenarios Agents –Foo –Bar Organization –Fubar Organization Foo and Bar exchange messages Stub Agents –FooStub –BarStub Test Agents –Scenario 1 Executes Foo with BarStub and verifies the expected behavior –Scenario 2 Executes Bar with FooStub and verifies the expected behavior

6 Laboratório de Engenharia de Software – PUC-Rio Scenario 1 - BarStub... Message addLawReply = getMediatorFacade().informOrganizationToMediator(lawURL.toString()); String orgExec = addLawReply.getContentValue(MessageContentConstants.KEY_ORGANIZATION_EXECUTION_ID); Message enterOrgReply = getMediatorFacade().enterOrganization(orgExec); Message performRoleReply = getMediatorFacade().performRole(orgExec,"bar"); Message startSceneReply = getMediatorFacade().startScene("game",orgExec); String sceneExec = startSceneReply.getContentValue(MessageContentConstants.KEY_SCENE_EXECUTION_ID); Message enterSceneReply = getMediatorFacade().enterInScene(sceneExec,orgExec,"bar"); Message barStubMsg = new Message(Message.INFORM); barStubMsg.setContentValue(MessageContentConstants.KEY_ORGANIZATION_EXECUTION_ID,orgExec); barStubMsg.setContentValue(MessageContentConstants.KEY_SCENE_EXECUTION_ID,sceneExec); barStubMsg.setContentValue("hello","Hello foo, how bar you?"); barStubMsg.setReceiver(fooId,"bar"); send(barStubMsg,"bar"); Message answer = waitForMessage();... System Interaction Create, set and send the message

7 Laboratório de Engenharia de Software – PUC-Rio Number of Stub Agents Analysis Each agent may need s scenarios to be tested Each scenario implies in n-1 Stub Agents In a system with n agents, the number of Stub agents is, in the worst case: Where S k is the number of scenarios for the agent k If each agent has only 1 scenario:

8 Laboratório de Engenharia de Software – PUC-Rio Generic Agents Is a XMLaw agent Make stub creation easier Important Features –Commands and Requests –Environment Variables –Stream approach

9 Laboratório de Engenharia de Software – PUC-Rio Generic Agents - Structural View

10 Laboratório de Engenharia de Software – PUC-Rio Commands and Requests Command –Execute an operation on the agent Request –Inform the command to execute –Inform arguments to the command –Example: performRole 171 bar Ask the system to perform the role bar in the organization 171 Extensions –Developer may create domain specific commands

11 Laboratório de Engenharia de Software – PUC-Rio Environment Variables Shared variables Storage of any string value Storage of messages –A message is a set of variables Example: –the message barMsg is represented by the set: –barMsg –barMsg.sender –barMsg.senderRole –barMsg.receiver –barMsg.receiverRole –barMsg.performative –barMsg.id –barMsg.protocol The content of a variable is identified when the character $ is used before a String The variable “last”

12 Laboratório de Engenharia de Software – PUC-Rio The Stream Approach

13 Laboratório de Engenharia de Software – PUC-Rio The Stream Approach Input Stream –Receives requests Output Stream –Write command responses Control Stream –Assert Command –Automated tests Several Streams Implementations available –Console –File –Socket –Stub –Composite –Piped The GA implementation don’t know the Stream type it is using –Flexibility

14 Laboratório de Engenharia de Software – PUC-Rio GA example 1 - Command Line... GenericAgent agent = new GenericAgent("command line agent"); CommandManager manager = new CommandManager(System.in, System.out, new StubOutputStream(), agent);... User inputs commands in the command line User reads responses in the command line Control Stream is not used Useful for a first contact with open system Hard to repeat

15 Laboratório de Engenharia de Software – PUC-Rio GA example 2– Script File User inputs commands in the script file User reads responses in the output file Control Stream is not used Easy to repeat User must know the commands... FileInputStream scriptStream = new FileInputStream("script.txt"); FileOutputStream outputStream = new FileOutputStream("output.txt"); GenericAgent agent = new GenericAgent("script agent"); CommandManager manager = new CommandManager(scriptStream, outputStream, new StubOutputStream(), agent);...

16 Laboratório de Engenharia de Software – PUC-Rio GA example 3 – Test Application Script TestApp CommandManager output in out control Test application uses a piped stream Uses the control stream to assert expected behavior

17 Laboratório de Engenharia de Software – PUC-Rio GA example 3 - Test Application... FileInputStream scriptStream = new FileInputStream("script.txt"); PipedInputStream pipeInScript = new PipedInputStream(); PipedOutputStream pipeOutScript = new PipedOutputStream(pipeInScript); PipedInputStream pipeInCtrl = new PipedInputStream(); PipedOutputStream pipeOutCtrl = new PipedOutputStream(pipeInCtrl); TestApp app = new TestApp(scriptStream, pipeOutScript, pipeInCtrl); FileOutputStream outputStream = new FileOutputStream("output.txt"); GenericAgent agent = new GenericAgent("tested agent"); CommandManager manager = new CommandManager(pipeInScript, outputStream, pipeOutCtrl, agent);...

18 Laboratório de Engenharia de Software – PUC-Rio Multiple Generic Agents - MuGA Single agent approach –Hard to create scenarios –Hard to execute Asynchronous execution Multiple agent approach –Several agents in a single script –Easy to execute Synchronous execution –Easy to assert behaviors

19 Laboratório de Engenharia de Software – PUC-Rio Multiple Generic Agents

20 Laboratório de Engenharia de Software – PUC-Rio Script Format agent1 agent2 #comments agent1: #requests for agent 1 agent2: #requests for agent 2 agent1: #requests for agent 1 …

21 Laboratório de Engenharia de Software – PUC-Rio Example – Airport Law Four agents –Announcer –Customer –Seller –Bank Four scenes –Announcement Scene –Selection Scene –Negotiation Scene –Payment Scene

22 Laboratório de Engenharia de Software – PUC-Rio Example announcer customer seller bank announcer: addLaw http://www.les.inf.puc-rio.br/xmlaw/leis/airport-law.xmlhttp://www.les.inf.puc-rio.br/xmlaw/leis/airport-law.xml set airportOrgId $last.orgExecutionId enterOrg $airportOrgId performRole $airportOrgId announcer customer: enterOrg $airportOrgId performRole $airportOrgId customer seller: enterOrg $airportOrgId performRole $airportOrgId seller bank: enterOrg $airportOrgId performRole $airportOrgId bank

23 Laboratório de Engenharia de Software – PUC-Rio Example (cont) ############################ #######ANNOUNCEMENT SCENE###### ############################ customer: startScene $airportOrgId announcement set announcementSceneId $last.sceneExecutionId enterScene $airportOrgId $announcementSceneId customer msg m1 request set m1.hello hello set m1.orgExecutionId $airportOrgId set m1.sceneExecutionId $announcementSceneId set m1.receiver announcer send $m1 announcer: receive 5 rm1 enterScene $airportOrgId $announcementSceneId announcer msg m2 inform set m2.services movies;date;food set m2.orgExecutionId $airportOrgId set m2.sceneExecutionId $announcementSceneId set m2.receiver customer send $m2 customer: receive 5 rm2 assert $rm2.services movies;date;food

24 Laboratório de Engenharia de Software – PUC-Rio Conclusions Instead of: We have: If each agent has only 1 scenario


Download ppt "Multiple Generic Agents for XMLaw Luiz Fernando Rodrigues."

Similar presentations


Ads by Google