| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (JmxBeansFactoryTest.groovy)

This example Groovy source code file (JmxBeansFactoryTest.groovy) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

baseembeddedclass, baseembeddedclass, groovytestcase, jmxbeansfactory, jmxbeansfactorytest, jmxbuilder, jmxbuilder, mockmanagedobject, mockmanagedobject, mocksimpleobject, mocksimpleobject

The Groovy JmxBeansFactoryTest.groovy source code

 * Copyright 2003-2010 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package groovy.jmx.builder

 * @author vladimir
class JmxBeansFactoryTest extends GroovyTestCase {
    def builder

    void setUp() {
        builder = new JmxBuilder()
        builder.registerFactory("beans", new JmxBeansFactory())

    void testFactoryNodeInstance() {
        def obj1 = new MockManagedObject()
        def obj2 = new BaseEmbeddedClass()
        def maps = builder.beans(obj1, obj2)

        assert maps
        assert maps.size == 2

        // test MockManagedObject map
        def map = maps[0]
        assert map

        def attribs = map.attributes
        assert attribs.Something
        assert attribs.Something.type == "java.lang.String"

        assert attribs.SomethingElse
        assert attribs.SomethingElse.type == "int"

        assert attribs.Available
        assert attribs.Available.type == "boolean"

        // test MockEmbeddedObject map
        map = maps[1]
        assert map.attributes
        assert map.attributes.Id
        assert map.attributes.Id.type == "int"

        assert map.attributes.Name
        assert map.attributes.Name.type == "java.lang.String"

        assert map.attributes.Location
        assert map.attributes.Location.type == "java.lang.Object"

        assert map.attributes.Available
        assert map.attributes.Available.type == "boolean"

    void testMBeanClass() {
        def object = new MockSimpleObject()
        def maps = builder.beans([object])
        assert maps
        def map = maps[0]
        assert map.isMBean
        assert map.jmxName
        assert map.attributes
        assert map.constructors
        assert !map.operations

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy JmxBeansFactoryTest.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.