Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test scripts

  • Loading branch information...
commit 10f5ed471697e85af8d877237ee2d4830e31ea51 1 parent 9f1f6b3
@lcharette lcharette authored
View
5 scripts/main.ape.js
@@ -10,4 +10,9 @@ Ape.addEvent("init", function() {
include("utils/checkTool.js"); //Just needed for the APE JSF diagnostic tool, once APE is installed you can remove it
//include("examples/ircserver.js");
//include("framework/http_auth.js");
+
+ //Those file are used to test feature of APE.
+ //include("test/MySQL.js");
+ //include("test/Socket.js");
+ //include("test/Pipes.js");
});
View
25 scripts/test/MySQL.js
@@ -0,0 +1,25 @@
+Ape.log(' =====================================>>> \n Start up for test/MySQL.js\n' );
+var sql = new Ape.MySQL("1.1.1.1:3306", "ape", "ape", "ape_test");
+
+Ape.log(sql); //Spidermonkey 1.8.5 check
+
+sql.onConnect = function() {
+ Ape.log('[MySQL] Connected to mysql server. Trying Query');
+
+ sql.query("SELECT * FROM test_table", function(res, errorNo) {
+ if (errorNo) {
+ Ape.log('[MySQL] Request error : ' + errorNo + ' : '+ this.errorString());
+ } else {
+ Ape.log('[MySQL] Fetching ' + res.length);
+ for(var i = 0; i < res.length; i++) {
+ Ape.log(res[i].ID + " -> " + res[i].value); //res[i].<column name>
+ }
+ }
+ });
+}
+
+sql.onError = function(errorNo) {
+ Ape.log('[MySQL] Connection Error : ' + errorNo + ' : '+ this.errorString());
+}
+
+Ape.log("<<< =====================================\n");
View
15 scripts/test/Pipes.js
@@ -0,0 +1,15 @@
+//We create a new custom pipe
+var pipe = new Ape.pipe();
+
+Ape.log(pipe); //Spidermonkey 1.8.5 check
+
+//Custom pipe is created with an unique pubid
+Ape.log('Custom pipe pubid: '+pipe.getProperty('pubid'));
+
+//We listen "SEND" commands received on this pipe
+pipe.onSend = function(user, params) {
+ Ape.log('Received data from custom pipe: '+params.msg);
+ if(params.destroy) {
+ pipe.destroy();
+ }
+}
View
17 scripts/test/Socket.js
@@ -0,0 +1,17 @@
+//Create Socket
+var socket = new Ape.sockClient('21', 'example.com', {flushlf: true});
+
+Ape.log(socket); //Spidermonkey 1.8.5 check
+
+socket.onConnect = function() {
+ Ape.log("[Socket] Connected to example.com");
+ //this.write("Hello\n"); //Uncomment this if connexion is successfull. If the spidermonkey issue is still there, APE will crash when this file is loaded
+}
+
+socket.onRead = function(data) {
+ Ape.log("[Socket] Data : " + data);
+}
+
+socket.onDisconnect = function() {
+ Ape.log("[Socket] Gone !");
+}
Please sign in to comment.
Something went wrong with that request. Please try again.