Permalink
Browse files

updated tests for server resources

  • Loading branch information...
1 parent 37fc8d1 commit 3de5739a3c5aebbef41c1b1ac7d9b0a60e15e941 @templth templth committed Jan 15, 2013
Showing with 24 additions and 3 deletions.
  1. +24 −3 tests/org.restlet.js.tests/src/nodejs/server/server-http-resource-tests.js
@@ -9,10 +9,31 @@ var application = restlet.Application.create(function() {
//r1
var r1 = restlet.resource.ServerResource.createSubServerResource();
r1.addMethod("get", "json", function() {
- console.log("---> r1.handle");
- var repr = new restlet.representation.StringRepresentation("test");
- response.endWithRepresentation(repr);
+ console.log("---> r1.handle get (1)");
+ console.log("---> "+restlet.data.MediaType.TEXT_HTML);
+ var repr = new restlet.representation.StringRepresentation("{test:1}", restlet.data.MediaType.TEXT_HTML);
+ console.log("> commit");
+ this.commit(repr);
+ console.log("< commit");
}),
+ r1.addMethod("get", "html", function() {
+ console.log("---> r1.handle get (2)");
+ console.log("---> "+restlet.data.MediaType.TEXT_HTML);
+ var repr = new restlet.representation.StringRepresentation("<html><body>test</body></html>", restlet.data.MediaType.TEXT_HTML);
+ this.commit(repr);
+ }),
+ r1.addMethod("put", "json", function(representation) {
+ console.log("---> r1.handle put (1)");
+ console.log("---> "+restlet.data.MediaType.TEXT_HTML);
+ var repr = new restlet.representation.StringRepresentation("<html><body>ok put (1)</body></html>", restlet.data.MediaType.TEXT_HTML);
+ this.commit(repr);
+ });
+ r1.addMethod("put", "txt", function(representation) {
+ console.log("---> r1.handle put (2)");
+ console.log("---> "+restlet.data.MediaType.TEXT_HTML);
+ var repr = new restlet.representation.StringRepresentation("<html><body>ok put (2)</body></html>", restlet.data.MediaType.TEXT_HTML);
+ this.commit(repr);
+ });
router.attach("/test1/{id}", r1);
return router;
});

0 comments on commit 3de5739

Please sign in to comment.