Zápis vlastních testů: Ukázka 4
Následující zdrojový kód je příkladem diagnostického nástroje. Tento kód použijte místo skutečného testovacího kódu k zápisu takových objektů do konzoly, které budou použity skutečným testovacím kódem.
/*
* Licensed Materials - Property of IBM
*
* 63H9336
* (c) Copyright IBM Corp. 2005, 2020. Všechna práva vyhrazena.
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
*/
package com.ibm.mq.explorer.tests.sample;
/**
* List all the context objects provided to standard out
*/
public class WMQTestSimple extends WMQTest {
/*
* (non-Javadoc)
*
* @see com.ibm.mq.explorer.tests.WMQTest#runTest(com.ibm.mq.explorer.tests.internal.actions.WMQTestEngine,
* org.eclipse.core.runtime.IProgressMonitor, com.ibm.mq.explorer.ui.extensions.MQExtObject[],
* java.lang.String)
*/
public void runTest(WMQTestEngine callback, IProgressMonitor guimonitor,
MQExtObject[] contextObjects, TreeNode treenodeId) {
super.runTest(callback, guimonitor, contextObjects, treenodeId);
// prepare space to store test results
ArrayList testresults = new ArrayList();
// Loop through all supplied MQExtObjects and output them to the console
System.out.println("Objects supplied to this test:"); //$NON-NLS-1$
for (int k = 0; k < contextObjects.length; k++) {
if (contextObjects[k] != null) {
System.out.println(contextObjects[k].getName());
}
}
// Output the tree node ID to the console
System.out.println("tree node ID supplied to this test: " + treenodeId); //$NON-NLS-1$
// Add a test result
testresults.add(new WMQTestResult(IMarker.SEVERITY_WARNING,
"SAMPLE: Listing context completed", //$NON-NLS-1$
"Object name", getTestSubCategory())); //$NON-NLS-1$
// package up results and return - test complete.
testComplete((WMQTestResult[]) testresults.toArray(new WMQTestResult[testresults.size()]));
}
}