Here are the examples of the java api class javax.management.ObjectName taken from open source projects.
1. MultipleDependenciesModuleTest#testMultipleDependencies()
Project: controller
File: MultipleDependenciesModuleTest.java
File: MultipleDependenciesModuleTest.java
@Test public void testMultipleDependencies() throws Exception { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName d1 = transaction.createModule(factory.getImplementationName(), "d1"); ObjectName d2 = transaction.createModule(factory.getImplementationName(), "d2"); assertEquals(transaction.getTransactionName(), getTransactionName(d1)); ObjectName parent = transaction.createModule(factory.getImplementationName(), "parent"); MultipleDependenciesModuleMXBean multipleDependenciesModuleMXBean = transaction.newMXBeanProxy(parent, MultipleDependenciesModuleMXBean.class); multipleDependenciesModuleMXBean.setTestingDeps(asList(d1, d2)); List<ObjectName> found = multipleDependenciesModuleMXBean.getTestingDeps(); ObjectName d1WithoutTxName = found.get(0); assertEquals(getInstanceName(d1), getInstanceName(d1WithoutTxName)); // check that transaction name gets stripped automatically from attribute. // d1,2 contained tx name, found doesn't assertNull(getTransactionName(d1WithoutTxName)); transaction.commit(); }
2. ScanManagerTest#testPreRegister()
Project: openjdk
File: ScanManagerTest.java
File: ScanManagerTest.java
/** * Test of preRegister method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testPreRegister() throws Exception { System.out.println("preRegister"); MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName("DownUnder:type=Wombat"); ScanManager instance = new ScanManager(); ObjectName expResult = ScanManager.SCAN_MANAGER_NAME; ObjectName result; try { result = instance.preRegister(server, name); throw new RuntimeException("bad name accepted!"); } catch (IllegalArgumentException x) { result = instance.preRegister(server, null); } assertEquals(expResult, result); result = instance.preRegister(server, ScanManager.SCAN_MANAGER_NAME); assertEquals(expResult, result); }
3. ScanManagerTest#testPreRegister()
Project: jdk7u-jdk
File: ScanManagerTest.java
File: ScanManagerTest.java
/** * Test of preRegister method, of class com.sun.jmx.examples.scandir.ScanManager. */ public void testPreRegister() throws Exception { System.out.println("preRegister"); MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName("DownUnder:type=Wombat"); ScanManager instance = new ScanManager(); ObjectName expResult = ScanManager.SCAN_MANAGER_NAME; ObjectName result; try { result = instance.preRegister(server, name); throw new RuntimeException("bad name accepted!"); } catch (IllegalArgumentException x) { result = instance.preRegister(server, null); } assertEquals(expResult, result); result = instance.preRegister(server, ScanManager.SCAN_MANAGER_NAME); assertEquals(expResult, result); }
4. ConfigTest#setUp()
Project: geronimo
File: ConfigTest.java
File: ConfigTest.java
protected void setUp() throws Exception { kernel = KernelFactory.newInstance().createKernel("test"); kernel.boot(); ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic"); GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO); kernel.loadGBean(configurationManagerData, getClass().getClassLoader()); kernel.startGBean(configurationManagerName); gbeanName1 = new ObjectName("geronimo.test:name=MyMockGMBean1"); GBeanData mockBean1 = new GBeanData(gbeanName1, MockGBean.getGBeanInfo()); mockBean1.setAttribute("value", "1234"); mockBean1.setAttribute("name", "child"); mockBean1.setAttribute("finalInt", new Integer(1)); gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2"); GBeanData mockBean2 = new GBeanData(gbeanName2, MockGBean.getGBeanInfo()); mockBean2.setAttribute("value", "5678"); mockBean2.setAttribute("name", "Parent"); mockBean2.setAttribute("finalInt", new Integer(3)); mockBean2.setReferencePatterns("MockEndpoint", Collections.singleton(gbeanName1)); mockBean2.setReferencePatterns("EndpointCollection", Collections.singleton(gbeanName1)); state = Configuration.storeGBeans(new GBeanData[] { mockBean1, mockBean2 }); }
5. MQTTNetworkOfBrokersFailoverTest#assertOneDurableSubOn()
Project: activemq-artemis
File: MQTTNetworkOfBrokersFailoverTest.java
File: MQTTNetworkOfBrokersFailoverTest.java
@SuppressWarnings("unused") private void assertOneDurableSubOn(BrokerService broker, String subName) throws Exception { BrokerViewMBean brokerView = broker.getAdminView(); ObjectName[] activeDurableSubs = brokerView.getDurableTopicSubscribers(); ObjectName[] inactiveDurableSubs = brokerView.getInactiveDurableTopicSubscribers(); ObjectName[] allDurables = (ObjectName[]) ArrayUtils.addAll(activeDurableSubs, inactiveDurableSubs); assertEquals(1, allDurables.length); // at this point our assertions should prove that we have only on durable sub DurableSubscriptionViewMBean durableSubView = (DurableSubscriptionViewMBean) broker.getManagementContext().newProxyInstance(allDurables[0], DurableSubscriptionViewMBean.class, true); assertEquals(subName, durableSubView.getClientId()); }
6. RuntimeBeanTest#testRecreate()
Project: controller
File: RuntimeBeanTest.java
File: RuntimeBeanTest.java
@Test public void testRecreate() throws Exception { ObjectName createdConfigBean = createScheduled(); // empty transaction ConfigTransactionJMXClient configTransaction = configRegistryClient.createTransaction(); ObjectName scheduledWritableON = configTransaction.lookupConfigBean(TestingScheduledThreadPoolModuleFactory.NAME, scheduled1); TestingScheduledThreadPoolConfigBeanMXBean scheduledWritableProxy = configTransaction.newMXBeanProxy(scheduledWritableON, TestingScheduledThreadPoolConfigBeanMXBean.class); scheduledWritableProxy.setRecreate(true); CommitStatus commitInfo = configTransaction.commit(); // check that it was recreated ObjectName readableConfigBean = ObjectNameUtil.withoutTransactionName(createdConfigBean); List<ObjectName> newInstances = Collections.<ObjectName>emptyList(); List<ObjectName> reusedInstances = Collections.<ObjectName>emptyList(); List<ObjectName> recreatedInstaces = Lists.newArrayList(readableConfigBean); assertEquals(new CommitStatus(newInstances, reusedInstances, recreatedInstaces), commitInfo); checkRuntimeBeans(); }
7. TomcatPoller#fetchRequestProcessorMetrics()
Project: servo
File: TomcatPoller.java
File: TomcatPoller.java
private static void fetchRequestProcessorMetrics(long now, MBeanServer mbs, List<Metric> metrics) throws JMException { final ObjectName globalName = new ObjectName("Catalina:type=GlobalRequestProcessor,*"); final Set<ObjectName> names = mbs.queryNames(globalName, null); if (names == null) { return; } for (ObjectName name : names) { AttributeList list = mbs.getAttributes(name, GLOBAL_REQ_ATTRS); for (Attribute a : list.asList()) { // the only gauge here is maxTime addMetric(metrics, a.getName().equals("maxTime") ? toGauge(now, name, a) : toCounter(now, name, a)); } } }
8. JMXMBeanTest#testMultipleBeanHandling()
Project: owner
File: JMXMBeanTest.java
File: JMXMBeanTest.java
/* * Test case for registering multiple mbeans with same configuration object. */ @Test public void testMultipleBeanHandling() throws Throwable { Properties props = new Properties(); JMXConfigMutableReloadable config = ConfigFactory.create(JMXConfigMutableReloadable.class, props); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mbeanName1 = new ObjectName("org.aeonbits.owner.jmx:type=testMultipleBeanHandling,id=JMXConfigMutableReloadable"); ObjectName mbeanName2 = new ObjectName("org.aeonbits.owner.jmx:type=testMultipleBeanHandling2,id=JMXConfigMutableReloadable"); mbs.registerMBean(config, mbeanName1); mbs.registerMBean(config, mbeanName2); mbs.setAttribute(mbeanName1, new Attribute("port", "7878")); assertEquals("7878", mbs.getAttribute(mbeanName1, "port")); assertEquals(mbs.getAttribute(mbeanName2, "port"), mbs.getAttribute(mbeanName1, "port")); }
9. MBeanServerRunner#main()
Project: twitter4j
File: MBeanServerRunner.java
File: MBeanServerRunner.java
public static void main(String[] args) throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName("twitter4j.mbean:type=APIStatistics"); ObjectName name2 = new ObjectName("twitter4j.mbean:type=APIStatisticsOpenMBean"); APIStatistics statsMBean = new APIStatistics(100); mbs.registerMBean(statsMBean, name); APIStatisticsOpenMBean openMBean = new APIStatisticsOpenMBean(statsMBean); mbs.registerMBean(openMBean, name2); for (int i = 0; i < 10; i++) { statsMBean.methodCalled("foo", 5, true); statsMBean.methodCalled("bar", 2, true); statsMBean.methodCalled("baz", 10, true); statsMBean.methodCalled("foo", 2, false); } Thread.sleep(1000 * 60 * 60); }
10. MBeanSupportImpl#registryDidShutdown()
Project: tapestry-5
File: MBeanSupportImpl.java
File: MBeanSupportImpl.java
private void registryDidShutdown() { lock.lock(); // store into new data structure so we can remove them from registered beans ObjectName[] objects = registeredBeans.toArray(new ObjectName[registeredBeans.size()]); for (final ObjectName name : objects) { doUnregister(name); } this.registeredBeans.clear(); }
11. NodeProbe#getCFSMBeans()
Project: stratio-cassandra
File: NodeProbe.java
File: NodeProbe.java
private List<Entry<String, ColumnFamilyStoreMBean>> getCFSMBeans(MBeanServerConnection mbeanServerConn, String type) throws MalformedObjectNameException, IOException { ObjectName query = new ObjectName("org.apache.cassandra.db:type=" + type + ",*"); Set<ObjectName> cfObjects = mbeanServerConn.queryNames(query, null); List<Entry<String, ColumnFamilyStoreMBean>> mbeans = new ArrayList<Entry<String, ColumnFamilyStoreMBean>>(cfObjects.size()); for (ObjectName n : cfObjects) { String keyspaceName = n.getKeyProperty("keyspace"); ColumnFamilyStoreMBean cfsProxy = JMX.newMBeanProxy(mbeanServerConn, n, ColumnFamilyStoreMBean.class); mbeans.add(new AbstractMap.SimpleImmutableEntry<String, ColumnFamilyStoreMBean>(keyspaceName, cfsProxy)); } return mbeans; }
12. TomcatPoller#fetchExecutorMetrics()
Project: servo
File: TomcatPoller.java
File: TomcatPoller.java
private static void fetchExecutorMetrics(long now, MBeanServer mbs, List<Metric> metrics) throws JMException { final ObjectName executorName = new ObjectName("Catalina:type=Executor,*"); final Set<ObjectName> names = mbs.queryNames(executorName, null); if (names == null) { return; } for (ObjectName name : names) { AttributeList list = mbs.getAttributes(name, EXECUTOR_ATTRS); for (Attribute a : list.asList()) { addMetric(metrics, a.getName().equals("completedTaskCount") ? toCounter(now, name, a) : toGauge(now, name, a)); } } }
13. JmxService#getMBeanAttributesByRegex()
Project: karyon
File: JmxService.java
File: JmxService.java
/** * Return a map of all attributes for objects matching the regex. * @param regex * @return * @throws Exception */ public Map<String, Map<String, String>> getMBeanAttributesByRegex(String regex) throws Exception { Map<String, Map<String, String>> result = Maps.newLinkedHashMap(); ObjectName name = new ObjectName(regex); Set<ObjectName> objs = mBeanServer.queryNames(name, null); // Convert object naems to a tree for (ObjectName objName : objs) { result.put(objName.getCanonicalName(), getMBeanAttributes(objName)); } return result; }
14. J4pReadResponse#getValue()
Project: jolokia
File: J4pReadResponse.java
File: J4pReadResponse.java
/** * Get the value for a certain MBean and a given attribute. This method is especially * useful if the request leading to this response was done for multiple MBeans (i.e. * a read for an MBean pattern) and multiple attributes. However, this method can be * used for a request for single MBeans and single attributes as well, but then the given * parameters must match the parameters given in the request. * * @param pObjectName name of the Mbean or <code>null</code> if the request was only for a single * Mbeans in which case this single MBean is taken from the request * @param pAttribute the attribute or <code>null</code> if the request was for a single * attribute in which case the attribute name is taken from the request * @param <V> the object type of the return value ({@link String},{@link Map} or {@link List}) * @return the value * @throws IllegalArgumentException if there was no value for the given parameters or if <code>null</code> * was given for given for one or both arguments and the request was for multiple MBeans * or attributes. */ public <V> V getValue(ObjectName pObjectName, String pAttribute) { ObjectName requestMBean = getRequest().getObjectName(); if (requestMBean.isPattern()) { JSONObject mAttributes = getAttributesForObjectNameWithPatternRequest(pObjectName); if (!mAttributes.containsKey(pAttribute)) { throw new IllegalArgumentException("No attribute " + pAttribute + " for ObjectName " + pObjectName + " returned for" + " the given request"); } return (V) mAttributes.get(pAttribute); } else { return (V) getValue(pAttribute); } }
15. J4pReadResponse#getAttributes()
Project: jolokia
File: J4pReadResponse.java
File: J4pReadResponse.java
/** * Get all attributes obtained. This method can be only used, if the requested MBean * was not a pattern (i.e. the request was for a single MBean). * * @return a list of attributes for this request. If the request was performed for * only a single attribute, the attribute name of the request is returend as * a single valued list. For more than one attribute, the attribute names * a returned from the returned list. */ public Collection<String> getAttributes() { J4pReadRequest request = getRequest(); ObjectName requestBean = request.getObjectName(); if (requestBean.isPattern()) { throw new IllegalArgumentException("Attributes can be fetched only for non-pattern request (current: " + requestBean.getCanonicalName() + ")"); } // The attribute names are the same as from the request if (request.hasSingleAttribute()) { // Contains only a single attribute: return request.getAttributes(); } else { JSONObject attributes = getValue(); return attributes.keySet(); } }
16. J4pReadResponse#getAttributes()
Project: jolokia
File: J4pReadResponse.java
File: J4pReadResponse.java
/** * Get the name of all attributes fetched for a certain MBean name. If the request was * performed for a single MBean, then the given name must match that of the MBean name * provided in the request. If <code>null</code> is given as argument, then this method * will return all attributes for the single MBean given in the request * * @param pObjectName MBean for which to get the attribute names, * @return a collection of attribute names */ public Collection<String> getAttributes(ObjectName pObjectName) { ObjectName requestMBean = getRequest().getObjectName(); if (requestMBean.isPattern()) { // We need to got down one level in the returned values JSONObject attributes = getAttributesForObjectNameWithPatternRequest(pObjectName); return attributes.keySet(); } else { if (pObjectName != null && !pObjectName.equals(requestMBean)) { throw new IllegalArgumentException("Given ObjectName " + pObjectName + " doesn't match with" + " the single ObjectName " + requestMBean + " given in the request"); } return getAttributes(); } }
17. J4pReadResponse#getObjectNames()
Project: jolokia
File: J4pReadResponse.java
File: J4pReadResponse.java
/** * Get all MBean names for which the request fetched values. If the request * contained an MBean pattern then all MBean names matching this pattern and which contained * attributes of the given name are returned. If the MBean wasnt a pattern a single * value collection with the single MBean name of the request is returned. * * @return list of MBean names * @throws MalformedObjectNameException if the returned MBean names could not be converted to * {@link ObjectName}s. Shouldnt occur, though. */ public Collection<ObjectName> getObjectNames() throws MalformedObjectNameException { ObjectName mBean = getRequest().getObjectName(); if (mBean.isPattern()) { // The result value contains the list of fetched object names JSONObject values = getValue(); Set<ObjectName> ret = new HashSet<ObjectName>(); for (Object name : values.keySet()) { ret.add(new ObjectName((String) name)); } return ret; } else { return Arrays.asList(mBean); } }
18. NetconfTestImplModuleTest#createInstance()
Project: controller
File: NetconfTestImplModuleTest.java
File: NetconfTestImplModuleTest.java
private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName, int depsCount) throws InstanceAlreadyExistsException { ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NetconfTestImplModuleMXBean.class); ObjectName dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX); mxBean.setTestingDep(dep); ArrayList<ObjectName> testingDeps = Lists.newArrayList(); for (int i = 0; i < depsCount; i++) { dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX + Integer.toString(i + 1)); testingDeps.add(dep); } mxBean.setTestingDeps(testingDeps); return nameCreated; }
19. MultipleDependenciesModuleTest#testDestroyModuleDependency()
Project: controller
File: MultipleDependenciesModuleTest.java
File: MultipleDependenciesModuleTest.java
@Test public void testDestroyModuleDependency() throws Exception { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1"); ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1"); MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class); r1Proxy.setSingle(m1); transaction.commit(); transaction = configRegistryClient.createTransaction(); transaction.destroyModule(factory.getImplementationName(), "middle1"); try { transaction.commit(); fail("Validation exception expected"); } catch (ValidationException e) { assertThat(e.getFailedValidations().keySet(), CoreMatchers.hasItem("multiple-dependencies")); } }
20. ScheduledThreadPoolConfigBeanTest#createScheduled()
Project: controller
File: ScheduledThreadPoolConfigBeanTest.java
File: ScheduledThreadPoolConfigBeanTest.java
private ObjectName createScheduled(ConfigTransactionJMXClient transaction, String instanceName, int maxThreadCount) throws InstanceAlreadyExistsException { ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName); ScheduledThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(nameCreated, ScheduledThreadPoolModuleMXBean.class); mxBean.setMaxThreadCount(maxThreadCount); ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, "naming"); NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, NamingThreadFactoryModuleMXBean.class); namingThreadFactoryModuleMXBean.setNamePrefix("prefix"); mxBean.setThreadFactory(threadFactoryON); return nameCreated; }
21. FlexibleThreadPoolConfigBeanTest#createFlexible()
Project: controller
File: FlexibleThreadPoolConfigBeanTest.java
File: FlexibleThreadPoolConfigBeanTest.java
private ObjectName createFlexible(ConfigTransactionJMXClient transaction, String instanceName, String threadFactoryName, int minThreadCount, long keepAliveMillis, int maxThreadCount) throws InstanceAlreadyExistsException { ObjectName threadFactoryON = transaction.createModule(NamingThreadFactoryModuleFactory.NAME, threadFactoryName); NamingThreadFactoryModuleMXBean namingThreadFactoryModuleMXBean = transaction.newMXBeanProxy(threadFactoryON, NamingThreadFactoryModuleMXBean.class); namingThreadFactoryModuleMXBean.setNamePrefix("prefix"); ObjectName flexibleON = transaction.createModule(flexibleFactory.getImplementationName(), instanceName); FlexibleThreadPoolModuleMXBean mxBean = transaction.newMBeanProxy(flexibleON, FlexibleThreadPoolModuleMXBean.class); mxBean.setKeepAliveMillis(keepAliveMillis); mxBean.setMaxThreadCount(maxThreadCount); mxBean.setMinThreadCount(minThreadCount); mxBean.setThreadFactory(threadFactoryON); return flexibleON; }
22. SimpleConfigurationTest#createFixedThreadPool()
Project: controller
File: SimpleConfigurationTest.java
File: SimpleConfigurationTest.java
static ObjectName createFixedThreadPool(ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException, InstanceNotFoundException { transaction.assertVersion(0, 1); ObjectName fixed1names = transaction.createModule(TestingFixedThreadPoolModuleFactory.NAME, fixed1); TestingFixedThreadPoolConfigMXBean fixedConfigProxy = transaction.newMXBeanProxy(fixed1names, TestingFixedThreadPoolConfigMXBean.class); fixedConfigProxy.setThreadCount(numberOfThreads); ObjectName retrievedNames = transaction.lookupConfigBean(TestingFixedThreadPoolModuleFactory.NAME, fixed1); assertEquals(fixed1names, retrievedNames); return fixed1names; }
23. TwoInterfacesExportTest#testWithAPSP_useScheduledNames()
Project: controller
File: TwoInterfacesExportTest.java
File: TwoInterfacesExportTest.java
@Test public void testWithAPSP_useScheduledNames() throws InstanceAlreadyExistsException, ValidationException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName scheduledName = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, scheduled1); ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1"); TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class); apspProxy.setThreadPool(scheduledName); apspProxy.setSomeParam("someParam"); transaction.validateConfig(); }
24. RuntimeBeanTest#testReuse()
Project: controller
File: RuntimeBeanTest.java
File: RuntimeBeanTest.java
@Test public void testReuse() throws Exception { ObjectName createdConfigBean = createScheduled(); // empty transaction CommitStatus commitInfo = configRegistryClient.createTransaction().commit(); // check that it was reused ObjectName readableConfigBean = ObjectNameUtil.withoutTransactionName(createdConfigBean); List<ObjectName> newInstances = Collections.<ObjectName>emptyList(); List<ObjectName> reusedInstances = Lists.newArrayList(readableConfigBean); List<ObjectName> recreatedInstaces = Collections.<ObjectName>emptyList(); assertEquals(new CommitStatus(newInstances, reusedInstances, recreatedInstaces), commitInfo); checkRuntimeBeans(); }
25. DependentWiringTest#testUsingServiceReferences()
Project: controller
File: DependentWiringTest.java
File: DependentWiringTest.java
@Test public void testUsingServiceReferences() throws Exception { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName threadPoolON = createFixed1(transaction, 10); transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1); String refName = "ref"; ObjectName serviceReferenceON = transaction.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName, threadPoolON); createParallelAPSP(transaction, serviceReferenceON); transaction.commit(); }
26. ObjectNameUtilTest#testRuntimeBeanName()
Project: controller
File: ObjectNameUtilTest.java
File: ObjectNameUtilTest.java
@Test public void testRuntimeBeanName() throws Exception { Map<String, String> properties = Maps.newHashMap(); properties.put("p1", "value"); properties.put("p2", "value2"); ObjectName on = ObjectNameUtil.createRuntimeBeanName(moduleName, instanceName, properties); ObjectNameUtil.checkDomain(on); ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_RUNTIME_BEAN); assertFalse(on.isPattern()); assertEquals(moduleName, ObjectNameUtil.getFactoryName(on)); assertEquals(instanceName, ObjectNameUtil.getInstanceName(on)); assertEquals(2, ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(on).size()); assertTrue(ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(on).containsKey("p1")); assertEquals("value", ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(on).get("p1")); assertTrue(ObjectNameUtil.getAdditionalProperties(on).containsKey("p2")); assertEquals("value2", ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(on).get("p2")); ObjectName pattern = ObjectNameUtil.createRuntimeBeanPattern(null, instanceName); assertPattern(on, pattern); }
27. ActiveMQBroker#getMessageHandlerConsumers()
Project: communote-server
File: ActiveMQBroker.java
File: ActiveMQBroker.java
@Override public MessageHandlerMQConsumer[] getMessageHandlerConsumers() throws MessageQueueJmxException { Set<MessageHandlerMQConsumer> res = new HashSet<MessageHandlerMQConsumer>(); ObjectName[] subscriberObjects = new ObjectName[0]; BrokerViewMBean viewMBean = getMBean(brokerViewBeanObjectName, BrokerViewMBean.class); if (viewMBean != null) { subscriberObjects = viewMBean.getQueueSubscribers(); } for (ObjectName objectName : subscriberObjects) { SubscriptionViewMBean subscriber = getMBean(objectName, SubscriptionViewMBean.class); MessageHandlerMQConsumer consumer = new MessageHandlerMQConsumer(); consumer.setSelector(subscriber.getSelector()); consumer.setDispatchedMessagesCount(subscriber.getDequeueCounter()); consumer.setPendingMessagesCount(subscriber.getMessageCountAwaitingAcknowledge()); res.add(consumer); } MessageHandlerMQConsumer[] sortedRes = new MessageHandlerMQConsumer[res.size()]; res.toArray(sortedRes); Arrays.sort(sortedRes); return sortedRes; }
28. ActiveMQBroker#getBrokerQueues()
Project: communote-server
File: ActiveMQBroker.java
File: ActiveMQBroker.java
@Override public Set<BrokerQueue> getBrokerQueues() throws MessageQueueJmxException { Set<BrokerQueue> res = new HashSet<BrokerQueue>(); ObjectName[] queueObjects = new ObjectName[0]; BrokerViewMBean viewMBean = getMBean(brokerViewBeanObjectName, BrokerViewMBean.class); if (viewMBean != null) { queueObjects = viewMBean.getQueues(); } for (ObjectName objectName : queueObjects) { QueueViewMBean queue = getMBean(objectName, QueueViewMBean.class); BrokerQueue brokerQueue = new BrokerQueue(); brokerQueue.setName(queue.getName()); brokerQueue.setDispatchedMessagesCount(queue.getDequeueCount()); brokerQueue.setPendingMessagesCount(queue.getQueueSize()); res.add(brokerQueue); } return res; }
29. TestBasicDataSource#testJmxDisabled()
Project: commons-dbcp
File: TestBasicDataSource.java
File: TestBasicDataSource.java
/** * Make sure setting jmxName to null suppresses JMX registration of connection and statement pools. * JIRA: DBCP-434 */ @Test public void testJmxDisabled() throws Exception { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); // Unregister leftovers from other tests (TODO: worry about concurrent test execution) final ObjectName commons = new ObjectName("org.apache.commons.*:*"); final Set<ObjectName> results = mbs.queryNames(commons, null); for (final ObjectName result : results) { mbs.unregisterMBean(result); } // Should disable JMX for both connection and statement pools ds.setJmxName(null); ds.setPoolPreparedStatements(true); // Trigger initialization ds.getConnection(); // Nothing should be registered assertEquals(0, mbs.queryNames(commons, null).size()); }
30. ManagedErrorHandlerTest#testManagedErrorHandler()
Project: camel
File: ManagedErrorHandlerTest.java
File: ManagedErrorHandlerTest.java
public void testManagedErrorHandler() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=errorhandlers,*"), null); // there should only be 2 error handler types as route 1 and route 3 uses the same default error handler assertEquals(2, set.size()); Iterator<ObjectName> it = set.iterator(); ObjectName on1 = it.next(); ObjectName on2 = it.next(); String name1 = on1.getCanonicalName(); String name2 = on2.getCanonicalName(); assertTrue("Should be a default error handler", name1.contains("CamelDefaultErrorHandlerBuilder") || name2.contains("CamelDefaultErrorHandlerBuilder")); assertTrue("Should be a dead letter error handler", name1.contains("DeadLetterChannelBuilder") || name2.contains("DeadLetterChannelBuilder")); }
31. JmxInstrumentationCustomMBeanTest#testCustomEndpoint()
Project: camel
File: JmxInstrumentationCustomMBeanTest.java
File: JmxInstrumentationCustomMBeanTest.java
public void testCustomEndpoint() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } assertDefaultDomain(); resolveMandatoryEndpoint("custom://end", CustomEndpoint.class); Set<ObjectName> s = mbsc.queryNames(new ObjectName(domainName + ":type=endpoints,*"), null); assertEquals("Could not find 2 endpoints: " + s, 2, s.size()); // get custom Iterator<ObjectName> it = s.iterator(); ObjectName on1 = it.next(); ObjectName on2 = it.next(); if (on1.getCanonicalName().contains("custom")) { assertEquals("bar", mbsc.getAttribute(on1, "Foo")); } else { assertEquals("bar", mbsc.getAttribute(on2, "Foo")); } }
32. NodeProbe#getCFSMBeans()
Project: cassandra
File: NodeProbe.java
File: NodeProbe.java
private List<Entry<String, ColumnFamilyStoreMBean>> getCFSMBeans(MBeanServerConnection mbeanServerConn, String type) throws MalformedObjectNameException, IOException { ObjectName query = new ObjectName("org.apache.cassandra.db:type=" + type + ",*"); Set<ObjectName> cfObjects = mbeanServerConn.queryNames(query, null); List<Entry<String, ColumnFamilyStoreMBean>> mbeans = new ArrayList<Entry<String, ColumnFamilyStoreMBean>>(cfObjects.size()); for (ObjectName n : cfObjects) { String keyspaceName = n.getKeyProperty("keyspace"); ColumnFamilyStoreMBean cfsProxy = JMX.newMBeanProxy(mbeanServerConn, n, ColumnFamilyStoreMBean.class); mbeans.add(new AbstractMap.SimpleImmutableEntry<String, ColumnFamilyStoreMBean>(keyspaceName, cfsProxy)); } return mbeans; }
33. TwoManagedCamelContextClashTest#testTwoManagedCamelContextNoClashCustomPattern()
Project: camel
File: TwoManagedCamelContextClashTest.java
File: TwoManagedCamelContextClashTest.java
public void testTwoManagedCamelContextNoClashCustomPattern() throws Exception { camel1 = createCamelContext("foo", "killer-#counter#"); camel2 = createCamelContext("foo", "killer-#counter#"); camel1.start(); assertTrue("Should be started", camel1.getStatus().isStarted()); MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"foo\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); // the pattern has a counter so no clash camel2.start(); ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"foo\""); assertTrue("Should be registered", mbeanServer.isRegistered(on2)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2)); }
34. TwoManagedCamelContextClashTest#testTwoManagedCamelContextNoClashDefault()
Project: camel
File: TwoManagedCamelContextClashTest.java
File: TwoManagedCamelContextClashTest.java
public void testTwoManagedCamelContextNoClashDefault() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } camel1 = createCamelContext("foo", null); camel2 = createCamelContext("foo", null); camel1.start(); assertTrue("Should be started", camel1.getStatus().isStarted()); MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"foo\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); // the default name pattern will ensure the JMX names is unique camel2.start(); ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"foo\""); assertTrue("Should be registered", mbeanServer.isRegistered(on2)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2)); }
35. TwoManagedCamelContextAutoAssignedNameClashTest#testTwoManagedCamelContextClash()
Project: camel
File: TwoManagedCamelContextAutoAssignedNameClashTest.java
File: TwoManagedCamelContextAutoAssignedNameClashTest.java
public void testTwoManagedCamelContextClash() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } camel1 = createCamelContext(); camel1.start(); assertTrue("Should be started", camel1.getStatus().isStarted()); MBeanServer mbeanServer = camel1.getManagementStrategy().getManagementAgent().getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camel1.getManagementName() + ",type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); // now cheat and reset the counter so we can test for a clash DefaultCamelContextNameStrategy.setCounter(0); camel2 = createCamelContext(); camel2.start(); ObjectName on2 = ObjectName.getInstance("org.apache.camel:context=" + camel2.getManagementName() + ",type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on2)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on)); assertTrue("Should still be registered after name clash", mbeanServer.isRegistered(on2)); }
36. JmxRegistrationCallbackTest#destroySimonTest()
Project: javasimon
File: JmxRegistrationCallbackTest.java
File: JmxRegistrationCallbackTest.java
@Test public void destroySimonTest() throws MalformedObjectNameException { String counterName = "test.1"; ObjectName counterObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.COUNTER + ",name=" + counterName); String stopwatchName = "test.2"; ObjectName stopwatchObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.STOPWATCH + ",name=" + stopwatchName); Assert.assertFalse(mbs.isRegistered(counterObjectName)); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); SimonManager.getCounter(counterName); Assert.assertTrue(mbs.isRegistered(counterObjectName)); SimonManager.destroySimon(counterName); Assert.assertFalse(mbs.isRegistered(counterObjectName)); SimonManager.getStopwatch(stopwatchName); Assert.assertTrue(mbs.isRegistered(stopwatchObjectName)); SimonManager.destroySimon(stopwatchName); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); }
37. JmxRegistrationCallbackTest#managerClearTest()
Project: javasimon
File: JmxRegistrationCallbackTest.java
File: JmxRegistrationCallbackTest.java
@Test public void managerClearTest() throws MalformedObjectNameException { String counterName = "test.1"; ObjectName counterObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.COUNTER + ",name=" + counterName); String stopwatchName = "test.2"; ObjectName stopwatchObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.STOPWATCH + ",name=" + stopwatchName); Assert.assertFalse(mbs.isRegistered(counterObjectName)); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); SimonManager.getCounter(counterName); Assert.assertTrue(mbs.isRegistered(counterObjectName)); SimonManager.getStopwatch(stopwatchName); Assert.assertTrue(mbs.isRegistered(stopwatchObjectName)); SimonManager.clear(); Assert.assertFalse(mbs.isRegistered(counterObjectName)); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); }
38. JMXControlService#getObjectNamesForInterface()
Project: incubator-quarks
File: JMXControlService.java
File: JMXControlService.java
private Set<ObjectName> getObjectNamesForInterface(String type, String alias, String interfaceName) throws MalformedObjectNameException { Hashtable<String, String> table = new Hashtable<>(); table.put("interface", ObjectName.quote(interfaceName)); table.put("type", ObjectName.quote(type)); if (alias != null) table.put("alias", ObjectName.quote(alias)); ObjectName objName = new ObjectName(getDomain(), table); // Add the wildcard for any other properties. objName = new ObjectName(objName.getCanonicalName() + ",*"); MBeanServer mBeanServer = getMbs(); return mBeanServer.queryNames(objName, null); }
39. IndexerModelImplTest#terminateZooKeeperConnections()
Project: hbase-indexer
File: IndexerModelImplTest.java
File: IndexerModelImplTest.java
public int terminateZooKeeperConnections() throws Exception { MBeanServerConnection connection = java.lang.management.ManagementFactory.getPlatformMBeanServer(); ObjectName replicationSources = new ObjectName("org.apache.ZooKeeperService:name0=*,name1=Connections,name2=*,name3=*"); Set<ObjectName> mbeans = connection.queryNames(replicationSources, null); int connectionCount = mbeans.size(); for (ObjectName name : mbeans) { connection.invoke(name, "terminateConnection", new Object[] {}, new String[] {}); } return connectionCount; }
40. ServerOverrideTest#testConfigurationXml()
Project: geronimo
File: ServerOverrideTest.java
File: ServerOverrideTest.java
public void testConfigurationXml() throws Exception { ConfigurationOverride dinnerMenu = new ConfigurationOverride("Dinner Menu", true); assertCopyIdentical(dinnerMenu); dinnerMenu.setLoad(false); assertCopyIdentical(dinnerMenu); GBeanOverride pizza = new GBeanOverride("Pizza", false); pizza.setAttribute("cheese", "mozzarella"); pizza.setAttribute("size", "x-large"); ObjectName pizzaOvenPattern = new ObjectName(":name=PizzaOven,j2eeType=oven,*"); ObjectName toasterOvenPattern = new ObjectName(":name=ToasterOven,j2eeType=oven,*"); pizza.setReferencePatterns("oven", new LinkedHashSet(Arrays.asList(new ObjectName[] { pizzaOvenPattern, toasterOvenPattern }))); assertCopyIdentical(dinnerMenu); dinnerMenu.addGBean(pizza); assertCopyIdentical(dinnerMenu); GBeanOverride garlicCheeseBread = new GBeanOverride("Garlic Cheese Bread", true); garlicCheeseBread.setReferencePattern("oven", toasterOvenPattern); dinnerMenu.addGBean(garlicCheeseBread); assertCopyIdentical(dinnerMenu); }
41. ServerOverrideTest#testGBeanXml()
Project: geronimo
File: ServerOverrideTest.java
File: ServerOverrideTest.java
public void testGBeanXml() throws Exception { GBeanOverride pizza = new GBeanOverride("Pizza", true); assertCopyIdentical(pizza); pizza.setLoad(false); assertCopyIdentical(pizza); pizza.setAttribute("cheese", "mozzarella"); assertCopyIdentical(pizza); pizza.setAttribute("size", "x-large"); assertCopyIdentical(pizza); ObjectName pizzaOvenPattern = new ObjectName(":name=PizzaOven,j2eeType=oven,*"); pizza.setReferencePattern("oven", pizzaOvenPattern); assertCopyIdentical(pizza); ObjectName toasterOvenPattern = new ObjectName(":name=ToasterOven,j2eeType=oven,*"); Set ovenPatterns = new LinkedHashSet(Arrays.asList(new ObjectName[] { pizzaOvenPattern, toasterOvenPattern })); pizza.setReferencePatterns("oven", ovenPatterns); assertCopyIdentical(pizza); }
42. MessageDestinationTest#testMessageDestinationsWithModule()
Project: geronimo
File: MessageDestinationTest.java
File: MessageDestinationTest.java
public void testMessageDestinationsWithModule() throws Exception { MessageDestinationType[] specdests = new MessageDestinationType[] { makeMD("d1"), makeMD("d2") }; GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] { makeGerMD("d1", "module1", "l1"), makeGerMD("d2", "module1", "l2") }; MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] { makeMDR("n1", "d1"), makeMDR("n2", "d2") }; ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests); ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext); ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext); namingContext.addGBean(new GBeanData(n1, null)); namingContext.addGBean(new GBeanData(n2, null)); ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder); Map context = builder.getContext(); assertEquals(2, context.size()); }
43. MessageDestinationTest#testMessageDestinations()
Project: geronimo
File: MessageDestinationTest.java
File: MessageDestinationTest.java
public void testMessageDestinations() throws Exception { MessageDestinationType[] specdests = new MessageDestinationType[] { makeMD("d1"), makeMD("d2") }; GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] { makeGerMD("d1", "l1"), makeGerMD("d2", "l2") }; MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] { makeMDR("n1", "d1"), makeMDR("n2", "d2") }; ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests); ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext); ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext); namingContext.addGBean(new GBeanData(n1, null)); namingContext.addGBean(new GBeanData(n2, null)); ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder); Map context = builder.getContext(); assertEquals(2, context.size()); }
44. ManagedRouteDumpRouteAsXmlTest#testCreateRouteStaticEndpointJson()
Project: camel
File: ManagedRouteDumpRouteAsXmlTest.java
File: ManagedRouteDumpRouteAsXmlTest.java
public void testCreateRouteStaticEndpointJson() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = getRouteObjectName(mbeanServer); // get the json String json = (String) mbeanServer.invoke(on, "createRouteStaticEndpointJson", null, null); assertNotNull(json); assertTrue(json.contains("\"myRoute\"")); assertTrue(json.contains("{ \"uri\": \"direct://start\" }")); assertTrue(json.contains("{ \"uri\": \"mock://result\" }")); }
45. ManagedRegisterTwoRoutesTest#testRoutes()
Project: camel
File: ManagedRegisterTwoRoutesTest.java
File: ManagedRegisterTwoRoutesTest.java
public void testRoutes() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null); assertEquals(2, set.size()); Set<String> uris = new HashSet<String>(); for (ObjectName on : set) { String uri = (String) mbeanServer.getAttribute(on, "EndpointUri"); uris.add(uri); } // the route has this starting endpoint uri assertTrue(uris.contains("direct://start")); assertTrue(uris.contains("direct://foo")); }
46. ManagedRegisterExchangeStatisticsTest#testExchangesCompletedStatistics()
Project: camel
File: ManagedRegisterExchangeStatisticsTest.java
File: ManagedRegisterExchangeStatisticsTest.java
public void testExchangesCompletedStatistics() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route1\""); Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted"); assertEquals(0, completed.longValue()); getMockEndpoint("mock:result").expectedMessageCount(1); template.sendBody("direct:start", "Hello World"); assertMockEndpointsSatisfied(); completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted"); assertEquals(1, completed.longValue()); }
47. ManagedRegisterCamelContextTest#testRegisterCamelContext()
Project: camel
File: ManagedRegisterCamelContextTest.java
File: ManagedRegisterCamelContextTest.java
public void testRegisterCamelContext() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\""); String name = (String) mbeanServer.getAttribute(on, "CamelId"); assertEquals("camel-1", name); String state = (String) mbeanServer.getAttribute(on, "State"); assertEquals(ServiceStatus.Started.name(), state); }
48. ManagedNamePatternTest#testManagedNamePattern()
Project: camel
File: ManagedNamePatternTest.java
File: ManagedNamePatternTest.java
public void testManagedNamePattern() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); assertTrue(context.getManagementName().startsWith("cool")); ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + context.getManagementName() + ",type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); }
49. ManagedNamePatternJvmSystemPropertyTest#testManagedNamePattern()
Project: camel
File: ManagedNamePatternJvmSystemPropertyTest.java
File: ManagedNamePatternJvmSystemPropertyTest.java
public void testManagedNamePattern() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); assertEquals("cool-camel-1", context.getManagementName()); ObjectName on = ObjectName.getInstance("org.apache.camel:context=cool-camel-1,type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); }
50. ManagedNamePatternIncludeHostNameTest#testManagedNamePattern()
Project: camel
File: ManagedNamePatternIncludeHostNameTest.java
File: ManagedNamePatternIncludeHostNameTest.java
public void testManagedNamePattern() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); assertTrue(context.getManagementName().startsWith("cool")); ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + context.getManagementName() + ",type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); }
51. ManagedNamePatternFixedTest#testManagedNamePattern()
Project: camel
File: ManagedNamePatternFixedTest.java
File: ManagedNamePatternFixedTest.java
public void testManagedNamePattern() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); assertEquals("cool", context.getManagementName()); ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + context.getManagementName() + ",type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); }
52. ManagedListComponentsTest#testListComponents()
Project: camel
File: ManagedListComponentsTest.java
File: ManagedListComponentsTest.java
public void testListComponents() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=20-camel-1,type=context,name=\"camel-1\""); // list all components found in classpath TabularData data = (TabularData) mbeanServer.invoke(on, "listComponents", null, null); assertTrue("There should be more than 20 components", data.size() > 20); }
53. ManagedEndpointTest#testManageEndpoint()
Project: camel
File: ManagedEndpointTest.java
File: ManagedEndpointTest.java
public void testManageEndpoint() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"seda://test\""); assertTrue(mbeanServer.isRegistered(on)); on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://result\""); assertTrue(mbeanServer.isRegistered(on)); }
54. ManagedEndpointExplainTest#testManageEndpointExplain()
Project: camel
File: ManagedEndpointExplainTest.java
File: ManagedEndpointExplainTest.java
public void testManageEndpointExplain() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"seda://test\""); assertTrue(mbeanServer.isRegistered(on)); on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://result\""); assertTrue(mbeanServer.isRegistered(on)); on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"log://foo\\?groupDelay=2000&groupSize=5&level=WARN\""); assertTrue(mbeanServer.isRegistered(on)); // there should be 3 parameters + 1 path = 4 TabularData data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" }); assertEquals(4, data.size()); // there should be 9 in total data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" }); assertEquals(27, data.size()); }
55. ManagedCamelContextTest#testManagedCamelContextExplainComponentModel()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testManagedCamelContextExplainComponentModel() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "explainComponentJson", new Object[] { "seda", false }, new String[] { "java.lang.String", "boolean" }); assertNotNull(json); assertTrue(json.contains("\"label\": \"core,endpoint\"")); assertTrue(json.contains("\"defaultQueueFactory\": { \"kind\": \"property\", \"type\": \"object\", \"javaType\":" + " \"org.apache.camel.component.seda.BlockingQueueFactory<org.apache.camel.Exchange>\",")); assertTrue(json.contains("\"queueSize\": { \"kind\": \"property\", \"type\": \"integer\", \"javaType\": \"int\", \"deprecated\": \"false\", \"secret\": \"false\", \"value\": \"0\"")); }
56. ManagedCamelContextTest#testManagedCamelContextExplainEipModel()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testManagedCamelContextExplainEipModel() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "explainEipJson", new Object[] { "aggregate", false }, new String[] { "java.lang.String", "boolean" }); assertNotNull(json); assertTrue(json.contains("\"description\": \"Aggregates many messages into a single message\"")); assertTrue(json.contains("\"label\": \"eip,routing\"")); assertTrue(json.contains("\"correlationExpression\": { \"kind\": \"expression\", \"required\": \"true\", \"type\": \"object\"")); assertTrue(json.contains("\"discardOnCompletionTimeout\": { \"kind\": \"attribute\", \"required\": \"false\", \"type\": \"boolean\"")); }
57. ManagedCamelContextTest#testManagedCamelContextExplainEipTrue()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testManagedCamelContextExplainEipTrue() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "explainEipJson", new Object[] { "myTransform", true }, new String[] { "java.lang.String", "boolean" }); assertNotNull(json); assertTrue(json.contains("\"label\": \"eip,transformation\"")); assertTrue(json.contains("\"expression\": { \"kind\": \"expression\", \"required\": \"true\", \"type\": \"object\"")); // and now we have the description option also assertTrue(json.contains("\"description\": { \"kind\": \"element\", \"required\": \"false\", \"type\": \"object\", \"javaType\"")); // we should see the constant value assertTrue(json.contains("Bye World")); }
58. ManagedCamelContextTest#testManagedCamelContextExplainEipFalse()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testManagedCamelContextExplainEipFalse() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "explainEipJson", new Object[] { "myTransform", false }, new String[] { "java.lang.String", "boolean" }); assertNotNull(json); assertTrue(json.contains("\"label\": \"eip,transformation\"")); assertTrue(json.contains("\"expression\": { \"kind\": \"expression\", \"required\": \"true\", \"type\": \"object\"")); // we should see the constant value assertTrue(json.contains("Bye World")); }
59. ManagedCamelContextTest#testManagedCamelContextCreateRouteStaticEndpointJson()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testManagedCamelContextCreateRouteStaticEndpointJson() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "createRouteStaticEndpointJson", null, null); assertNotNull(json); assertEquals(7, StringHelper.countChar(json, '{')); assertEquals(7, StringHelper.countChar(json, '}')); assertTrue(json.contains("{ \"uri\": \"direct://start\" }")); assertTrue(json.contains("{ \"uri\": \"direct://foo\" }")); }
60. ManagedCamelContextTest#testFindComponentsInClasspath()
Project: camel
File: ManagedCamelContextTest.java
File: ManagedCamelContextTest.java
public void testFindComponentsInClasspath() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=19-camel-1,type=context,name=\"camel-1\""); assertTrue("Should be registered", mbeanServer.isRegistered(on)); @SuppressWarnings("unchecked") Map<String, Properties> info = (Map<String, Properties>) mbeanServer.invoke(on, "findComponents", null, null); assertNotNull(info); assertTrue(info.size() > 20); Properties prop = info.get("seda"); assertNotNull(prop); assertEquals("seda", prop.get("name")); assertEquals("org.apache.camel", prop.get("groupId")); assertEquals("camel-core", prop.get("artifactId")); }
61. ManagedCamelContextNewProxyTest#testNewProxy()
Project: camel
File: ManagedCamelContextNewProxyTest.java
File: ManagedCamelContextNewProxyTest.java
public void testNewProxy() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\""); ManagedCamelContextMBean proxy = JMX.newMBeanProxy(mbeanServer, on, ManagedCamelContextMBean.class); assertNotNull(proxy); }
62. ManagedCamelContextEmptyRouteTest#testManagedCamelContextCreateRouteStaticEndpointJson()
Project: camel
File: ManagedCamelContextEmptyRouteTest.java
File: ManagedCamelContextEmptyRouteTest.java
public void testManagedCamelContextCreateRouteStaticEndpointJson() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=20-camel-1,type=context,name=\"camel-1\""); // get the json String json = (String) mbeanServer.invoke(on, "createRouteStaticEndpointJson", null, null); assertNotNull(json); assertEquals(2, StringHelper.countChar(json, '{')); assertEquals(2, StringHelper.countChar(json, '}')); }
63. ManagedCamelContextDumpRoutesAsXmlTest#testDumpAsXml()
Project: camel
File: ManagedCamelContextDumpRoutesAsXmlTest.java
File: ManagedCamelContextDumpRoutesAsXmlTest.java
public void testDumpAsXml() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\""); String xml = (String) mbeanServer.invoke(on, "dumpRoutesAsXml", null, null); assertNotNull(xml); log.info(xml); assertTrue(xml.contains("route")); assertTrue(xml.contains("myRoute")); assertTrue(xml.contains("myOtherRoute")); assertTrue(xml.contains("direct:start")); assertTrue(xml.contains("mock:result")); assertTrue(xml.contains("seda:bar")); assertTrue(xml.contains("mock:bar")); assertTrue(xml.contains("<header>bar</header>")); }
64. ManagedBrowsableEndpointEmptyTest#testBrowseableEndpointEmpty()
Project: camel
File: ManagedBrowsableEndpointEmptyTest.java
File: ManagedBrowsableEndpointEmptyTest.java
public void testBrowseableEndpointEmpty() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://result\""); String out = (String) mbeanServer.invoke(name, "browseExchange", new Object[] { 0 }, new String[] { "java.lang.Integer" }); assertNull(out); }
65. ManagedBrowsableEndpointAsXmlTest#testBrowseableEndpointAsXmlRangeInvalidIndex()
Project: camel
File: ManagedBrowsableEndpointAsXmlTest.java
File: ManagedBrowsableEndpointAsXmlTest.java
public void testBrowseableEndpointAsXmlRangeInvalidIndex() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://result\""); try { mbeanServer.invoke(name, "browseRangeMessagesAsXml", new Object[] { 3, 1, false }, new String[] { "java.lang.Integer", "java.lang.Integer", "java.lang.Boolean" }); fail("Should have thrown exception"); } catch (Exception e) { assertIsInstanceOf(IllegalArgumentException.class, e.getCause()); assertEquals("From index cannot be larger than to index, was: 3 > 1", e.getCause().getMessage()); } }
66. ManagedBrowsableEndpointAsXmlFileTest#testBrowseableEndpointAsXmlAllIncludeBody()
Project: camel
File: ManagedBrowsableEndpointAsXmlFileTest.java
File: ManagedBrowsableEndpointAsXmlFileTest.java
public void testBrowseableEndpointAsXmlAllIncludeBody() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } template.sendBodyAndHeader("direct:start", "Hello World", Exchange.FILE_NAME, "hello.txt"); MBeanServer mbeanServer = getMBeanServer(); ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"file://target/files\""); String out = (String) mbeanServer.invoke(name, "browseAllMessagesAsXml", new Object[] { true }, new String[] { "java.lang.Boolean" }); assertNotNull(out); log.info(out); assertTrue("Should contain the body", out.contains("Hello World</body>")); }
67. JmxNotificationEventNotifierTest#testExchangeFailed()
Project: camel
File: JmxNotificationEventNotifierTest.java
File: JmxNotificationEventNotifierTest.java
public void testExchangeFailed() throws Exception { ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=eventnotifiers,name=JmxEventNotifier"); MyNotificationListener listener = new MyNotificationListener(); context.getManagementStrategy().getManagementAgent().getMBeanServer().addNotificationListener(on, listener, new NotificationFilter() { private static final long serialVersionUID = 1L; public boolean isNotificationEnabled(Notification notification) { return true; } }, null); try { template.sendBody("direct:fail", "Hello World"); fail("Should have thrown an exception"); } catch (Exception e) { assertIsInstanceOf(IllegalArgumentException.class, e.getCause()); } assertEquals("Get a wrong number of events", 4, listener.getEventCounter()); context.stop(); }
68. JmxInstrumentationCustomMBeanTest#testManagedEndpoint()
Project: camel
File: JmxInstrumentationCustomMBeanTest.java
File: JmxInstrumentationCustomMBeanTest.java
public void testManagedEndpoint() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } assertDefaultDomain(); resolveMandatoryEndpoint("direct:start", DirectEndpoint.class); ObjectName objName = new ObjectName(domainName + ":type=endpoints,*"); Set<ObjectName> s = mbsc.queryNames(objName, null); assertEquals(2, s.size()); }
69. EndpointCompletionTest#testEndpointConfigurationJson()
Project: camel
File: EndpointCompletionTest.java
File: EndpointCompletionTest.java
public void testEndpointConfigurationJson() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\""); assertNotNull(on); mbeanServer.isRegistered(on); assertParameterJsonSchema(mbeanServer, on, "bean"); assertParameterJsonSchema(mbeanServer, on, "timer"); }
70. EndpointCompletionTest#testEndpointCompletion()
Project: camel
File: EndpointCompletionTest.java
File: EndpointCompletionTest.java
public void testEndpointCompletion() throws Exception { // JMX tests dont work well on AIX CI servers (hangs them) if (isPlatform("aix")) { return; } MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\""); assertNotNull(on); mbeanServer.isRegistered(on); String componentName = "file"; Map<String, Object> properties = new HashMap<String, Object>(); assertCompletion(mbeanServer, on, componentName, properties, ""); assertCompletion(mbeanServer, on, componentName, properties, "po"); assertCompletion(mbeanServer, on, componentName, properties, "/"); assertCompletion(mbeanServer, on, componentName, properties, "/usr/local"); assertCompletion(mbeanServer, on, componentName, properties, "/usr/local/"); assertCompletion(mbeanServer, on, componentName, properties, "/usr/local/b"); }
71. ManagedXsltOutputBytesTest#testXsltOutput()
Project: camel
File: ManagedXsltOutputBytesTest.java
File: ManagedXsltOutputBytesTest.java
public void testXsltOutput() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>"); mock.message(0).body().isInstanceOf(byte[].class); template.sendBody("direct:start", "<hello>world!</hello>"); assertMockEndpointsSatisfied(); MBeanServer mbeanServer = getMBeanServer(); ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"xslt://org/apache/camel/component/xslt/example.xsl\\?output=bytes\""); String uri = (String) mbeanServer.getAttribute(on, "EndpointUri"); assertEquals("xslt://org/apache/camel/component/xslt/example.xsl?output=bytes", uri); Boolean saxon = (Boolean) mbeanServer.getAttribute(on, "Saxon"); assertEquals(false, saxon.booleanValue()); XsltOutput output = (XsltOutput) mbeanServer.getAttribute(on, "Output"); assertEquals(XsltOutput.bytes, output); String state = (String) mbeanServer.getAttribute(on, "State"); assertEquals("Started", state); }
72. LanguageLoadScriptFromFileCachedTest#testClearCachedScriptViaJmx()
Project: camel
File: LanguageLoadScriptFromFileCachedTest.java
File: LanguageLoadScriptFromFileCachedTest.java
public void testClearCachedScriptViaJmx() throws Exception { getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello World", "Bye World"); template.sendBody("direct:start", "World"); // even if we update the file the content is cached template.sendBodyAndHeader("file:target/script", "Bye ${body}", Exchange.FILE_NAME, "myscript.txt"); template.sendBody("direct:start", "World"); // now clear the cache via the mbean server MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer(); Set<ObjectName> objNameSet = mbeanServer.queryNames(new ObjectName("org.apache.camel:type=endpoints,name=\"language://simple:*contentCache=true*\",*"), null); ObjectName managedObjName = new ArrayList<ObjectName>(objNameSet).get(0); mbeanServer.invoke(managedObjName, "clearContentCache", null, null); template.sendBody("direct:start", "World"); assertMockEndpointsSatisfied(); }
73. ManagedManagementStrategy#getObjectName()
Project: camel
File: ManagedManagementStrategy.java
File: ManagedManagementStrategy.java
private ObjectName getObjectName(Object managedObject, Object preferedName) throws Exception { ObjectName objectName; if (preferedName != null && preferedName instanceof String) { String customName = (String) preferedName; objectName = getManagedObjectName(managedObject, customName, ObjectName.class); } else if (preferedName != null && preferedName instanceof ObjectName) { objectName = (ObjectName) preferedName; } else { objectName = getManagedObjectName(managedObject, null, ObjectName.class); } return objectName; }
74. MBeansTest#test()
Project: boon
File: MBeansTest.java
File: MBeansTest.java
@Test public void test() throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); Set<ObjectName> objectNames = server.queryNames(null, null); for (ObjectName name : objectNames) { System.out.println(name.toString()); System.out.println(MBeans.map(server, name)); } //Set<ObjectInstance> instances = server.queryMBeans(null, null); }
75. JMXBundleDeployer#uninstall()
Project: bnd
File: JMXBundleDeployer.java
File: JMXBundleDeployer.java
/** * Calls through directly to the OSGi frameworks MBean uninstallBundle * operation * * @param id id of bundle to uninstall * @throws Exception */ public void uninstall(long id) throws Exception { final ObjectName framework = getFramework(mBeanServerConnection); Object[] objects = new Object[] { id }; String[] params = new String[] { "long" }; mBeanServerConnection.invoke(framework, "uninstallBundle", objects, params); }
76. JMXBundleDeployer#getFramework()
Project: bnd
File: JMXBundleDeployer.java
File: JMXBundleDeployer.java
private static ObjectName getFramework(MBeanServerConnection mBeanServerConnection) throws MalformedObjectNameException, IOException { final ObjectName objectName = new ObjectName(OBJECTNAME + ":type=framework,*"); final Set<ObjectName> objectNames = mBeanServerConnection.queryNames(objectName, null); if (objectNames != null && objectNames.size() > 0) { return objectNames.iterator().next(); } return null; }
77. MultipleMBeanStoresMBeanGetterTest#getFakeOperationMBeansAndTransformToXml()
Project: BeanSpy
File: MultipleMBeanStoresMBeanGetterTest.java
File: MultipleMBeanStoresMBeanGetterTest.java
/** * <p> * Retrieve the fake MBeans from the JMX Store (note this is a fake store) * and dynamically transform this MBeans into XML. * </p> * * <p> * This test is meant to verify that the class developed for the unit-test behaves * as expected. * <p> * * @throws Exception * If the generic operation on the MBean store failed */ @Test public void getFakeOperationMBeansAndTransformToXml() throws Exception { ObjectName objectName = new ObjectName("*:*"); QueryExp query = null; List<ObjectName> results = _mbeanGetter.getAllMatchingMBeans(objectName, query); Assert.assertEquals("Query for matching operationCall MBeans returned the wrong number of results", 30, results.size()); }
78. MBeanGetterTest#getFakeOperationMBeansAndTransformToXml()
Project: BeanSpy
File: MBeanGetterTest.java
File: MBeanGetterTest.java
/** * <p> * Retrieve the fake MBeans from the JMX Store (note this is a fake store) * and dynamically transform this MBeans into XML. * </p> * * <p> * This test is meant to verify that the class developed for the unit-test behaves * as expected. * <p> * * @throws Exception * If the generic operation on the MBean store failed */ @Test public void getFakeOperationMBeansAndTransformToXml() throws Exception { ObjectName objectName = new ObjectName("*:*"); QueryExp query = null; List<ObjectName> results = _mbeanGetter.getAllMatchingMBeans(objectName, query); Assert.assertEquals("Query for matching operationCall MBeans returned the wrong number of results", 15, results.size()); // Right now the primary reason for this method is to verify no // exceptions are thrown. Fake/mock implementation of the JMX Store // returns all contents }
79. FakeJmxGenerator#getEscapedObjectNameObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'EscapedObjectName' ObjectInstance */ public static ObjectInstance getEscapedObjectNameObjectInstance() { ObjectName o = null; try { o = new ObjectName(getEscapedObjectNameMBean().getObjectName()); } catch (Exception e) { Assert.fail("Creation of 'EscapedObjectName MBean' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new EscapedObjectName().getClass().getName()); }
80. FakeJmxGenerator#getFauxJBossManagementMBeanObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'JBoss Web Application' ObjectInstance */ public static ObjectInstance getFauxJBossManagementMBeanObjectInstance() { ObjectName o = null; try { o = new ObjectName(getFauxJBossWebApplicationMBean().getObjectName()); } catch (Exception e) { Assert.fail("Creation of 'JBoss Web Application' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new J2EEApplication().getClass().getName()); }
81. FakeJmxGenerator#getBasicTypesWrapperObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'BasicTypesWrapper' ObjectInstance */ public static ObjectInstance getBasicTypesWrapperObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(1); properties.put("theLabel", "BasicTypesWrapperMBean"); properties.put("payload", getBasicTypesWrapperMBean().getPayload().toString()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("Creation of 'BasicTypesWrapper' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new BasicTypesWrapper().getClass().getName()); }
82. FakeJmxGenerator#getBasicTypeArraysObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'BasicTypeArrays' ObjectInstance */ public static ObjectInstance getBasicTypeArraysObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(1); properties.put("theLabel", getBasicTypeArraysMBean().getTheLabel()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("Creation of 'BasicTypeArrays' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new BasicTypeArrays().getClass().getName()); }
83. FakeJmxGenerator#getComplexTypeObjectInstanceForMaxFileSize()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * <P> * Modified from getComplexTypeObjectInstance() for the test cases * when the size limit of a XML file is reached. * </P> * * @return A 'ComplexTypeForMaxFileSize' ObjectInstance * */ public static ObjectInstance getComplexTypeObjectInstanceForMaxFileSize() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(1); properties.put("theLabel", getComplexTypeMBeanforMaxFileSize().getTheLabel()); properties.put("complexitem", getComplexTypeMBeanforMaxFileSize().getComplexClass().toString()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("Creation of 'ComplexType' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new ComplexTypeForMaxFileSize().getClass().getName()); }
84. FakeJmxGenerator#getComplexTypeObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'ComplexType' ObjectInstance */ public static ObjectInstance getComplexTypeObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(1); properties.put("theLabel", getComplexTypeMBean().getTheLabel()); properties.put("complexitem", getComplexTypeMBean().getComplexClass().toString()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("Creation of 'ComplexType' ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new ComplexType().getClass().getName()); }
85. FakeJmxGenerator#getMultiplyToAddOperationCallObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return A 'multiply-to-add' OperationCall ObjectInstance */ public static ObjectInstance getMultiplyToAddOperationCallObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(4); properties.put("sourceEndpoint", StringMangler.EncodeForJmx(getMultiplyEndpointMBean().getUrl())); properties.put("sourceOperation", getMultiplyOperationMBean().getName()); properties.put("targetEndpoint", StringMangler.EncodeForJmx(getAddEndpointMBean().getUrl())); properties.put("targetOperation", getAddOperationMBean().getName()); properties.put("jmxType", new OperationCall().getJmxType()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("Creation of 'Divide-Subtract' OperationCall ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new OperationCall().getClass().getName()); }
86. FakeJmxGenerator#getDivideOperationObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * <p> * Helper/Fixture function for returning a standard ObjectInstance for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return An ObjectInstance representing a 'divide' Operation */ public static ObjectInstance getDivideOperationObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(4); properties.put("name", StringMangler.EncodeForJmx(getDivideOperationMBean().getName())); properties.put("jmxType", new Operation().getJmxType()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("'Divide' Operation ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new Operation().getClass().getName()); }
87. FakeJmxGenerator#getAddOperationObjectInstance()
Project: BeanSpy
File: FakeJmxGenerator.java
File: FakeJmxGenerator.java
/** * * <p> * Helper/Fixture function for returning a standard Operation MBean for use * in multiple tests. This method is meant to standardize and streamline the * test setup phase. * </p> * * @return An ObjectInstance representing a 'add' Operation */ public static ObjectInstance getAddOperationObjectInstance() { ObjectName o = null; try { Hashtable<String, String> properties = new Hashtable<String, String>(4); properties.put("name", StringMangler.EncodeForJmx(getAddOperationMBean().getName())); properties.put("jmxType", new Operation().getJmxType()); o = new ObjectName(_domain, properties); } catch (Exception e) { Assert.fail("'Add' Operation ObjectInstance could not be created. " + e.getMessage()); } return new ObjectInstance(o, new Operation().getClass().getName()); }
88. AzkabanWebServer#registerMbean()
Project: azkaban
File: AzkabanWebServer.java
File: AzkabanWebServer.java
private void registerMbean(String name, Object mbean) { Class<?> mbeanClass = mbean.getClass(); ObjectName mbeanName; try { mbeanName = new ObjectName(mbeanClass.getName() + ":name=" + name); mbeanServer.registerMBean(mbean, mbeanName); logger.info("Bean " + mbeanClass.getCanonicalName() + " registered."); registeredMBeans.add(mbeanName); } catch (Exception e) { logger.error("Error registering mbean " + mbeanClass.getCanonicalName(), e); } }
89. AzkabanExecutorServer#registerMbean()
Project: azkaban
File: AzkabanExecutorServer.java
File: AzkabanExecutorServer.java
private void registerMbean(String name, Object mbean) { Class<?> mbeanClass = mbean.getClass(); ObjectName mbeanName; try { mbeanName = new ObjectName(mbeanClass.getName() + ":name=" + name); mbeanServer.registerMBean(mbean, mbeanName); logger.info("Bean " + mbeanClass.getCanonicalName() + " registered."); registeredMBeans.add(mbeanName); } catch (Exception e) { logger.error("Error registering mbean " + mbeanClass.getCanonicalName(), e); } }
90. CassandraJmxBeanFactory#create()
Project: atlasdb
File: CassandraJmxBeanFactory.java
File: CassandraJmxBeanFactory.java
public <T> T create(String name, Class<T> interfaceClass) { MBeanServerConnection mBeanServerConnection = null; ObjectName objectName = null; try { mBeanServerConnection = jmxConnector.getMBeanServerConnection(); objectName = new ObjectName(name); } catch (MalformedObjectNameException e) { Throwables.propagate(e); } catch (IOException e) { Throwables.propagate(e); } return JMX.newMBeanProxy(mBeanServerConnection, objectName, interfaceClass); }
91. JMXTestRunnerTestCase#testJMXTestRunner()
Project: arquillian-core
File: JMXTestRunnerTestCase.java
File: JMXTestRunnerTestCase.java
@Test public void testJMXTestRunner() throws Throwable { MBeanServer mbeanServer = getMBeanServer(); JMXTestRunner jmxTestRunner = new JMXTestRunner(null); ObjectName oname = jmxTestRunner.registerMBean(mbeanServer); try { JMXTestRunnerMBean testRunner = getMBeanProxy(mbeanServer, oname, JMXTestRunnerMBean.class); TestResult result = Serializer.toObject(TestResult.class, testRunner.runTestMethod(DummyTestCase.class.getName(), "testMethod", new HashMap<String, String>())); assertNotNull("TestResult not null", result); assertNotNull("Status not null", result.getStatus()); if (result.getStatus() == Status.FAILED) throw result.getThrowable(); } finally { mbeanServer.unregisterMBean(oname); } }
92. MBeanTest#test_simple_MBean_different_package()
Project: aries
File: MBeanTest.java
File: MBeanTest.java
@Test public void test_simple_MBean_different_package() throws Exception { final String instanceName = "simple.test.instance.2"; final String objectNameString = "domain:instance=" + instanceName; final ObjectName objectName = new ObjectName(objectNameString); final TestClass testInstance = new TestClass2(instanceName); final MBeanServer server = getStaticMBeanServer(); // expect MBean to not be registered yet assertNotRegistered(server, objectName); // expect the MBean to be registered with the static server final ServiceRegistration reg = registerService(TestClassMBean.class.getName(), testInstance, objectNameString); assertRegistered(server, objectName); // expect MBean to return expected value TestCase.assertEquals(instanceName, server.getAttribute(objectName, "InstanceName")); // unregister MBean, expect to not be registered any more reg.unregister(); assertNotRegistered(server, objectName); }
93. MBeanTest#test_simple_MBean()
Project: aries
File: MBeanTest.java
File: MBeanTest.java
@Test public void test_simple_MBean() throws Exception { final String instanceName = "simple.test.instance"; final String objectNameString = "domain:instance=" + instanceName; final ObjectName objectName = new ObjectName(objectNameString); final TestClass testInstance = new TestClass(instanceName); final MBeanServer server = getStaticMBeanServer(); // expect MBean to not be registered yet assertNotRegistered(server, objectName); // expect the MBean to be registered with the static server final ServiceRegistration reg = registerService(TestClassMBean.class.getName(), testInstance, objectNameString); assertRegistered(server, objectName); // expect MBean to return expected value TestCase.assertEquals(instanceName, server.getAttribute(objectName, "InstanceName")); // unregister MBean, expect to not be registered any more reg.unregister(); assertNotRegistered(server, objectName); }
94. JmxWhiteboardSupport#registerMBean()
Project: aries
File: JmxWhiteboardSupport.java
File: JmxWhiteboardSupport.java
protected synchronized void registerMBean(Object mbean, final ServiceReference props) { log.debug("registerMBean: Adding MBean {}", mbean); ObjectName objectName = getObjectName(props); if (objectName != null || mbean instanceof MBeanRegistration) { MBeanHolder holder = MBeanHolder.create(mbean, objectName); if (holder != null) { MBeanServer[] mbeanServers = this.mbeanServers; for (MBeanServer mbeanServer : mbeanServers) { holder.register(mbeanServer); } mbeans.put(mbean, holder); } else { log.error("registerMBean: Cannot register MBean service {} with MBean servers: Not an instanceof DynamicMBean or not MBean spec compliant standard MBean", mbean); } } else { log.error("registerMBean: MBean service {} not registered with valid jmx.objectname propety and not implementing MBeanRegistration interface; not registering with MBean servers", mbean); } }
95. MBeanTest#test_simple_MBean_different_package()
Project: apache-aries
File: MBeanTest.java
File: MBeanTest.java
@Test public void test_simple_MBean_different_package() throws Exception { final String instanceName = "simple.test.instance.2"; final String objectNameString = "domain:instance=" + instanceName; final ObjectName objectName = new ObjectName(objectNameString); final TestClass testInstance = new TestClass2(instanceName); final MBeanServer server = getStaticMBeanServer(); // expect MBean to not be registered yet assertNotRegistered(server, objectName); // expect the MBean to be registered with the static server final ServiceRegistration reg = registerService(TestClassMBean.class.getName(), testInstance, objectNameString); assertRegistered(server, objectName); // expect MBean to return expected value TestCase.assertEquals(instanceName, server.getAttribute(objectName, "InstanceName")); // unregister MBean, expect to not be registered any more reg.unregister(); assertNotRegistered(server, objectName); }
96. MBeanTest#test_simple_MBean()
Project: apache-aries
File: MBeanTest.java
File: MBeanTest.java
@Test public void test_simple_MBean() throws Exception { final String instanceName = "simple.test.instance"; final String objectNameString = "domain:instance=" + instanceName; final ObjectName objectName = new ObjectName(objectNameString); final TestClass testInstance = new TestClass(instanceName); final MBeanServer server = getStaticMBeanServer(); // expect MBean to not be registered yet assertNotRegistered(server, objectName); // expect the MBean to be registered with the static server final ServiceRegistration reg = registerService(TestClassMBean.class.getName(), testInstance, objectNameString); assertRegistered(server, objectName); // expect MBean to return expected value TestCase.assertEquals(instanceName, server.getAttribute(objectName, "InstanceName")); // unregister MBean, expect to not be registered any more reg.unregister(); assertNotRegistered(server, objectName); }
97. JmxWhiteboardSupport#registerMBean()
Project: apache-aries
File: JmxWhiteboardSupport.java
File: JmxWhiteboardSupport.java
protected synchronized void registerMBean(Object mbean, final ServiceReference props) { log.debug("registerMBean: Adding MBean {}", mbean); ObjectName objectName = getObjectName(props); if (objectName != null || mbean instanceof MBeanRegistration) { MBeanHolder holder = MBeanHolder.create(mbean, objectName); if (holder != null) { MBeanServer[] mbeanServers = this.mbeanServers; for (MBeanServer mbeanServer : mbeanServers) { holder.register(mbeanServer); } mbeans.put(mbean, holder); } else { log.error("registerMBean: Cannot register MBean service {} with MBean servers: Not an instanceof DynamicMBean or not MBean spec compliant standard MBean", mbean); } } else { log.error("registerMBean: MBean service {} not registered with valid jmx.objectname propety and not implementing MBeanRegistration interface; not registering with MBean servers", mbean); } }
98. MBeanResource#getMBeans()
Project: airlift
File: MBeanResource.java
File: MBeanResource.java
@GET @Path("mbean") @Produces(MediaType.APPLICATION_JSON) public List<MBeanRepresentation> getMBeans() throws JMException { ImmutableList.Builder<MBeanRepresentation> mbeans = ImmutableList.builder(); for (ObjectName objectName : mbeanServer.queryNames(ObjectName.WILDCARD, null)) { mbeans.add(new MBeanRepresentation(mbeanServer, objectName, objectMapper)); } return mbeans.build(); }
99. LocalTestServer#listAllSubscribersForTopic()
Project: activemq-artemis
File: LocalTestServer.java
File: LocalTestServer.java
@Override public List<String> listAllSubscribersForTopic(final String s) throws Exception { ObjectName objectName = ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(s); TopicControl topic = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), objectName, TopicControl.class, false); Object[] subInfos = topic.listAllSubscriptions(); List<String> subs = new ArrayList<>(); for (Object o : subInfos) { Object[] data = (Object[]) o; subs.add((String) data[2]); } return subs; }
100. JMSBridgeTest#testMBeanServer()
Project: activemq-artemis
File: JMSBridgeTest.java
File: JMSBridgeTest.java
@Test public void testMBeanServer() throws Exception { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName objectName = new ObjectName("example.jmsbridge:service=JMSBridge"); JMSBridgeImpl bridge = new JMSBridgeImpl(cff0, cff0, sourceQueueFactory, localTargetQueueFactory, null, null, null, null, null, 5000, 10, QualityOfServiceMode.AT_MOST_ONCE, 1, -1, null, null, false, mbeanServer, objectName.getCanonicalName()).setBridgeName("test-bridge"); Assert.assertTrue(mbeanServer.isRegistered(objectName)); bridge.destroy(); Assert.assertFalse(mbeanServer.isRegistered(objectName)); }