Skip to content

Commit

Permalink
- Correction of Service loading to load the entire parent definition …
Browse files Browse the repository at this point in the history
…while loading a child application.

- Added functional test ParentFunctions to check parent functions inheritance.
  • Loading branch information
thomasjammet committed Dec 18, 2014
1 parent 788956f commit dce13da
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 5 deletions.
2 changes: 2 additions & 0 deletions FunctionalTests/src/FunctionalTests.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@
group.children.push(new RTMPBadRequests(this, hostDefault));
group.children.push(new RTMPLoad(this, hostDefault, applicationDefault, "RTMP"));
group.children.push(new RTMPLoad(this, hostDefault, applicationDefault, "RTMPE"));
// TODO : group.children.push(new RTMPp2p(this, hostDefault, applicationDefault));
mapTests.push(group);
group = new Test(this, "RTMFP", "List of RTMFP tests", true);
group.children.push(new RTMFPLoad(this, hostDefault, applicationDefault));
mapTests.push(group);
group = new Test(this, "Other", "List of other tests", true);
group.children.push(new DeserializationJSON(this, hostDefault, applicationDefault));
group.children.push(new DeserializationXMLRPC(this, hostDefault, applicationDefault));
group.children.push(new ParentFunctions(this, hostDefault, applicationDefault));
mapTests.push(group);
luaGroup = new Test(this, "LUA", "List of LUA server tests", true);
Expand Down
89 changes: 89 additions & 0 deletions FunctionalTests/src/ParentFunctions.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package
{
import flash.events.NetStatusEvent;
import flash.events.TimerEvent;
import flash.net.NetConnection;
import flash.net.Responder;
import flash.utils.Timer;

import mx.controls.Alert;

public class ParentFunctions extends Test
{
private var _host:String;
private var _url:String;
private var _connection:NetConnection;

public function ParentFunctions(app:FunctionalTests, host:String, url:String)
{
super(app, "ParentFunctions", "Check heritage of sub applications");
_host=host;
_url=url;
}

override public function run(onFinished:Function):void {

super.run(onFinished);

_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, onStatus);
_connection.connect("rtmfp://" + _host + _url + "subapp/subsubapp");
}

// 1st response
public function onRealNameApp(response:String):void {
if (response=="subsubapp") {
_connection.call("getNameParentApp", new Responder(onNameParentApp));
} else {
onResult({err:"onRealNameApp : Expected 'subsubapp' and received '"+response+"'"});
_connection.close();
}
}

// 2nd response
public function onNameParentApp(response:String):void {
if (response=="subapp") {
// getNameApp doesn't exists in subsubApp => so it will fail
_connection.call("getNameApp", new Responder(null, onErrorNameApp));
} else {
onResult({err:"onNameParentApp : Expected 'subapp' and received '"+response+"'"});
_connection.close();
}
}

// 3rd response
public function onErrorNameApp(error:Object):void {
if (error.description=="Method 'getNameApp' not found on application /FunctionalTests/subapp/subsubapp") {
_connection.call("getNameSuperParentApp", new Responder(onNameSuperParentApp));
} else {
onResult({err:"onErrorNameApp : Unexpected error '"+error.description+"'"});
_connection.close();
}
}

// Last response
public function onNameSuperParentApp(response:String):void {
if (response=="FunctionalTests") {
_connection.close();
onResult({}); // Test Terminated!
} else {
onResult({err:"onNameSuperParentApp : Expected 'subapp' and received '"+response+"'"});
_connection.close();
}
}

public function onStatus(event:NetStatusEvent):void {

switch(event.info.code) {
case "NetConnection.Connect.Success":
_connection.call("getRealNameApp", new Responder(onRealNameApp));
break;
case "NetConnection.Connect.Closed":
break;
default:
onResult({err:event.info.code});
}
}

}
}
Binary file modified FunctionalTests/www/FunctionalTests/FunctionalTests.swf
Binary file not shown.
7 changes: 7 additions & 0 deletions FunctionalTests/www/FunctionalTests/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ function serverPolicyFile:onConnection(client)
end
serverPolicyFile:start(843); -- start the server on the port 843


-- ******* For ParentFunctions Test *******
function getNameApp()
INFO("FunctionalTests::getNameApp called")
return "FunctionalTests"
end

-- ******* Main functions *******
function onConnection(client,...)

Expand Down
6 changes: 6 additions & 0 deletions FunctionalTests/www/FunctionalTests/subapp/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

-- For ParentFunctions test
function getNameApp()
INFO("subapp::getNameApp called")
return "subapp"
end

function onConnection(client,...)

INFO("New client on FunctionalTests/subapp (protocol : ", client.protocol, ")")
Expand Down
20 changes: 20 additions & 0 deletions FunctionalTests/www/FunctionalTests/subapp/subsubapp/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

function onConnection(client,...)

INFO("New client on FunctionalTests/subapp/subapp (protocol : ", client.protocol, ")")

function client:getRealNameApp()
INFO("getRealNameApp called")
return "subsubapp"
end

function client:getNameParentApp()
INFO("getNameParentApp called")
return super:getNameApp()
end

function client:getNameSuperParentApp()
INFO("getNameSuperParentApp called")
return super.super:getNameApp()
end
end
10 changes: 5 additions & 5 deletions MonaServer/sources/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ Service* Service::open(Exception& ex, const string& path) {
pSubService = it->second;
}

if (!nextPath.empty())
// if file or folder exists, return the service (or sub service)
if (pSubService->open(ex)) {
if (nextPath.empty())
return pSubService;
return pSubService->open(ex, nextPath);

// if file or folder exists, return the service
if (pSubService->open(ex))
return pSubService;
}

// service doesn't exist (and no children possible here!)
if (it != _services.end() && ex.code() == Exception::APPLICATION) {
Expand Down

0 comments on commit dce13da

Please sign in to comment.