Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleBasicMBean() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleBasicMBean()
        {
            // given
            when(_jmxServer.getAttribute(_beanName, "name")).thenReturn("Hello, world!");
            JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), _jmxServer);

            // when
            RawIterator <object[], ProcedureException> result = procedure.Apply(null, new object[] { "*:*" }, _resourceTracker);

            // then
            assertThat(asList(result), contains(equalTo(new object[] { "org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference", "This is a description", map(_attributeName, map("description", "This is the attribute desc.", "value", "Hello, world!")) })));
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.Map<String,Object> toNeo4jValue(javax.management.ObjectName name, javax.management.MBeanAttributeInfo attribute) throws javax.management.JMException
        private IDictionary <string, object> ToNeo4jValue(ObjectName name, MBeanAttributeInfo attribute)
        {
            object value;

            try
            {
                value = toNeo4jValue(_jmxServer.getAttribute(name, attribute.Name));
            }
            catch (RuntimeMBeanException e)
            {
                if (e.InnerException != null && e.InnerException is System.NotSupportedException)
                {
                    // We include the name and description of this attribute still - but the value of it is
                    // unknown. We do this rather than rethrow the exception, because several MBeans built into
                    // the JVM will throw exception on attribute access depending on their runtime state, even
                    // if the attribute is marked as readable. Notably the GC beans do this.
                    value = null;
                }
                else
                {
                    throw e;
                }
            }
            return(map("description", attribute.Description, "value", value));
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") public static <T> T getAttribute(javax.management.ObjectName objectName, String attribute)
        public static T GetAttribute <T>(ObjectName objectName, string attribute)
        {
            try
            {
                return(( T )_mbeanServer.getAttribute(objectName, attribute));
            }
            catch (Exception e)
            {
                throw new Exception(e);
            }
        }