Search in sources :

Example 31 with Adapter

use of com.adaptris.core.Adapter in project interlok by adaptris.

the class AdapterRegistryTest method testAddAdapterMBean_ExistingObjectName.

@Test
public void testAddAdapterMBean_ExistingObjectName() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObjectName = adapterManager.createObjectName();
    adapterManager.registerMBean();
    AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
    int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
    myAdapterRegistry.addAdapter(adapterManager);
    assertEquals(ClosedState.getInstance(), adapterManager.getComponentState());
    assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
    try {
        myAdapterRegistry.addAdapter(adapterManager);
        fail();
    } catch (CoreException expected) {
        assertTrue(expected.getMessage().contains("already exists in the registry, remove it first"));
    }
}
Also used : CoreException(com.adaptris.core.CoreException) 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 32 with Adapter

use of com.adaptris.core.Adapter in project interlok by adaptris.

the class AdapterRegistryTest method testProxy_PersistAdapter_Bean_to_URL.

@Test
public void testProxy_PersistAdapter_Bean_to_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);
    String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
    ObjectName objName = registry.createAdapter(xml);
    assertNotNull(objName);
    AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
    registry.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 33 with Adapter

use of com.adaptris.core.Adapter 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 34 with Adapter

use of com.adaptris.core.Adapter 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 35 with Adapter

use of com.adaptris.core.Adapter in project interlok by adaptris.

the class AdapterManagerTest method testMBean_AddSharedConnection_NoUniqueID.

@Test
public void testMBean_AddSharedConnection_NoUniqueID() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    ObjectName adapterObj = adapterManager.createObjectName();
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    try {
        adapterManager.registerMBean();
        AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
        try {
            amp.addSharedConnection(m.marshal(new NullConnection()));
            fail();
        } catch (IllegalArgumentException e) {
        }
    } finally {
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) NullConnection(com.adaptris.core.NullConnection) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)342 Test (org.junit.Test)318 ObjectName (javax.management.ObjectName)234 Channel (com.adaptris.core.Channel)136 StandardWorkflow (com.adaptris.core.StandardWorkflow)93 ArrayList (java.util.ArrayList)80 URLString (com.adaptris.util.URLString)48 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)47 Properties (java.util.Properties)46 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)43 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)41 Workflow (com.adaptris.core.Workflow)40 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)40 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)38 File (java.io.File)37 CoreException (com.adaptris.core.CoreException)32 Notification (javax.management.Notification)28 TimeInterval (com.adaptris.util.TimeInterval)26 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)25 NullConnection (com.adaptris.core.NullConnection)21