List of usage examples for javax.management InstanceNotFoundException InstanceNotFoundException
public InstanceNotFoundException()
From source file:org.jolokia.http.HttpRequestHandlerTest.java
@Test public void requestErrorHandling() throws MalformedObjectNameException, InstanceNotFoundException, IOException, ReflectionException, AttributeNotFoundException, MBeanException { Object[] exceptions = new Object[] { new ReflectionException(new NullPointerException()), 404, 500, new InstanceNotFoundException(), 404, 500, new MBeanException(new NullPointerException()), 500, 500, new AttributeNotFoundException(), 404, 500, new UnsupportedOperationException(), 500, 500, new IOException(), 500, 500, new IllegalArgumentException(), 400, 400, new SecurityException(), 403, 403, new RuntimeMBeanException(new NullPointerException()), 500, 500 }; for (int i = 0; i < exceptions.length; i += 3) { Exception e = (Exception) exceptions[i]; reset(backend);/*from w w w .j ava 2s . c om*/ expect(backend.isDebug()).andReturn(true).anyTimes(); backend.error(find("" + exceptions[i + 1]), EasyMock.<Throwable>anyObject()); backend.error(find("" + exceptions[i + 2]), EasyMock.<Throwable>anyObject()); expect(backend.handleRequest(EasyMock.<JmxRequest>anyObject())).andThrow(e); replay(backend); JSONObject resp = (JSONObject) handler.handleGetRequest("/jolokia", "/read/java.lang:type=Memory/HeapMemoryUsage", null); assertEquals(resp.get("status"), exceptions[i + 1]); resp = handler.handleThrowable(e); assertEquals(resp.get("status"), exceptions[i + 2], e.getClass().getName()); } }
From source file:be.fgov.kszbcss.rhq.websphere.mbean.MBeanClient.java
/** * Check whether an MBean matching this client's {@link MBeanLocator} is registered in the MBean * server.// w w w .j a va2 s . c o m * * @return <code>true</code> if the MBean is registered, <code>false</code> otherwise * @throws JMException * @throws ConnectorException * @throws InterruptedException */ public boolean isRegistered() throws JMException, ConnectorException, InterruptedException { try { execute(new Action<Void>() { public Void execute(AdminClient adminClient, ObjectName objectName) throws JMException, ConnectorException { // We need to take into account the case where the MBean has been re-registered // with an object name that is different than the last known object name, // but that still matches the MBeanLocator. To achieve this, we throw an // InstanceNotFoundException if the MBean is not registered. The execute method // will then attempt to re-resolve the object name. if (!adminClient.isRegistered(objectName)) { throw new InstanceNotFoundException(); } return null; } }); return true; } catch (InstanceNotFoundException ex) { return false; } }
From source file:org.codice.ddf.admin.application.service.impl.ApplicationServiceBeanTest.java
/** * Tests the {@link ApplicationServiceBean#destroy()} method * for the case where an InstanceNotFoundException is thrown by mBeanServer.unregisterMBean(...) * * @throws Exception/*from ww w . ja va 2s . c o m*/ */ @Test(expected = ApplicationServiceException.class) public void testDestroyWhenUnregisterMBeanThrowsInstanceNotFoundException() throws Exception { ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer); doThrow(new InstanceNotFoundException()).when(mBeanServer).unregisterMBean(objectName); serviceBean.destroy(); }