use of org.opennms.protocols.wmi.test.stubs.OnmsWbemObjectSetBiosStub in project opennms by OpenNMS.
the class WmiManagerTest method testPerformOpValidObject.
/**
* Test the performOp method with a valid WMI class and valid WMI object.
*
* Test method for
* {@link org.opennms.protocols.wmi.WmiManager#performOp(org.opennms.protocols.wmi.WmiParams)}.
*
* @throws WmiException if there is a problem with the mock object.
*/
public final void testPerformOpValidObject() throws WmiException {
//
// Create parameter holder.
WmiParams params = new WmiParams(WmiParams.WMI_OPERATION_INSTANCEOF, "2/12/2004 00:00:00", "EQ", "Win32_BIOS", "ReleaseDate");
// Set up WMI mock client.
// 1) Expect a call to connect() with a bad hostname.
// 2) Throw a new WmiException indictating a bad hostname.
OnmsWbemObjectSet wos = new OnmsWbemObjectSetBiosStub(new OnmsWbemObjectBiosStub(new OnmsWbemPropSetBiosStub(new OnmsWbemPropBiosStub())));
m_WmiMock.connect("127.0.0.1", "Administrator", "password", WmiParams.WMI_DEFAULT_NAMESPACE);
expect(m_WmiMock.performInstanceOf("Win32_BIOS")).andReturn(wos);
replay(m_WmiMock);
try {
// Create a manager.
WmiManager wmiManager = new WmiManager("127.0.0.1", "Administrator", "password");
// Initialize
wmiManager.init(m_WmiMock);
// Perform an operation.
// WmiResult res =
wmiManager.performOp(params);
// assertTrue(res)
} catch (WmiException e) {
// assertTrue("Exception missing message: Unknown name: " + e, e
// .getMessage().contains("Unknown name"));
}
verify(m_WmiMock);
reset(m_WmiMock);
}
use of org.opennms.protocols.wmi.test.stubs.OnmsWbemObjectSetBiosStub in project opennms by OpenNMS.
the class WmiManagerTest method testPerformOpInvalidObject.
/**
* Test the performOp method with an valid WMI class and invalid WMI object.
*
* Test method for
* {@link org.opennms.protocols.wmi.WmiManager#performOp(org.opennms.protocols.wmi.WmiParams)}.
*
* @throws WmiException if there is a problem with the mock object.
*/
public final void testPerformOpInvalidObject() throws WmiException {
//
// Create parameter holder.
WmiParams params = new WmiParams(WmiParams.WMI_OPERATION_INSTANCEOF, "2/12/2004 00:00:00", "EQ", "Win32_BIOS", "RelDate");
// Set up WMI mock client.
// 1) Expect a call to connect() with a bad hostname.
// 2) Throw a new WmiException indictating a bad hostname.
OnmsWbemObjectSet wos = new OnmsWbemObjectSetBiosStub(new OnmsWbemObjectBiosStub(new OnmsWbemPropSetBiosStub(new OnmsWbemPropBiosStub())));
m_WmiMock.connect("127.0.0.1", "Administrator", "password", WmiParams.WMI_DEFAULT_NAMESPACE);
expect(m_WmiMock.performInstanceOf("Win32_BIOS")).andReturn(wos);
replay(m_WmiMock);
try {
// Create a manager.
WmiManager wmiManager = new WmiManager("127.0.0.1", "Administrator", "password");
// Initialize
wmiManager.init(m_WmiMock);
// Perform an operation.
wmiManager.performOp(params);
} catch (WmiException e) {
assertTrue("Exception missing message: Unknown name: " + e, e.getMessage().contains("Unknown name"));
}
verify(m_WmiMock);
reset(m_WmiMock);
}
Aggregations