AdapterComponentChecker extends ChildRuntimeInfoComponentImpl implements AdapterComponentCheckerMBean { @Override public void checkInitialise(String xml) throws CoreException { AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller(); AdaptrisComponent component = (AdaptrisComponent) marshaller.unmarshal(xml); prepare(component); if (component instanceof AllowsRetriesConnection) { AllowsRetriesConnection retry = (AllowsRetriesConnection) component; if (retry.connectionAttempts() == -1) { retry.setConnectionAttempts(0); } } try { init(component); } finally { close(component); } } private  AdapterComponentChecker();  AdapterComponentChecker(AdapterManager owner); @Override RuntimeInfoComponent getParentRuntimeInfoComponent(); @Override void checkInitialise(String xml); @Override SerializableMessage applyService(String xml, SerializableMessage serializedMsg); @Override SerializableMessage applyService(String xml, SerializableMessage serializedMsg, boolean rewriteConnections);  }
@Test public void testCheckInitialised() throws Exception { String adapterName = this.getClass().getSimpleName() + "." + getName(); Adapter adapter = createAdapter(adapterName, 2, 2); List<BaseComponentMBean> mBeans = createJmxManagers(adapter); ObjectName objectName = createComponentCheckerObjectName(adapterName); register(mBeans); AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class); manager.checkInitialise(createServiceForTests()); }
@Test public void testCheckInitialised_NotComponent() throws Exception { String adapterName = this.getClass().getSimpleName() + "." + getName(); Adapter adapter = createAdapter(adapterName, 2, 2); List<BaseComponentMBean> mBeans = createJmxManagers(adapter); ObjectName objectName = createComponentCheckerObjectName(adapterName); register(mBeans); AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class); try { manager.checkInitialise("<Document/>"); fail(); } catch (CoreException expected) { } }
@Test public void testCheckInitialised_Connection() throws Exception { String adapterName = this.getClass().getSimpleName() + "." + getName(); Adapter adapter = createAdapter(adapterName, 2, 2); List<BaseComponentMBean> mBeans = createJmxManagers(adapter); ObjectName objectName = createComponentCheckerObjectName(adapterName); register(mBeans); AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class); manager.checkInitialise(DefaultMarshaller.getDefaultMarshaller().marshal(new NullConnection())); }
@Test public void testCheckInitialised_RetriesConnection() throws Exception { String adapterName = this.getClass().getSimpleName() + "." + getName(); Adapter adapter = createAdapter(adapterName, 2, 2); List<BaseComponentMBean> mBeans = createJmxManagers(adapter); ObjectName objectName = createComponentCheckerObjectName(adapterName); register(mBeans); AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class); manager.checkInitialise(DefaultMarshaller.getDefaultMarshaller().marshal(new MockAllowsRetriesConnection())); manager.checkInitialise(DefaultMarshaller.getDefaultMarshaller().marshal(new MockAllowsRetriesConnection(1))); }