System.out.println("Testing lookup of control objects by name");
List<QmfConsoleData> controls = _console.getObjects("com.profitron.gizmo", "control");
if (controls.size() > 0)
{
System.out.println("control object found");
QmfConsoleData control = controls.get(0);
//control.listValues();
ObjectId oid = control.getObjectId();
//System.out.println("Agent Name = " + oid.getAgentName());
//System.out.println("Agent Epoch = " + oid.getAgentEpoch());
//System.out.println("Object Name = " + oid.getObjectName());
System.out.println("Testing lookup of object by ObjectId");
controls = _console.getObjects(oid);
if (controls.size() == 0)
{
System.out.println("No objects returned from ObjectId lookup: AgentTestConsole failed");
System.exit(1);
}
System.out.println("MethodCount = " + control.getLongValue("methodCount"));
QmfData inArgs;
QmfData outArgs;
MethodResult results;
/*
System.out.println("Testing invokeMethod(toString, args) - method called directly on Agent");
results = _gizmo.invokeMethod("toString", null);
System.out.println("gizmo.toString() = " + results.getArguments().getStringValue("string"));
*/
// ********** Invoke create_child nethod **********
System.out.println("Testing invokeMethod(create_child, args)");
inArgs = new QmfData();
inArgs.setValue("name", "child 1");
results = control.invokeMethod("create_child", inArgs);
if (!results.succeeded())
{
System.out.println("create_child returned an exception object");
System.exit(1);
}
if (!results.hasValue("childAddr"))
{
System.out.println("create_child returned an unexpected value");
System.exit(1);
}
ObjectId childId = results.getRefValue("childAddr");
System.out.println("childId = " + childId);
System.out.println("childAddr subtype = " + results.getSubtype("childAddr"));
QmfConsoleData child1 = _console.getObjects(childId).get(0);
System.out.println("child1 name = " + child1.getStringValue("name"));
// Update and display state of control object
control.refresh();
System.out.println("MethodCount = " + control.getLongValue("methodCount"));