Skip to content

Commit

Permalink
Fix #getAttributes method
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Jul 15, 2015
1 parent de03e8f commit 4b89b12
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Returns an attribute from a MBean.

### Client.getAttributes(mbean, attributes, callback)

Returns an attribute from a MBean.
Returns an attribute list from a MBean.

* `mbean` - MBean query address as string. For example "java.lang:type=Memory".
* `attributes` - Attribute names as an array of strings.
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/mbeanServerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ MBeanServerConnection.prototype.getAttributes = function(name, attributes, callb
this.mbeanServerConnection,
'getAttributes',
[ "javax.management.ObjectName", "[Ljava.lang.String;" ], // methodParamsClass
[ name, attributes ], // methodParams
[ name, xattributes ], // methodParams
callback
);
};
Expand Down
6 changes: 5 additions & 1 deletion test/adapters/mbeanServerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ describe("MBeanServerConnection", function() {

it("#getAttributes", function(done) {
var method = "getAttributes";

var attributesArray = java.newArray("java.lang.String", [ "attribute", "attribute" ]);

var methodParamsClass = [ "javax.management.ObjectName", "[Ljava.lang.String;" ];
var methodParams = [ "name", [ "attribute", "attribute" ] ];
testReflectionCall(method, methodParamsClass, methodParams, function(obj, method2, methodParamsClass2, methodParams2, callback2) {
var newMethodParams = [ "name", attributesArray ];
assert.deepEqual(methodParamsClass, methodParamsClass2);
assert.deepEqual(methodParams, methodParams2);
assert.deepEqual(newMethodParams, methodParams2);
done();
});
});
Expand Down
8 changes: 6 additions & 2 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ describe("Integration tests", function() {
});

it("#getAttributes", function(done) {
client.getAttributes("com.onddo.test:type=JmxAppExample", [ "LongAttr", "LongAttr" ], function(value) {
assert.ok(typeof value === "object" && typeof value.longValue === "string");
client.getAttributes("com.onddo.test:type=JmxAppExample", [ "LongAttr", "LongAttr" ], function(values) {
valuesAr = values.toArraySync();
valuesAr.forEach(function(value) {
attributeValue = value.getValueSync();
assert.ok(typeof attributeValue === "object" && typeof attributeValue.longValue === "string");
});
done();
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/javaJmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ describe("JavaJmx", function() {
it("#getAttributes", function(done) {
javaJmx.mbeanServerConnection.getAttributes = function(objectName, attributes, callback, undef) {
assert.strictEqual(objectName.toString(), "MBean1:type=MBean1");
assert.strictEqual(attributes, [ "attribute", "attribute" ] );
assert.deepEqual(attributes, [ "attribute", "attribute" ] );
assert.strictEqual(typeof callback, "function");
assert.strictEqual(undef, undefined);
callback();
};
javaJmx.getAttributes("mbean", "attributes", function(attr) {
javaJmx.getAttributes("mbean", [ "attribute", "attribute" ], function(attr) {
done();
});
});
Expand Down

0 comments on commit 4b89b12

Please sign in to comment.