indexing description: "Represents a dummy server for origo xml-rpc calls" author: "" date: "$Date$" revision: "$Revision$" class DUMMY_SERVER inherit GOA_SERVICE redefine make end create make feature -- Initialisation make is -- Creation procedure, -- Create a new dummy server do Precursor self_register end self_register is -- Register all offered features of this server do register_with_help (agent cow, cow_name, cow_help) register_with_help (agent list_methods, list_methods_name, list_methods_help) register_with_help (agent login, login_name, login_help) register_with_help (agent list_projects, list_projects_name, list_projects_help) end new_tuple (a_name: STRING): TUPLE is -- Tuple of default-valued arguments to pass to call `a_name' do if a_name.is_equal (list_methods_name) then Result := create {TUPLE[]} elseif a_name.is_equal (login_name) then Result := create {TUPLE[STRING]} elseif a_name.is_equal (cow_name) then Result := create {TUPLE[]} elseif a_name.is_equal (list_projects_name) then Result := create {TUPLE[STRING]} end end feature -- access cow: STRING is -- returns "moo" do Result := "moo" end list_methods: ARRAY[ANY] is -- returns the list of methods local i: INTEGER a_method_name: STRING a_help_string: STRING do create Result.make (1, elements.count) from elements.start i := 1 until elements.after loop a_method_name := elements.key_for_iteration.out a_help_string := help (a_method_name).out if a_help_string.is_empty then a_help_string := a_method_name.out end a_help_string.append_character ('%N') Result.put (a_help_string, i) -- increment elements.forth i := i + 1 end ensure result_not_void: Result /= Void end login (key: STRING): STRING is -- returns the autentication token or "Failure" require key_not_void: key /= Void do if key.is_equal ("origo") then Result := "muhkuh" else Result := "Failure" end end list_projects (session: STRING): ARRAY[ANY] is -- returns a list of project names of the user associated with `session' -- returns an empty array if `session' is not valikd local a_project_name: STRING do if session.is_equal ("muhkuh") then create Result.make (1, 3) Result.put ("Minestrone", 1) Result.put ("BrickBreakerCE", 2) Result.put ("MooForPresident", 3) else create Result.make(1,1) Result.put ("", 1) end ensure result_not_void: Result /= Void end feature {NONE} -- Constants list_methods_name: STRING is "list_methods" list_methods_help: STRING is "list_methods: ARRAY [STRING]%N%TLists all available methods." login_name: STRING is "login" login_help: STRING is "login (key: STRING): STRING%N%TLogs in into Origo and returns the session string.%N%TIf it's %"Failure%" the login failed" cow_name: STRING is "cow" cow_help: STRING is "cow: STRING%N%TMoos" list_projects_name: STRING is "list_projects" list_projects_help: STRING is "list_projects (session: STRING): ARRAY[STRING]%N%TLists all project names of the user associated with session%N%TIf session is invalid the result contains a single element which is an empty string" invariant invariant_clause: True -- Your invariant here end