Search in sources :

Example 6 with URLString

use of com.adaptris.util.URLString in project interlok by adaptris.

the class AdapterRegistryTest method testProxy_CreateAdapter_URL.

@Test
public void testProxy_CreateAdapter_URL() 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);
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    ObjectName objName = registry.createAdapter(new URLString(filename));
    assertNotNull(objName);
    assertTrue(mBeanServer.isRegistered(objName));
    AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
    assertNotNull(manager);
    assertEquals(ClosedState.getInstance(), manager.getComponentState());
    assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
    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) File(java.io.File) URLString(com.adaptris.util.URLString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 7 with URLString

use of com.adaptris.util.URLString in project interlok by adaptris.

the class AdapterRegistryTest method testProxy_Destroy_With_GetConfigurationURL.

@Test
public void testProxy_Destroy_With_GetConfigurationURL() throws Exception {
    AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    AdapterRegistryMBean registry = JMX.newMBeanProxy(mBeanServer, adapterRegistry.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));
    registry.destroyAdapter(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 8 with URLString

use of com.adaptris.util.URLString in project interlok by adaptris.

the class AdapterRegistryTest method testReloadFromVersionControl_WithVCS.

@Test
public void testReloadFromVersionControl_WithVCS() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
    Properties p = new Properties();
    p.put("adapterConfigUrl.1", filename.toURI().toURL().toString());
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(p));
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    ObjectName myObjectName = myAdapterRegistry.createAdapter(new URLString(filename));
    assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
    AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
    builder.overrideRuntimeVCS(new MockRuntimeVersionControl());
    // This should destroy the adapter just created; and create a new one...
    myAdapterRegistry.reloadFromVersionControl();
    assertEquals(expectedCount, myAdapterRegistry.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) File(java.io.File) URLString(com.adaptris.util.URLString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 9 with URLString

use of com.adaptris.util.URLString in project interlok by adaptris.

the class AdapterRegistryTest method testReloadFromConfig.

@Test
public void testReloadFromConfig() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
    Properties p = new Properties();
    p.put("adapterConfigUrl.1", filename.toURI().toURL().toString());
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(p));
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    ObjectName myObjectName = myAdapterRegistry.createAdapter(new URLString(filename));
    assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
    // This should destroy the adapter just created; and create a new one...
    myAdapterRegistry.reloadFromConfig();
    assertEquals(expectedCount, myAdapterRegistry.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) File(java.io.File) URLString(com.adaptris.util.URLString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 10 with URLString

use of com.adaptris.util.URLString 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)

Aggregations

URLString (com.adaptris.util.URLString)32 Test (org.junit.Test)21 Adapter (com.adaptris.core.Adapter)19 File (java.io.File)19 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)18 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)18 Properties (java.util.Properties)18 ObjectName (javax.management.ObjectName)14 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)3 ConfigPreProcessors (com.adaptris.core.config.ConfigPreProcessors)2 GuidGenerator (com.adaptris.util.GuidGenerator)2 InputStream (java.io.InputStream)2 TransformerException (javax.xml.transform.TransformerException)2 SAXException (org.xml.sax.SAXException)2 CoreException (com.adaptris.core.CoreException)1 StandaloneProducer (com.adaptris.core.StandaloneProducer)1 DummyConfigurationPreProcessor (com.adaptris.core.config.DummyConfigurationPreProcessor)1 HttpException (com.adaptris.http.HttpException)1 HttpsClient (com.adaptris.http.HttpsClient)1 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)1