Search in sources :

Example 21 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.

the class AdapterRegistryTest method testProxy_CreateAdapter_String.

@Test
public void testProxy_CreateAdapter_String() throws Exception {
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    AdapterRegistryMBean registry = JMX.newMBeanProxy(mBeanServer, myAdapterRegistry.createObjectName(), AdapterRegistryMBean.class);
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    ObjectName objName = registry.createAdapter(xml);
    assertNotNull(objName);
    assertNotNull(registry.getBuilder(objName));
    assertTrue(mBeanServer.isRegistered(objName));
    AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
    assertNotNull(manager);
    assertEquals(ClosedState.getInstance(), manager.getComponentState());
    assertEquals(expectedCount, registry.getAdapters().size());
}
Also used : JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 22 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.

the class AdapterRegistryTest method testSendShutdownEvent.

@Test
public void testSendShutdownEvent() throws Exception {
    AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    DefaultEventHandler evh = new DefaultEventHandler();
    StaticMockEventProducer producer = new StaticMockEventProducer(Arrays.asList(new Class[] { AdapterShutdownEvent.class }));
    producer.getMessages().clear();
    evh.setProducer(producer);
    adapter.setEventHandler(evh);
    String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
    int expectedCount = adapterRegistry.getAdapters().size() + 1;
    ObjectName objName = adapterRegistry.createAdapter(xml);
    assertEquals(expectedCount, adapterRegistry.getAdapters().size());
    AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
    manager.requestStart();
    assertEquals(0, producer.messageCount());
    // This should send an extra event.
    AdapterRegistry.sendShutdownEvent(adapterRegistry.getAdapters());
    waitForMessages(producer, 1);
    assertEquals(1, producer.messageCount());
    AdapterRegistry.close(adapterRegistry.getAdapters());
    producer.getMessages().clear();
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler) StaticMockEventProducer(com.adaptris.core.stubs.StaticMockEventProducer) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) AdapterShutdownEvent(com.adaptris.core.event.AdapterShutdownEvent) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 23 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.

the class AdapterRegistryTest method testPreProcessorsLoaded.

@Test
public void testPreProcessorsLoaded() throws Exception {
    Properties bsProperties = new Properties();
    bsProperties.put(AdapterConfigManager.CONFIGURATION_PRE_PROCESSORS, DummyConfigurationPreProcessor.class.getName());
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(bsProperties));
    AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
    builder.setConfigurationPreProcessorLoader(spyPreProcessorLoader);
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
    myAdapterRegistry.createAdapter(new URLString(filename));
    verify(spyPreProcessorLoader, times(1)).load(any(BootstrapProperties.class));
}
Also used : BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) DummyConfigurationPreProcessor(com.adaptris.core.config.DummyConfigurationPreProcessor) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) File(java.io.File) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Example 24 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.

the class ConfigPreProcessorImplTest method testProperties.

@Test
public void testProperties() {
    BootstrapProperties props = new JunitBootstrapProperties(new Properties());
    DummyConfigurationPreProcessor p = new DummyConfigurationPreProcessor(props);
    p.setProperties(new Properties());
    assertNotNull(p.getProperties());
}
Also used : JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) Test(org.junit.Test)

Example 25 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.

the class ConfigPreProcessorImplTest method testConfiguration.

@Test
@SuppressWarnings("deprecation")
public void testConfiguration() {
    BootstrapProperties props = new JunitBootstrapProperties(new Properties());
    DummyConfigurationPreProcessor p = new DummyConfigurationPreProcessor(props);
    assertNotSame(props, p.getBootstrapProperties());
    assertNotNull(p.getConfiguration());
    assertEquals(0, p.getConfiguration().size());
}
Also used : JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) Test(org.junit.Test)

Aggregations

JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)55 Properties (java.util.Properties)55 Test (org.junit.Test)55 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)49 URLString (com.adaptris.util.URLString)43 Adapter (com.adaptris.core.Adapter)39 ObjectName (javax.management.ObjectName)35 File (java.io.File)20 CoreException (com.adaptris.core.CoreException)4 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)2 XStreamJsonMarshaller (com.adaptris.core.XStreamJsonMarshaller)2 ConfigPreProcessors (com.adaptris.core.config.ConfigPreProcessors)2 AdapterShutdownEvent (com.adaptris.core.event.AdapterShutdownEvent)2 StaticMockEventProducer (com.adaptris.core.stubs.StaticMockEventProducer)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 NullConnection (com.adaptris.core.NullConnection)1 DummyConfigurationPreProcessor (com.adaptris.core.config.DummyConfigurationPreProcessor)1 ReformatMetadata (com.adaptris.core.services.metadata.ReformatMetadata)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1