Search in sources :

Example 11 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testPutConfigurationUrlString.

@Test
public void testPutConfigurationUrlString() throws Exception {
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    myAdapterRegistry.putConfigurationURL(myAdapterRegistry.createObjectName(), "http://localhost/1234");
    assertEquals("http://localhost/1234", myAdapterRegistry.getConfigurationURLString(myAdapterRegistry.createObjectName()));
}
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 12 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testPersistAdapter_MBean_to_URL.

@Test
public void testPersistAdapter_MBean_to_URL() throws Exception {
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
    ObjectName objName = myAdapterRegistry.createAdapter(xml);
    assertNotNull(objName);
    AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
    myAdapterRegistry.persistAdapter(manager, new URLString(filename));
    Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(filename);
    assertRoundtripEquality(adapter, marshalledAdapter);
}
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 13 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testPersistAdapter_ObjectName_To_File.

@Test
public void testPersistAdapter_ObjectName_To_File() throws Exception {
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
    ObjectName objName = myAdapterRegistry.createAdapter(xml);
    myAdapterRegistry.persistAdapter(objName, new URLString(filename));
    Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(filename);
    assertRoundtripEquality(adapter, marshalledAdapter);
}
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 14 with JunitBootstrapProperties

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

the class AdapterRegistryTest method testPreProcessorCalled.

@Test
public void testPreProcessorCalled() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    File filename = deleteLater(adapter);
    DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
    builder.setConfigurationPreProcessorLoader(mockPreProcessorLoader);
    ConfigPreProcessors preProcessorsList = new ConfigPreProcessors();
    preProcessorsList.add(mockPreProcessor);
    when(mockPreProcessorLoader.load(any(BootstrapProperties.class))).thenReturn(preProcessorsList);
    when(mockPreProcessor.process(any(String.class))).thenReturn(FileUtils.readFileToString(filename));
    myAdapterRegistry.createAdapter(new URLString(filename));
    // Make sure our pre-processor was called - even though our pre-processor does nothing!
    verify(mockPreProcessor, times(1)).process(any(String.class));
}
Also used : ConfigPreProcessors(com.adaptris.core.config.ConfigPreProcessors) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) 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) Test(org.junit.Test)

Example 15 with JunitBootstrapProperties

use of com.adaptris.core.stubs.JunitBootstrapProperties 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)

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