Search in sources :

Example 51 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testClose.

@Test
public void testClose() throws Exception {
    AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    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();
    AdapterRegistry.close(adapterRegistry.getAdapters());
    assertEquals(ClosedState.getInstance(), manager.getComponentState());
}
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 52 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testProxy_GetConfigurationURL.

@Test
public void testProxy_GetConfigurationURL() 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);
    File filename = deleteLater(adapter);
    DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
    URLString expectedURL = new URLString(filename);
    ObjectName objName = registry.createAdapter(expectedURL);
    assertNotNull(objName);
    assertTrue(mBeanServer.isRegistered(objName));
    assertEquals(expectedURL, registry.getConfigurationURL(objName));
}
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) File(java.io.File) URLString(com.adaptris.util.URLString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 53 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testStart.

@Test
public void testStart() throws Exception {
    AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    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);
    AdapterRegistry.start(adapterRegistry.getAdapters());
    assertEquals(StartedState.getInstance(), manager.getComponentState());
}
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 54 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testGetVersionControl.

@Test
public void testGetVersionControl() throws Exception {
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    assertNull(myAdapterRegistry.getVersionControl());
    AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
    builder.overrideRuntimeVCS(new MockRuntimeVersionControl());
    assertEquals("MOCK", myAdapterRegistry.getVersionControl());
}
Also used : JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) Test(org.junit.Test)

Example 55 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testValidateConfig_InvalidXML.

@Test
public void testValidateConfig_InvalidXML() throws Exception {
    String xml = "<adapter><hello-world/></adapter>";
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    try {
        myAdapterRegistry.validateConfig(xml);
        fail();
    } catch (CoreException expected) {
        System.err.println(expected.getMessage());
    }
}
Also used : CoreException(com.adaptris.core.CoreException) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) 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