You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Jacek Laskowski <jl...@apache.org> on 2004/03/01 16:38:38 UTC

Questions about GBeanMBeanAttribute tests

Hey,

I'm trying to crack it down and keep failing :( I can't figure out how 
to get at GBeanMBeanAttribute once GBean is registered to Kernel.

Here's a snippet I'm working on:

   // create a MBean of GBean
   GBeanMBean gbean = new GBeanMBean(MockGBean.getGBeanInfo());
   // assign a value to an attribute of the GBean
   gbean.setAttribute(attributeName, attributeValue);
   // load the GBean
   kernel.loadGBean(objectName, gbean);
   // start it up
   kernel.startGBean(objectName);

At that point I can't access the GBean attributes other than via Kernel 
accessors (setter and getter) or directly via MBeanServer ones, which 
actually do nothing more than return or set an attribute's value.

I'd like to retrieve instances of GBeanMBeanAttribute and test it out.

Is the only approach to test the class to conduct it indirectly via 
Kernel or MBeanServer?

Cheers,
Jacek

Re: Questions about GBeanMBeanAttribute tests

Posted by Dain Sundstrom <da...@coredevelopers.net>.
On Mar 1, 2004, at 9:38 AM, Jacek Laskowski wrote:

> Hey,
>
> I'm trying to crack it down and keep failing :( I can't figure out how 
> to get at GBeanMBeanAttribute once GBean is registered to Kernel.
>
> Here's a snippet I'm working on:
>
>   // create a MBean of GBean
>   GBeanMBean gbean = new GBeanMBean(MockGBean.getGBeanInfo());
>   // assign a value to an attribute of the GBean
>   gbean.setAttribute(attributeName, attributeValue);
>   // load the GBean
>   kernel.loadGBean(objectName, gbean);
>   // start it up
>   kernel.startGBean(objectName);
>
> At that point I can't access the GBean attributes other than via 
> Kernel accessors (setter and getter) or directly via MBeanServer ones, 
> which actually do nothing more than return or set an attribute's 
> value.
>
> I'd like to retrieve instances of GBeanMBeanAttribute and test it out.
>
> Is the only approach to test the class to conduct it indirectly via 
> Kernel or MBeanServer?

I see I have done my job correctly :)

You're not never supposed to be able to have access to a 
GBeanMBeanAttribute instance directly.  It is an abstraction internal 
to the GBeanMBean implementation.  The only way to perform an 
integration test should be through the public interface on GBeanMBean.

-dain