[Pkg-javascript-commits] [sockjs-client] 256/434: Test server was moved out to sockjs-node
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:17 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit bb17c8ba4deb242b7280f0e6eabfcd1256852690
Author: Marek Majkowski <majek04 at gmail.com>
Date: Tue Dec 13 14:20:11 2011 +0000
Test server was moved out to sockjs-node
---
README.md | 63 ++++++++++++++++++++++++++--------------
tests/config.js | 17 ++++-------
tests/server.js | 6 ----
tests/sockjs_app.js | 82 -----------------------------------------------------
4 files changed, 48 insertions(+), 120 deletions(-)
diff --git a/README.md b/README.md
index e5f0bd8..72f0889 100644
--- a/README.md
+++ b/README.md
@@ -200,26 +200,22 @@ session stickiness, take a look at the
[SockJS-node readme](https://github.com/sockjs/sockjs-node#readme).
-Development
------------
+Development and testing
+-----------------------
-SockJS-client uses [Node.js](http://nodejs.org/) for testing and
-Javascript minification. If you want to play with SockJS code, check
-out the git repo and follow this steps:
+SockJS-client needs [Node.js](http://nodejs.org/) for running a test
+server and JavaScript minification. If you want to work on
+SockJS-client source code, check out the git repo and follow this
+steps:
cd sockjs-client
npm install
-(SockJS-client uses
-[SockJS-node](https://github.com/sockjs/sockjs-node) for testing, you
-may want to link 'node_modules/sockjs' to directory with cloned
-SockJS-node.)
-
-To generate javascript run:
+To generate JavaScript run:
make sockjs.js
-To generate minified javascript run:
+To generate minified JavaScript run:
make sockjs.min.js
@@ -228,20 +224,45 @@ To generate minified javascript run:
### Testing
-To run qunit tests, type:
+Once you compiled SockJS-client you may want to check if your changes
+pass all the tests. To run the tests you need a server that can answer
+various SockJS requests. A common way is to use `SockJS-node` test
+server for that. To run it (by default it will be listening on port 8081):
+
+ cd sockjs-node
+ npm install --dev
+ make test_server
+
+At this point you're ready to run a SockJS-client server that will
+server your freshly compiled JavaScript and various static http and
+javscript files (by default it will run on port 8080).
+ cd sockjs-client
make test
-This command runs script 'tests/server.js' which starts a web server
-that listens on http://127.0.0.1:8080/ . It serves static QUnit files
-and serves a simple SockJS.
+At that point you should have two web servers running: sockjs-node on
+8081 and sockjs-client on 8080. When you open the browser on
+[http://localhost:8080/](http://localhost:8080/) you should be able
+run the QUnit tests against your sockjs-node server.
+
+If you want to test the sockjs completely you also must change the
+`sockjs_url` that is used by SockJS-node test server. To do that
+edit the `config.js` file:
+
+ vim sockjs-node/examples/test_server/config.js
+
+And replace `sockjs_url` setting which by default points to CDN:
+
+ sockjs_url: 'http://cdn.sockjs.org/sockjs-0.1.min.js',
+
+to a compiled sockjs javascript that you're serving. For example:
+
+ sockjs_url: 'http://localhost:8080/lib/sockjs.js',
-To run QUnit tests simply point your browser at
-http://127.0.0.1:8080/.
-If you want the javascript to be recompiled when the source files are
-modified and automatically restart the http server run `make serve`.
-You will need `inotifywait` command from package `inotify-tools`.
+Additionally, if you're doing more serious development consider using
+`make serve`, which will automatically reload the server when you
+modify the source code.
Browser Quirks
diff --git a/tests/config.js b/tests/config.js
index 94ada9f..94eab6d 100644
--- a/tests/config.js
+++ b/tests/config.js
@@ -1,16 +1,11 @@
exports.config = {
- opts: {
- sockjs_url: "/lib/sockjs.js"
- },
- port: process.env.PORT || 8080,
- host: '0.0.0.0',
-
client_opts: {
- // May be set to empty string if you don't need to test
- // cross-domain features. In other case set it to a full
- // url, like: "http://localhost:8080"
- url: '',
+ // Address of a sockjs test server.
+ url: 'http://localhost:8081',
disabled_transports: [],
sockjs_opts: {devel:true, debug:true}
- }
+ },
+
+ port: 8080,
+ host: '0.0.0.0'
};
diff --git a/tests/server.js b/tests/server.js
index b5110c5..f5f4a2f 100644
--- a/tests/server.js
+++ b/tests/server.js
@@ -1,7 +1,6 @@
var http = require('http');
var node_static = require('node-static');
-var sockjs_app = require('./sockjs_app');
var config = require('./config').config;
@@ -25,11 +24,6 @@ server.addListener('request', function(req, res) {
static_directory.serve(req, res);
}
});
-server.addListener('upgrade', function(req,res){
- res.end();
- });
-config.response_limit = 4*1024;
-sockjs_app.install(config, server);
console.log(" [*] Listening on", config.host + ':' + config.port);
server.listen(config.port, config.host);
diff --git a/tests/sockjs_app.js b/tests/sockjs_app.js
deleted file mode 100644
index 385590a..0000000
--- a/tests/sockjs_app.js
+++ /dev/null
@@ -1,82 +0,0 @@
-var sockjs = require('sockjs');
-
-exports.install = function(config, server) {
- var sjs_echo = sockjs.createServer(config.opts);
- sjs_echo.on('connection', function(conn) {
- console.log(' [+] echo open ' + conn);
- conn.on('close', function() {
- console.log(' [-] echo close ' + conn);
- });
- conn.on('data', function(m) {
- var d = JSON.stringify(m);
- console.log(' [ ] echo message ' + conn,
- d.slice(0,64)+
- ((d.length > 64) ? '...' : ''));
- conn.write(m);
- });
- });
-
- var sjs_close = sockjs.createServer(config.opts);
- sjs_close.on('connection', function(conn) {
- console.log(' [+] clos open ' + conn);
- conn.close(3000, "Go away!");
- conn.on('close', function() {
- console.log(' [-] clos close ' + conn);
- });
- });
-
- var sjs_ticker = sockjs.createServer(config.opts);
- sjs_ticker.on('connection', function(conn) {
- console.log(' [+] ticker open ' + conn);
- var tref;
- var schedule = function() {
- conn.write('tick!');
- tref = setTimeout(schedule, 1000);
- };
- tref = setTimeout(schedule, 1000);
- conn.on('close', function() {
- clearTimeout(tref);
- console.log(' [-] ticker close ' + conn);
- });
- });
-
- var broadcast = {};
- var sjs_broadcast = sockjs.createServer(config.opts);
- sjs_broadcast.on('connection', function(conn) {
- console.log(' [+] broadcast open ' + conn);
- broadcast[conn.id] = conn;
- conn.on('close', function() {
- delete broadcast[conn.id];
- console.log(' [-] broadcast close' + conn);
- });
- conn.on('data', function(m) {
- console.log(' [-] broadcast message', m);
- for(var id in broadcast) {
- broadcast[id].write(m);
- }
- });
- });
-
- var sjs_amplify = sockjs.createServer(config.opts);
- sjs_amplify.on('connection', function(conn) {
- console.log(' [+] amp open ' + conn);
- conn.on('close', function() {
- console.log(' [-] amp close ' + conn);
- });
- conn.on('data', function(m) {
- var n = Math.floor(Number(m));
- n = (n > 0 && n < 19) ? n : 1;
- console.log(' [ ] amp message: 2^' + n);
- conn.write(Array(Math.pow(2, n)+1).join('x'));
- });
- });
-
-
- sjs_echo.installHandlers(server, {prefix:'[/]echo'});
- sjs_echo.installHandlers(server, {prefix:'[/]disabled_websocket_echo',
- disabled_transports: ['websocket']});
- sjs_close.installHandlers(server, {prefix:'[/]close'});
- sjs_ticker.installHandlers(server, {prefix:'[/]ticker'});
- sjs_amplify.installHandlers(server, {prefix:'[/]amplify'});
- sjs_broadcast.installHandlers(server, {prefix:'[/]broadcast'});
-};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list