@Test public void testComponentAdapterReturnsSame() { final Touchable touchable = new SimpleTouchable(); final ComponentAdapter componentAdapter = new InstanceAdapter( Touchable.class, touchable, new NullLifecycleStrategy(), new NullComponentMonitor()); assertSame(touchable, componentAdapter.getComponentInstance(null, null)); }
/** * Register the component as MBean. The implementation uses the known DynamicMBeanProvider * instances to get the MBean from the component. * * @see com.picocontainer.PicoVisitor#visitComponentAdapter(com.picocontainer.ComponentAdapter) */ @Override public void visitComponentAdapter(final ComponentAdapter componentAdapter) { super.visitComponentAdapter(componentAdapter); if (picoContainer == null) { throw new JMXRegistrationException( "Cannot start JMXVisitor traversal with a ComponentAdapter"); } if (!visited.contains(componentAdapter.getComponentKey())) { visited.add(componentAdapter.getComponentKey()); for (final DynamicMBeanProvider provider : mBeanProviders) { final JMXRegistrationInfo info = provider.provide(picoContainer, componentAdapter); if (info != null) { registeredInfo.add(register(info.getMBean(), info.getObjectName())); break; } } } }
@Test public void testFindAdapterOfType() { ComponentAdapter adapter = new InstanceAdapter("test", "test"); assertEquals(adapter, adapter.findAdapterOfType(InstanceAdapter.class)); }