From d28757902d62d37b766f95d05a4a13c5933adf5b Mon Sep 17 00:00:00 2001 From: Xabier de Zuazo Date: Sat, 15 Nov 2014 17:28:20 +0100 Subject: [PATCH] Avoid using "should in test" --- test/adapters/helpers/conversions.js | 8 ++-- test/adapters/helpers/jmxServiceUrlBuilder.js | 12 +++--- test/adapters/javaReflection.js | 6 +-- test/adapters/mbeanServerConnection.js | 22 +++++------ test/client.js | 10 ++--- test/helpers/error.js | 20 +++++----- test/integration.js | 38 +++++++++---------- test/javaJmx.js | 28 +++++++------- 8 files changed, 72 insertions(+), 72 deletions(-) diff --git a/test/adapters/helpers/conversions.js b/test/adapters/helpers/conversions.js index b047a6e..0e3bd3e 100644 --- a/test/adapters/helpers/conversions.js +++ b/test/adapters/helpers/conversions.js @@ -36,13 +36,13 @@ describe("conversions", function() { var param = value[0]; var javaClass = value[1]; - it("should return \"" + javaClass + "\" for argument value \"" + param + "\" and typeof \"" + typeof param + "\"", function() { + it("returns \"" + javaClass + "\" for argument value \"" + param + "\" and typeof \"" + typeof param + "\"", function() { assert.strictEqual(conversions.v8ToJavaClass(param), javaClass); }); }); - it("should throw an exception when the object cannot be converted", function() { + it("throws an exception when the object cannot be converted", function() { assert.throws( function() { conversions.v8ToJavaClass(undefined); @@ -65,7 +65,7 @@ describe("conversions", function() { "boolean", "char" ].forEach(function(className) { - it("should return true for \"" + className + "\"", function() { + it("returns true for \"" + className + "\"", function() { assert.strictEqual(conversions.isJavaPrimitiveClass(className), true); }); }); @@ -82,7 +82,7 @@ describe("conversions", function() { "java.lang.Object", java.newInstanceSync("javax.management.Attribute", "name", "value").getClassSync().getNameSync() ].forEach(function(className) { - it("should return false for \"" + className + "\"", function() { + it("returns false for \"" + className + "\"", function() { assert.strictEqual(conversions.isJavaPrimitiveClass(className), false); }); }); diff --git a/test/adapters/helpers/jmxServiceUrlBuilder.js b/test/adapters/helpers/jmxServiceUrlBuilder.js index 55a916b..0bf6fb2 100644 --- a/test/adapters/helpers/jmxServiceUrlBuilder.js +++ b/test/adapters/helpers/jmxServiceUrlBuilder.js @@ -6,37 +6,37 @@ var assert = require("assert"), describe("JmxServiceUrlBuilder", function() { - it("should accept service name as first argument", function() { + it("accepts service name as first argument", function() { var service = JmxServiceUrlBuilder("service:jmx:rmi://jndi/rmi://localhost:3000/jmxrmi"); assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL"); assert.strictEqual(service.toStringSync(), "service:jmx:rmi://jndi/rmi://localhost:3000/jmxrmi"); }); - it("should accept host name and port as arguments", function() { + it("accepts host name and port as arguments", function() { var service = JmxServiceUrlBuilder("localhost", 3000); assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL"); assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/jndi/rmi://localhost:3000/jmxrmi"); }); - it("should accept host name and port in string form as arguments", function() { + it("accepts host name and port in string form as arguments", function() { var service = JmxServiceUrlBuilder("localhost", "3000"); assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL"); assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/jndi/rmi://localhost:3000/jmxrmi"); }); - it("should accept protocol as third argument", function() { + it("accepts protocol as third argument", function() { var service = JmxServiceUrlBuilder("localhost", 3000, "proto1"); assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL"); assert.strictEqual(service.toStringSync(), "service:jmx:proto1://localhost:3000/jndi/proto1://localhost:3000/jmxproto1"); }); - it("should accept urlPath as fourth argument", function() { + it("accepts urlPath as fourth argument", function() { var service = JmxServiceUrlBuilder("localhost", 3000, "rmi", "/myUrl"); assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL"); assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/myUrl"); }); - it("should throw an exception when the first argument is not a string", function() { + it("throws an exception when the first argument is not a string", function() { assert.throws( function() { JmxServiceUrlBuilder(null); diff --git a/test/adapters/javaReflection.js b/test/adapters/javaReflection.js index d262591..5b1f80b 100644 --- a/test/adapters/javaReflection.js +++ b/test/adapters/javaReflection.js @@ -20,7 +20,7 @@ describe("JavaReflection", function() { }); } - it("should be able to call java methods with no arguments", function(done) { + it("is able to call java methods with no arguments", function(done) { var obj = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1"); var paramsClass = []; var params = []; @@ -31,7 +31,7 @@ describe("JavaReflection", function() { }); }); - it("should be able to call java methods with arguments", function(done) { + it("is able to call java methods with arguments", function(done) { var obj1 = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1"); var obj2 = java.newInstanceSync("javax.management.Attribute", "attributeName2", "value2"); var paramsClass = [ "java.lang.Object" ]; @@ -43,7 +43,7 @@ describe("JavaReflection", function() { }); }); - it("should emit an error when the object method does not exist", function(done) { + it("emits an error when the object method does not exist", function(done) { var obj1 = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1"); var paramsClass = []; var params = []; diff --git a/test/adapters/mbeanServerConnection.js b/test/adapters/mbeanServerConnection.js index 8f030c5..5f18b77 100644 --- a/test/adapters/mbeanServerConnection.js +++ b/test/adapters/mbeanServerConnection.js @@ -28,12 +28,12 @@ describe("MBeanServerConnection", function() { }; }); - it("should receive URI as argument", function() { + it("receives URI as argument", function() { var mbeanServerConnection = new MBeanServerConnection("uri2"); assert.strictEqual(mbeanServerConnection.jmxServiceUrl, "uri2"); }); - it("should subscribe to javaReflector error events", function() { + it("subscribes to javaReflector error events", function() { mbeanServerConnection.javaReflection.emit("error"); assert.deepEqual(emitted, [ "error" ]); }); @@ -42,7 +42,7 @@ describe("MBeanServerConnection", function() { describe("#connect", function() { - it("should emit connect event when connected", function(done) { + it("emits connect event when connected", function(done) { mbeanServerConnection.emit = function(ev) { if (ev === "connect") { done(); @@ -51,12 +51,12 @@ describe("MBeanServerConnection", function() { mbeanServerConnection.connect(); }); - it("should receive URI as argument", function() { + it("receives URI as argument", function() { mbeanServerConnection.connect("uri2"); assert.strictEqual(mbeanServerConnection.jmxServiceUrl, "uri2"); }); - it("should generate authentication credentials when required", function(done) { + it("generates authentication credentials when required", function(done) { mbeanServerConnection.username = "username1"; mbeanServerConnection.password = "password2"; mbeanServerConnection.JMXConnectorFactory.connect = function(jmxServiceUrl, map, callback) { @@ -79,14 +79,14 @@ describe("MBeanServerConnection", function() { }; }); - it("should try to close de connection when called", function(done) { + it("tries to close de connection when called", function(done) { mbeanServerConnection.jmxConnector.close = function() { done(); }; mbeanServerConnection.close(); }); - it("should emit disconnect event when connected", function(done) { + it("emits disconnect event when connected", function(done) { mbeanServerConnection.emit = function(ev) { if (ev === "disconnect") { done(); @@ -119,7 +119,7 @@ describe("MBeanServerConnection", function() { }; } - it("should return the correct MBeans", function(done) { + it("returns the correct MBeans", function(done) { testOnConnected(function() { stubQueryMBeans(); mbeanServerConnection.queryMBeans(null, "MBean1:type=MBean1", function(instance, callback) { @@ -129,7 +129,7 @@ describe("MBeanServerConnection", function() { }); }); - it("should accept empty query", function(done) { + it("accepts empty query", function(done) { testOnConnected(function() { stubQueryMBeans(); mbeanServerConnection.queryMBeans(null, null, function(instance, callback) { @@ -139,7 +139,7 @@ describe("MBeanServerConnection", function() { }); }); - it("should call the final callback function when done", function(done) { + it("calls the final callback function when done", function(done) { testOnConnected(function() { stubQueryMBeans(); mbeanServerConnection.queryMBeans(null, "MBean1:type=MBean1", function(instance,callback) { @@ -151,7 +151,7 @@ describe("MBeanServerConnection", function() { }); }); - it("should emit error on premature disconnections", function(done) { + it("emits error on premature disconnections", function(done) { testOnConnected(function() { mbeanServerConnection.emit = function(ev, err) { if (ev === "error" && /Premature disconnect/.test(err)) { diff --git a/test/client.js b/test/client.js index 6d6e566..7d2dd01 100644 --- a/test/client.js +++ b/test/client.js @@ -7,12 +7,12 @@ describe("Client", function() { describe("#Client", function() { - it("should return a Client object passing the correct arguments", function() { + it("returns a Client object passing the correct arguments", function() { var client = new Client("localhost", 3000); assert.ok(client instanceof Client); }); - it("should throw the correct exception when no argument is passed", function() { + it("throws the correct exception when no argument is passed", function() { assert.throws( function() { new Client(); @@ -21,13 +21,13 @@ describe("Client", function() { ); }); - it("should accept username and password as arguments", function() { + it("accepts username and password as arguments", function() { var client = new Client("localhost", 3000, undefined, undefined, "username", "password"); assert.strictEqual(client.username, "username"); assert.strictEqual(client.password, "password"); }); - describe("should subscribe to JavaJmx events", function() { + describe("subscribes to JavaJmx events", function() { var client; var emitted; beforeEach(function() { @@ -53,7 +53,7 @@ describe("Client", function() { }); - describe("Methods that should call javaJmx directly and with the correct arguments", function() { + describe("Methods that calls javaJmx directly and with the correct arguments", function() { this.timeout(100); var client; var method; diff --git a/test/helpers/error.js b/test/helpers/error.js index df51eee..f98ea77 100644 --- a/test/helpers/error.js +++ b/test/helpers/error.js @@ -12,7 +12,7 @@ describe("error", function() { describe("#debug", function() { - it("should have an empty/nop debug function by default", function() { + it("has an empty/nop debug function by default", function() { var debug; var old_node_debug = process.env.NODE_DEBUG; @@ -27,7 +27,7 @@ describe("error", function() { assert.strictEqual(debug(), undefined); }); - it("should not print to console by default", function() { + it("does not print to console by default", function() { var old_node_debug = process.env.NODE_DEBUG; process.env.NODE_DEBUG = "other-node-module"; var debug = require_debug_reload(); @@ -53,7 +53,7 @@ describe("error", function() { assert.strictEqual(count, 0); }); - it("should print to console when debug is enabled", function() { + it("prints to console when debug is enabled", function() { var old_node_debug = process.env.NODE_DEBUG; process.env.NODE_DEBUG = "jmx"; var debug = require_debug_reload(); @@ -82,7 +82,7 @@ describe("error", function() { }); - it("should return without error when console.error does not exist", function() { + it("returns without error when console.error does not exist", function() { var old_node_debug = process.env.NODE_DEBUG; process.env.NODE_DEBUG = "jmx"; var debug = require_debug_reload(); @@ -100,11 +100,11 @@ describe("error", function() { describe("when no object is passed as argument", function() { - it("should return false when there is no error", function() { + it("returns false when there is no error", function() { assert.strictEqual(checkError(undefined, undefined), false); }); - it("should throw an exception when there is an error", function() { + it("throws an exception when there is an error", function() { assert.throws( function() { checkError("One important error", undefined); @@ -126,21 +126,21 @@ describe("error", function() { emitCount = 0; }); - it("should emit no error when there is no error", function() { + it("emits no error when there is no error", function() { checkError(undefined, obj); assert.strictEqual(emitCount, 0); }); - it("should emit an error when there is an error", function() { + it("emits an error when there is an error", function() { checkError("One important error", obj); assert.strictEqual(emitCount, 1); }); - it("should return false when there is no error", function() { + it("returns false when there is no error", function() { assert.strictEqual(checkError(undefined, obj), false); }); - it("should return true when there is an error", function() { + it("returns true when there is an error", function() { assert.strictEqual(checkError("One important error", obj), true); }); diff --git a/test/integration.js b/test/integration.js index 36f1e7a..671db47 100644 --- a/test/integration.js +++ b/test/integration.js @@ -27,7 +27,7 @@ describe("Integration tests", function() { }); }); - it("should run java JMX test app", function(done) { + it("runs java JMX test app", function(done) { var jmxApp = new StartJmxApp(jmxPort, null, function() { jmxApp.stop(done); }); @@ -42,7 +42,7 @@ describe("Integration tests", function() { jmxApp.stop(done); }); - it("should connect successfully", function(done) { + it("connects successfully", function(done) { var client = jmx.createClient({ host: "127.0.0.1", port: jmxPort @@ -51,7 +51,7 @@ describe("Integration tests", function() { client.on("connect", done); }); - it("should disconnect successfully", function(done) { + it("disconnects successfully", function(done) { var client = jmx.createClient({ host: "127.0.0.1", port: jmxPort @@ -61,7 +61,7 @@ describe("Integration tests", function() { client.on("disconnect", done); }); - it("should work with multiple clients", function(done) { + it("works with multiple clients", function(done) { var clients = [ jmx.createClient({ host: "127.0.0.1", port: jmxPort }), jmx.createClient({ host: "127.0.0.1", port: jmxPort }) @@ -77,7 +77,7 @@ describe("Integration tests", function() { }, done); }); - it("should work when disconnecting prematurely", function(done) { + it("works when disconnecting prematurely", function(done) { var client = jmx.createClient({ host: "127.0.0.1", port: jmxPort @@ -96,7 +96,7 @@ describe("Integration tests", function() { }); }); - it("should not connect when the port is wrong", function(done) { + it("does not connect when the port is wrong", function(done) { this.timeout(20000); var client = jmx.createClient({ host: "127.0.0.1", @@ -170,19 +170,19 @@ describe("Integration tests", function() { describe("#invoke", function() { - it("should invoke a method", function(done) { + it("invokes a method", function(done) { client.invoke("com.onddo.test:type=JmxAppExample", "callVoidMethod", [], function(data) { done(); }); }); - it("should invoke a method with simple args", function(done) { + it("invokes a method with simple args", function(done) { client.invoke("com.onddo.test:type=JmxAppExample", "callVoidWithSimpleArgs", [ "hello" ], function(data) { done(); }); }); - it("should invoke a method with complex args using className", function(done) { + it("invokes a method with complex args using className", function(done) { var values = [ 1, 5, 22]; var classNames = [ "long", "int", "java.lang.Long" ]; client.invoke("com.onddo.test:type=JmxAppExample", "callVoidWithMixedArguments", values, classNames, function(data) { @@ -190,14 +190,14 @@ describe("Integration tests", function() { }); }); - it("should return long values correctly", function(done) { + it("returns long values correctly", function(done) { client.invoke("com.onddo.test:type=JmxAppExample", "callLongWithSimpleArgs", [], function(data) { assert.ok(typeof data.longValue === "string"); done(); }); }); - it("should return java.lang.Long values correctly", function(done) { + it("returns java.lang.Long values correctly", function(done) { client.invoke("com.onddo.test:type=JmxAppExample", "callLongObjWithSimpleArgs", [], function(data) { assert.ok(typeof data.longValue === "string"); done(); @@ -208,7 +208,7 @@ describe("Integration tests", function() { describe("#setAttribute", function() { - it("should set a simple string value", function(done) { + it("sets a simple string value", function(done) { var domain = "com.onddo.test:type=JmxAppExample"; var attribute = "StringAttr"; var values = [ "begin", "end" ]; @@ -225,19 +225,19 @@ describe("Integration tests", function() { }); }); - it("should accept String object values", function(done) { + it("accepts String object values", function(done) { client.setAttribute("com.onddo.test:type=JmxAppExample", "StringAttr", "test", "java.lang.String", function() { done(); }); }); - it("should set long values", function(done) { + it("sets long values", function(done) { client.setAttribute("com.onddo.test:type=JmxAppExample", "LongAttr", 22, function() { done(); }); }); - it("should set java.lang.Long values using className", function(done) { + it("sets java.lang.Long values using className", function(done) { client.setAttribute("com.onddo.test:type=JmxAppExample", "LongObjAttr", 33, "java.lang.Long", function() { done(); }); @@ -249,7 +249,7 @@ describe("Integration tests", function() { }); - it("should run java JMX test app with authentication enabled", function(done) { + it("runs java JMX test app with authentication enabled", function(done) { var jmxApp = new StartJmxApp(jmxPort, "jmxremote.password", function() { jmxApp.stop(function() { done(); @@ -270,7 +270,7 @@ describe("Integration tests", function() { }); }); - it("should not connect successfully without credentials", function(done) { + it("does not connect successfully without credentials", function(done) { client = jmx.createClient({ host: "127.0.0.1", port: jmxPort @@ -290,7 +290,7 @@ describe("Integration tests", function() { }); }); - it("should connect successfully with the correct credentials", function(done) { + it("connects successfully with the correct credentials", function(done) { client = jmx.createClient({ host: "127.0.0.1", port: jmxPort, @@ -322,7 +322,7 @@ describe("Integration tests", function() { }); }); - it("should emit disconnect event", function(done) { + it("emits disconnect event", function(done) { client.on("connect", function() { client.getMBeanCount(function(count) { client.on("disconnect", done); diff --git a/test/javaJmx.js b/test/javaJmx.js index e3e81bf..1441f63 100644 --- a/test/javaJmx.js +++ b/test/javaJmx.js @@ -17,15 +17,15 @@ describe("JavaJmx", function() { describe("#JavaJmx", function() { - it("should return a JavaJmx object passing the correct arguments", function() { + it("returns a JavaJmx object passing the correct arguments", function() { assert.ok(javaJmx instanceof JavaJmx); }); - it("should create an internal MBeanServerConnection object", function() { + it("creates an internal MBeanServerConnection object", function() { assert.ok(javaJmx.mbeanServerConnection instanceof MBeanServerConnection); }); - describe("should subscribe to MBeanServerConnection events", function() { + describe("subscribes to MBeanServerConnection events", function() { var emitted; beforeEach(function() { emitted = []; @@ -51,7 +51,7 @@ describe("JavaJmx", function() { }); - it("should close the connection when a \"Connection Refused\" java error is returned", function(done) { + it("closes the connection when a \"Connection Refused\" java error is returned", function(done) { javaJmx.mbeanServerConnection.close = function() { done(); }; @@ -64,7 +64,7 @@ describe("JavaJmx", function() { }); describe("#JmxServiceUrl", function() { - it("should create a JMXServiceURL java object", function() { + it("creates a JMXServiceURL java object", function() { var jmxServiceUrl = javaJmx.JmxServiceUrl("localhost", 3000); assert.strictEqual( jmxServiceUrl.getClassSync().getNameSync(), @@ -129,7 +129,7 @@ describe("JavaJmx", function() { describe("#setAttribute", function() { - it("should accept three parameters", function(done) { + it("accepts three parameters", function(done) { javaJmx.mbeanServerConnection.setAttribute = function(objectName, attribute, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(attribute.getClassSync().getNameSync(), "javax.management.Attribute"); @@ -142,7 +142,7 @@ describe("JavaJmx", function() { javaJmx.setAttribute("mbean", "attributeName", "value"); }); - it("should accept a callback as the third parameter", function(done) { + it("accepts a callback as the third parameter", function(done) { javaJmx.mbeanServerConnection.setAttribute = function(objectName, attribute, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(attribute.getClassSync().getNameSync(), "javax.management.Attribute"); @@ -155,7 +155,7 @@ describe("JavaJmx", function() { javaJmx.setAttribute("mbean", "attributeName", "value", done); }); - it("should accept a className as third parameter with a callback", function(done) { + it("accepts a className as third parameter with a callback", function(done) { javaJmx.mbeanServerConnection.setAttribute = function(objectName, attribute, callback) { assert.strictEqual(attribute.getValueSync().getClassSync().getNameSync(), "javax.management.ObjectName"); assert.strictEqual(attribute.getValueSync().getDomainSync(), "domain"); @@ -164,7 +164,7 @@ describe("JavaJmx", function() { javaJmx.setAttribute("mbean", "attributeName", [ "domain", "name", "value" ], "javax.management.ObjectName", done); }); - it("should accept a className as third parameter without a callback", function(done) { + it("accepts a className as third parameter without a callback", function(done) { javaJmx.mbeanServerConnection.setAttribute = function(objectName, attribute, callback) { assert.strictEqual(attribute.getValueSync().getClassSync().getNameSync(), "javax.management.ObjectName"); assert.strictEqual(attribute.getValueSync().getDomainSync(), "domain"); @@ -187,7 +187,7 @@ describe("JavaJmx", function() { describe("#invoke", function() { - it("should accept three parameters", function(done) { + it("accepts three parameters", function(done) { javaJmx.mbeanServerConnection.invoke = function(objectName, methodName, params, signature, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(methodName, "methodName"); @@ -200,7 +200,7 @@ describe("JavaJmx", function() { javaJmx.invoke("mbean", "methodName", [ "param1" ]); }); - it("should accept a callback as the fourth parameter", function(done) { + it("accepts a callback as the fourth parameter", function(done) { javaJmx.mbeanServerConnection.invoke = function(objectName, methodName, params, signature, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(methodName, "methodName"); @@ -215,7 +215,7 @@ describe("JavaJmx", function() { }); }); - it("should accept a signature as the fourth parameter with a callback", function(done) { + it("accepts a signature as the fourth parameter with a callback", function(done) { javaJmx.mbeanServerConnection.invoke = function(objectName, methodName, params, signature, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(methodName, "methodName"); @@ -230,7 +230,7 @@ describe("JavaJmx", function() { }); }); - it("should accept a signature as the fourth parameter without a callback", function(done) { + it(" accepts a signature as the fourth parameter without a callback", function(done) { javaJmx.mbeanServerConnection.invoke = function(objectName, methodName, params, signature, callback, undef) { assert.strictEqual(objectName.toString(), "MBean1:type=MBean1"); assert.strictEqual(methodName, "methodName"); @@ -243,7 +243,7 @@ describe("JavaJmx", function() { javaJmx.invoke("mbean", "methodName", [ "param1" ], [ "int" ]); }); - it("should throw an exception when params has unknown types", function(done) { + it("throws an exception when params has unknown types", function(done) { javaJmx.mbeanServerConnection.invoke = function(objectName, methodName, params, signature, callback, undef) {}; javaJmx.on("error", function(err) { assert.ok(/v8ToJavaClass[(][)]: unknown object type/.test(err));